mirror of https://github.com/tc39/test262.git
class fields: add ASI tests
This commit is contained in:
parent
214e9969d5
commit
dd371194fe
|
@ -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);
|
|
@ -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');
|
|
@ -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]() {}
|
||||
}
|
|
@ -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() {}
|
||||
}
|
|
@ -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");
|
|
@ -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);
|
|
@ -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');
|
|
@ -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]() {}
|
||||
}
|
|
@ -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() {}
|
||||
}
|
|
@ -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…
Reference in New Issue