mirror of https://github.com/tc39/test262.git
Add three testcases for test262 suite. (#2692)
* Add tests for escape function when parameter is not a string. Fixes #2687 Fixes #2637 * Add test for indirect eval calls when script is a for statement. When for statement doesn't have a body, it should throw a SyntaxError. Fixes #2661 * Add tests for Function Constructor when body contains usestrict. Fixes #2688 Fixes #2638
This commit is contained in:
parent
d3c693bdfe
commit
91a9abff4e
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) 2020 Qu Xing. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-escape-string
|
||||
description: Input is a null, undefined or boolean
|
||||
info: |
|
||||
B.2.1.1 escape ( string )
|
||||
|
||||
1. Let string be ? ToString(string).
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.sameValue(escape(null), 'null');
|
||||
|
||||
assert.sameValue(escape(undefined), 'undefined');
|
||||
|
||||
assert.sameValue(escape(true), 'true');
|
||||
|
||||
assert.sameValue(escape(false), 'false');
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright (C) 2020 Xing Qu. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-createdynamicfunction
|
||||
description: Strictfunction shouldn't have the reserved word "with"
|
||||
info: |
|
||||
CreateDynamicFunction ( constructor, newTarget, kind, args )
|
||||
|
||||
...
|
||||
20 Perform the following substeps in an implementation-dependent order, possibly interleaving parsing and error detection:
|
||||
...
|
||||
c. Let strict be ContainsUseStrict of body.
|
||||
d. If any static semantics errors are detected for parameters or body, throw a SyntaxError exception.
|
||||
If strict is true, the Early Error rules for UniqueFormalParameters:FormalParameters are applied.
|
||||
...
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.throws(SyntaxError, function() {
|
||||
new Function("'use strict'; with ({}) {}");
|
||||
});
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright 2020 Qu Xing. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-performeval
|
||||
description: For statement
|
||||
info: |
|
||||
...
|
||||
9. Perform the following substeps in an implementation-dependent order, possibly interleaving parsing and error detection:
|
||||
a. Let script be the ECMAScript code that is the result of parsing ! UTF16DecodeString(x),for the goal symbol Script.
|
||||
If the parse fails, throw a SyntaxError exception. If any early errors are detected, throw a SyntaxError exception
|
||||
(but see also clause 16).
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.throws(SyntaxError, function() {
|
||||
eval("for(;false;)");
|
||||
});
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright 2020 Qu Xing. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-performeval
|
||||
description: For statement
|
||||
info: |
|
||||
...
|
||||
9. Perform the following substeps in an implementation-dependent order, possibly interleaving parsing and error detection:
|
||||
a. Let script be the ECMAScript code that is the result of parsing ! UTF16DecodeString(x),for the goal symbol Script.
|
||||
If the parse fails, throw a SyntaxError exception. If any early errors are detected, throw a SyntaxError exception
|
||||
(but see also clause 16).
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.throws(SyntaxError, function() {
|
||||
(0, eval)("for(;false;)");
|
||||
});
|
Loading…
Reference in New Issue