summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cffi.ur15
-rw-r--r--tests/clib.urp1
-rw-r--r--tests/test.c15
-rw-r--r--tests/test.h2
-rw-r--r--tests/test.urs2
5 files changed, 35 insertions, 0 deletions
diff --git a/tests/cffi.ur b/tests/cffi.ur
index 039eac55..bcb9944c 100644
--- a/tests/cffi.ur
+++ b/tests/cffi.ur
@@ -8,7 +8,22 @@ fun effect () =
<button value="Either" onclick={Test.print}/>
</body></xml>
+fun xact () =
+ Test.transactional;
+ return <xml><body>
+ All good.
+ </body></xml>
+
+fun xact2 () =
+ Test.transactional;
+ error <xml>Failure</xml>;
+ return <xml><body>
+ All gooder.
+ </body></xml>
+
fun main () = return <xml><body>
{[Test.out (Test.frob (Test.create "Hello ") "world!")]}
<form><submit action={effect}/></form>
+ <form><submit action={xact}/></form>
+ <form><submit action={xact2}/></form>
</body></xml>
diff --git a/tests/clib.urp b/tests/clib.urp
index b803a604..de89d03a 100644
--- a/tests/clib.urp
+++ b/tests/clib.urp
@@ -5,5 +5,6 @@ link test.o
effectful Test.print
serverOnly Test.foo
clientOnly Test.bar
+effectful Test.transactional
jsFunc Test.print=print
jsFunc Test.bar=bar
diff --git a/tests/test.c b/tests/test.c
index 1249721e..ef8558d7 100644
--- a/tests/test.c
+++ b/tests/test.c
@@ -25,3 +25,18 @@ uw_Basis_unit uw_Test_foo(uw_context ctx) {
printf("FOO!\n");
return uw_unit_v;
}
+
+static void commit(void *data) {
+ printf("Commit: %s\n", data);
+}
+static void rollback(void *data) {
+ printf("Rollback: %s\n", data);
+}
+static void free(void *data) {
+ printf("Free: %s\n", data);
+}
+
+uw_Basis_unit uw_Test_transactional(uw_context ctx) {
+ uw_register_transactional(ctx, "Beppo", commit, rollback, free);
+ return uw_unit_v;
+}
diff --git a/tests/test.h b/tests/test.h
index d1574e1b..c0dec379 100644
--- a/tests/test.h
+++ b/tests/test.h
@@ -8,3 +8,5 @@ uw_Test_t uw_Test_frob(uw_context, uw_Test_t, uw_Basis_string);
uw_Basis_unit uw_Test_print(uw_context);
uw_Basis_unit uw_Test_foo(uw_context);
+
+uw_Basis_unit uw_Test_transactional(uw_context);
diff --git a/tests/test.urs b/tests/test.urs
index 05efcb5b..b4ca6fb6 100644
--- a/tests/test.urs
+++ b/tests/test.urs
@@ -7,3 +7,5 @@ val print : transaction unit
val foo : transaction unit
val bar : string -> transaction unit
+
+val transactional : transaction unit