js-on-sx: baseline commit (278/280 unit, 148/148 slice, runner stub)

Initial commit of the lib/js/ tree and plans/ directory. A previous
session left template-string work in progress — 278/280 unit tests pass
(2 failing: tpl part-count off-by-one, escaped-backtick ident lookup).
test262-runner.py and scoreboard are placeholders (0/8 with 7 timeouts);
fixing the runner is the next queue item.
This commit is contained in:
2026-04-23 19:42:16 +00:00
parent 14b6586e41
commit 9e568ad886
310 changed files with 7056 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
# JS-on-SX cherry-picked conformance slice
A hand-picked slice inspired by test262 expression tests. Each test is one
JS expression in a `.js` file, paired with an `.expected` file containing
the SX-printed result that `js-eval` should produce.
Run via:
bash lib/js/conformance.sh
The slice intentionally avoids anything not yet implemented (statements,
`var`/`let`, `function`, regex, template strings, prototypes, `new`,
`this`, classes, async). Those land in later phases.
## Expected value format
`js-eval` returns SX values. The epoch protocol prints them thus:
| JS value | Expected file contents |
|------------------|-----------------------|
| `42` | `42` |
| `3.14` | `3.14` |
| `true` / `false` | `true` / `false` |
| `"hi"` | `"hi"` |
| `null` | `nil` |
| `undefined` | `"js-undefined"` |
| `[1,2,3]` | `(1 2 3)` |
| `{}` | `{}` |
The runner does a substring match — the `.expected` file can contain just
the distinguishing part of the result.

View File

@@ -0,0 +1 @@
3

View File

@@ -0,0 +1 @@
1 + 2

View File

@@ -0,0 +1 @@
5

View File

@@ -0,0 +1 @@
1 + 2 * 3 - 4 / 2

View File

@@ -0,0 +1 @@
-6

View File

@@ -0,0 +1 @@
~5

View File

@@ -0,0 +1 @@
10

View File

@@ -0,0 +1 @@
1 + 2 + 3 + 4

View File

@@ -0,0 +1 @@
3

View File

@@ -0,0 +1 @@
12 / 4

View File

@@ -0,0 +1 @@
"12"

View File

@@ -0,0 +1 @@
1 + "2"

View File

@@ -0,0 +1 @@
1

View File

@@ -0,0 +1 @@
10 % 3

View File

@@ -0,0 +1 @@
-5

View File

@@ -0,0 +1 @@
-5

View File

@@ -0,0 +1 @@
9

View File

@@ -0,0 +1 @@
(1 + 2) * 3

View File

@@ -0,0 +1 @@
5

View File

@@ -0,0 +1 @@
+5

View File

@@ -0,0 +1 @@
1024

View File

@@ -0,0 +1 @@
2 ** 10

View File

@@ -0,0 +1 @@
512

View File

@@ -0,0 +1 @@
2 ** 3 ** 2

View File

@@ -0,0 +1 @@
7

View File

@@ -0,0 +1 @@
1 + 2 * 3

View File

@@ -0,0 +1 @@
"ab"

View File

@@ -0,0 +1 @@
"a" + "b"

View File

@@ -0,0 +1 @@
6

View File

@@ -0,0 +1 @@
10 - 4

View File

@@ -0,0 +1 @@
42

View File

@@ -0,0 +1,5 @@
var double = async x => x * 2;
var r = null;
double(21).then(v => { r = v; });
__drain();
r

View File

@@ -0,0 +1 @@
42

View File

@@ -0,0 +1,5 @@
var add = async (a, b) => a + b;
var r = null;
add(10, 32).then(v => { r = v; });
__drain();
r

View File

@@ -0,0 +1 @@
42

View File

@@ -0,0 +1,5 @@
async function f() { return 42; }
var r = null;
f().then(v => { r = v; });
__drain();
r

View File

@@ -0,0 +1 @@
nope

View File

@@ -0,0 +1,5 @@
async function f() { throw "nope"; }
var r = null;
f().catch(e => { r = e; });
__drain();
r

View File

@@ -0,0 +1 @@
33

View File

@@ -0,0 +1,7 @@
async function inner(x) { return x * 2; }
async function middle(x) { var r = await inner(x); return r + 1; }
async function outer(x) { var r = await middle(x); return r * 3; }
var result = null;
outer(5).then(v => { result = v; });
__drain();
result

View File

@@ -0,0 +1 @@
100

View File

@@ -0,0 +1,5 @@
async function wrap(x) { return Promise.resolve(x); }
var r = null;
wrap(100).then(v => { r = v; });
__drain();
r

View File

@@ -0,0 +1 @@
70

View File

@@ -0,0 +1,9 @@
async function add(a, b) { return a + b; }
async function main() {
var r = await add(3, 4);
return r * 10;
}
var result = null;
main().then(v => { result = v; });
__drain();
result

View File

