163 Commits

Author SHA1 Message Date
Ross Kirsling
609614febe
Add tests for "Runtime Errors for Function Call Assignment Targets" (#4459)
* Add tests for ecma262#3568

* "Late" -> "Runtime"

* Check for functions named `async` too.
2025-07-15 09:22:15 -07:00
André Bargull
98a7f03f5c Remove leading space characters in YAML frontmatter
Remove leading space characters so directly loading the frontmatter text
with `yaml.safe_load` doesn't throw an exception.
2024-12-17 17:52:36 +01:00
Boshen
42d83277b7
Fix single-line-html-close-first-line-* failing with Test262Error is not defined (#4333)
Fix `single-line-html-close-first-line-*` failing with `Test262Error is not defined`

closes #4020
2024-12-04 11:55:40 -08:00
André Bargull
92b592547d Ensure NaN time values are correctly handled in various Date setters
Related PR: https://github.com/tc39/ecma262/pull/2136
2024-10-11 12:19:13 -07:00
Peter Hoddie
e4f4abdcb2
Compatibility with Hardened JavaScript (#4088)
This PR proposes changes to existing test262 tests to allow them to pass under Hardened JavaScript (see Secure ECMAScript proposal and Hardened JavaScript). Moddable uses Hardened JavaScript for JavaScript runtimes on resource constrained embedded devices, including those targeted by ECMA-419.

The changes fall into four groups:

1. Replace use of new Date() with new Date(1970). Scripts running inside a Compartment cannot retrieve the current time, so new Date() throws but new Date(1970) succeeds. Very few tests need the current time, but instead simply need a Date instance.
2. Use Object.defineProperty instead of setting existing built-in properties directly, such as toString and toValue. In Hardened JavaScript, prototypes of built-in objects are frozen. Consequently, setting properties of an instance that exist on the prototype throw (Hardened JavaScript is always in strict mode).
3. Eliminate use of Math.random(). Scripts running inside a Compartment cannot generate random numbers. One test identified so far uses Math.random() in a way that can easily be replaced with a counter.
4. Narrow the scope of exception tests. Consider the following

assert.throws(TypeError, () => {
  var s1 = new Date();
  s1.toString = Boolean.prototype.toString;
  s1.toString();
});

This test passes, but only because new Date() fails by throwing a TypeError. If the invocation of the Date constructor is resolved by (1) above, then the assignment to toString fails as per (2) above. The script should be modified as below to ensure that assert.throws only tests the intended statement, s1.toString(). The modified script tests the intended functionality and passes under Hardened JavaScript

var s1 = new Date(1970);
Object.defineProperty(s1, "toString", {
  value: Boolean.prototype.toString
});
assert.throws(TypeError, () => {
  s1.toString();
});

This is an initial PR to begin the process of adapting test262 for use with Hardened JavaScript. Further changes are expected, with the vast majority likely to fall into the four groups described above.

Thank you to gibson042, kriskowal, and erights for their advice on this work.
2024-07-04 08:19:23 -07:00
Shu-yu Guo
c5a80993cd Allow global var-via-eval be declared
See https://github.com/tc39/ecma262/pull/3226
2024-04-11 17:22:43 -07:00
Kevin Gibbons
961480ac61 remove some auto-generated error messages in "assert.throws" tests 2024-03-25 12:09:10 +01:00
Nicolò Ribaudo
866d24deb2 Improve test robustness 2024-02-09 16:28:05 -08:00
Nicolò Ribaudo
98938f4c0a Add tests for --> in the first line 2024-02-09 16:28:05 -08:00
Lucas Mirelmann
b628e4b054 Update single-line-html-close.js
Fix comment with the description of the syntax
2023-12-18 09:42:42 -05:00
Alexey Shvayka
be53234590
Test that HasVarDeclaration accounts for bindings created via eval() (#3914)
Co-authored-by: Alexey Shvayka <ashvayka@apple.com>
2023-09-28 18:16:33 +02:00
Philip Chimento
d77d9b2b85 Duplicate named capture groups: Syntax tests
Parse-time syntax for RegExp literals is already tested. These two files
test runtime RegExp compilation, with respect to duplicate named capture
groups.

See: #3704
2022-11-02 15:22:58 +01:00
André Bargull
c335322537 Add exhaustive test for String.prototype.substr with various number inputs
Also see: https://github.com/tc39/ecma262/pull/2844
2022-09-20 09:57:12 -07:00
Jan Štola
71a0bb9e7f RegExp.prototype.compile from other realm should throw TypeError from other realm. 2021-09-10 15:04:11 -04:00
Rick Waldron
2bb2256877
chore: migrate $ERROR -> throw new Test262Error in test/annexB (#3121) 2021-07-29 11:03:18 -07:00
Mike Pennisi
d454b8389b Move some AnnexB tests per proposed spec change
Additionally, update test metadata and introduce two new tests to
complete coverage.

Reference: "Normative: Make B.1.{1,2} normative"
https://github.com/tc39/ecma262/pull/1867
2021-05-21 13:06:41 -04:00
Gus Caplan
881c9e3ba5 move __proto__ tests 2020-10-08 18:05:00 -04:00
Gus Caplan
14788fee59 move define/lookup tests 2020-10-08 18:05:00 -04:00
Rick Waldron
d576baf73f Info: adds "sec-evaluatenew" step to info for all "not-a-constructor.js" tests. 2020-10-06 12:01:34 -04:00
Rick Waldron
c644ede430 Built-in function objects that are not identified as constructors must throw a TypeError exception when new'ed. Fixes gh-1739 2020-10-06 12:01:34 -04:00
ExE Boss
9c754bc3ce Add tests for cross‑realm and subclass calls of legacy static accessors 2020-09-10 16:07:17 -04:00
ExE Boss
391f799152 Add tests for cross‑realm and subclass RegExp.prototype.compile calls 2020-09-10 16:07:17 -04:00
ExE Boss
d06c21c03a Add tests for property descriptors of legacy RegExp accessors 2020-09-10 16:07:17 -04:00
Alexey Shvayka
b9cbff7378 Add poisoned Object.prototype.__proto__ test 2020-09-02 15:31:42 -04:00
Alexey Shvayka
e0758bbeac Add if statement test 2020-08-12 14:09:22 -04:00
Alexey Shvayka
73c04fc61d Add logical OR operator test 2020-08-12 14:09:22 -04:00
Alexey Shvayka
69d74c18c2 Add logical NOT operator test 2020-08-12 14:09:22 -04:00
Alexey Shvayka
61188b8abc Add logical assignment tests 2020-08-12 14:09:22 -04:00
Alexey Shvayka
ec6f77c4d1 Add logical AND operator test 2020-08-12 14:09:22 -04:00
Alexey Shvayka
8c2c50df3b Add conditional operator test 2020-08-12 14:09:22 -04:00
Alexey Shvayka
4312dfa6a6 Add coalesce expression test 2020-08-12 14:09:22 -04:00
Alexey Shvayka
2f6d3a90b5 Add switch statement test 2020-08-12 14:06:34 -04:00
Alexey Shvayka
3732589424 Add abstract equality tests 2020-08-12 14:06:34 -04:00
Alexey Shvayka
f2036e21bf Add strict equality tests 2020-08-12 14:06:34 -04:00
Alexey Shvayka
f95e9d3f85 Add Object.is test 2020-08-12 14:06:34 -04:00
Alexey Shvayka
c619375b46
Test [[IsHTMLDDA]] object with typeof operator (#2706) 2020-07-21 14:14:56 -07:00
Alexey Shvayka
e193b449d4
Test [[IsHTMLDDA]] object as "prototype" of superclass (#2702) 2020-07-15 10:50:02 -07:00
QuXing9
19653bdfc8
Additional tests for escape and unescape methods (#2695)
Co-authored-by: Leo Balter <leonardo.balter@gmail.com>
2020-07-09 10:16:18 -07:00
QuXing9
91a9abff4e
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
2020-07-09 09:57:55 -07:00
Leo Balter
5908ed29ac
Fix tests for HTML comments in function body evaluation (#2109)
Ref tc39/ecma262#1479
2020-06-19 15:06:16 -07:00
Alexey Shvayka
8095883a81 Test [[IsHTMLDDA]] object as superclass 2020-06-10 14:03:10 -04:00
Alexey Shvayka
5f1e61e427 Fix [[IsHTMLDDA]] Symbol.replaceAll test 2020-05-20 13:38:32 -04:00
Alexey Shvayka
35a31d157b Add String.prototype.split test 2020-05-13 10:52:57 -04:00
Alexey Shvayka
fd74f97067 Add String.prototype.search test 2020-05-13 10:52:57 -04:00
Alexey Shvayka
825dd31d27 Add String.prototype.replaceAll test 2020-05-13 10:52:57 -04:00
Alexey Shvayka
6cce955d6d Add String.prototype.replace test 2020-05-13 10:52:57 -04:00
Alexey Shvayka
a66fe41259 Add String.prototype.matchAll test 2020-05-13 10:52:57 -04:00
Alexey Shvayka
3abf511728 Add String.prototype.match test 2020-05-13 10:52:57 -04:00
Alexey Shvayka
5498ab79a1 Add %TypedArray%.from test 2020-05-13 10:52:57 -04:00
Alexey Shvayka
2dac38815f Add Array.from test 2020-05-13 10:52:57 -04:00