aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-05-04 18:36:12 +0900
committernsfisis <nsfisis@gmail.com>2024-05-05 14:12:30 +0900
commit2eab009a251fa14631b59e60afa455136e71b44e (patch)
tree41f71fec3669fb71687c174e0f876cdf244fbff2
parent21dba0f4527505e7fecc0135490d277edb506dc9 (diff)
downloadphp-waddiwasi-2eab009a251fa14631b59e60afa455136e71b44e.tar.gz
php-waddiwasi-2eab009a251fa14631b59e60afa455136e71b44e.tar.zst
php-waddiwasi-2eab009a251fa14631b59e60afa455136e71b44e.zip
test: BrTableTest passed
-rw-r--r--tests/src/SpecTestsuites/SpecTestsuiteBase.php17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/src/SpecTestsuites/SpecTestsuiteBase.php b/tests/src/SpecTestsuites/SpecTestsuiteBase.php
index d6cd85e..cd5da89 100644
--- a/tests/src/SpecTestsuites/SpecTestsuiteBase.php
+++ b/tests/src/SpecTestsuites/SpecTestsuiteBase.php
@@ -6,6 +6,8 @@ namespace Nsfisis\Waddiwasi\Tests\SpecTestsuites;
use Nsfisis\Waddiwasi\BinaryFormat\Decoder;
use Nsfisis\Waddiwasi\BinaryFormat\InvalidBinaryFormatException;
+use Nsfisis\Waddiwasi\Execution\Ref;
+use Nsfisis\Waddiwasi\Execution\Refs\RefExtern;
use Nsfisis\Waddiwasi\Execution\Runtime;
use Nsfisis\Waddiwasi\Execution\Store;
use Nsfisis\Waddiwasi\Execution\TrapException;
@@ -136,7 +138,7 @@ abstract class SpecTestsuiteBase extends TestCase
/**
* @param array{type: string, value: string} $arg
*/
- private function toWasmArg(array $arg): int|float
+ private function toWasmArg(array $arg): int|float|Ref
{
$type = $arg['type'];
$value = $arg['value'];
@@ -145,6 +147,7 @@ abstract class SpecTestsuiteBase extends TestCase
'i64' => (int)$value,
'f32' => unpack('g', pack('l', (int)$value))[1],
'f64' => unpack('e', pack('q', (int)$value))[1],
+ 'externref' => Ref::RefExtern((int)$value),
default => $this->assertTrue(false, "unknown arg type: $type"),
};
}
@@ -234,6 +237,18 @@ abstract class SpecTestsuiteBase extends TestCase
"result $i mismatch" . $message,
);
}
+ } elseif ($expectedResult['type'] === 'externref') {
+ $expectedValue = (int)$expectedResult['value'];
+ $this->assertInstanceOf(
+ RefExtern::class,
+ $actualResult,
+ "result $i is not an externref" . $message,
+ );
+ $this->assertSame(
+ $expectedValue,
+ $actualResult->addr,
+ "result $i mismatch" . $message,
+ );
} else {
$this->assertTrue(false, "unknown result type: {$expectedResult['type']}");
}