summaryrefslogtreecommitdiff
path: root/caching-tests
diff options
context:
space:
mode:
authorGravatar Ziv Scully <ziv@mit.edu>2014-03-25 02:04:06 -0400
committerGravatar Ziv Scully <ziv@mit.edu>2014-03-25 02:04:06 -0400
commit93d6de491838eb3607a12686bfdc250366aa60e4 (patch)
tree2da01b66e562296fe3720e6fcfdee0311bb7d077 /caching-tests
parent0e1252d5a6330570df698df924a0554b688042e8 (diff)
ML half of initial prototype. (Doesn't compile because there's no C yet.)
Diffstat (limited to 'caching-tests')
-rw-r--r--caching-tests/test.ur81
-rw-r--r--caching-tests/test.urp6
-rw-r--r--caching-tests/test.urs6
3 files changed, 93 insertions, 0 deletions
diff --git a/caching-tests/test.ur b/caching-tests/test.ur
new file mode 100644
index 00000000..4703e229
--- /dev/null
+++ b/caching-tests/test.ur
@@ -0,0 +1,81 @@
+table foo01 : {Id : int, Bar : string} PRIMARY KEY Id
+table foo10 : {Id : int, Bar : string} PRIMARY KEY Id
+
+(* val query = (SELECT * FROM foo WHERE foo.Bar = "baz") *)
+(* val insert = (INSERT INTO foo (Id, Bar) VALUES (42, "baz")) *)
+
+fun flush01 () : transaction page=
+ dml (INSERT INTO foo01 (Id, Bar) VALUES (42, "baz"));
+ return
+ <xml>
+ <body>
+ Flushed 1!
+ </body>
+ </xml>
+
+fun flush10 () : transaction page=
+ dml (INSERT INTO foo10 (Id, Bar) VALUES (42, "baz"));
+ return
+ <xml>
+ <body>
+ Flushed 2!
+ </body>
+ </xml>
+
+fun flush11 () : transaction page=
+ dml (INSERT INTO foo01 (Id, Bar) VALUES (42, "baz"));
+ dml (INSERT INTO foo10 (Id, Bar) VALUES (42, "baz"));
+ return
+ <xml>
+ <body>
+ Flushed 1 and 2!
+ </body>
+ </xml>
+
+fun cache01 () : transaction page =
+ res <- oneOrNoRows (SELECT foo01.Id, foo01.Bar
+ FROM foo01
+ WHERE foo01.Bar = "baz");
+ return
+ <xml>
+ <body>
+ Reading 1.
+ {case res of
+ None => <xml></xml>
+ | Some row => <xml>{[row.Foo01.Bar]}</xml>}
+ </body>
+ </xml>
+
+fun cache10 () : transaction page =
+ res <- oneOrNoRows (SELECT foo10.Id, foo10.Bar
+ FROM foo10
+ WHERE foo10.Bar = "baz");
+ return
+ <xml>
+ <body>
+ Reading 2.
+ {case res of
+ None => <xml></xml>
+ | Some row => <xml>{[row.Foo10.Bar]}</xml>}
+ </body>
+ </xml>
+
+fun cache11 () : transaction page =
+ res <- oneOrNoRows (SELECT foo01.Id, foo01.Bar
+ FROM foo01
+ WHERE foo01.Bar = "baz");
+ bla <- oneOrNoRows (SELECT foo10.Id, foo10.Bar
+ FROM foo10
+ WHERE foo10.Bar = "baz");
+ return
+ <xml>
+ <body>
+ Reading 1 and 2.
+ {case res of
+ None => <xml></xml>
+ | Some row => <xml>{[row.Foo01.Bar]}</xml>}
+ {case bla of
+ None => <xml></xml>
+ | Some row => <xml>{[row.Foo10.Bar]}</xml>}
+ </body>
+ </xml>
diff --git a/caching-tests/test.urp b/caching-tests/test.urp
new file mode 100644
index 00000000..e5111220
--- /dev/null
+++ b/caching-tests/test.urp
@@ -0,0 +1,6 @@
+database dbname=test
+safeGet Test/flush01
+safeGet Test/flush10
+safeGet Test/flush11
+
+test
diff --git a/caching-tests/test.urs b/caching-tests/test.urs
new file mode 100644
index 00000000..ce7d0350
--- /dev/null
+++ b/caching-tests/test.urs
@@ -0,0 +1,6 @@
+val cache01 : unit -> transaction page
+val cache10 : unit -> transaction page
+val cache11 : unit -> transaction page
+val flush01 : unit -> transaction page
+val flush10 : unit -> transaction page
+val flush11 : unit -> transaction page