764 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
5920cb8e1b Add coverage for IteratorClose throw-completion forwarding in destructuring contexts
SM doesn't pass these tests.
2025-06-03 10:41:41 +02:00
Nicolò Ribaudo
bcdafc269f
Increase coverage for dynamic import and top-level await (#4421) 2025-05-08 16:55:49 +02:00
Andreu Botella
c5257e6119
Test that string comparison is per-code-unit (#4457) 2025-04-18 11:57:19 +02:00
Philip Chimento
84f820258b harness: Remove hidden-constructors harness file
The objects it provides are also available in another harness file,
wellKnownIntrinsicObjects.js. There's no point in duplicating that in the
harness. Rewrite each test that used hidden-constructors.js to use
getWellKnownIntrinsicObject instead.
2025-03-11 18:14:55 -07:00
Nicolò Ribaudo
bc5c14176e
Add evaluation tests for import.defer with sync/async modules (#4375)
* Add evaluation tests for `import.defer` with sync/async modules

* Remove accidental import declaration
2025-02-04 11:43:57 -08:00
Nicolò Ribaudo
573058ed2e
Add syntax tests for import.defer (#4374)
These tests are all based on the existing dynamic import syntax tests, just updated to use the new syntax.

This PR does not contain any manually written tests -- they are all generated.
2025-02-04 11:38:19 -08: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
Chengzhong Wu
3f0a24f4f6 [source-phase-imports] update missing source error type 2024-10-25 11:37:04 +02:00
_Kerman
0add42b556
fix: heritage-arrow-function.js (#4273) 2024-10-21 15:54:30 +02:00
André Bargull
18ae34d8f2 Improve coverage for reference type in various contexts
Missing coverage encountered while implementing
<https://github.com/tc39/ecma262/pull/3307> in SpiderMonkey.

Ensure environment lookups are performed in the correct order:
- keyed-destructuring-property-reference-target-evaluation-order-with-bindings.js

Ensure `delete super[elem]` steps are correctly performed:
- delete/super-property-topropertykey.js
- delete/super-property-uninitialized-this.js

Ensure ToPropertyKey for computed property names in object literals
correctly performed:
- object/computed-property-name-topropertykey-before-value-evaluation.js

Ensure `GetSuperBase` is executed before `ToPropertKey`:
- super/prop-expr-getsuperbase-before-topropertykey-*

Ensure `GetThisBinding` is executed first:
- super/prop-expr-uninitialized-this-*
2024-09-20 16:00:53 +02:00
Aapo Alasuutari
cff5a6012f
fix: Use Object.getPrototypeOf to get prototype in __proto__-fn-name.js (#4205) 2024-09-09 14:37:00 +02:00
Jonatan Klemets
3b4d9f53b5 Remove README about keeping import-assertions tests in sync 2024-08-22 12:19:08 -07:00
Jonatan Klemets
3b56bf655f Remove generated import-assertions test files
Generated by running `./make.py clean` and `./make.py`
2024-08-22 12:19:08 -07:00
Jonatan Klemets
cfd81e1698 Remove import-assertions test files 2024-08-22 12:19:08 -07:00
Richard Gibson
b70b75793d Test await in ConditionalExpression 2024-08-21 10:19:55 +02: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
Linus Groh
a82f5382ff Remove 'AsyncArrowFunction' test
There is no such hidden constructor, it's the same as the hidden
AsyncFunction constructor. In other words:

```js
Object.getPrototypeOf(async () => {}).constructor ===
Object.getPrototypeOf(async function () {}).constructor
```

Also add a test to ensure that %AsyncFunction.prototype% is indeed the
prototype of an async arrow function.

Closes #4044.
2024-07-04 11:03:23 +02:00
Chengzhong Wu
8a2229cde8
Add tests for Source Phase Imports (#3980) 2024-06-27 14:58:04 +02:00
Ross Kirsling
007b333af2 Add additional tests for tc39/ecma262#3307.
Ensure that the following cases are covered:
- https://github.com/tc39/ecma262/issues/3295#issuecomment-2058110314
- https://github.com/tc39/ecma262/issues/2659#issue-1131245695
2024-04-22 12:36:07 -07:00
Marko Lahma
263c514afa Add missing DummyError function definition to target-super-computed-reference.js 2024-04-15 11:30:42 -07:00
Ross Kirsling
142a6a6fbe
Update test for o[p] = f() (#4052)
* Update test for o[p] = f()

Update S11.13.1_A7_T3.js now that consensus has been reached on https://github.com/tc39/ecma262/pull/3307.

* Rename test and add an analogous one for super.
2024-04-12 11:59:40 -07:00
Richard Gibson
2060494f28 Test for assignment with target wrapped in two sets of parentheses 2023-11-21 09:51:03 -05:00
Nicolò Ribaudo
0a6dabf1e2 Add readmes 2023-10-26 18:21:19 -07:00
Nicolò Ribaudo
41515e87e5 Use import-attributes flag in new generated tests 2023-10-26 18:21:19 -07:00
Nicolò Ribaudo
3ddb9e5e95 Update import attributes tests to use the with keyword 2023-10-26 18:21:19 -07:00
Nicolò Ribaudo
06f6ae960a Copy all import assertions tests as a basis for import attributes tests 2023-10-26 18:21:19 -07:00
Daniel Minor
55e8cceb80 Revert "Revert "Fixup class names in class decorator private identifier tests.""
This reverts commit 31f703cbe69ec2e0fd4b94de2fdf505fb722b552.

The changes are needed to both the templates and the generated files.
2023-10-05 10:23:12 -07:00
Daniel Minor
3ef0777c04 Revert "Fixup class names in class decorator private identifier tests."
This changed the test files, not the templates used to generate the tests.
2023-10-05 10:23:12 -07:00
Daniel Minor
581de2d0f8 Fixup class names in class decorator private identifier tests.
For the statement level test, the inner class name is not initialized
at the time the decorators evaluate, resulting in a ReferenceError
that the declaration can not be accessed prior to initialization.

Similar, non-decorator code, like:
    class C {
        static dec() {}
        static {
            this.x = C.dec();
            class C {}
        }
    }
also results in a ReferenceError.

For the expression level test, the var C is undefined at the time the
decorators are evaluated, resulting in TypeError while trying to access
a member of undefined.

Similar, non-decorator code, like:
    var C = class {
        static f() {};
        static {
            this.x = C.f();
        }
    }
also results in a TypeError.
2023-10-05 10:23:12 -07:00
André Bargull
08a7b9d4b6 Use verifyProperty in language/expressions tests 2023-09-13 16:05:40 +02:00
Nicolò Ribaudo
1bb53aee3e
Update import attributes assert tests to current semantics (#3919)
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2023-09-13 11:35:06 +02:00
Nicolò Ribaudo
7ef1833109 Move all tests using import assertions to files named as such 2023-07-17 16:32:25 +02:00
Michael Dyck
f5c932144a Delete trailing space after |
I'm not sure if YAML disallows it,
but test262 avoids it.
2023-06-29 14:08:47 +02:00
Veera
88a2f0dcd1 Fix copyright 2023-05-18 11:19:31 -07:00
Veera
732cfff666 Fix YAML indentation 2023-05-18 11:19:31 -07:00
Veera
bf337727a0 Try to fix CI errors 2023-05-18 11:19:31 -07:00
Veera
377231a1de Add tests for increment and decrement operations on this 2023-05-18 11:19:31 -07:00
Huáng Jùnliàng
ff405fd0df update fixtures 2023-03-29 12:54:37 -07:00
José Julián Espina
4a6439e4a7
Add Array.prototype.includes and exponentiation features (#3799) 2023-03-23 10:51:08 +01:00
Cam Tenny
4fe158d39d Generated tests for refactoring (IIFE/async function).then(\$DONE, \$DONE); to use asyncTest 2023-02-21 11:04:09 -08:00
Cam Tenny
4d9d5c570d Refactor simple cases of (IIFE/async function).then(\$DONE, \$DONE); to use asyncTest 2023-02-21 11:04:09 -08:00
Philip Chimento
cc559ac106 Rebuild generated tests 2022-11-30 16:04:02 -08:00
Philip Chimento
d87a7da6e1 Replace Object.hasOwnProperty.call with Object.prototype.hasOwnProperty.call
While we're at it, use assert() instead of assert.sameValue() for brevity,
if we are not specifically testing that the return value of hasOwnProperty
is the value true or false; and add more informative assertion messages to
help with debugging.

In some cases, the Object.hasOwnProperty.call could be replaced with
verifyProperty(), if the property descriptor was also being verified at
the same time.

This fixes some tests that were faulty to begin with: a common mistake was
Object.hasOwnProperty(obj, prop) which is probably going to return false
when that's not what you want.

The only instances left of `Object.hasOwnProperty` are one regression test
in implementation-contributed which I can't tell if it was intentionally
needed to trigger the regression, and a few instances of
`Object.hasOwnProperty('prototype')` which would defeat the purpose to
convert into `Object.prototype.hasOwnProperty.call(Object, 'prototype')`
form.

Closes: #3524
2022-11-30 16:04:02 -08:00
Gokhan Kurt
f5369c26a4 add async-functions feature to files which should have it 2022-10-17 11:21:23 +02:00
legendecas
ee521159d5 Fix decorator tests 2022-06-23 15:17:43 -04:00
Youssef Soliman
79c4496559 Fixed spelling error identifer -> identifier. 2022-06-21 10:14:17 +02:00
Huáng Jùnliàng
79e3bc5176
add noStrict flag to yield-as-binding-id cases (#3551) 2022-06-09 09:01:21 +02:00
legendecas
6f8e0f67ca Decorators: add initial tests on class 2022-05-18 09:49:49 -04:00
Richard Gibson
c58ac691eb Test that "infinity" is not recognized as numeric 2022-04-04 16:56:40 -04:00