aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/src/SpecTestsuites/SpecTestsuiteBase.php
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-04-29 15:24:33 +0900
committernsfisis <nsfisis@gmail.com>2024-04-29 22:13:31 +0900
commitb8d11855e22fa1637d809397ac75ee0c65e649ca (patch)
tree5420e7be774c9b8efbdb64dc526b660be3600210 /tests/src/SpecTestsuites/SpecTestsuiteBase.php
parente397e0e356384cedd20d40d46cf1a8ed8aadad24 (diff)
downloadphp-waddiwasi-b8d11855e22fa1637d809397ac75ee0c65e649ca.tar.gz
php-waddiwasi-b8d11855e22fa1637d809397ac75ee0c65e649ca.tar.zst
php-waddiwasi-b8d11855e22fa1637d809397ac75ee0c65e649ca.zip
fix: leb128 encoding
Diffstat (limited to 'tests/src/SpecTestsuites/SpecTestsuiteBase.php')
-rw-r--r--tests/src/SpecTestsuites/SpecTestsuiteBase.php23
1 files changed, 16 insertions, 7 deletions
diff --git a/tests/src/SpecTestsuites/SpecTestsuiteBase.php b/tests/src/SpecTestsuites/SpecTestsuiteBase.php
index b215a16..285ce12 100644
--- a/tests/src/SpecTestsuites/SpecTestsuiteBase.php
+++ b/tests/src/SpecTestsuites/SpecTestsuiteBase.php
@@ -194,7 +194,21 @@ abstract class SpecTestsuiteBase extends TestCase
for ($i = 0; $i < count($expectedResults); $i++) {
$expectedResult = $expectedResults[$i];
$actualResult = $actualResults[$i];
- if ($expectedResult['type'] === 'f32') {
+ if ($expectedResult['type'] === 'i32') {
+ $expectedValue = unpack('l', pack('l', (int)$expectedResult['value']))[1];
+ $this->assertSame(
+ $expectedValue,
+ $actualResult,
+ "result $i mismatch" . $message,
+ );
+ } elseif ($expectedResult['type'] === 'i64') {
+ $expectedValue = unpack('q', pack('q', (int)$expectedResult['value']))[1];
+ $this->assertSame(
+ $expectedValue,
+ $actualResult,
+ "result $i mismatch" . $message,
+ );
+ } elseif ($expectedResult['type'] === 'f32') {
$expectedValue = unpack('g', pack('l', (int)$expectedResult['value']))[1];
if (is_nan($expectedValue)) {
// @todo check NaN bit pattern.
@@ -225,12 +239,7 @@ abstract class SpecTestsuiteBase extends TestCase
);
}
} else {
- $expectedValue = (int)$expectedResult['value'];
- $this->assertSame(
- $expectedValue,
- $actualResult,
- "result $i mismatch" . $message,
- );
+ $this->assertTrue(false, "unknown result type: {$expectedResult['type']}");
}
}
}