Meta: Don't roundtrip floats for i64/i32 hex literals in wasm tests

This commit is contained in:
Ali Mohammad Pur 2021-08-09 02:53:40 +04:30 committed by Andreas Kling
parent c6a137dbac
commit 799471d16f
Notes: sideshowbarker 2024-07-18 07:04:14 +09:00

View file

@ -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)