@@ -0,0 +1 @@
3

View File

@@ -0,0 +1,11 @@
async function step() { return 1; }
async function main() {
var a = await step();
var b = await step();
var c = await step();
return a + b + c;
}
var r = null;
main().then(v => { r = v; });
__drain();
r

View File

@@ -0,0 +1 @@
5

View File

@@ -0,0 +1,12 @@
async function one() { return 1; }
async function main() {
var sum = 0;
for (var i = 0; i < 5; i = i + 1) {
sum = sum + await one();
}
return sum;
}
var r = null;
main().then(v => { r = v; });
__drain();
r

View File

@@ -0,0 +1 @@
43

View File

@@ -0,0 +1,8 @@
async function main() {
var x = await 42;
return x + 1;
}
var r = null;
main().then(v => { r = v; });
__drain();
r

View File

@@ -0,0 +1 @@
6

View File

@@ -0,0 +1,8 @@
async function main() {
var vs = await Promise.all([Promise.resolve(1), Promise.resolve(2), Promise.resolve(3)]);
return vs[0] + vs[1] + vs[2];
}
var r = null;
main().then(v => { r = v; });
__drain();
r

View File

@@ -0,0 +1 @@
caught:no

View File

@@ -0,0 +1,9 @@
async function bad() { throw "no"; }
async function main() {
try { await bad(); return "unreachable"; }
catch (e) { return "caught:" + e; }
}
var r = null;
main().then(v => { r = v; });
__drain();
r

View File

@@ -0,0 +1 @@
bad

View File

@@ -0,0 +1,9 @@
async function failing() { throw new Error("bad"); }
async function main() {
try { await failing(); return "unreachable"; }
catch (e) { return e.message; }
}
var r = null;
main().then(v => { r = v; });
__drain();
r

View File

@@ -0,0 +1 @@
44

View File

@@ -0,0 +1 @@
function mk(n) { return x => x + n; } let add7 = mk(7); add7(10) + add7(20)

View File

@@ -0,0 +1 @@
4

View File

@@ -0,0 +1 @@
function mkc() { let n = 0; return () => { n = n + 1; return n; }; } let c = mkc(); c(); c(); c(); c()

View File

@@ -0,0 +1 @@
42

View File

@@ -0,0 +1 @@
function mkPair() { let x = 0; let y = 0; let setX = v => { x = v; }; let setY = v => { y = v; }; let get = () => x + y; setX(17); setY(25); return get(); } mkPair()

View File

@@ -0,0 +1 @@
3

View File

@@ -0,0 +1 @@
function outer() { let a = 1; function inner() { let b = 2; function deepest() { return a + b; } return deepest(); } return inner(); } outer()

View File

@@ -0,0 +1 @@
55

View File

@@ -0,0 +1 @@
function sumSq(xs) { let t = 0; for (let i = 0; i < xs.length; i = i + 1) t = t + xs[i] * xs[i]; return t; } sumSq([1,2,3,4,5])

View File

@@ -0,0 +1 @@
"n=42"

View File

@@ -0,0 +1 @@
"n=" + 42

View File

@@ -0,0 +1 @@
true

View File

@@ -0,0 +1 @@
"5" == 5

View File

@@ -0,0 +1 @@
"boolean"

View File

@@ -0,0 +1 @@
typeof true

View File

@@ -0,0 +1 @@
"function"

View File

@@ -0,0 +1 @@
typeof (x => x)

View File

@@ -0,0 +1 @@
"object"

View File

@@ -0,0 +1 @@
typeof null

View File

@@ -0,0 +1 @@
"number"

View File

@@ -0,0 +1 @@
typeof 42

View File

@@ -0,0 +1 @@
"string"

View File

@@ -0,0 +1 @@
typeof "x"

View File

@@ -0,0 +1 @@
"undefined"

View File

@@ -0,0 +1 @@
typeof undefined

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1 @@
[].length

View File

@@ -0,0 +1 @@
20

View File

@@ -0,0 +1 @@
[10,20,30][1]

View File

@@ -0,0 +1 @@
3

View File

@@ -0,0 +1 @@
[1,2,3].length

View File

@@ -0,0 +1 @@
3

View File

@@ -0,0 +1 @@
[[1,2],[3,4]][1][0]

View File

@@ -0,0 +1 @@
5

View File

@@ -0,0 +1 @@
[1,2,3].length + [4,5].length

View File

@@ -0,0 +1 @@
42

View File

@@ -0,0 +1 @@
({a:{b:{c:42}}}).a.b.c

View File

@@ -0,0 +1 @@
1

View File

@@ -0,0 +1 @@
({x:1,y:2}).x

View File

@@ -0,0 +1 @@
"e"

View File

@@ -0,0 +1 @@
"hello"[1]

View File

@@ -0,0 +1 @@
5

Some files were not shown because too many files have changed in this diff Show More