mirror of
https://github.com/tc39/test262.git
synced 2025-07-09 23:24:38 +02:00
class fields: add ASI tests
This commit is contained in:
parent
214e9969d5
commit
dd371194fe
19
test/language/expressions/class/fields-asi-1.js
Normal file
19
test/language/expressions/class/fields-asi-1.js
Normal 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);
|
17
test/language/expressions/class/fields-asi-2.js
Normal file
17
test/language/expressions/class/fields-asi-2.js
Normal 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');
|
18
test/language/expressions/class/fields-asi-3.js
Normal file
18
test/language/expressions/class/fields-asi-3.js
Normal 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]() {}
|
||||||
|
}
|
18
test/language/expressions/class/fields-asi-4.js
Normal file
18
test/language/expressions/class/fields-asi-4.js
Normal 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() {}
|
||||||
|
}
|
28
test/language/expressions/class/fields-asi-5.js
Normal file
28
test/language/expressions/class/fields-asi-5.js
Normal 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");
|
19
test/language/statements/class/fields-asi-1.js
Normal file
19
test/language/statements/class/fields-asi-1.js
Normal 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);
|
17
test/language/statements/class/fields-asi-2.js
Normal file
17
test/language/statements/class/fields-asi-2.js
Normal 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');
|
18
test/language/statements/class/fields-asi-3.js
Normal file
18
test/language/statements/class/fields-asi-3.js
Normal 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]() {}
|
||||||
|
}
|
18
test/language/statements/class/fields-asi-4.js
Normal file
18
test/language/statements/class/fields-asi-4.js
Normal 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() {}
|
||||||
|
}
|
27
test/language/statements/class/fields-asi-5.js
Normal file
27
test/language/statements/class/fields-asi-5.js
Normal 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");
|
Loading…
x
Reference in New Issue
Block a user