aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/src/SpecTestsuites/SpecTestsuiteBase.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/SpecTestsuites/SpecTestsuiteBase.php')
-rw-r--r--tests/src/SpecTestsuites/SpecTestsuiteBase.php24
1 files changed, 12 insertions, 12 deletions
diff --git a/tests/src/SpecTestsuites/SpecTestsuiteBase.php b/tests/src/SpecTestsuites/SpecTestsuiteBase.php
index 6d92ed8..5b3cc4d 100644
--- a/tests/src/SpecTestsuites/SpecTestsuiteBase.php
+++ b/tests/src/SpecTestsuites/SpecTestsuiteBase.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Nsfisis\Waddiwasi\Tests\SpecTestsuites;
+use Nsfisis\Waddiwasi\BitOps\BinaryConversion;
use Nsfisis\Waddiwasi\Stream\FileStream;
use Nsfisis\Waddiwasi\WebAssembly\BinaryFormat\Decoder;
use Nsfisis\Waddiwasi\WebAssembly\BinaryFormat\InvalidBinaryFormatException;
@@ -12,7 +13,6 @@ use Nsfisis\Waddiwasi\WebAssembly\Execution\FuncInst;
use Nsfisis\Waddiwasi\WebAssembly\Execution\GlobalInst;
use Nsfisis\Waddiwasi\WebAssembly\Execution\Linker;
use Nsfisis\Waddiwasi\WebAssembly\Execution\MemInst;
-use Nsfisis\Waddiwasi\WebAssembly\Execution\NumericOps;
use Nsfisis\Waddiwasi\WebAssembly\Execution\Ref;
use Nsfisis\Waddiwasi\WebAssembly\Execution\Refs\RefExtern;
use Nsfisis\Waddiwasi\WebAssembly\Execution\Refs\RefFunc;
@@ -254,15 +254,15 @@ abstract class SpecTestsuiteBase extends TestCase
$type = $arg['type'];
$value = $arg['value'];
return match ($type) {
- 'i32' => unpack('l', pack('V', (int)$value))[1],
- 'i64' => unpack('q', self::convertInt64ToBinary($value))[1],
+ 'i32' => BinaryConversion::deserializeS32(BinaryConversion::serializeI32((int)$value)),
+ 'i64' => BinaryConversion::deserializeS64(self::convertInt64ToBinary($value)),
'f32' => match ($value) {
'nan:canonical', 'nan:arithmetic' => $value,
- default => unpack('g', pack('V', (int)$value))[1],
+ default => BinaryConversion::deserializeF32(BinaryConversion::serializeI32((int)$value)),
},
'f64' => match ($value) {
'nan:canonical', 'nan:arithmetic' => $value,
- default => unpack('e', self::convertInt64ToBinary($value))[1],
+ default => BinaryConversion::deserializeF64(self::convertInt64ToBinary($value)),
},
'externref' => $value === 'null' ? Ref::RefNull(ValType::ExternRef) : Ref::RefExtern((int)$value),
'funcref' => $value === 'null' ? Ref::RefNull(ValType::FuncRef) : Ref::RefFunc((int)$value),
@@ -320,16 +320,16 @@ abstract class SpecTestsuiteBase extends TestCase
is_nan($actualResult),
"result $i is not NaN" . $message,
);
- $actualBits = sprintf("%064b", NumericOps::reinterpretF64AsI64($actualResult));
+ $actualBits = sprintf("%064b", BinaryConversion::reinterpretF64AsI64($actualResult));
if (str_starts_with($actualBits, '0')) {
$this->assertSame(
- sprintf("%064b", NumericOps::reinterpretF64AsI64(NAN)),
+ sprintf("%064b", BinaryConversion::reinterpretF64AsI64(NAN)),
$actualBits,
"result $i is not canonical NaN" . $message,
);
} else {
$this->assertSame(
- sprintf("1%b", NumericOps::reinterpretF64AsI64(NAN)),
+ sprintf("1%b", BinaryConversion::reinterpretF64AsI64(NAN)),
$actualBits,
"result $i is not canonical NaN" . $message,
);
@@ -339,7 +339,7 @@ abstract class SpecTestsuiteBase extends TestCase
is_nan($actualResult),
"result $i is not NaN" . $message,
);
- $actualBits = sprintf("%064b", NumericOps::reinterpretF64AsI64($actualResult));
+ $actualBits = sprintf("%064b", BinaryConversion::reinterpretF64AsI64($actualResult));
if (str_starts_with($actualBits, '0')) {
$this->assertStringStartsWith(
'0111111111111',
@@ -359,8 +359,8 @@ abstract class SpecTestsuiteBase extends TestCase
"result $i is not NaN" . $message,
);
$this->assertSame(
- sprintf("%b", NumericOps::reinterpretF64AsI64($expectedValue)),
- sprintf("%b", NumericOps::reinterpretF64AsI64($actualResult)),
+ sprintf("%b", BinaryConversion::reinterpretF64AsI64($expectedValue)),
+ sprintf("%b", BinaryConversion::reinterpretF64AsI64($actualResult)),
"result $i Nan payload mismatch" . $message,
);
} elseif ($expectedValue instanceof RefNull) {
@@ -434,6 +434,6 @@ abstract class SpecTestsuiteBase extends TestCase
if (bccomp(bcsub(bcpow('2', '63'), '1'), $value) < 0) {
$value = bcsub($value, bcpow('2', '64'));
}
- return pack('q', (int)$value);
+ return BinaryConversion::serializeI64((int)$value);
}
}