Add test for Prelude's unsafeCompare FFI call
commita1b6402f5454d186f439383707ad679701a55bbb
authorGary Burgess <gary.burgess@gmail.com>
dateFri 18 Jul 2014, 20:57 (12 years ago)
parent09f7c46
examples/passing/Comparisons.pursnew file+23
@@ -0,0 +1,23 @@
1+module Main where
2+
3+import Control.Monad.Eff
4+import Debug.Trace
5+
6+foreign import data Assert :: !
7+
8+foreign import assert
9+ "function assert(x) {\
10+ \ return function () {\
11+ \ if (!x) throw new Error('assertion failed');\
12+ \ return {};\
13+ \ };\
14+ \};" :: forall e. Boolean -> Eff (assert :: Assert | e) Unit
15+
16+main = do
17+ assert (1 < 2)
18+ assert (2 == 2)
19+ assert (3 > 1)
20+ assert ("a" < "b")
21+ assert ("a" == "a")
22+ assert ("z" > "a")
23+ trace "Done!"