diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-09-22 15:12:09 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-09-22 15:12:09 -0400 |
commit | ee1639d9e3afa41c85382ab991e2229a91be4c21 (patch) | |
tree | 53528b85a9933aa85de2178d4f23249408427d4c /tests | |
parent | 5053cc1cc65d193cc4d3298a9d2485c0139a9bf9 (diff) |
Quoting JavaScript working
Diffstat (limited to 'tests')
-rw-r--r-- | tests/jscomp.ur | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/jscomp.ur b/tests/jscomp.ur index 1d5e3b54..e2cf4f94 100644 --- a/tests/jscomp.ur +++ b/tests/jscomp.ur @@ -6,12 +6,25 @@ fun fact n = 0 => 1 | _ => n * fact (n - 1) +datatype t = + A + | B of {C : int, D : float} + | E of t * t + +fun render x = + case x of + A => "A" + | B {C = n1, D = n2} => "B(" ^ show n1 ^ "," ^ show n2 ^ ")" + | E (x, y) => "C(" ^ render x ^ "," ^ render y ^ ")" + fun main () = s <- source ""; s' <- source ""; f <- source (plus 1); f2 <- source fst; r <- source {A = "x", B = "y"}; + t <- source (E (A, B {C = 10, D = 1.23})); + ht <- source <xml>Nothing here yet.</xml>; return <xml><body> <ctextbox source={s}/> <ctextbox source={s'}/><br/><br/> @@ -22,7 +35,10 @@ fun main () = Function2: <button value="Fst" onclick={set f2 fst}/> <button value="Snd" onclick={set f2 snd}/><br/><br/> + Both: <button value="*3,Snd" onclick={set f (times 3); set f2 snd}/><br/><br/> + <button value="Echo" onclick={s <- get s; alert s}/> + <button value="Echo2" onclick={s <- get s; alert s; alert s}/> <button value="-" onclick={s <- get s; alert (show (-(readError s : int)))}/> <button value="+1" onclick={s <- get s; alert (show (readError s + 1))}/> <button value="*3" onclick={s <- get s; alert (show ((readError s) * 3))}/> @@ -35,5 +51,11 @@ fun main () = <button value="f2" onclick={s <- get s; s' <- get s'; f2 <- get f2; alert (f2 s s')}/><br/><br/> <button value="A" onclick={r <- get r; alert r.A}/> - <button value="B" onclick={r <- get r; alert r.B}/> + <button value="B" onclick={r <- get r; alert r.B}/><br/><br/> + + <button value="render" onclick={t <- get t; alert (render t)}/><br/><br/> + + <dyn signal={signal ht}/> + <button value="Set" onclick={s <- get s; + set ht <xml><button value="Dynamic!" onclick={alert s}/></xml>}/> </body></xml> |