From e5ddbd619b1f85a3f67fe8e09c48b4761d9fe177 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 29 Jun 2024 17:25:26 +0900 Subject: fix: some float ops --- tests/src/SpecTestsuites/SpecTestsuiteBase.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'tests/src') diff --git a/tests/src/SpecTestsuites/SpecTestsuiteBase.php b/tests/src/SpecTestsuites/SpecTestsuiteBase.php index 1e74e13..ee9c65d 100644 --- a/tests/src/SpecTestsuites/SpecTestsuiteBase.php +++ b/tests/src/SpecTestsuites/SpecTestsuiteBase.php @@ -159,8 +159,16 @@ abstract class SpecTestsuiteBase extends TestCase return match ($type) { 'i32' => unpack('l', pack('V', (int)$value))[1], 'i64' => unpack('q', self::convertInt64ToBinary($value))[1], - 'f32' => unpack('g', pack('V', (int)$value))[1], - 'f64' => unpack('e', self::convertInt64ToBinary($value))[1], + 'f32' => match ($value) { + 'nan:canonical' => NAN, + 'nan:arithmetic' => NAN, + default => unpack('g', pack('V', (int)$value))[1], + }, + 'f64' => match ($value) { + 'nan:canonical' => NAN, + 'nan:arithmetic' => NAN, + default => unpack('e', self::convertInt64ToBinary($value))[1], + }, 'externref' => $value === 'null' ? Ref::RefNull(RefType::ExternRef) : Ref::RefExtern((int)$value), 'funcref' => $value === 'null' ? Ref::RefNull(RefType::FuncRef) : Ref::RefFunc((int)$value), default => throw new RuntimeException("unknown type: $type"), -- cgit v1.2.3-70-g09d2