summaryrefslogtreecommitdiff
path: root/test/example/c-api-multiple-tables.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/example/c-api-multiple-tables.c')
-rw-r--r--test/example/c-api-multiple-tables.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/test/example/c-api-multiple-tables.c b/test/example/c-api-multiple-tables.c
index 625af444c..c19dcdb6f 100644
--- a/test/example/c-api-multiple-tables.c
+++ b/test/example/c-api-multiple-tables.c
@@ -31,28 +31,42 @@ int main() {
BinaryenAddFunction(module, "adder", params, results, NULL, 0, add);
const char* funcNames[] = {"adder"};
- BinaryenAddTable(module,
- "tab",
- 1,
- 1,
- funcNames,
- 1,
- BinaryenConst(module, BinaryenLiteralInt32(0)));
+ BinaryenAddTable(module, "tab", 1, 1);
assert(BinaryenGetTable(module, "tab") != NULL);
-
- BinaryenAddTable(module,
- "t2",
- 1,
- 1,
- funcNames,
- 1,
- BinaryenConst(module, BinaryenLiteralInt32(0)));
+ BinaryenAddActiveElementSegment(
+ module,
+ "tab",
+ "0",
+ funcNames,
+ 1,
+ BinaryenConst(module, BinaryenLiteralInt32(0)));
+
+ BinaryenAddTable(module, "t2", 1, 1);
+ BinaryenAddActiveElementSegment(
+ module,
+ "t2",
+ "1",
+ funcNames,
+ 1,
+ BinaryenConst(module, BinaryenLiteralInt32(0)));
+ BinaryenAddPassiveElementSegment(module, "passive", funcNames, 1);
+ assert(NULL != BinaryenGetElementSegmentByIndex(module, 2));
+ assert(1 == BinayenElementSegmentIsPassive(
+ BinaryenGetElementSegment(module, "passive")));
BinaryenTableRef t2 = BinaryenGetTableByIndex(module, 1);
assert(t2 != NULL);
+ BinaryenElementSegmentRef elem1 = BinaryenGetElementSegment(module, "1");
+ assert(elem1 != NULL);
+ assert(strcmp(BinaryenElementSegmentGetName(elem1), "1") == 0);
+ assert(strcmp(BinaryenElementSegmentGetTable(elem1), "t2") == 0);
+ assert(BinaryenElementSegmentGetLength(elem1) == 1);
+ assert(strcmp(BinaryenElementSegmentGetData(elem1, 0), funcNames[0]) == 0);
assert(strcmp(BinaryenTableGetName(t2), "t2") == 0);
BinaryenTableSetName(t2, "table2");
assert(strcmp(BinaryenTableGetName(t2), "table2") == 0);
+ BinaryenElementSegmentSetTable(elem1, "table2");
+ assert(strcmp(BinaryenElementSegmentGetTable(elem1), "table2") == 0);
assert(BinaryenTableGetInitial(t2) == 1);
BinaryenTableSetInitial(t2, 2);
assert(BinaryenTableGetInitial(t2) == 2);