From 96e78366acf3abab5117931f4d154b1985cbd22e Mon Sep 17 00:00:00 2001 From: "Alon Zakai (kripken)" Date: Tue, 26 Sep 2017 14:09:27 -0700 Subject: [PATCH] test for wasm clamp mode on unsigned float-to-int --- tests/test_core.py | 4 ++-- tests/wasm/trap-f2i.cpp | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/test_core.py b/tests/test_core.py index ea008a4379ee3..93604b3014818 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -7413,8 +7413,8 @@ def test_binaryen_trap_mode(self): print ' f2i' self.do_run(open(path_from_root('tests', 'wasm', 'trap-f2i.cpp')).read(), { - 'js': '|1337|', # JS did an fmod 2^32 - 'clamp': '|-2147483648|', + 'js': '|1337|\n|4294967295|', # JS did an fmod 2^32 | normal + 'clamp': '|-2147483648|\n|4294967295|', 'allow': TRAP_OUTPUTS }[mode]) diff --git a/tests/wasm/trap-f2i.cpp b/tests/wasm/trap-f2i.cpp index e587f33bb80ab..95c6d86369b00 100644 --- a/tests/wasm/trap-f2i.cpp +++ b/tests/wasm/trap-f2i.cpp @@ -1,9 +1,18 @@ #include int main() { - volatile double d = 17179870521; - EM_ASM({ - Module.print('|' + $0 + '|') - }, int(d)); + { + volatile double d = 17179870521; + EM_ASM({ + Module.print('|' + $0 + '|') + }, int(d)); + } + { + // unsigned + volatile double d = 4294967295.0; + EM_ASM({ + Module.print('|' + ($0 >>> 0) + '|') + }, unsigned(d)); + } }