summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2020-10-05 01:18:05 +0700
committerDavid Peter <sharkdp@users.noreply.github.com>2020-10-04 21:25:05 +0200
commit88ea21b2762b3715d3816248953ed7f551cdaa7b (patch)
tree00ade3ef29826f74e1405bf05bfdf1e1305e9fd9 /tests
parent62397dbd0b49f4d9866423ddf8fb4f09aebb9d92 (diff)
Add an SML syntax test file.
Diffstat (limited to 'tests')
-rw-r--r--tests/syntax-tests/highlighted/SML/sample.sml47
-rw-r--r--tests/syntax-tests/source/SML/sample.sml47
2 files changed, 94 insertions, 0 deletions
diff --git a/tests/syntax-tests/highlighted/SML/sample.sml b/tests/syntax-tests/highlighted/SML/sample.sml
new file mode 100644
index 00000000..0c1d7037
--- /dev/null
+++ b/tests/syntax-tests/highlighted/SML/sample.sml
@@ -0,0 +1,47 @@
+val x = 0
+
+val hello = "hello world"
+
+val id = fn x => x
+
+fun id' x = x
+
+val () = print "hello world\n"
+
+val _ = let
+ val hello = "hello"
+ val world = "world"
+in
+ print (hello ^ " " ^ world ^ "\n")
+end
+
+fun isZero n =
+ if n = 0 then true
+ else false
+
+fun isTrue b =
+ case b of
+ true => true
+ | false => false
+
+exception Bad_value of string
+
+fun isTrue' b =
+ case b of
+ true => true
+ | _ => raise (Bad_value "value is not true!")
+
+val alwaysTrue =
+ isTrue' false handle Bad_value _ => true
+
+datatype myBool = True | False
+
+datatype shape = Square of real | Circle of real | Point
+
+signature FOO = sig
+ val foo : 'a -> 'a
+end
+
+structure Foo :> FOO = struct
+ fun foo x = x
+end
diff --git a/tests/syntax-tests/source/SML/sample.sml b/tests/syntax-tests/source/SML/sample.sml
new file mode 100644
index 00000000..17118ec0
--- /dev/null
+++ b/tests/syntax-tests/source/SML/sample.sml
@@ -0,0 +1,47 @@
+val x = 0
+
+val hello = "hello world"
+
+val id = fn x => x
+
+fun id' x = x
+
+val () = print "hello world\n"
+
+val _ = let
+ val hello = "hello"
+ val world = "world"
+in
+ print (hello ^ " " ^ world ^ "\n")
+end
+
+fun isZero n =
+ if n = 0 then true
+ else false
+
+fun isTrue b =
+ case b of
+ true => true
+ | false => false
+
+exception Bad_value of string
+
+fun isTrue' b =
+ case b of
+ true => true
+ | _ => raise (Bad_value "value is not true!")
+
+val alwaysTrue =
+ isTrue' false handle Bad_value _ => true
+
+datatype myBool = True | False
+
+datatype shape = Square of real | Circle of real | Point
+
+signature FOO = sig
+ val foo : 'a -> 'a
+end
+
+structure Foo :> FOO = struct
+ fun foo x = x
+end