summaryrefslogtreecommitdiff
path: root/test/example/c-api-kitchen-sink.c
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-07-06 09:23:58 -0700
committerGitHub <noreply@github.com>2016-07-06 09:23:58 -0700
commit05d7bd3028793de007043eacc6e73b1c0cedb7ba (patch)
treec56eeafd134d22087694948d725c8d9c40aa9fb3 /test/example/c-api-kitchen-sink.c
parent50eff30d0ccda99dc2af71c1636f782cdf9dafa6 (diff)
downloadbinaryen-05d7bd3028793de007043eacc6e73b1c0cedb7ba.tar.gz
binaryen-05d7bd3028793de007043eacc6e73b1c0cedb7ba.tar.bz2
binaryen-05d7bd3028793de007043eacc6e73b1c0cedb7ba.zip
validate set_local types against the function #618 (#620)
Diffstat (limited to 'test/example/c-api-kitchen-sink.c')
-rw-r--r--test/example/c-api-kitchen-sink.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c
index 444ed9384..ace95177a 100644
--- a/test/example/c-api-kitchen-sink.c
+++ b/test/example/c-api-kitchen-sink.c
@@ -1,11 +1,15 @@
+// We always need asserts here
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <binaryen-c.h>
-
// kitchen sink, tests the full API
@@ -467,9 +471,26 @@ void test_interpret() {
BinaryenModuleDispose(module);
}
+void test_nonvalid() {
+ // create a module that fails to validate
+ BinaryenModuleRef module = BinaryenModuleCreate();
+
+ BinaryenFunctionTypeRef v = BinaryenAddFunctionType(module, "v", BinaryenNone(), NULL, 0);
+ BinaryenType localTypes[] = { BinaryenInt32() };
+ BinaryenFunctionRef func = BinaryenAddFunction(module, "func", v, localTypes, 1,
+ BinaryenSetLocal(module, 0, makeInt64(module, 1234)) // wrong type!
+ );
+
+ BinaryenModulePrint(module);
+ printf("validation: %d\n", BinaryenModuleValidate(module));
+
+ BinaryenModuleDispose(module);
+}
+
int main() {
test_core();
test_relooper();
test_binaries();
test_interpret();
+ test_nonvalid();
}