Permalink
Browse files

revised syntax alist tests

  • Loading branch information...
1 parent b487524 commit 39a4df70096f4d2c4cf78192bf171b4c0ac93399 Jake Donham committed Sep 10, 2010
Showing with 29 additions and 5 deletions.
  1. +21 −5 applications/alist/alist_tests_revised.ml
  2. +8 −0 applications/alist/pa_alist.ml
View
26 applications/alist/alist_tests_revised.ml
@@ -9,9 +9,25 @@ value test thunk =
Printf.fprintf stderr "Test failed: %d:%d (%s)\n" line chr msg;
flush stderr) ];
module Tests (S : sig end) =
- struct
- end;
-(* object bindings + lazy patterns disallowed (no test)*)
- let module T = Tests(struct end)
- in if passed.val then print_endline "lazy tests (revised syntax) succeeded!" else ();
+struct
+
+ value _ =
+ test
+ (lazy
+ (assert
+ (match [("foo", 5); ("bar", 6); ("baz", 7)] with
+ [ alist ["bar", x; "foo", y] ->
+ x - y = 1 ])));
+
+ value _ =
+ test
+ (lazy
+ (assert
+ (match [("foo", [("bar", 6)])] with
+ [ alist ["foo", (alist ["bar", x ] | alist [ "baz", x ]) ] ->
+ x = 6 ])));
+end;
+
+let module T = Tests(struct end)
+in if passed.val then print_endline "alist tests (revised syntax) succeeded!" else ();
View
8 applications/alist/pa_alist.ml
@@ -9,6 +9,14 @@ EXTEND Gram
"alist"; "["; l = LIST0 [ e = expr LEVEL "simple"; ","; p = patt LEVEL "simple" -> Ast.PaOlbi (loc, "", p, e) ] SEP ";"; "]" ->
<:patt< $uid:"alist"$ $Ast.paSem_of_list l$ >>
]];
+
+ (*
+ XXX
+
+ the above is a little weird for revised syntax, since tuples are
+ supposed to have parens, but I'm not sure how to have a different
+ rule for original and revised.
+ *)
END
object

0 comments on commit 39a4df7

Please sign in to comment.