At this point with an alpha version, we need to ensure that behavior is maintained across versions, this means:
I push ( please block main, yeah kind of a skill issue from expecting main to be protected) a prototype for testing using bun.
You can check out the changes in this commit.
It is required to install bun and have your own
compilerintest/
To run it:
bun test
Optimizations don't affect standard behavior and this will save us a lot of time, please let me know about any new feature so I can make a test or if you consider that this proposal needs more improvements.
Milestone: later.
i want to re-iterate that a behavior test is testing Parse + Transform + Sema + ANY BACKEND. When wasm backend starts, it should be able to re-use all of these behavior tests.
an example
fn f(a: float) -> float { a }
fn addFloat(a: float, b: float) -> float {
a + b
}
fn subFloat(a: float, b: float) -> float {
a - b
}
fn mulFloat(a: float, b: float) -> float {
a * b
}
fn divFloat(a: float, b: float) -> float {
a / b
}
let assertEqual = @js("assertEqual");
assertEqual(addFloat(1, 2), f(3));
assertEqual(addFloat(1.5, 2.2), f(3.7));
assertEqual(subFloat(1, 2), f(-1));
assertEqual(subFloat(1.5, 2.2), f(-0.7000000000000002));
assertEqual(mulFloat(1, 2), f(2));
assertEqual(mulFloat(1.5, 2.2), f(3.3000000000000003));
assertEqual(divFloat(1, 2), f(0.5));
assertEqual(divFloat(1.5, 2.2), f(0.6818181818181818));
Once the standard library has an assertion function like this, we will switch to that. For now we will assume an external symbol assertEqual
function assertEqual(actual, expected) {
if (actual !== expected) {
var err;
try {
err = new Error("Expected " + expected + ", but got " + actual);
} catch (e) {
err = new Error("Assertion failure");
}
throw err;
}
}
also, all of the behavior tests should succeed to compile without warnings. later (probably in #79), i will introduce a second category of tests to ensure errors are valid.
This issue is to remain open until all behavior up to this point has behavior tests (of course, all new behavior needs tests).