test: Add tests for duplicate private methods (early-errors)

This commit is contained in:
Kubilay Kahveci 2018-09-16 09:36:25 +01:00 committed by Rick Waldron
parent fec7982e09
commit 6b808920dd
12 changed files with 209 additions and 0 deletions

View File

@ -0,0 +1,17 @@
// Copyright (C) 2018 Kubilay Kahveci (Bloomberg LP). All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: It's a SyntaxError if a class contains a private getter and a private field with the same name
info: |
Static Semantics: Early Errors
ClassBody : ClassElementList
It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries.
template: syntax/invalid
features: [class-methods-private, class-fields-private]
---*/
//- elements
#m;
get #m() {}

View File

@ -0,0 +1,17 @@
// Copyright (C) 2018 Kubilay Kahveci (Bloomberg LP). All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: It's a SyntaxError if a class contains multiple private getters with the same name
info: |
Static Semantics: Early Errors
ClassBody : ClassElementList
It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries.
template: syntax/invalid
features: [class-methods-private]
---*/
//- elements
get #m() {}
get #m() {}

View File

@ -0,0 +1,17 @@
// Copyright (C) 2018 Kubilay Kahveci (Bloomberg LP). All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: It's valid if a class contains a private getter and a private setter with the same name
info: |
Static Semantics: Early Errors
ClassBody : ClassElementList
It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries.
template: syntax/valid
features: [class-methods-private]
---*/
//- elements
get #m() {}
set #m(_) {}

View File

@ -0,0 +1,17 @@
// Copyright (C) 2018 Kubilay Kahveci (Bloomberg LP). All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: It's a SyntaxError if a class contains a private method and a private field with the same name
info: |
Static Semantics: Early Errors
ClassBody : ClassElementList
It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries.
template: syntax/invalid
features: [class-methods-private, class-fields-private]
---*/
//- elements
#m;
#m() {}

View File

@ -0,0 +1,17 @@
// Copyright (C) 2018 Kubilay Kahveci (Bloomberg LP). All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: It's a SyntaxError if a class contains a private method and a private getter with the same name
info: |
Static Semantics: Early Errors
ClassBody : ClassElementList
It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries.
template: syntax/invalid
features: [class-methods-private]
---*/
//- elements
get #m() {}
#m() {}

View File

@ -0,0 +1,17 @@
// Copyright (C) 2018 Kubilay Kahveci (Bloomberg LP). All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: It's a SyntaxError if a class contains multiple private methods with the same name
info: |
Static Semantics: Early Errors
ClassBody : ClassElementList
It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries.
template: syntax/invalid
features: [class-methods-private]
---*/
//- elements
#m() {}
#m() {}

View File

@ -0,0 +1,22 @@
// Copyright (C) 2018 Kubilay Kahveci (Bloomberg LP). All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: It's valid if a nested class shadows a private method
info: |
Static Semantics: Early Errors
ClassBody : ClassElementList
It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries.
template: syntax/valid
features: [class-methods-private]
---*/
//- elements
constructor() {
class B {
#m() {}
}
}
#m() {}

View File

@ -0,0 +1,17 @@
// Copyright (C) 2018 Kubilay Kahveci (Bloomberg LP). All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: It's a SyntaxError if a class contains a private method and a private setter with the same name
info: |
Static Semantics: Early Errors
ClassBody : ClassElementList
It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries.
template: syntax/invalid
features: [class-methods-private]
---*/
//- elements
set #m(_) {}
#m() {}

View File

@ -0,0 +1,17 @@
// Copyright (C) 2018 Kubilay Kahveci (Bloomberg LP). All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: It's a SyntaxError if a class contains a private method and a private static field with the same name
info: |
Static Semantics: Early Errors
ClassBody : ClassElementList
It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries.
template: syntax/invalid
features: [class-methods-private, class-static-fields-private]
---*/
//- elements
static #m;
#m() {}

View File

@ -0,0 +1,17 @@
// Copyright (C) 2018 Kubilay Kahveci (Bloomberg LP). All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: It's a SyntaxError if a class contains a private method and a private static method with the same name
info: |
Static Semantics: Early Errors
ClassBody : ClassElementList
It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries.
template: syntax/invalid
features: [class-methods-private, class-static-methods-private]
---*/
//- elements
static #m() {}
#m() {}

View File

@ -0,0 +1,17 @@
// Copyright (C) 2018 Kubilay Kahveci (Bloomberg LP). All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: It's a SyntaxError if a class contains a private setter and a private field with the same name
info: |
Static Semantics: Early Errors
ClassBody : ClassElementList
It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries.
template: syntax/invalid
features: [class-methods-private, class-fields-private]
---*/
//- elements
#m;
set #m(_) {}

View File

@ -0,0 +1,17 @@
// Copyright (C) 2018 Kubilay Kahveci (Bloomberg LP). All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: It's a SyntaxError if a class contains multiple private setters with the same name
info: |
Static Semantics: Early Errors
ClassBody : ClassElementList
It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries.
template: syntax/invalid
features: [class-methods-private]
---*/
//- elements
set #m(_) {}
set #m(_) {}