From 6b808920dddfc19265e0d5a325c0e53254c3d7c1 Mon Sep 17 00:00:00 2001 From: Kubilay Kahveci Date: Sun, 16 Sep 2018 09:36:25 +0100 Subject: [PATCH] test: Add tests for duplicate private methods (early-errors) --- ...ammar-privatemeth-duplicate-get-field.case | 17 ++++++++++++++ ...grammar-privatemeth-duplicate-get-get.case | 17 ++++++++++++++ ...grammar-privatemeth-duplicate-get-set.case | 17 ++++++++++++++ ...mmar-privatemeth-duplicate-meth-field.case | 17 ++++++++++++++ ...rammar-privatemeth-duplicate-meth-get.case | 17 ++++++++++++++ ...ammar-privatemeth-duplicate-meth-meth.case | 17 ++++++++++++++ ...temeth-duplicate-meth-nestedclassmeth.case | 22 +++++++++++++++++++ ...rammar-privatemeth-duplicate-meth-set.case | 17 ++++++++++++++ ...rivatemeth-duplicate-meth-staticfield.case | 17 ++++++++++++++ ...privatemeth-duplicate-meth-staticmeth.case | 17 ++++++++++++++ ...ammar-privatemeth-duplicate-set-field.case | 17 ++++++++++++++ ...grammar-privatemeth-duplicate-set-set.case | 17 ++++++++++++++ 12 files changed, 209 insertions(+) create mode 100644 src/class-elements/grammar-privatemeth-duplicate-get-field.case create mode 100644 src/class-elements/grammar-privatemeth-duplicate-get-get.case create mode 100644 src/class-elements/grammar-privatemeth-duplicate-get-set.case create mode 100644 src/class-elements/grammar-privatemeth-duplicate-meth-field.case create mode 100644 src/class-elements/grammar-privatemeth-duplicate-meth-get.case create mode 100644 src/class-elements/grammar-privatemeth-duplicate-meth-meth.case create mode 100644 src/class-elements/grammar-privatemeth-duplicate-meth-nestedclassmeth.case create mode 100644 src/class-elements/grammar-privatemeth-duplicate-meth-set.case create mode 100644 src/class-elements/grammar-privatemeth-duplicate-meth-staticfield.case create mode 100644 src/class-elements/grammar-privatemeth-duplicate-meth-staticmeth.case create mode 100644 src/class-elements/grammar-privatemeth-duplicate-set-field.case create mode 100644 src/class-elements/grammar-privatemeth-duplicate-set-set.case diff --git a/src/class-elements/grammar-privatemeth-duplicate-get-field.case b/src/class-elements/grammar-privatemeth-duplicate-get-field.case new file mode 100644 index 0000000000..90cfc9dd00 --- /dev/null +++ b/src/class-elements/grammar-privatemeth-duplicate-get-field.case @@ -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() {} diff --git a/src/class-elements/grammar-privatemeth-duplicate-get-get.case b/src/class-elements/grammar-privatemeth-duplicate-get-get.case new file mode 100644 index 0000000000..5b9d0a962b --- /dev/null +++ b/src/class-elements/grammar-privatemeth-duplicate-get-get.case @@ -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() {} diff --git a/src/class-elements/grammar-privatemeth-duplicate-get-set.case b/src/class-elements/grammar-privatemeth-duplicate-get-set.case new file mode 100644 index 0000000000..c7a9283c50 --- /dev/null +++ b/src/class-elements/grammar-privatemeth-duplicate-get-set.case @@ -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(_) {} diff --git a/src/class-elements/grammar-privatemeth-duplicate-meth-field.case b/src/class-elements/grammar-privatemeth-duplicate-meth-field.case new file mode 100644 index 0000000000..3fce8c753b --- /dev/null +++ b/src/class-elements/grammar-privatemeth-duplicate-meth-field.case @@ -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() {} diff --git a/src/class-elements/grammar-privatemeth-duplicate-meth-get.case b/src/class-elements/grammar-privatemeth-duplicate-meth-get.case new file mode 100644 index 0000000000..3f666f13f9 --- /dev/null +++ b/src/class-elements/grammar-privatemeth-duplicate-meth-get.case @@ -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() {} diff --git a/src/class-elements/grammar-privatemeth-duplicate-meth-meth.case b/src/class-elements/grammar-privatemeth-duplicate-meth-meth.case new file mode 100644 index 0000000000..51f8a4625e --- /dev/null +++ b/src/class-elements/grammar-privatemeth-duplicate-meth-meth.case @@ -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() {} diff --git a/src/class-elements/grammar-privatemeth-duplicate-meth-nestedclassmeth.case b/src/class-elements/grammar-privatemeth-duplicate-meth-nestedclassmeth.case new file mode 100644 index 0000000000..91b7649859 --- /dev/null +++ b/src/class-elements/grammar-privatemeth-duplicate-meth-nestedclassmeth.case @@ -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() {} diff --git a/src/class-elements/grammar-privatemeth-duplicate-meth-set.case b/src/class-elements/grammar-privatemeth-duplicate-meth-set.case new file mode 100644 index 0000000000..d81f63fcb9 --- /dev/null +++ b/src/class-elements/grammar-privatemeth-duplicate-meth-set.case @@ -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() {} diff --git a/src/class-elements/grammar-privatemeth-duplicate-meth-staticfield.case b/src/class-elements/grammar-privatemeth-duplicate-meth-staticfield.case new file mode 100644 index 0000000000..787f7dd1b7 --- /dev/null +++ b/src/class-elements/grammar-privatemeth-duplicate-meth-staticfield.case @@ -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() {} diff --git a/src/class-elements/grammar-privatemeth-duplicate-meth-staticmeth.case b/src/class-elements/grammar-privatemeth-duplicate-meth-staticmeth.case new file mode 100644 index 0000000000..ed4ab412c5 --- /dev/null +++ b/src/class-elements/grammar-privatemeth-duplicate-meth-staticmeth.case @@ -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() {} diff --git a/src/class-elements/grammar-privatemeth-duplicate-set-field.case b/src/class-elements/grammar-privatemeth-duplicate-set-field.case new file mode 100644 index 0000000000..ef422105fe --- /dev/null +++ b/src/class-elements/grammar-privatemeth-duplicate-set-field.case @@ -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(_) {} diff --git a/src/class-elements/grammar-privatemeth-duplicate-set-set.case b/src/class-elements/grammar-privatemeth-duplicate-set-set.case new file mode 100644 index 0000000000..7216563a2e --- /dev/null +++ b/src/class-elements/grammar-privatemeth-duplicate-set-set.case @@ -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(_) {}