Commit | Line | Data |
---|---|---|
7f918cf1 CE |
1 | fun assert (msg,b) = |
2 | if b then () | |
3 | else print ("assertion failed: " ^ msg ^ "\n") | |
4 | ||
5 | datatype 'a tree = | |
6 | Leaf of 'a | |
7 | | Node of 'a * 'a tree * 'a tree | |
8 | ||
9 | val _ = | |
10 | (assert ("string equal", "foobar" = "foobar") ; | |
11 | assert ("string not equal", "foobar" <> "foobaz") ; | |
12 | assert ("tuple equal", (1,2,3) = (1,2,3)) ; | |
13 | assert ("tuple not equal", (1,2,3) <> (1,2,4)) ; | |
14 | assert ("list equal", [1,2,3] = [1,2,3]) ; | |
15 | assert ("list not equal", [1,2,3] <> [1,2,3,4]) ; | |
16 | assert ("pair list equal", [(1,2), (3,4)] = [(1,2), (3,4)]) ; | |
17 | assert ("pair list not equal", [(1,2), (3,4)] <> [(1,2), (3,5)]) ; | |
18 | assert ("tree equal", | |
19 | let val t = Node (1, Leaf 2, Node (3, Leaf 4, Leaf 5)) | |
20 | in t = t | |
21 | end)) | |
22 | ||
23 | ||
24 |