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:
QuXing9 2020-07-10 00:57:55 +08:00 committed by GitHub
parent d3c693bdfe
commit 91a9abff4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 74 additions and 0 deletions

View File

@ -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');

View File

@ -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 ({}) {}");
});

View File

@ -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;)");
});

View File

@ -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;)");
});