summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2025-01-30 14:36:15 +0100
committerGitHub <noreply@github.com>2025-01-30 13:36:15 +0000
commitbe1fa91a00a9bff6c5eb9744266f252b8cc23fe4 (patch)
tree398667e7da4e44d910dbf69f4d6b6d18f9141e0c /tests
parent7a0d7092bc00ee4f5c0d4887ea3ccf3fbceb2426 (diff)
Modular, multi-threaded, transitioning plugins (#5779)
Diffstat (limited to 'tests')
-rw-r--r--tests/suite/foundations/plugin.typ31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/suite/foundations/plugin.typ b/tests/suite/foundations/plugin.typ
index 0842980e..9feacc03 100644
--- a/tests/suite/foundations/plugin.typ
+++ b/tests/suite/foundations/plugin.typ
@@ -9,6 +9,37 @@
bytes("value3-value1-value2"),
)
+--- plugin-func ---
+#let p = plugin("/assets/plugins/hello.wasm")
+#test(type(p.hello), function)
+#test(("a", "b").map(bytes).map(p.double_it), ("a.a", "b.b").map(bytes))
+
+--- plugin-import ---
+#import plugin("/assets/plugins/hello.wasm"): hello, double_it
+
+#test(hello(), bytes("Hello from wasm!!!"))
+#test(double_it(bytes("hey!")), bytes("hey!.hey!"))
+
+--- plugin-transition ---
+#let empty = plugin("/assets/plugins/hello-mut.wasm")
+#test(str(empty.get()), "[]")
+
+#let hello = plugin.transition(empty.add, bytes("hello"))
+#test(str(empty.get()), "[]")
+#test(str(hello.get()), "[hello]")
+
+#let world = plugin.transition(empty.add, bytes("world"))
+#let hello_you = plugin.transition(hello.add, bytes("you"))
+
+#test(str(empty.get()), "[]")
+#test(str(hello.get()), "[hello]")
+#test(str(world.get()), "[world]")
+#test(str(hello_you.get()), "[hello, you]")
+
+#let hello2 = plugin.transition(empty.add, bytes("hello"))
+#test(hello == world, false)
+#test(hello == hello2, true)
+
--- plugin-wrong-number-of-arguments ---
#let p = plugin("/assets/plugins/hello.wasm")