diff options
Diffstat (limited to 'test/example')
-rw-r--r-- | test/example/c-api-kitchen-sink.c | 14 | ||||
-rw-r--r-- | test/example/c-api-kitchen-sink.txt | 10 |
2 files changed, 24 insertions, 0 deletions
diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c index 726dc9ce8..5b5b012e1 100644 --- a/test/example/c-api-kitchen-sink.c +++ b/test/example/c-api-kitchen-sink.c @@ -278,6 +278,19 @@ void test_core() { BinaryenModuleDispose(module); } +void test_unreachable() { + BinaryenModuleRef module = BinaryenModuleCreate(); + BinaryenFunctionTypeRef i = BinaryenAddFunctionType(module, "i", BinaryenInt32(), NULL, 0); + BinaryenFunctionTypeRef I = BinaryenAddFunctionType(module, "I", BinaryenInt64(), NULL, 0); + + BinaryenExpressionRef body = BinaryenCallIndirect(module, BinaryenUnreachable(module), NULL, 0, "I"); + BinaryenFunctionRef fn = BinaryenAddFunction(module, "unreachable-fn", i, NULL, 0, body); + + assert(BinaryenModuleValidate(module)); + BinaryenModulePrint(module); + BinaryenModuleDispose(module); +} + BinaryenExpressionRef makeCallCheck(BinaryenModuleRef module, int x) { BinaryenExpressionRef callOperands[] = { makeInt32(module, x) }; return BinaryenCallImport(module, "check", callOperands, 1, BinaryenNone()); @@ -556,6 +569,7 @@ void test_tracing() { int main() { test_types(); test_core(); + test_unreachable(); test_relooper(); test_binaries(); test_interpret(); diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index d366a3c7f..16d48ea5b 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -536,6 +536,16 @@ BinaryenFloat64: 4 (nop) ) ) +(module + (type $i (func (result i32))) + (type $I (func (result i64))) + (memory $0 0) + (func $unreachable-fn (type $i) (result i32) + (call_indirect $I + (unreachable) + ) + ) +) raw: (module (type $v (func)) |