mirror of https://github.com/tc39/test262.git
Add tests for early errors from `super`
This commit is contained in:
parent
fce8b5852d
commit
24391fb9e8
|
@ -0,0 +1,27 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-scripts-static-semantics-early-errors
|
||||
es6id: 15.1.1
|
||||
description: >
|
||||
A direct eval in the functon code of an ArrowFunction may not contain
|
||||
SuperCall
|
||||
info: |
|
||||
- It is a Syntax Error if StatementList Contains super unless the source code
|
||||
containing super is eval code that is being processed by a direct eval that
|
||||
is contained in function code that is not the function code of an
|
||||
ArrowFunction.
|
||||
features: [super, arrow-function]
|
||||
---*/
|
||||
|
||||
var caught;
|
||||
var f = () => eval('super();');
|
||||
|
||||
try {
|
||||
f();
|
||||
} catch (err) {
|
||||
caught = err;
|
||||
}
|
||||
|
||||
assert.sameValue(typeof caught, 'object');
|
||||
assert.sameValue(caught.constructor, SyntaxError);
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-scripts-static-semantics-early-errors
|
||||
es6id: 15.1.1
|
||||
description: >
|
||||
A direct eval in the functon code of a non-ArrowFunction may contain
|
||||
SuperCall
|
||||
info: |
|
||||
- It is a Syntax Error if StatementList Contains super unless the source code
|
||||
containing super is eval code that is being processed by a direct eval that
|
||||
is contained in function code that is not the function code of an
|
||||
ArrowFunction.
|
||||
features: [super]
|
||||
---*/
|
||||
|
||||
var executed = false;
|
||||
function f() {
|
||||
eval('executed = true; super();');
|
||||
}
|
||||
|
||||
assert.throws(ReferenceError, function() {
|
||||
f();
|
||||
});
|
||||
|
||||
assert.sameValue(executed, true);
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-scripts-static-semantics-early-errors
|
||||
es6id: 15.1.1
|
||||
description: A direct eval in global code may not contain SuperCall
|
||||
info: |
|
||||
- It is a Syntax Error if StatementList Contains super unless the source code
|
||||
containing super is eval code that is being processed by a direct eval that
|
||||
is contained in function code that is not the function code of an
|
||||
ArrowFunction.
|
||||
features: [super]
|
||||
---*/
|
||||
|
||||
var caught;
|
||||
|
||||
try {
|
||||
eval('super();');
|
||||
} catch (err) {
|
||||
caught = err;
|
||||
}
|
||||
|
||||
assert.sameValue(typeof caught, 'object');
|
||||
assert.sameValue(caught.constructor, SyntaxError);
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-scripts-static-semantics-early-errors
|
||||
es6id: 15.1.1
|
||||
description: >
|
||||
A direct eval in the functon code of an ArrowFunction may not contain
|
||||
SuperProperty
|
||||
info: |
|
||||
- It is a Syntax Error if StatementList Contains super unless the source code
|
||||
containing super is eval code that is being processed by a direct eval that
|
||||
is contained in function code that is not the function code of an
|
||||
ArrowFunction.
|
||||
features: [super, arrow-function]
|
||||
---*/
|
||||
|
||||
var caught;
|
||||
var f = () => eval('super.property;');
|
||||
|
||||
try {
|
||||
f();
|
||||
} catch (err) {
|
||||
caught = err;
|
||||
}
|
||||
|
||||
assert.sameValue(typeof caught, 'object');
|
||||
assert.sameValue(caught.constructor, SyntaxError);
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-scripts-static-semantics-early-errors
|
||||
es6id: 15.1.1
|
||||
description: >
|
||||
A direct eval in the functon code of a non-ArrowFunction may contain
|
||||
SuperProperty
|
||||
info: |
|
||||
- It is a Syntax Error if StatementList Contains super unless the source code
|
||||
containing super is eval code that is being processed by a direct eval that
|
||||
is contained in function code that is not the function code of an
|
||||
ArrowFunction.
|
||||
features: [super]
|
||||
---*/
|
||||
|
||||
var superProp = null;
|
||||
var o = {
|
||||
test262: null,
|
||||
method() {
|
||||
superProp = eval('super.test262;');
|
||||
}
|
||||
};
|
||||
|
||||
o.method();
|
||||
|
||||
assert.sameValue(superProp, undefined);
|
||||
|
||||
Object.setPrototypeOf(o, { test262: 262 });
|
||||
|
||||
o.method();
|
||||
|
||||
assert.sameValue(superProp, 262);
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-scripts-static-semantics-early-errors
|
||||
es6id: 15.1.1
|
||||
description: A direct eval in global code may not contain SuperProperty
|
||||
info: |
|
||||
- It is a Syntax Error if StatementList Contains super unless the source code
|
||||
containing super is eval code that is being processed by a direct eval that
|
||||
is contained in function code that is not the function code of an
|
||||
ArrowFunction.
|
||||
features: [super]
|
||||
---*/
|
||||
|
||||
var caught;
|
||||
|
||||
try {
|
||||
eval('super.property;');
|
||||
} catch (err) {
|
||||
caught = err;
|
||||
}
|
||||
|
||||
assert.sameValue(typeof caught, 'object');
|
||||
assert.sameValue(caught.constructor, SyntaxError);
|
|
@ -0,0 +1,46 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-scripts-static-semantics-early-errors
|
||||
es6id: 15.1.1
|
||||
description: >
|
||||
An indirect eval may not contain SuperCall
|
||||
info: |
|
||||
- It is a Syntax Error if StatementList Contains super unless the source code
|
||||
containing super is eval code that is being processed by a direct eval that
|
||||
is contained in function code that is not the function code of an
|
||||
ArrowFunction.
|
||||
features: [super]
|
||||
---*/
|
||||
|
||||
var caught;
|
||||
|
||||
try {
|
||||
(0,eval)('super();');
|
||||
} catch (err) {
|
||||
caught = err;
|
||||
}
|
||||
|
||||
assert.sameValue(typeof caught, 'object', 'object value thrown (global code)');
|
||||
assert.sameValue(
|
||||
caught.constructor, SyntaxError, 'SyntaxError thrown (global code)'
|
||||
);
|
||||
|
||||
caught = null;
|
||||
|
||||
try {
|
||||
({
|
||||
m() {
|
||||
(0,eval)('super();');
|
||||
}
|
||||
}).m();
|
||||
} catch (err) {
|
||||
caught = err;
|
||||
}
|
||||
|
||||
assert.sameValue(
|
||||
typeof caught, 'object', 'object value thrown (function code)'
|
||||
);
|
||||
assert.sameValue(
|
||||
caught.constructor, SyntaxError, 'SyntaxError thrown (function code)'
|
||||
);
|
|
@ -0,0 +1,46 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-scripts-static-semantics-early-errors
|
||||
es6id: 15.1.1
|
||||
description: >
|
||||
An indirect eval may not contain SuperProperty
|
||||
info: |
|
||||
- It is a Syntax Error if StatementList Contains super unless the source code
|
||||
containing super is eval code that is being processed by a direct eval that
|
||||
is contained in function code that is not the function code of an
|
||||
ArrowFunction.
|
||||
features: [super]
|
||||
---*/
|
||||
|
||||
var caught;
|
||||
|
||||
try {
|
||||
(0,eval)('super.property;');
|
||||
} catch (err) {
|
||||
caught = err;
|
||||
}
|
||||
|
||||
assert.sameValue(typeof caught, 'object', 'object value thrown (global code)');
|
||||
assert.sameValue(
|
||||
caught.constructor, SyntaxError, 'SyntaxError thrown (global code)'
|
||||
);
|
||||
|
||||
caught = null;
|
||||
|
||||
try {
|
||||
({
|
||||
m() {
|
||||
(0,eval)('super.property;');
|
||||
}
|
||||
}).m();
|
||||
} catch (err) {
|
||||
caught = err;
|
||||
}
|
||||
|
||||
assert.sameValue(
|
||||
typeof caught, 'object', 'object value thrown (function code)'
|
||||
);
|
||||
assert.sameValue(
|
||||
caught.constructor, SyntaxError, 'SyntaxError thrown (function code)'
|
||||
);
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-scripts-static-semantics-early-errors
|
||||
es6id: 15.1.1
|
||||
description: An ArrowFunction in global code may not contain SuperCall
|
||||
info: |
|
||||
- It is a Syntax Error if StatementList Contains super unless the source code
|
||||
containing super is eval code that is being processed by a direct eval that
|
||||
is contained in function code that is not the function code of an
|
||||
ArrowFunction.
|
||||
|
||||
14.2.3 Static Semantics: Contains
|
||||
|
||||
With parameter symbol.
|
||||
|
||||
ArrowFunction : ArrowParameters => ConciseBody
|
||||
|
||||
1. If symbol is not one of NewTarget, SuperProperty, SuperCall, super or
|
||||
this, return false.
|
||||
2. If ArrowParameters Contains symbol is true, return true.
|
||||
3. Return ConciseBody Contains symbol.
|
||||
|
||||
NOTE Normally, Contains does not look inside most function forms. However,
|
||||
Contains is used to detect new.target, this, and super usage within an
|
||||
ArrowFunction.
|
||||
features: [super, arrow-function]
|
||||
negative: SyntaxError
|
||||
---*/
|
||||
|
||||
() => {
|
||||
super();
|
||||
};
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-scripts-static-semantics-early-errors
|
||||
es6id: 15.1.1
|
||||
description: Global code may not contain SuperCall
|
||||
info: |
|
||||
- It is a Syntax Error if StatementList Contains super unless the source code
|
||||
containing super is eval code that is being processed by a direct eval that
|
||||
is contained in function code that is not the function code of an
|
||||
ArrowFunction.
|
||||
negative: SyntaxError
|
||||
features: [super]
|
||||
---*/
|
||||
|
||||
super();
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-scripts-static-semantics-early-errors
|
||||
es6id: 15.1.1
|
||||
description: An ArrowFunction in global code may not contain SuperProperty
|
||||
info: |
|
||||
- It is a Syntax Error if StatementList Contains super unless the source code
|
||||
containing super is eval code that is being processed by a direct eval that
|
||||
is contained in function code that is not the function code of an
|
||||
ArrowFunction.
|
||||
|
||||
14.2.3 Static Semantics: Contains
|
||||
|
||||
With parameter symbol.
|
||||
|
||||
ArrowFunction : ArrowParameters => ConciseBody
|
||||
|
||||
1. If symbol is not one of NewTarget, SuperProperty, SuperCall, super or
|
||||
this, return false.
|
||||
2. If ArrowParameters Contains symbol is true, return true.
|
||||
3. Return ConciseBody Contains symbol.
|
||||
|
||||
NOTE Normally, Contains does not look inside most function forms. However,
|
||||
Contains is used to detect new.target, this, and super usage within an
|
||||
ArrowFunction.
|
||||
features: [super, arrow-function]
|
||||
negative: SyntaxError
|
||||
---*/
|
||||
|
||||
() => {
|
||||
super.property;
|
||||
};
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-scripts-static-semantics-early-errors
|
||||
es6id: 15.1.1
|
||||
description: Global code may not contain SuperProperty
|
||||
info: |
|
||||
- It is a Syntax Error if StatementList Contains super unless the source code
|
||||
containing super is eval code that is being processed by a direct eval that
|
||||
is contained in function code that is not the function code of an
|
||||
ArrowFunction.
|
||||
negative: SyntaxError
|
||||
features: [super]
|
||||
---*/
|
||||
|
||||
super.property;
|
Loading…
Reference in New Issue