aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-04-28 17:57:32 +0900
committernsfisis <nsfisis@gmail.com>2024-04-28 17:57:32 +0900
commitbe3c470d0ff373344d4d723b271a1bde726f01af (patch)
treea719ccf13a3617de43537ba8da72e0c7314c487e /tests
parent3e280296990d2ebbc5b34e9ce5bea08ab3227fb6 (diff)
downloadphp-waddiwasi-be3c470d0ff373344d4d723b271a1bde726f01af.tar.gz
php-waddiwasi-be3c470d0ff373344d4d723b271a1bde726f01af.tar.zst
php-waddiwasi-be3c470d0ff373344d4d723b271a1bde726f01af.zip
test: implement assert_malformed command
Diffstat (limited to 'tests')
-rw-r--r--tests/src/SpecTestsuites/SpecTestsuiteBase.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/src/SpecTestsuites/SpecTestsuiteBase.php b/tests/src/SpecTestsuites/SpecTestsuiteBase.php
index f01d13a..b215a16 100644
--- a/tests/src/SpecTestsuites/SpecTestsuiteBase.php
+++ b/tests/src/SpecTestsuites/SpecTestsuiteBase.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Nsfisis\Waddiwasi\Tests\SpecTestsuites;
use Nsfisis\Waddiwasi\BinaryFormat\Decoder;
+use Nsfisis\Waddiwasi\BinaryFormat\InvalidBinaryFormatException;
use Nsfisis\Waddiwasi\Execution\Runtime;
use Nsfisis\Waddiwasi\Execution\Store;
use Nsfisis\Waddiwasi\Execution\TrapException;
@@ -96,7 +97,16 @@ abstract class SpecTestsuiteBase extends TestCase
string $text,
int $line,
): void {
- $this->assertTrue(false, "assert_malformed");
+ $filePath = __DIR__ . "/../../fixtures/spec_testsuites/core/$filename";
+ $wasmBinary = file_get_contents($filePath);
+ $exception = null;
+ try {
+ (new Decoder($wasmBinary))->decode();
+ } catch (InvalidBinaryFormatException $e) {
+ $exception = $e;
+ }
+ // @todo Check error message.
+ $this->assertNotNull($exception, "decoding $filename is expected to fail (at $line)");
}
protected function runAssertInvalidCommand(