From 39e6c4bfb1f3fb96bba47e3eec8e6451038a3d22 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 21 Feb 2026 23:22:25 +0900 Subject: feat: implement validation phase --- tests/src/SpecTestsuites/SpecTestsuiteBase.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/src/SpecTestsuites/SpecTestsuiteBase.php b/tests/src/SpecTestsuites/SpecTestsuiteBase.php index 7106407..bcf7fa0 100644 --- a/tests/src/SpecTestsuites/SpecTestsuiteBase.php +++ b/tests/src/SpecTestsuites/SpecTestsuiteBase.php @@ -31,6 +31,7 @@ use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\MemType; use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\Mut; use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\TableType; use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\ValType; +use Nsfisis\Waddiwasi\WebAssembly\Validation\Validator; use PHPUnit\Framework\TestCase; use RuntimeException; use function count; @@ -157,8 +158,18 @@ abstract class SpecTestsuiteBase extends TestCase string $text, int $line, ): void { - // @todo Our implementation does not support "validation" step. - $this->assertTrue(true); + $filePath = __DIR__ . "/../../fixtures/spec_testsuites/core/{$filename}"; + $wasmBinaryStream = new FileStream($filePath); + try { + $module = (new Decoder($wasmBinaryStream))->decode(); + } catch (InvalidBinaryFormatException) { + // Malformed binary is also a form of invalid module. + $this->assertTrue(true); + return; + } + $result = (new Validator($module))->validate(); + // @todo Check error message. + $this->assertNotEmpty($result->errors, "validating {$filename} is expected to fail (at {$line})"); } protected function runAssertExhaustionCommand( -- cgit v1.3-1-g0d28