From 5d9ef0e276e092d2a8aeaed2bff0f1520022add0 Mon Sep 17 00:00:00 2001 From: "Johan B.W. de Vries" Date: Sun, 6 Apr 2025 12:58:20 +0200 Subject: [PATCH] Code review Added a test, simplified another and added a lot of TODO's. --- TODO.md | 17 +++++++++++++++++ tests/integration/test_lang/test_fractional.py | 16 +++++++++++++++- tests/integration/test_lang/test_tuple.py | 6 ++---- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index 076ce21..c0ef17e 100644 --- a/TODO.md +++ b/TODO.md @@ -10,3 +10,20 @@ - Storing u8 in memory still claims 32 bits (since that's what you need in local variables). However, using load8_u / loadu_s we can optimize this. - Implement a FizzBuzz example - Also, check the codes for FIXME and TODO +- Allocation is done using pointers for members, is this desired? + +- Merge in type classes + +- test_bitwise_or_inv_type +- test_bytes_index_out_of_bounds vs static trap(?) +- test_num.py is probably best as part of the generator? +- Find pytest.mark.skip +- There's a weird resolve_as reference in calculate_alloc_size + - Either there should be more of them or less + - At first glance, looks like failure in the typing system + - Related to the FIXME in phasm_type3? +- WEBASSEMBLY_BUILTIN_FLOAT_OPS and WEBASSEMBLY_BUILTIN_BYTES_OPS are special cased + - Should be part of a prelude +- Casting is not implemented except u32 which is special cased +- Parser is putting stuff in ModuleDataBlock + - Compiler should probably do that diff --git a/tests/integration/test_lang/test_fractional.py b/tests/integration/test_lang/test_fractional.py index 3ad8a41..46ee8e8 100644 --- a/tests/integration/test_lang/test_fractional.py +++ b/tests/integration/test_lang/test_fractional.py @@ -20,7 +20,7 @@ def testEntry() -> {type_}: @pytest.mark.integration_test @pytest.mark.parametrize('type_', TYPE_LIST) -def test_division_zero_let_it_crash_float(type_): +def test_division_float_follow_ieee_so_inf_pos(type_): code_py = f""" @exported def testEntry() -> {type_}: @@ -31,3 +31,17 @@ def testEntry() -> {type_}: # https://www.w3.org/TR/wasm-core-1/#-hrefop-fdivmathrmfdiv_n-z_1-z_2 result = Suite(code_py).run_code() assert float('+inf') == result.returned_value + +@pytest.mark.integration_test +@pytest.mark.parametrize('type_', TYPE_LIST) +def test_division_float_follow_ieee_so_inf_neg(type_): + code_py = f""" +@exported +def testEntry() -> {type_}: + return -10.0 / 0.0 +""" + + # WebAssembly dictates that float division follows the IEEE rules + # https://www.w3.org/TR/wasm-core-1/#-hrefop-fdivmathrmfdiv_n-z_1-z_2 + result = Suite(code_py).run_code() + assert float('-inf') == result.returned_value diff --git a/tests/integration/test_lang/test_tuple.py b/tests/integration/test_lang/test_tuple.py index 66d24ee..cef2824 100644 --- a/tests/integration/test_lang/test_tuple.py +++ b/tests/integration/test_lang/test_tuple.py @@ -74,11 +74,9 @@ CONSTANT: (u32, u8, u8, ) = (24, 4000, 1, ) @pytest.mark.integration_test def test_tuple_must_use_literal_for_indexing(): code_py = """ -CONSTANT: u32 = 0 - @exported -def testEntry(x: (u8, u32, u64)) -> u64: - return x[CONSTANT] +def testEntry(x: (u8, u32, u64), y: u8) -> u64: + return x[y] """ with pytest.raises(Type3Exception, match='Must index with literal'):