summaryrefslogtreecommitdiff
path: root/test/example/c-api-unused-mem.cpp
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2019-11-26 01:45:36 -0800
committerGitHub <noreply@github.com>2019-11-26 01:45:36 -0800
commit98ab07f9e471e713e7b00732a84e260aaaecc25f (patch)
treeb93311d401a4b44663e2014ad757656250c25485 /test/example/c-api-unused-mem.cpp
parent6a384c13500fab5dd937de65249a1975e1e599aa (diff)
downloadbinaryen-98ab07f9e471e713e7b00732a84e260aaaecc25f.tar.gz
binaryen-98ab07f9e471e713e7b00732a84e260aaaecc25f.tar.bz2
binaryen-98ab07f9e471e713e7b00732a84e260aaaecc25f.zip
Ensure example tests validate (#2470)
This makes sure example tests validate by adding missing `assert` on `BinaryenModuleValidate` calls and fixes existing errors in the example tests.
Diffstat (limited to 'test/example/c-api-unused-mem.cpp')
-rw-r--r--test/example/c-api-unused-mem.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/test/example/c-api-unused-mem.cpp b/test/example/c-api-unused-mem.cpp
index 03a6746f7..3ca6f49e2 100644
--- a/test/example/c-api-unused-mem.cpp
+++ b/test/example/c-api-unused-mem.cpp
@@ -1,8 +1,11 @@
// beginning a Binaryen API trace
+
+#include <cassert>
#include <stdio.h>
#include <math.h>
#include <map>
#include "binaryen-c.h"
+
int main() {
std::map<size_t, BinaryenFunctionTypeRef> functionTypes;
std::map<size_t, BinaryenExpressionRef> expressions;
@@ -39,7 +42,7 @@ int main() {
RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[0], expressions[0]);
{
BinaryenType paramTypes[] = {BinaryenTypeNone()};
- functionTypes[0] = BinaryenAddFunctionType(the_module, "rustfn-0-3", 0, paramTypes, 0);
+ functionTypes[0] = BinaryenAddFunctionType(the_module, "rustfn-0-3", BinaryenTypeNone(), paramTypes, 0);
}
expressions[7] = BinaryenConst(the_module, BinaryenLiteralInt32(0));
expressions[8] =
@@ -56,7 +59,7 @@ int main() {
BinaryenAddFunctionExport(the_module, "main", "main");
{
BinaryenType paramTypes[] = {BinaryenTypeNone()};
- functionTypes[1] = BinaryenAddFunctionType(the_module, "__wasm_start", 0, paramTypes, 0);
+ functionTypes[1] = BinaryenAddFunctionType(the_module, "__wasm_start", BinaryenTypeNone(), paramTypes, 0);
}
{
const char* segments[] = { 0 };
@@ -71,7 +74,7 @@ int main() {
the_module, 4, 0, 0, expressions[12], expressions[11], BinaryenTypeInt32());
{
BinaryenExpressionRef operands[] = { 0 };
- expressions[14] = BinaryenCall(the_module, "main", operands, 0, 0);
+ expressions[14] = BinaryenCall(the_module, "main", operands, 0, BinaryenTypeNone());
}
{
BinaryenExpressionRef children[] = { expressions[13], expressions[14] };
@@ -82,7 +85,7 @@ int main() {
BinaryenType varTypes[] = {BinaryenTypeNone()};
functions[1] = BinaryenAddFunction(the_module, "__wasm_start", functionTypes[1], varTypes, 0, expressions[15]);
}
- BinaryenModuleValidate(the_module);
+ assert(BinaryenModuleValidate(the_module));
BinaryenModulePrint(the_module);
// check that binary read-write works
{