From dd371194fed81ace9a38f8ff9f4682e6d0acc483 Mon Sep 17 00:00:00 2001 From: Valerie R Young Date: Mon, 30 Oct 2017 12:43:37 -0400 Subject: [PATCH] class fields: add ASI tests --- .../expressions/class/fields-asi-1.js | 19 +++++++++++++ .../expressions/class/fields-asi-2.js | 17 +++++++++++ .../expressions/class/fields-asi-3.js | 18 ++++++++++++ .../expressions/class/fields-asi-4.js | 18 ++++++++++++ .../expressions/class/fields-asi-5.js | 28 +++++++++++++++++++ .../language/statements/class/fields-asi-1.js | 19 +++++++++++++ .../language/statements/class/fields-asi-2.js | 17 +++++++++++ .../language/statements/class/fields-asi-3.js | 18 ++++++++++++ .../language/statements/class/fields-asi-4.js | 18 ++++++++++++ .../language/statements/class/fields-asi-5.js | 27 ++++++++++++++++++ 10 files changed, 199 insertions(+) create mode 100644 test/language/expressions/class/fields-asi-1.js create mode 100644 test/language/expressions/class/fields-asi-2.js create mode 100644 test/language/expressions/class/fields-asi-3.js create mode 100644 test/language/expressions/class/fields-asi-4.js create mode 100644 test/language/expressions/class/fields-asi-5.js create mode 100644 test/language/statements/class/fields-asi-1.js create mode 100644 test/language/statements/class/fields-asi-2.js create mode 100644 test/language/statements/class/fields-asi-3.js create mode 100644 test/language/statements/class/fields-asi-4.js create mode 100644 test/language/statements/class/fields-asi-5.js diff --git a/test/language/expressions/class/fields-asi-1.js b/test/language/expressions/class/fields-asi-1.js new file mode 100644 index 0000000000..aed503ba6c --- /dev/null +++ b/test/language/expressions/class/fields-asi-1.js @@ -0,0 +1,19 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- computed name interpreted as property +esid: sec-automatic-semicolon-insertion +features: [class-fields] +---*/ + +var obj = {} +var C = class { + x = obj + ['lol'] = 42 +} + +var c = new C(); + +assert.sameValue(c.x, 42) +assert.sameValue(obj['lol'], 42); diff --git a/test/language/expressions/class/fields-asi-2.js b/test/language/expressions/class/fields-asi-2.js new file mode 100644 index 0000000000..bc153cd8cc --- /dev/null +++ b/test/language/expressions/class/fields-asi-2.js @@ -0,0 +1,17 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- computed name interpreted as string index +esid: sec-automatic-semicolon-insertion +features: [class-fields] +---*/ + +var C = class { + x = "lol" + [1] +} + +var c = new C(); + +assert.sameValue(c.x, 'o'); diff --git a/test/language/expressions/class/fields-asi-3.js b/test/language/expressions/class/fields-asi-3.js new file mode 100644 index 0000000000..256a257d53 --- /dev/null +++ b/test/language/expressions/class/fields-asi-3.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- error when computed name interpreted as index +esid: sec-automatic-semicolon-insertion +features: [class-fields] +negative: + phase: early + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +var C = class { + x = "string" + [0]() {} +} diff --git a/test/language/expressions/class/fields-asi-4.js b/test/language/expressions/class/fields-asi-4.js new file mode 100644 index 0000000000..1e0edec706 --- /dev/null +++ b/test/language/expressions/class/fields-asi-4.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- error when generator interpreted as multiplication +esid: sec-automatic-semicolon-insertion +features: [class-fields] +negative: + phase: early + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +var C = class { + x = 42 + *gen() {} +} diff --git a/test/language/expressions/class/fields-asi-5.js b/test/language/expressions/class/fields-asi-5.js new file mode 100644 index 0000000000..a57fd2bb9b --- /dev/null +++ b/test/language/expressions/class/fields-asi-5.js @@ -0,0 +1,28 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- field with PropertyName "in" interpreted as index +esid: sec-automatic-semicolon-insertion +features: [class-fields] +---*/ + +var x = 1 +var y = 2 +var z = [42] + +var C = class { + a = x + in + z + b = y + in + z +} + +var c = new C(); + +assert.sameValue(c.a, true, 'a = x in z') +assert.sameValue(c.a, false, 'a = y in z') +assert.sameValue(Object.hasOwnProperty.call(c, "in"), false, "'in' interpreted as index"); +assert.sameValue(Object.hasOwnProperty.call(c, "z"), false, "'z' interpreted as variable"); diff --git a/test/language/statements/class/fields-asi-1.js b/test/language/statements/class/fields-asi-1.js new file mode 100644 index 0000000000..56a9dda58b --- /dev/null +++ b/test/language/statements/class/fields-asi-1.js @@ -0,0 +1,19 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- computed name interpreted as property +esid: sec-automatic-semicolon-insertion +features: [class-fields] +---*/ + +var obj = {} +class C { + x = obj + ['lol'] = 42 +} + +var c = new C(); + +assert.sameValue(c.x, 42); +assert.sameValue(obj['lol'], 42); diff --git a/test/language/statements/class/fields-asi-2.js b/test/language/statements/class/fields-asi-2.js new file mode 100644 index 0000000000..70488e9e66 --- /dev/null +++ b/test/language/statements/class/fields-asi-2.js @@ -0,0 +1,17 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- computed name interpreted as string index +esid: sec-automatic-semicolon-insertion +features: [class-fields] +---*/ + +class C { + x = "lol" + [1] +} + +var c = new C(); + +assert.sameValue(c.x, 'o'); diff --git a/test/language/statements/class/fields-asi-3.js b/test/language/statements/class/fields-asi-3.js new file mode 100644 index 0000000000..42f49fd1e1 --- /dev/null +++ b/test/language/statements/class/fields-asi-3.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- error when computed name interpreted as index +esid: sec-automatic-semicolon-insertion +features: [class-fields] +negative: + phase: early + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +class C { + x = "string" + [0]() {} +} diff --git a/test/language/statements/class/fields-asi-4.js b/test/language/statements/class/fields-asi-4.js new file mode 100644 index 0000000000..c1506f34f8 --- /dev/null +++ b/test/language/statements/class/fields-asi-4.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- error when generator interpreted as multiplication +esid: sec-automatic-semicolon-insertion +features: [class-fields] +negative: + phase: early + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +class C { + x = 42 + *gen() {} +} diff --git a/test/language/statements/class/fields-asi-5.js b/test/language/statements/class/fields-asi-5.js new file mode 100644 index 0000000000..86bc18f882 --- /dev/null +++ b/test/language/statements/class/fields-asi-5.js @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- field with PropertyName "in" interpreted as index +esid: sec-automatic-semicolon-insertion +features: [class-fields] +---*/ + +var x = 1 +var y = 2 +var z = [42] + +class C { + a = x + in + z + b = y + in + z +} + +var c = new C(); +assert.sameValue(c.a, true, 'a = x in z') +assert.sameValue(c.a, false, 'a = y in z') +assert.sameValue(Object.hasOwnProperty.call(c, "in"), false, "'in' interpreted as index"); +assert.sameValue(Object.hasOwnProperty.call(c, "z"), false, "'z' interpreted as variable");