37 Commits

Author SHA1 Message Date
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
Kevin Gibbons
67a5153cf5
add Float16Array to all generic TypedArray tests (#3849) 2024-01-10 14:07:57 +01:00
Kevin Gibbons
5a263f5b19 add the TypedArray feature flag to some tests which were missing it 2024-01-08 17:21:46 -08:00
André Bargull
ff81dccfc3 Use verifyProperty in language/statements tests 2023-09-13 16:05:40 +02:00
Rick Waldron
8b4382d2f2
Transform compareArray -> assert.compareArray: test/language/**/*.js (#3239) 2021-10-15 20:35:01 -04:00
Mike Pennisi
d9ddf80479 Revert "Merge pull request #3219 from tc39/rwaldron/migrate-comparearray"
This reverts commit b690cb67be9b487eb10156c03e2c00869e88cc9d, reversing
changes made to 50dd431dffe5cf86e9064a652d6b01dbbe542cf0. This is
necessary because the reverted changeset reduced coverage by an unknown
extent.
2021-10-01 10:18:47 -04:00
rwaldron
4847d9db5a chore: update test/**/*.js to use assert.compareArray wherever applicable 2021-09-24 12:58:15 -04:00
André Bargull
b74b15c49c
Derived class constructor checks are executed after leaving the function body (#3129) 2021-08-04 09:58:24 -07:00
rwaldron
4a125f2f4e chore: migrate $ERROR -> throw new Test262Error in test/language/s* 2021-07-29 10:38:53 -04:00
Gus Caplan
516ca9af39 Update tests for ECMA262 #2216
https://github.com/tc39/ecma262/pull/2216
2021-02-26 11:49:49 -05:00
Alexey Shvayka
9bd8813674 Rename bound function test and update meta 2020-05-13 12:58:33 -04:00
Alexey Shvayka
47abdd0c5e Add async generator function test 2020-05-13 12:58:33 -04:00
Alexey Shvayka
4118a67bef Add async function test 2020-05-13 12:58:33 -04:00
Alexey Shvayka
a71bc984ff Add arrow function test 2020-05-13 12:58:33 -04:00
Alexey Shvayka
9ff500ed70 Rename & improve generator function test 2020-05-13 12:58:33 -04:00
Gus Caplan
922e27fd8c fix super evaluation order tests 2020-02-20 12:37:03 -05:00
Shu-yu Guo
27bda64012 Update tests for removal of per-parameter position var scope (#2445)
See https://github.com/tc39/ecma262/pull/1046
2019-12-23 13:36:09 -05:00
Gus Caplan
34333993d7 tag subclass tests with WeakSet and WeakMap (#2421) 2019-11-11 20:58:38 -05:00
Gus Caplan
a53f43e1ce
add missing newlines in tests 2019-11-10 20:18:56 -08:00
André Bargull
f717982c94 Remove unused includes 2018-01-25 13:59:37 -05:00
Rick Waldron
92a2621901 Frontmatter: fixup "info: >" to "info: |" 2018-01-05 12:27:59 -05:00
Leo Balter
f8f5a7a1e7
Add missing generators flags 2017-10-26 19:04:57 -04:00
Leo Balter
7f88a6d7f9 Add other missing Symbol feature flags 2017-09-08 10:13:50 -04:00
Leo Balter
c41faf1aca Add missing Symbol features flags 2017-09-07 15:51:13 -04:00
André Bargull
d59e30c95e Remove execute bit from files (#976) 2017-04-13 16:24:07 -04:00
André Bargull
7e94b8b7ac Fix executor arguments validation in Promise subclass test 2017-02-22 18:05:08 +01:00
André Bargull
c16359bc3c Update tests for classes extending null
Per https://github.com/tc39/ecma262/pull/781
2017-02-22 18:04:43 +01:00
Adam Klein
4ff7e4342e Fix test for instantiating a class extending null (#813)
The sameValue assertion should be that the [[Prototype]] is
equal to the class's prototype, not the constructor.
2016-12-28 17:18:19 -08:00
Kevin Gibbons
fcc9e07265 Add test for extending a constructor with null .prototype (#806) 2016-12-21 01:30:06 -05:00
jugglinmike
35206ee85b Add test for subclassing bound functions (#720)
The semantics under test have been incorrectly implemented by the
SpiderMonkey engine.
2016-07-11 13:46:03 -07:00
Leonardo Balter
c204c30a54 Remove invalid test from ArrayBuffer subclassing
Fixes gh-696

As pointed in gh-696, the ArrayBuffer ctor won't throw a RangeError when
invoked without arguments.

Instead of fixing the invalid assertion, this commit removes it as the
coverage for subclassing is already satisfied by the use of slice.
2016-07-05 16:29:21 -04:00
jugglinmike
dee1526ca7 Update tests concerning null-extending classes (#658)
The latest revision of ECMA262 makes special provisions for classes
which extend the `null` value [1]. Update the relevant tests
accordingly.

[1] https://github.com/tc39/ecma262/issues/543
2016-06-10 15:10:32 -04:00
André Bargull
2acbd3e98e Improve coverage for default class constructors 2016-03-01 19:15:21 +01:00
Leonardo Balter
d9a277aa7c Fix location based return value for Date on subclassing tests
Fixes #489
2016-02-22 13:53:43 -05:00
Leonardo Balter
42d1a10d6d fixup! Add tests for Array - calling super with a single argument 2016-01-13 13:28:00 -05:00
Leonardo Balter
c99ace29d7 Move subclass tests to test/language/statements/class/subclass/builtin-objects 2016-01-12 16:45:03 -05:00
Rick Waldron
29e2990d9b 14.5 Class Definitions
- 14.5.1 Static Semantics: Early Errors
- 14.5.3 Static Semantics: ConstructorMethod
- 14.5.14 Runtime Semantics: ClassDefinitionEvaluation
2015-05-02 14:06:57 -04:00