summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/example/c-api-kitchen-sink.c13
-rw-r--r--test/example/c-api-kitchen-sink.txt22
2 files changed, 35 insertions, 0 deletions
diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c
index 0efafde52..43069c865 100644
--- a/test/example/c-api-kitchen-sink.c
+++ b/test/example/c-api-kitchen-sink.c
@@ -785,6 +785,19 @@ void test_binaries() {
assert(BinaryenModuleValidate(module));
printf("module loaded from binary form:\n");
BinaryenModulePrint(module);
+
+ // write the s-expr representation of the module.
+ BinaryenModuleWriteText(module, buffer, 1024);
+ printf("module s-expr printed (in memory):\n%s\n", buffer);
+
+
+ // writ the s-expr representation to a pointer which is managed by the
+ // caller
+ char *text = BinaryenModuleAllocateAndWriteText(module);
+ printf("module s-expr printed (in memory, caller-owned):\n%s\n", text);
+ free(text);
+
+
BinaryenModuleDispose(module);
}
diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt
index 5a4055ddb..f1eba84b7 100644
--- a/test/example/c-api-kitchen-sink.txt
+++ b/test/example/c-api-kitchen-sink.txt
@@ -1875,6 +1875,28 @@ module loaded from binary form:
)
)
)
+module s-expr printed (in memory):
+(module
+ (type $0 (func (param i32 i32) (result i32)))
+ (func $adder (; 0 ;) (type $0) (param $0 i32) (param $1 i32) (result i32)
+ (i32.add
+ (local.get $0)
+ (local.get $1)
+ )
+ )
+)
+
+module s-expr printed (in memory, caller-owned):
+(module
+ (type $0 (func (param i32 i32) (result i32)))
+ (func $adder (; 0 ;) (type $0) (param $0 i32) (param $1 i32) (result i32)
+ (i32.add
+ (local.get $0)
+ (local.get $1)
+ )
+ )
+)
+
(module
(type $vi (func (param i32)))
(type $v (func))