diff tests/utest.ur @ 19:5e03668972ea

Utest example
author Adam Chlipala <adam@chlipala.net>
date Thu, 06 Jan 2011 15:25:11 -0500
parents
children 354dae3008de
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/utest.ur	Thu Jan 06 15:25:11 2011 -0500
@@ -0,0 +1,46 @@
+style inputs
+
+structure U = OpenidUser.Make(struct
+                                  con cols = [Nam = string]
+
+                                  val sessionLifetime = 3600
+                                  val afterLogout = bless "/main"
+                                  val secureCookies = False
+                                  val association = Openid.Stateful {AssociationType = Openid.HMAC_SHA256,
+                                                                     AssociationSessionType = Openid.NoEncryption}
+                                  val realm = None
+
+                                  val creationState =
+                                      n <- source "";
+                                      return {Nam = n}
+                                      
+                                  fun render r = <xml>
+                                    <tr> <th class={inputs}>Name:</th> <td><ctextbox source={r.Nam}/></td> </tr>
+                                  </xml>
+
+                                  fun tabulate r =
+                                      n <- signal r.Nam;
+                                      return {Nam = n}
+
+                                  fun choose _ r = return r
+
+                                  val formClass = inputs
+                              end)
+
+fun wrap title body =
+    userStuff <- U.main wrap;
+    return <xml><head>
+      <title>{[title]}</title>
+    </head><body>
+      {userStuff}
+
+      <h1>{[title]}</h1>
+
+      {body}
+    </body></xml>
+
+fun main () =
+    whoami <- U.current;
+    wrap "Main page" (case whoami of
+                          None => <xml>I don't think you're logged in.</xml>
+                        | Some whoami => <xml>Apparently you are <b>{[whoami]}</b>!</xml>)