summaryrefslogtreecommitdiff
path: root/Meta/generate-libwasm-spec-test.py
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2021-05-23 23:22:46 +0430
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-05-27 17:28:41 +0430
commitb2bd5132c41d8c26b0d9e52a9791982ab990ea4c (patch)
treed39fc1fae1dba31dce109186cb4df0fe8b3e099e /Meta/generate-libwasm-spec-test.py
parentbc936a5fac14165a1d75ccd16ecae22dfd25582d (diff)
downloadserenity-b2bd5132c41d8c26b0d9e52a9791982ab990ea4c.zip
Meta: Correctly parse numeric literals in wasm tests
This was previously parsing them as hex numbers, causing tests to fail. With this fix, 88% of the generated tests are passing :^)
Diffstat (limited to 'Meta/generate-libwasm-spec-test.py')
-rw-r--r--Meta/generate-libwasm-spec-test.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/Meta/generate-libwasm-spec-test.py b/Meta/generate-libwasm-spec-test.py
index dad5157131..dc968bf323 100644
--- a/Meta/generate-libwasm-spec-test.py
+++ b/Meta/generate-libwasm-spec-test.py
@@ -126,7 +126,7 @@ def genarg(spec):
return '-NaN'
try:
- x = float.fromhex(x)
+ x = float(x)
if math.isnan(x):
# FIXME: This is going to mess up the different kinds of nan
return '-NaN' if math.copysign(1.0, x) < 0 else 'NaN'
@@ -135,10 +135,19 @@ def genarg(spec):
return str(x)
except ValueError:
try:
- x = int(x, 0)
+ x = float.fromhex(x)
+ if math.isnan(x):
+ # FIXME: This is going to mess up the different kinds of nan
+ return '-NaN' if math.copysign(1.0, x) < 0 else 'NaN'
+ if math.isinf(x):
+ return 'Infinity' if x > 0 else '-Infinity'
return str(x)
except ValueError:
- return x
+ try:
+ x = int(x, 0)
+ return str(x)
+ except ValueError:
+ return x
x = gen()
if x.startswith('nan'):
@@ -173,7 +182,7 @@ def genresult(ident, entry):
def gentest(entry, main_name):
- name = entry["function"]["name"]
+ name = json.dumps(entry["function"]["name"])[1:-1]
if type(name) != str:
print("Unsupported test case (call to", name, ")", file=stderr)
return '\n '