Skip to content

Commit

Permalink
made failure case more clear
Browse files Browse the repository at this point in the history
  • Loading branch information
AjaniBilby committed Mar 24, 2024
1 parent d72e96d commit b95a4a6
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions tests/e2e/compiler/numeric.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,25 @@ fn right(): f32 {
return 10.0 - 1.0 / 2.0 % 10.0 - 8.0;
}
fn main(): bool {
fn main(): i32 {
// (-2.5 % 2.0) * -3.0 == 10.0 - ((1.0 / 2.0) % 10.0) - 8.0;
// 1.5 == 1.5
// true == 1
// doing this in a single expression to also ensure == is applied correctly
return -2.5 % 2.0 * -3.0 == 10.0 - 1.0 / 2.0 % 10.0 - 8.0;
if ( (-2.5 % 2.0) * -3.0 ) != ( 10.0 - ( (1.0 / 2.0) % 10.0 ) - 8.0 ) {
return 25;
};
if ( (-2.5 % 2.0) * -3.0 != 10.0 - ( (1.0 / 2.0) % 10.0 ) - 8.0 ) {
return 29;
};
if ( -2.5 % 2.0 * -3.0 != 10.0 - 1.0 / 2.0 % 10.0 - 8.0 ) {
return 33;
};
return 36;
}`;

Deno.test(`Numeric logic test`, async () => {
Expand Down Expand Up @@ -59,13 +71,13 @@ Deno.test(`Numeric logic test`, async () => {
: fail(`Expected _start to be a function`);

const code = main() as number;
if (code === 0) {
if (code !== 0) {
const leftFn: () => number = exports.left as any;
assert(leftFn instanceof Function, "Missing left function");

const rightFn: () => number = exports.right as any;
assert(rightFn instanceof Function, "Missing right function");

fail(`equivalence checks failed ${leftFn()} != ${rightFn()}`);
fail(`equivalence checks failed ${leftFn()} != ${rightFn()} at line ${code}`);
};
});

0 comments on commit b95a4a6

Please sign in to comment.