Skip to content

Support running test262 using Jint.Repl#2326

Merged
lahma merged 3 commits into
sebastienros:mainfrom
ivankra:test262
Mar 21, 2026
Merged

Support running test262 using Jint.Repl#2326
lahma merged 3 commits into
sebastienros:mainfrom
ivankra:test262

Conversation

@ivankra

@ivankra ivankra commented Mar 15, 2026

Copy link
Copy Markdown
Contributor

Add $262 object, --module flag and printing of exception type to Jint.Repl so that it can be used to run test262 test suite via an external tester like eshost + test262-harness.

@lahma lahma left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, nice addition. Comment about unnecessary public type.

Comment thread Jint/Test262Object.cs Outdated
@lahma

lahma commented Mar 19, 2026

Copy link
Copy Markdown
Collaborator

@ivankra can you please rebase this againt main and consider just sharing via csproj linking. Let me know when you feel PR is good to go from your part.

ivankra added 3 commits March 21, 2026 18:24
So that it can be used to run test262 test suite via an external tester
like eshost + test262-harness.

Extracted out Test262Object.cs from Jint.Tests.Test262/Test262Test.cs
and moved it together with Test262AgentManager.cs to Jint/ so that
they could be used in both Jint.Repl and Jint.Tests.Test262.

Both classes are internal and rely on some engine internals as well.
Made visible to Jint.Repl via Jint/AssemblyInfoExtras.cs, similarly
to how it was already done for Jint.Tests.Test262.
Needed for running test262 via an external tester to properly support
negative test cases - they prescribe checking exception type.

Testing:

$ echo x | ./Jint.Repl
Uncaught exception: ReferenceError: x is not defined
    at stdin:1:1
$ echo 'function Test262Error(){}; throw new Test262Error();' | ./dist/Jint.Repl
Uncaught exception: Test262Error
    at stdin:1:29
Needed for running test262's module tests via an external tester.
Automatically set it if file has .mjs extension (d8/node convention).

Testing:

$ echo 'import { f } from "./b.js"; console.log(f("hel", "lo"));' >a.js
$ echo 'export const f = (a, b) => a + b;' >b.js
$ ./Jint.Repl -m a.js
hello
$ ./Jint.Repl a.js
Uncaught exception: SyntaxError: Cannot use import statement outside a module (a.js:1:1)
@ivankra

ivankra commented Mar 21, 2026

Copy link
Copy Markdown
Contributor Author

Sorry for late reply, I rebased now. I think it's in a good state now.

I fixed a couple things since the original PR:

  • Also moved Test262AgentManager.cs to Jint -- it's responsible for $262.agent object.
  • Automatically set --module if the file has .mjs extension, similarly to d8/node.
  • Cleaner formatting for user-defined exceptions. E.g. echo 'function Test262Error(){}; throw new Test262Error();' | ./dist/Jint.Repl: Uncaught exception: Error: Test262Error: undefined becomes now a cleaner: Uncaught exception: Test262Error

I explored linking via csproj and leaving the Test262* files in Jint.Tests.Test262, but they reference some engine internals, so looks like I need to add that internal visibility bit for Jint.Repl anyway:

jint/Jint.Tests.Test262/Test262Object.cs(20,24): error CS1061: 'Engine' does not contain a definition for 'Realm' and no accessible extension method 'Realm' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)
Jint.Tests.Test262/Test262Object.cs(41,36): error CS1061: 'Engine' does not contain a definition for '_host' and no accessible extension method '_host' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)
Jint.Tests.Test262/Test262Object.cs(50,24): error CS1061: 'JsArrayBuffer' does not contain a definition for 'DetachArrayBuffer' and no accessible extension method 'DetachArrayBuffer' accepting a first argument of type 'JsArrayBuffer' could be found (are you missing a using directive or an assembly reference?)
Jint.Tests.Test262/Test262Object.cs(62,67): error CS0122: 'IsHTMLDDA' is inaccessible due to its protection level

@lahma lahma left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you!

@lahma
lahma merged commit b52eb9e into sebastienros:main Mar 21, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants