Skip to content

Commit

Permalink
chore(compiler)!: Require floats always have a digit on left & right …
Browse files Browse the repository at this point in the history
…of dot (#1703)

* chore(compiler)!: Require floats always have a digit on left & right of dot

* chore(stdlib): Update floats that did not have digits on both sides

* chore(compiler): Update test floats that did not have digit on both sides

* Add error message for invalid float use

* Also capture w and W for invalid floats

* Update tests and add some for f & d suffix

---------

Co-authored-by: Oscar Spencer <oscar@grain-lang.org>
  • Loading branch information
phated and ospencer authored Feb 28, 2023
1 parent 5f8a39f commit b657e1c
Show file tree
Hide file tree
Showing 19 changed files with 171 additions and 130 deletions.
23 changes: 19 additions & 4 deletions compiler/src/parsing/lexer.re
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ type error =
| UnclosedDocComment(int)
| IllegalUnicodeCodePoint(string)
| IllegalByteStringUnicodeChar(string)
| IllegalByteStringUnicodeEscape(string);
| IllegalByteStringUnicodeEscape(string)
| FloatWithoutLeadingZero(string);

exception Error(Location.t, error);

Expand Down Expand Up @@ -46,6 +47,12 @@ let report_error = (ppf, err) =>
"Byte strings may not contain unicode escapes: %S",
cp,
)
| FloatWithoutLeadingZero(f) =>
Format.fprintf(
ppf,
"Floats must contain a leading zero. Use 0%s instead.",
f,
)
};

let () =
Expand Down Expand Up @@ -119,8 +126,7 @@ let unsigned_int = [%sedlex.regexp? dec_int | hex_int | oct_int | bin_int];
let dec_float_exp = [%sedlex.regexp?
('e' | 'E', Opt('+' | '-'), dec_digit, Star(dec_digit | '_'))
];
let dec_float_decimal = [%sedlex.regexp? ('.', Star(dec_digit | '_'))];
let dec_float_decimal_explicit = [%sedlex.regexp?
let dec_float_decimal = [%sedlex.regexp?
('.', dec_digit, Star(dec_digit | '_'))
];
let dec_float_integral = [%sedlex.regexp?
Expand All @@ -130,12 +136,14 @@ let dec_float_alphabetic = [%sedlex.regexp? "Infinity" | "NaN"];

let dec_float = [%sedlex.regexp?
(dec_float_integral, dec_float_decimal, Opt(dec_float_exp)) |
(dec_float_decimal_explicit, Opt(dec_float_exp)) |
(dec_float_integral, dec_float_exp) |
dec_float_alphabetic
];

let unsigned_float = [%sedlex.regexp? dec_float];
let invalid_float = [%sedlex.regexp?
(dec_float_decimal, Opt(dec_float_exp))
];

let uident = [%sedlex.regexp?
(Intersect(xid_start, lu), Star(xid_continue))
Expand Down Expand Up @@ -244,6 +252,13 @@ let rec token = lexbuf => {
| (unsigned_float, 'd') => positioned(FLOAT64(sub_lexeme(lexbuf, 0, -1)))
| unsigned_float =>
positioned(NUMBER_FLOAT(Sedlexing.Utf8.lexeme(lexbuf)))
| (invalid_float, Opt('f' | 'd' | 'w' | 'W')) =>
raise(
Error(
lexbuf_loc(lexbuf),
FloatWithoutLeadingZero(Sedlexing.Utf8.lexeme(lexbuf)),
),
)
| (unsigned_int, 's') => positioned(INT8(sub_lexeme(lexbuf, 0, -1)))
| (unsigned_int, 'S') => positioned(INT16(sub_lexeme(lexbuf, 0, -1)))
| (unsigned_int, 'l') => positioned(INT32(sub_lexeme(lexbuf, 0, -1)))
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/stdlib/float32.test.gr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from Float32 use *

// Constants Test
// smoke test:
assert gt(infinity, 100000000.f)
assert gt(infinity, 100000000.0f)
// test infinity-specific semantics:
assert toNumber(infinity) == toNumber(infinity)
assert toNumber(infinity) == toNumber(infinity) - 1
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/stdlib/float64.test.gr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from Float64 use *

// Constants Tests
// smoke test:
assert gt(infinity, 100000000.d)
assert gt(infinity, 100000000.0d)
// test infinity-specific semantics:
assert toNumber(infinity) == toNumber(infinity) - 1
assert nan != nan
Expand Down
6 changes: 3 additions & 3 deletions compiler/test/stdlib/marshal.test.gr
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ assert roundtripOk(42l)
assert roundtripOk(42L)
assert roundtripOk(42ul)
assert roundtripOk(42uL)
assert roundtripOk(42.)
assert roundtripOk(42.f)
assert roundtripOk(42.d)
assert roundtripOk(42.0)
assert roundtripOk(42.0f)
assert roundtripOk(42.0d)
assert roundtripOk(-1s)
assert roundtripOk(-1S)
assert roundtripOk(42us)
Expand Down
62 changes: 31 additions & 31 deletions compiler/test/stdlib/number.test.gr
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ assert Number.neg(Infinity) == -Infinity
// isFloat
assert Number.isFloat(0.0)
assert Number.isFloat(1.5)
assert Number.isFloat(42.)
assert Number.isFloat(42.0)
assert Number.isFloat(9e6)
assert Number.isFloat(0) == false
assert Number.isFloat(10) == false
Expand Down Expand Up @@ -396,8 +396,8 @@ assert Number.isInfinite(BI.toNumber(-1t)) == false
// parseFloat
// tests taken from Go's /src/strconv/atof_test.go
assert Number.parseFloat("") == Err("Invalid string")
assert Number.parseFloat("1") == Ok(1.)
assert Number.parseFloat("+1") == Ok(1.)
assert Number.parseFloat("1") == Ok(1.0)
assert Number.parseFloat("+1") == Ok(1.0)
assert Number.parseFloat("1x") == Err("Invalid float")
assert Number.parseFloat("1.1.") == Err("Invalid float")
assert Number.parseFloat("1e23") == Ok(1e+23)
Expand All @@ -414,30 +414,30 @@ assert Number.parseFloat("100000000000000016777215") ==
Ok(1.0000000000000001e+23)
assert Number.parseFloat("100000000000000016777216") ==
Ok(1.0000000000000003e+23)
assert Number.parseFloat("-1") == Ok(-1.)
assert Number.parseFloat("-1") == Ok(-1.0)
assert Number.parseFloat("-0.1") == Ok(-0.1)
assert Number.parseFloat("-0") == Ok(-0.0)
assert Number.parseFloat("1e-20") == Ok(1e-20)
assert Number.parseFloat("625e-3") == Ok(0.625)
// zeros
assert Number.parseFloat("0") == Ok(0.)
assert Number.parseFloat("0e0") == Ok(0.)
assert Number.parseFloat("-0e0") == Ok(-0.)
assert Number.parseFloat("+0e0") == Ok(0.)
assert Number.parseFloat("0e-0") == Ok(0.)
assert Number.parseFloat("-0e-0") == Ok(-0.)
assert Number.parseFloat("+0e-0") == Ok(0.)
assert Number.parseFloat("0e+0") == Ok(0.)
assert Number.parseFloat("-0e+0") == Ok(-0.)
assert Number.parseFloat("+0e+0") == Ok(0.)
assert Number.parseFloat("0e+01234567890123456789") == Ok(0.)
assert Number.parseFloat("0.00e-01234567890123456789") == Ok(0.)
assert Number.parseFloat("-0e+01234567890123456789") == Ok(-0.)
assert Number.parseFloat("-0.00e-01234567890123456789") == Ok(-0.)
assert Number.parseFloat("0e291") == Ok(0.)
assert Number.parseFloat("0e292") == Ok(0.)
assert Number.parseFloat("0e347") == Ok(0.)
assert Number.parseFloat("0e348") == Ok(0.)
assert Number.parseFloat("0") == Ok(0.0)
assert Number.parseFloat("0e0") == Ok(0.0)
assert Number.parseFloat("-0e0") == Ok(-0.0)
assert Number.parseFloat("+0e0") == Ok(0.0)
assert Number.parseFloat("0e-0") == Ok(0.0)
assert Number.parseFloat("-0e-0") == Ok(-0.0)
assert Number.parseFloat("+0e-0") == Ok(0.0)
assert Number.parseFloat("0e+0") == Ok(0.0)
assert Number.parseFloat("-0e+0") == Ok(-0.0)
assert Number.parseFloat("+0e+0") == Ok(0.0)
assert Number.parseFloat("0e+01234567890123456789") == Ok(0.0)
assert Number.parseFloat("0.00e-01234567890123456789") == Ok(0.0)
assert Number.parseFloat("-0e+01234567890123456789") == Ok(-0.0)
assert Number.parseFloat("-0.00e-01234567890123456789") == Ok(-0.0)
assert Number.parseFloat("0e291") == Ok(0.0)
assert Number.parseFloat("0e292") == Ok(0.0)
assert Number.parseFloat("0e347") == Ok(0.0)
assert Number.parseFloat("0e348") == Ok(0.0)
// NaNs
assert Number.isNaN(
Result.expect("float should parse", Number.parseFloat("nan"))
Expand Down Expand Up @@ -496,14 +496,14 @@ assert Number.parseFloat("5e-324") == Ok(5e-324)
assert Number.parseFloat("4e-324") == Ok(5e-324)
assert Number.parseFloat("3e-324") == Ok(5e-324)
// too small
assert Number.parseFloat("2e-324") == Ok(0.)
assert Number.parseFloat("2e-324") == Ok(0.0)
// way too small
assert Number.parseFloat("1e-350") == Ok(0.)
assert Number.parseFloat("1e-400000") == Ok(0.)
assert Number.parseFloat("1e-350") == Ok(0.0)
assert Number.parseFloat("1e-400000") == Ok(0.0)
// try to overflow exponent
assert Number.parseFloat("1e-4294967296") == Ok(0.)
assert Number.parseFloat("1e-4294967296") == Ok(0.0)
assert Number.parseFloat("1e+4294967296") == Ok(Infinity)
assert Number.parseFloat("1e-18446744073709551616") == Ok(0.)
assert Number.parseFloat("1e-18446744073709551616") == Ok(0.0)
assert Number.parseFloat("1e+18446744073709551616") == Ok(Infinity)
// Parse errors
assert Number.parseFloat("1e") == Err("Invalid exponent")
Expand All @@ -526,12 +526,12 @@ assert Number.parseFloat(
assert Number.parseFloat(
"1.00000000000000011102230246251565404236316680908203125"
) ==
Ok(1.)
Ok(1.0)
// Slightly lower; still round down.
assert Number.parseFloat(
"1.00000000000000011102230246251565404236316680908203124"
) ==
Ok(1.)
Ok(1.0)
// Slightly higher; round up.
assert Number.parseFloat(
"1.00000000000000011102230246251565404236316680908203126"
Expand All @@ -555,12 +555,12 @@ assert Number.parseFloat("1090544144181609348671888949248") ==
assert Number.parseFloat("1090544144181609348835077142190") ==
Ok(1.0905441441816094e+30)
// underscores
assert Number.parseFloat("1__") == Ok(1.)
assert Number.parseFloat("1__") == Ok(1.0)
assert Number.parseFloat("1_e2_3_") == Ok(1e+23)
assert Number.parseFloat("100_000_000_000_000_000_000_000") == Ok(1e+23)
assert Number.parseFloat("1_2345_6700") == Ok(1.234567e+08)
assert Number.parseFloat("625e-3__") == Ok(0.625)
assert Number.parseFloat("0_0e+0_12__3___4____567890123456789") == Ok(0.)
assert Number.parseFloat("0_0e+0_12__3___4____567890123456789") == Ok(0.0)
assert Number.parseFloat("1_e400_000") == Ok(Infinity)
assert Number.parseFloat("-1_e400_000") == Ok(-Infinity)
assert Number.parseFloat(
Expand Down
12 changes: 6 additions & 6 deletions compiler/test/stdlib/pervasives.test.gr
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ assert compare(0, 0) == 0
assert compare(1, 0) > 0
// Specific NaN and Infinity tests
assert compare(1 / 0.0, 987654321) > 0
assert compare(1 / 0.0, 987654321.) > 0
assert compare(1 / 0.0, 987654321.0) > 0
assert compare(0.0 / 0.0, -1 / 0.0) < 0
assert compare(0.0 / 0.0, 987654321.) < 0
assert compare(0.0 / 0.0, 987654321.0) < 0
assert compare(0.0 / 0.0, 987654321) < 0
assert compare(0.0 / 0.0, 0) < 0
assert !(0.0 / 0.0 < 0.0 / 0.0)
assert !(0.0 / 0.0 < 10)
assert !(0.0 / 0.0 < 10.)
assert !(0.0 / 0.0 < 10.0)
assert !(0.0 / 0.0 <= 0.0 / 0.0)
assert !(0.0 / 0.0 <= 10)
assert !(0.0 / 0.0 <= 10.)
assert !(0.0 / 0.0 <= 10.0)
assert !(0.0 / 0.0 > 0.0 / 0.0)
assert !(0.0 / 0.0 > 10)
assert !(0.0 / 0.0 > 10.)
assert !(0.0 / 0.0 > 10.0)
assert !(0.0 / 0.0 >= 0.0 / 0.0)
assert !(0.0 / 0.0 >= 10)
assert !(0.0 / 0.0 >= 10.)
assert !(0.0 / 0.0 >= 10.0)
// Booleans
assert compare(false, true) < 0
assert compare(true, false) > 0
Expand Down
48 changes: 24 additions & 24 deletions compiler/test/stdlib/wasmf32.test.gr
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ let test = () => {
assert WasmF32.eq(WasmF32.neg(1.23w), -1.23w)
assert WasmF32.eq(WasmF32.abs(1.23w), 1.23w)
assert WasmF32.eq(WasmF32.abs(-1.23w), 1.23w)
assert WasmF32.eq(WasmF32.ceil(1.5w), 2.w)
assert WasmF32.eq(WasmF32.ceil(-1.5w), -1.w)
assert WasmF32.eq(WasmF32.floor(1.5w), 1.w)
assert WasmF32.eq(WasmF32.floor(-1.5w), -2.w)
assert WasmF32.eq(WasmF32.trunc(1.23w), 1.w)
assert WasmF32.eq(WasmF32.trunc(-1.23w), -1.w)
assert WasmF32.eq(WasmF32.nearest(1.23w), 1.w)
assert WasmF32.eq(WasmF32.nearest(1.73w), 2.w)
assert WasmF32.eq(WasmF32.nearest(-1.23w), -1.w)
assert WasmF32.eq(WasmF32.nearest(-1.73w), -2.w)
assert WasmF32.eq(WasmF32.sqrt(16.w), 4.w)
assert WasmF32.eq(WasmF32.ceil(1.5w), 2.0w)
assert WasmF32.eq(WasmF32.ceil(-1.5w), -1.0w)
assert WasmF32.eq(WasmF32.floor(1.5w), 1.0w)
assert WasmF32.eq(WasmF32.floor(-1.5w), -2.0w)
assert WasmF32.eq(WasmF32.trunc(1.23w), 1.0w)
assert WasmF32.eq(WasmF32.trunc(-1.23w), -1.0w)
assert WasmF32.eq(WasmF32.nearest(1.23w), 1.0w)
assert WasmF32.eq(WasmF32.nearest(1.73w), 2.0w)
assert WasmF32.eq(WasmF32.nearest(-1.23w), -1.0w)
assert WasmF32.eq(WasmF32.nearest(-1.73w), -2.0w)
assert WasmF32.eq(WasmF32.sqrt(16.0w), 4.0w)

// binary tests
assert WasmF32.eq(WasmF32.add(2.5w, 4.w), 6.5w)
assert WasmF32.eq(WasmF32.sub(2.5w, 4.w), -1.5w)
assert WasmF32.eq(WasmF32.mul(2.5w, 4.w), 10.w)
assert WasmF32.eq(WasmF32.div(2.5w, 4.w), .625w)
assert WasmF32.eq(WasmF32.copySign(2.5w, 4.w), 2.5w)
assert WasmF32.eq(WasmF32.copySign(2.5w, -4.w), -2.5w)
assert WasmF32.eq(WasmF32.min(2.5w, 4.w), 2.5w)
assert WasmF32.eq(WasmF32.max(2.5w, 4.w), 4.w)
assert WasmF32.eq(WasmF32.add(2.5w, 4.0w), 6.5w)
assert WasmF32.eq(WasmF32.sub(2.5w, 4.0w), -1.5w)
assert WasmF32.eq(WasmF32.mul(2.5w, 4.0w), 10.0w)
assert WasmF32.eq(WasmF32.div(2.5w, 4.0w), 0.625w)
assert WasmF32.eq(WasmF32.copySign(2.5w, 4.0w), 2.5w)
assert WasmF32.eq(WasmF32.copySign(2.5w, -4.0w), -2.5w)
assert WasmF32.eq(WasmF32.min(2.5w, 4.0w), 2.5w)
assert WasmF32.eq(WasmF32.max(2.5w, 4.0w), 4.0w)
assert WasmF32.eq(1.23w, 1.23w)
assert !WasmF32.eq(1.23w, -1.23w)
assert WasmF32.ne(1.23w, -1.23w)
Expand All @@ -47,11 +47,11 @@ let test = () => {
assert !WasmF32.ge(1.23w, 1.24w)

// conversion tests
assert WasmF32.eq(WasmF32.reinterpretI32(0x42280000n), 42.w)
assert WasmF32.eq(WasmF32.convertI32S(-1n), -1.w)
assert WasmF32.eq(WasmF32.convertI32U(-1n), 4294967296.w)
assert WasmF32.eq(WasmF32.convertI64S(-1N), -1.w)
assert WasmF32.eq(WasmF32.convertI64U(-1N), 18446744073709552000.w)
assert WasmF32.eq(WasmF32.reinterpretI32(0x42280000n), 42.0w)
assert WasmF32.eq(WasmF32.convertI32S(-1n), -1.0w)
assert WasmF32.eq(WasmF32.convertI32U(-1n), 4294967296.0w)
assert WasmF32.eq(WasmF32.convertI64S(-1N), -1.0w)
assert WasmF32.eq(WasmF32.convertI64U(-1N), 18446744073709552000.0w)
assert WasmF32.eq(WasmF32.demoteF64(1.23W), 1.23w)

// Grain conversion tests
Expand Down
48 changes: 24 additions & 24 deletions compiler/test/stdlib/wasmf64.test.gr
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ let test = () => {
assert WasmF64.eq(WasmF64.neg(1.23W), -1.23W)
assert WasmF64.eq(WasmF64.abs(1.23W), 1.23W)
assert WasmF64.eq(WasmF64.abs(-1.23W), 1.23W)
assert WasmF64.eq(WasmF64.ceil(1.5W), 2.W)
assert WasmF64.eq(WasmF64.ceil(-1.5W), -1.W)
assert WasmF64.eq(WasmF64.floor(1.5W), 1.W)
assert WasmF64.eq(WasmF64.floor(-1.5W), -2.W)
assert WasmF64.eq(WasmF64.trunc(1.23W), 1.W)
assert WasmF64.eq(WasmF64.trunc(-1.23W), -1.W)
assert WasmF64.eq(WasmF64.nearest(1.23W), 1.W)
assert WasmF64.eq(WasmF64.nearest(1.73W), 2.W)
assert WasmF64.eq(WasmF64.nearest(-1.23W), -1.W)
assert WasmF64.eq(WasmF64.nearest(-1.73W), -2.W)
assert WasmF64.eq(WasmF64.sqrt(16.W), 4.W)
assert WasmF64.eq(WasmF64.ceil(1.5W), 2.0W)
assert WasmF64.eq(WasmF64.ceil(-1.5W), -1.0W)
assert WasmF64.eq(WasmF64.floor(1.5W), 1.0W)
assert WasmF64.eq(WasmF64.floor(-1.5W), -2.0W)
assert WasmF64.eq(WasmF64.trunc(1.23W), 1.0W)
assert WasmF64.eq(WasmF64.trunc(-1.23W), -1.0W)
assert WasmF64.eq(WasmF64.nearest(1.23W), 1.0W)
assert WasmF64.eq(WasmF64.nearest(1.73W), 2.0W)
assert WasmF64.eq(WasmF64.nearest(-1.23W), -1.0W)
assert WasmF64.eq(WasmF64.nearest(-1.73W), -2.0W)
assert WasmF64.eq(WasmF64.sqrt(16.0W), 4.0W)

// binary tests
assert WasmF64.eq(WasmF64.add(2.5W, 4.W), 6.5W)
assert WasmF64.eq(WasmF64.sub(2.5W, 4.W), -1.5W)
assert WasmF64.eq(WasmF64.mul(2.5W, 4.W), 10.W)
assert WasmF64.eq(WasmF64.div(2.5W, 4.W), .625W)
assert WasmF64.eq(WasmF64.copySign(2.5W, 4.W), 2.5W)
assert WasmF64.eq(WasmF64.copySign(2.5W, -4.W), -2.5W)
assert WasmF64.eq(WasmF64.min(2.5W, 4.W), 2.5W)
assert WasmF64.eq(WasmF64.max(2.5W, 4.W), 4.W)
assert WasmF64.eq(WasmF64.add(2.5W, 4.0W), 6.5W)
assert WasmF64.eq(WasmF64.sub(2.5W, 4.0W), -1.5W)
assert WasmF64.eq(WasmF64.mul(2.5W, 4.0W), 10.0W)
assert WasmF64.eq(WasmF64.div(2.5W, 4.0W), 0.625W)
assert WasmF64.eq(WasmF64.copySign(2.5W, 4.0W), 2.5W)
assert WasmF64.eq(WasmF64.copySign(2.5W, -4.0W), -2.5W)
assert WasmF64.eq(WasmF64.min(2.5W, 4.0W), 2.5W)
assert WasmF64.eq(WasmF64.max(2.5W, 4.0W), 4.0W)
assert WasmF64.eq(1.23W, 1.23W)
assert !WasmF64.eq(1.23W, -1.23W)
assert WasmF64.ne(1.23W, -1.23W)
Expand All @@ -47,11 +47,11 @@ let test = () => {
assert !WasmF64.ge(1.23W, 1.24W)

// conversion tests
assert WasmF64.eq(WasmF64.reinterpretI64(0x4045000000000000N), 42.W)
assert WasmF64.eq(WasmF64.convertI32S(-1n), -1.W)
assert WasmF64.eq(WasmF64.convertI32U(-1n), 4294967295.W)
assert WasmF64.eq(WasmF64.convertI64S(-1N), -1.W)
assert WasmF64.eq(WasmF64.convertI64U(-1N), 18446744073709552000.W)
assert WasmF64.eq(WasmF64.reinterpretI64(0x4045000000000000N), 42.0W)
assert WasmF64.eq(WasmF64.convertI32S(-1n), -1.0W)
assert WasmF64.eq(WasmF64.convertI32U(-1n), 4294967295.0W)
assert WasmF64.eq(WasmF64.convertI64S(-1N), -1.0W)
assert WasmF64.eq(WasmF64.convertI64U(-1N), 18446744073709552000.0W)
assert WasmF64.eq(WasmF64.promoteF32(1.5w), 1.5W)

// Grain conversion tests
Expand Down
6 changes: 3 additions & 3 deletions compiler/test/stdlib/wasmi32.test.gr
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ let test = () => {
assert WasmI32.eq(WasmI32.wrapI64(42N), 42n)
assert WasmI32.eq(WasmI32.wrapI64(0x0000ffffffff0000N), 0xffff0000n)
assert WasmI32.eq(WasmI32.truncF32S(42.17w), 42n)
assert WasmI32.eq(WasmI32.truncF32U(2147483648.w), 0x80000000n)
assert WasmI32.eq(WasmI32.truncF32U(2147483648.0w), 0x80000000n)
assert WasmI32.eq(WasmI32.truncF64S(42.17W), 42n)
assert WasmI32.eq(WasmI32.truncF64U(2147483648.W), 0x80000000n)
assert WasmI32.eq(WasmI32.reinterpretF32(42.w), 0x42280000n)
assert WasmI32.eq(WasmI32.truncF64U(2147483648.0W), 0x80000000n)
assert WasmI32.eq(WasmI32.reinterpretF32(42.0w), 0x42280000n)
assert WasmI32.eq(WasmI32.extendS8(0x00n), 0x00n)
assert WasmI32.eq(WasmI32.extendS8(0x80n), 0xffffff80n)
assert WasmI32.eq(WasmI32.extendS16(0x0000n), 0x0000n)
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/stdlib/wasmi64.test.gr
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ let test = () => {
assert WasmI64.eq(WasmI64.truncF32U(9.223372e+18w), 0x8000000000000000N)
assert WasmI64.eq(WasmI64.truncF64S(42.17W), 42N)
assert WasmI64.eq(WasmI64.truncF64U(9.233372e+18W), 0x802386E9DB09C000N)
assert WasmI64.eq(WasmI64.reinterpretF64(42.W), 0x4045000000000000N)
assert WasmI64.eq(WasmI64.reinterpretF64(42.0W), 0x4045000000000000N)
assert WasmI64.eq(WasmI64.extendS8(0x00N), 0x00N)
assert WasmI64.eq(WasmI64.extendS8(0x80N), 0xffffffffffffff80N)
assert WasmI64.eq(WasmI64.extendS16(0x0000N), 0x0000N)
Expand Down
Loading

0 comments on commit b657e1c

Please sign in to comment.