changeset 2225:6262dabc08d6

Simplify example.
author Ziv Scully <ziv@mit.edu>
date Fri, 27 Mar 2015 11:19:15 -0400
parents 5709482a2afd
children e10881cd92da
files caching-tests/test.ur caching-tests/test.urp caching-tests/test.urs
diffstat 3 files changed, 11 insertions(+), 66 deletions(-) [+]
line wrap: on
line diff
--- a/caching-tests/test.ur	Thu Dec 11 02:05:41 2014 -0500
+++ b/caching-tests/test.ur	Fri Mar 27 11:19:15 2015 -0400
@@ -1,59 +1,9 @@
-table foo01 : {Id : int, Bar : string} PRIMARY KEY Id
-table foo10 : {Id : int, Bar : string} PRIMARY KEY Id
 table tab : {Id : int, Val : int} PRIMARY KEY Id
 
-fun cache01 () =
-    res <- oneOrNoRows (SELECT foo01.Bar FROM foo01 WHERE foo01.Id = 43);
-    return <xml><body>
-      Reading 1.
-      {case res of
-           None => <xml>?</xml>
-         | Some row => <xml>{[row.Foo01.Bar]}</xml>}
-    </body></xml>
-
-(* fun cache10 () = *)
-(*     res <- queryX (SELECT foo10.Bar FROM foo10 WHERE foo10.Id = 42) *)
-(*                   (fn row => <xml>{[row.Foo10.Bar]}</xml>); *)
-(*     return <xml><body> *)
-(*       Reading 2. *)
-(*       {res} *)
-(*     </body></xml> *)
-
-(* fun cache11 () = *)
-(*     res <- oneOrNoRows (SELECT foo01.Bar FROM foo01 WHERE foo01.Id = 42); *)
-(*     bla <- oneOrNoRows (SELECT foo10.Bar FROM foo10 WHERE foo10.Id = 42); *)
-(*     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> *)
-
-fun flush01 () =
-    dml (INSERT INTO foo01 (Id, Bar) VALUES (42, "baz01"));
-    (* dml (UPDATE foo01 SET Bar = "baz01" WHERE Id = 42); *)
-    return <xml><body>
-      Flushed 1!
-    </body></xml>
-
-(* fun flush10 () = *)
-(*     dml (UPDATE foo10 SET Bar = "baz10" WHERE Id = 42); *)
-(*     return <xml><body> *)
-(*       Flushed 2! *)
-(*     </body></xml> *)
-
-(* fun flush11 () = *)
-(*     dml (UPDATE foo01 SET Bar = "baz11" WHERE Id = 42); *)
-(*     dml (UPDATE foo10 SET Bar = "baz11" WHERE Id = 42); *)
-(*     return <xml><body> *)
-(*       Flushed 1 and 2! *)
-(*     </body></xml> *)
-
 fun cache id =
-    res <- oneOrNoRows (SELECT tab.Val FROM tab WHERE tab.Id = {[id]});
+    res <- oneOrNoRows (SELECT tab.Val
+                        FROM tab
+                        WHERE tab.Id = {[id]});
     return <xml><body>
       Reading {[id]}.
       {case res of
@@ -62,12 +12,16 @@
     </body></xml>
 
 fun flush id =
-    res <- oneOrNoRows (SELECT tab.Val FROM tab WHERE tab.Id = {[id]});
+    res <- oneOrNoRows (SELECT tab.Val
+                        FROM tab
+                        WHERE tab.Id = {[id]});
     (case res of
-         None => dml (INSERT INTO tab (Id, Val) VALUES ({[id]}, 0))
-       | Some row => dml (UPDATE tab SET Val = {[row.Tab.Val + 1]} WHERE Id = {[id]}));
+         None => dml (INSERT INTO tab (Id, Val)
+                      VALUES ({[id]}, 0))
+       | Some row => dml (UPDATE tab
+                          SET Val = {[row.Tab.Val + 1]}
+                          WHERE Id = {[id]}));
     return <xml><body>
-      (* Flushed {[id]}! *)
       {case res of
            None => <xml>Initialized {[id]}!</xml>
          | Some row => <xml>Incremented {[id]}!</xml>}
--- a/caching-tests/test.urp	Thu Dec 11 02:05:41 2014 -0500
+++ b/caching-tests/test.urp	Fri Mar 27 11:19:15 2015 -0400
@@ -1,8 +1,5 @@
 database test.db
 sql test.sql
-safeGet Test/flush01
-safeGet Test/flush10
-safeGet Test/flush11
 safeGet Test/flush
 
 test
--- a/caching-tests/test.urs	Thu Dec 11 02:05:41 2014 -0500
+++ b/caching-tests/test.urs	Fri Mar 27 11:19:15 2015 -0400
@@ -1,8 +1,2 @@
-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 *)
 val cache : int -> transaction page
 val flush : int -> transaction page