summaryrefslogtreecommitdiff
path: root/Meta/generate-libwasm-spec-test.py
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2021-08-09 02:53:40 +0430
committerAndreas Kling <kling@serenityos.org>2021-08-12 21:03:53 +0200
commit799471d16f8255285a19c9ce8d7ca5675c6ce390 (patch)
tree2d4d7371cfc94bfe56313b190e044432ac778c99 /Meta/generate-libwasm-spec-test.py
parentc6a137dbac4782ddcf1d1eeb07a6496907673d0b (diff)
downloadserenity-799471d16f8255285a19c9ce8d7ca5675c6ce390.zip
Meta: Don't roundtrip floats for i64/i32 hex literals in wasm tests
Diffstat (limited to 'Meta/generate-libwasm-spec-test.py')
-rw-r--r--Meta/generate-libwasm-spec-test.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/Meta/generate-libwasm-spec-test.py b/Meta/generate-libwasm-spec-test.py
index 4f894dfe06..0b5b1b83a2 100644
--- a/Meta/generate-libwasm-spec-test.py
+++ b/Meta/generate-libwasm-spec-test.py
@@ -238,6 +238,16 @@ def genarg(spec):
def gen():
x = spec['value']
+ if spec['type'] in ('i32', 'i64'):
+ if x.startswith('0x'):
+ if spec['type'] == 'i32':
+ # cast back to i32 to get the correct sign
+ return str(struct.unpack('>i', struct.pack('>Q', int(x, 16))[4:])[0])
+
+ # cast back to i64 to get the correct sign
+ return str(struct.unpack('>q', struct.pack('>Q', int(x, 16)))[0])
+ return x
+
if x == 'nan':
return 'NaN'
if x == '-nan':
@@ -274,9 +284,6 @@ def genarg(spec):
if x.startswith('-nan'):
return '-NaN'
return x
- if spec['type'] == 'i32':
- # cast back to i32 to get the correct sign
- return str(struct.unpack('>i', struct.pack('>q', int(x))[4:])[0])
return str(x)