class fields: add ASI tests

This commit is contained in:
Valerie R Young 2017-10-30 12:43:37 -04:00 committed by Leo Balter
parent 214e9969d5
commit dd371194fe
No known key found for this signature in database
GPG Key ID: 2C75F319D398E36B
10 changed files with 199 additions and 0 deletions

View File

@ -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);

View File

@ -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');

View File

@ -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]() {}
}

View File

@ -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() {}
}

View File

@ -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");

View File

@ -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);

View File

@ -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');

View File

@ -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]() {}
}

View File

@ -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() {}
}

View File

@ -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");