Skip to content
Snippets Groups Projects
Unverified Commit dd371194 authored by Valerie R Young's avatar Valerie R Young Committed by Leo Balter
Browse files

class fields: add ASI tests

parent 214e9969
No related branches found
No related tags found
No related merge requests found
// 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);
// 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');
// 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]() {}
}
// 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() {}
}
// 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");
// 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);
// 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');
// 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]() {}
}
// 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() {}
}
// 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");
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment