summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <orib@google.com>2013-01-16 15:46:24 -0500
committerOri Bernstein <orib@google.com>2013-01-16 15:46:24 -0500
commit4d3579d9e03400cc44fca47638454207c86b9fd2 (patch)
tree70a7e54220da0b9e71e63afc0108a00c0db7b58c
parent9f7256a2c8174fc94b8ceafa13b0a7960083edc1 (diff)
downloadmc-4d3579d9e03400cc44fca47638454207c86b9fd2.tar.gz
Comment the purpose of the tests.
Each test now gets a comment describing what it actually checks, and what it exits with.
-rw-r--r--libstd/Makefile1
-rw-r--r--libstd/alloc.myr2
-rw-r--r--test/add.myr1
-rw-r--r--test/arityhigh.myr1
-rw-r--r--test/aritylow.myr1
-rw-r--r--test/array.myr1
-rw-r--r--test/arrayaddr.myr1
-rw-r--r--test/arraylen.myr1
-rw-r--r--test/arraylit-ni.myr1
-rw-r--r--test/arraylit.myr1
-rw-r--r--test/bsr.myr1
-rw-r--r--test/call.myr1
-rw-r--r--test/callbig.myr2
-rw-r--r--test/catfile.myr1
-rw-r--r--test/closure.myr1
-rw-r--r--test/condiffalse.myr2
-rw-r--r--test/condifrel.myr2
-rw-r--r--test/condiftrue.myr1
-rw-r--r--test/cstr-builtin.myr18
-rw-r--r--test/declmismatch.myr4
-rw-r--r--test/derefassign.myr1
-rw-r--r--test/div.myr5
-rw-r--r--test/encodechar.myr1
-rw-r--r--test/fib.myr1
-rw-r--r--test/float.myr3
-rw-r--r--test/generic-in-const.myr4
-rw-r--r--test/generic.myr1
-rw-r--r--test/genericcall.myr1
-rw-r--r--test/generictype.myr1
-rw-r--r--test/global-arrayvar.myr2
-rw-r--r--test/gsizeof.myr1
-rw-r--r--test/helloworld.myr1
-rw-r--r--test/infermismatch.myr4
-rw-r--r--test/log-and.myr1
-rw-r--r--test/log-or.myr1
-rw-r--r--test/loop.myr1
-rw-r--r--test/main.myr1
-rw-r--r--test/match-badtypes.myr6
-rw-r--r--test/matchargunion.myr2
-rw-r--r--test/matchbind.myr2
-rw-r--r--test/matchconst.myr2
-rw-r--r--test/matchint.myr1
-rw-r--r--test/matchunion.myr2
-rw-r--r--test/mkunion.myr1
-rw-r--r--test/mod.myr1
-rw-r--r--test/mul.myr1
-rw-r--r--test/nestfn.myr2
-rw-r--r--test/neststruct.myr1
-rw-r--r--test/occur.myr6
-rw-r--r--test/outparam-sl.myr1
-rw-r--r--test/outparam.myr1
-rw-r--r--test/overlappingif.myr2
-rw-r--r--test/ptrpreinc.myr1
-rw-r--r--test/sizeof.myr1
-rw-r--r--test/slalloc.myr3
-rw-r--r--test/slgrow.myr1
-rw-r--r--test/slice.myr1
-rw-r--r--test/slicelen.myr2
-rw-r--r--test/str.myr2
-rw-r--r--test/struct.myr1
-rw-r--r--test/struct1.myr3
-rw-r--r--test/structarray.myr1
-rw-r--r--test/structasn.myr1
-rw-r--r--test/structlit.myr2
-rw-r--r--test/structptr.myr1
-rw-r--r--test/structret.myr1
-rw-r--r--test/swidencast.myr7
-rw-r--r--test/tests5
-rw-r--r--test/trait-builtin.myr26
-rw-r--r--test/trunccast.myr1
-rw-r--r--test/tuple.myr1
-rw-r--r--test/tyoccur.myr5
-rw-r--r--test/union-extraarg.myr5
-rw-r--r--test/usedef.myr4
-rw-r--r--test/voidcall.myr2
-rw-r--r--test/zwidencast.myr1
76 files changed, 156 insertions, 27 deletions
diff --git a/libstd/Makefile b/libstd/Makefile
index 9db8413..e2e7077 100644
--- a/libstd/Makefile
+++ b/libstd/Makefile
@@ -5,6 +5,7 @@ MYRSRC= \
die.myr \
extremum.myr \
fmt.myr \
+ maybe.myr \
option.myr \
rand.myr \
slurp.myr \
diff --git a/libstd/alloc.myr b/libstd/alloc.myr
index 21c337e..2f4fd96 100644
--- a/libstd/alloc.myr
+++ b/libstd/alloc.myr
@@ -2,6 +2,7 @@ use "die.use"
use "sys.use"
use "types.use"
use "extremum.use"
+use "fmt.use"
pkg std =
generic alloc : ( -> @a*)
@@ -73,6 +74,7 @@ generic slgrow = {sl, len
new = slalloc(len)
n = min(len, sl.len)
+ put("growing from min(%i,%i) to %i\n", sl.len, len, n)
for i = 0; i < n; i++
new[i] = sl[i]
;;
diff --git a/test/add.myr b/test/add.myr
index 72424e3..a1d5d86 100644
--- a/test/add.myr
+++ b/test/add.myr
@@ -1,3 +1,4 @@
+/* should exit with status 53 */
const main = {
var a
var b
diff --git a/test/arityhigh.myr b/test/arityhigh.myr
index 17c91a3..457f3a0 100644
--- a/test/arityhigh.myr
+++ b/test/arityhigh.myr
@@ -1,3 +1,4 @@
+/* should fail because we call f with too many args */
const f = {a:int
}
diff --git a/test/aritylow.myr b/test/aritylow.myr
index e519fe9..b829907 100644
--- a/test/aritylow.myr
+++ b/test/aritylow.myr
@@ -1,3 +1,4 @@
+/* should fail because we call f with too few args */
const f = {a:int, b:int, c:int
}
diff --git a/test/array.myr b/test/array.myr
index dd448cb..76082a7 100644
--- a/test/array.myr
+++ b/test/array.myr
@@ -1,3 +1,4 @@
+/* tests reading and writing to arrays. should exit with 7 */
const main = {
var a : int[3]
a[0] = 3
diff --git a/test/arrayaddr.myr b/test/arrayaddr.myr
index b524ccd..31d8b94 100644
--- a/test/arrayaddr.myr
+++ b/test/arrayaddr.myr
@@ -1,3 +1,4 @@
+/* tests taking the address of array elements. should exit with 42. */
const main = {
var v : int[3]
var p
diff --git a/test/arraylen.myr b/test/arraylen.myr
index 48bdef3..04ead33 100644
--- a/test/arraylen.myr
+++ b/test/arraylen.myr
@@ -1,3 +1,4 @@
+/* checks that array lengths work. should exit with 12. */
const main = {
var a : int[12]
diff --git a/test/arraylit-ni.myr b/test/arraylit-ni.myr
index e6498db..2cbc260 100644
--- a/test/arraylit-ni.myr
+++ b/test/arraylit-ni.myr
@@ -1,3 +1,4 @@
+/* checks that we can create arrays without indexed initializers. exits with 2. */
const main = {
var a = [1, 3, 2]
-> a[2]
diff --git a/test/arraylit.myr b/test/arraylit.myr
index 24a4792..01cb9d4 100644
--- a/test/arraylit.myr
+++ b/test/arraylit.myr
@@ -1,3 +1,4 @@
+/* checks we can make indexed array literals. exits with 3. */
const main = {
var a = [#0=1,
#2=3,
diff --git a/test/bsr.myr b/test/bsr.myr
index d2d7c5f..8504a88 100644
--- a/test/bsr.myr
+++ b/test/bsr.myr
@@ -1,3 +1,4 @@
+/* should exit with status 5 */
const main = {
var a = 42
-> a >> 3
diff --git a/test/call.myr b/test/call.myr
index d731399..2bf1205 100644
--- a/test/call.myr
+++ b/test/call.myr
@@ -1,3 +1,4 @@
+/* checks that simple function calls work. should exit with 42. */
const f = {
-> 21
}
diff --git a/test/callbig.myr b/test/callbig.myr
index a9a717a..343dc23 100644
--- a/test/callbig.myr
+++ b/test/callbig.myr
@@ -1,3 +1,5 @@
+/* checks that calls with large return values (ie, ones that don't fit in a
+* register) works correctly. Should exit with 42. */
type pair = struct
a : int
b : int
diff --git a/test/catfile.myr b/test/catfile.myr
index f956776..340cac9 100644
--- a/test/catfile.myr
+++ b/test/catfile.myr
@@ -1,3 +1,4 @@
+/* checks that we can read a data file. */
use std
const main = {args : byte[:][:]
diff --git a/test/closure.myr b/test/closure.myr
index d03dbae..6d45bfb 100644
--- a/test/closure.myr
+++ b/test/closure.myr
@@ -1,3 +1,4 @@
+/* checks that functions with environment capture work. should exit with 42. */
const main = {
var a = 42
var f = {b
diff --git a/test/condiffalse.myr b/test/condiffalse.myr
index ec442c1..dce6426 100644
--- a/test/condiffalse.myr
+++ b/test/condiffalse.myr
@@ -1,3 +1,5 @@
+/* checks that false conditions lead to the false branch of an if statement.
+* should exit with 9. */
var x = 5
var y = 7
const main = {
diff --git a/test/condifrel.myr b/test/condifrel.myr
index f76f5f3..32048cc 100644
--- a/test/condifrel.myr
+++ b/test/condifrel.myr
@@ -1,4 +1,4 @@
-
+/* checks if relatonal operators work. should exit with 9. */
var x = 3
var y = 9
const main = {
diff --git a/test/condiftrue.myr b/test/condiftrue.myr
index 0874d5e..47d044a 100644
--- a/test/condiftrue.myr
+++ b/test/condiftrue.myr
@@ -1,3 +1,4 @@
+/* checks that true complex boolean conditions work. exits with 7. */
var x = 5
var y = 7
const main = {
diff --git a/test/cstr-builtin.myr b/test/cstr-builtin.myr
deleted file mode 100644
index 663d343..0000000
--- a/test/cstr-builtin.myr
+++ /dev/null
@@ -1,18 +0,0 @@
-generic max = {a:@a::tcnum, b:@a::tcnum
- if a > b
- -> a
- else
- -> b
- ;;
-}
-
-generic intlike_is42 = {a : @a::(tcnum,tctest,tcint)
- -> a == 42
-}
-const main = {
- if intlike_is42(123)
- -> 16
- else
- -> max(12, 42)
- ;;
-}
diff --git a/test/declmismatch.myr b/test/declmismatch.myr
index 29a4df5..595c0be 100644
--- a/test/declmismatch.myr
+++ b/test/declmismatch.myr
@@ -1,3 +1,7 @@
+/*
+should fail to compile with a type error.
+char is incompatible with int.
+*/
const main = {
var a : int
var b : char
diff --git a/test/derefassign.myr b/test/derefassign.myr
index d24f247..5b56ade 100644
--- a/test/derefassign.myr
+++ b/test/derefassign.myr
@@ -1,3 +1,4 @@
+/* should assign to v through pointer p, exiting with 123 */
const main = {
var p
var v
diff --git a/test/div.myr b/test/div.myr
index fbb4947..2ed25be 100644
--- a/test/div.myr
+++ b/test/div.myr
@@ -1,8 +1,9 @@
+/* should exit with status 42 */
const main = {
var a
var b
- a = 84
- b = 2
+ a = 127
+ b = 3
-> a / b
}
diff --git a/test/encodechar.myr b/test/encodechar.myr
index 411b99d..eb32e18 100644
--- a/test/encodechar.myr
+++ b/test/encodechar.myr
@@ -1,3 +1,4 @@
+/* checks that we can decode and encode characters from a utf8 string. */
use std
const main = {args : byte[:][:]
diff --git a/test/fib.myr b/test/fib.myr
index 935dc4a..141ffe2 100644
--- a/test/fib.myr
+++ b/test/fib.myr
@@ -1,3 +1,4 @@
+/* checks if recursive functions work. should return 21. */
const fib = {n
if n <= 0
-> 0
diff --git a/test/float.myr b/test/float.myr
index b7889e2..b6cc72e 100644
--- a/test/float.myr
+++ b/test/float.myr
@@ -1,3 +1,4 @@
+/* basic sanity check on floating point operations. should return 84. */
const main = {
- -> 42.0 + 42.0
+ -> (42.0 + 42.0) castto(int)
}
diff --git a/test/generic-in-const.myr b/test/generic-in-const.myr
index 150fe18..2dd01be 100644
--- a/test/generic-in-const.myr
+++ b/test/generic-in-const.myr
@@ -1,3 +1,7 @@
+/*
+should fail to compile because generic types
+are only allowed in generic declarations.
+*/
const foo = {v : @a
-> v
}
diff --git a/test/generic.myr b/test/generic.myr
index 4b7a73f..c9e2345 100644
--- a/test/generic.myr
+++ b/test/generic.myr
@@ -1,3 +1,4 @@
+/* checks that simple generics are specialized correctly. exits with 42. */
generic id = {a:@a
-> a
}
diff --git a/test/genericcall.myr b/test/genericcall.myr
index adeb2d6..f752c37 100644
--- a/test/genericcall.myr
+++ b/test/genericcall.myr
@@ -1,3 +1,4 @@
+/* checks that generics can call non-generics. exits with 42. */
const f = {
-> 42
}
diff --git a/test/generictype.myr b/test/generictype.myr
index 4d33c33..e203eaf 100644
--- a/test/generictype.myr
+++ b/test/generictype.myr
@@ -1,3 +1,4 @@
+/* checks that parameterized types work. exits with 0. */
type option(@a) = union
`Some @a
`None
diff --git a/test/global-arrayvar.myr b/test/global-arrayvar.myr
index 23ef915..7482f6e 100644
--- a/test/global-arrayvar.myr
+++ b/test/global-arrayvar.myr
@@ -1,3 +1,5 @@
+/* tests that global arrays work as expected, and are zero-initialized by
+* default. should exit with 7 */
var a : int[10]
const main = {
diff --git a/test/gsizeof.myr b/test/gsizeof.myr
index 8108541..6322c06 100644
--- a/test/gsizeof.myr
+++ b/test/gsizeof.myr
@@ -1,3 +1,4 @@
+/* checks that sizeof works on generics. exits with 5. */
generic sz = {a:@a
-> sizeof(@a)
}
diff --git a/test/helloworld.myr b/test/helloworld.myr
index 940e20c..602a8b0 100644
--- a/test/helloworld.myr
+++ b/test/helloworld.myr
@@ -1,3 +1,4 @@
+/* checks that this program prints Hello-世界\n */
use std
const main = {args : byte[:][:]
diff --git a/test/infermismatch.myr b/test/infermismatch.myr
index 839f6c4..e606223 100644
--- a/test/infermismatch.myr
+++ b/test/infermismatch.myr
@@ -1,3 +1,7 @@
+/*
+should fail to compile after infering that a is a float, b is a char, and
+the types are incompatible.
+*/
const main = {
var a
var b
diff --git a/test/log-and.myr b/test/log-and.myr
index 2882acf..b8f1fb2 100644
--- a/test/log-and.myr
+++ b/test/log-and.myr
@@ -1,3 +1,4 @@
+/* checks that evaluating a logical and to a bool works. should return 0. */
const main = {
-> 0 && 1
}
diff --git a/test/log-or.myr b/test/log-or.myr
index 567a829..e11155a 100644
--- a/test/log-or.myr
+++ b/test/log-or.myr
@@ -1,3 +1,4 @@
+/* checks that evaluating a logical or works. exits with 1. */
const main = {
-> 0 || 1
}
diff --git a/test/loop.myr b/test/loop.myr
index 94863e1..113987a 100644
--- a/test/loop.myr
+++ b/test/loop.myr
@@ -1,3 +1,4 @@
+/* checks that loops work. exits with 45. */
const main = {
var i
var n
diff --git a/test/main.myr b/test/main.myr
index ec78127..cfdfe93 100644
--- a/test/main.myr
+++ b/test/main.myr
@@ -1 +1,2 @@
+/* should exit with status 0 */
const main = {; -> 0 }
diff --git a/test/match-badtypes.myr b/test/match-badtypes.myr
index 5fd5d56..1b43cfe 100644
--- a/test/match-badtypes.myr
+++ b/test/match-badtypes.myr
@@ -1,3 +1,9 @@
+/*
+should fail to compile because
+all types matched over should be
+compatible. Strings are not compatible
+with integers.
+*/
const foo = {
match 123
"asdf": 123
diff --git a/test/matchargunion.myr b/test/matchargunion.myr
index 48fb6f9..fcf65dc 100644
--- a/test/matchargunion.myr
+++ b/test/matchargunion.myr
@@ -1,3 +1,5 @@
+/* checks pattern matching on unions with arguments.
+exits with 42. */
type u = union
`Int int
`Chr char
diff --git a/test/matchbind.myr b/test/matchbind.myr
index 755f6a8..c601252 100644
--- a/test/matchbind.myr
+++ b/test/matchbind.myr
@@ -1,3 +1,5 @@
+/* checks that we can bind values in pattern matches.
+exits with 11. */
type u = union
`Int int
`Chr char
diff --git a/test/matchconst.myr b/test/matchconst.myr
index dfc321c..150c2d2 100644
--- a/test/matchconst.myr
+++ b/test/matchconst.myr
@@ -1,3 +1,5 @@
+/* checks that matching works when comparing against constants,
+instead of just literals. exits with 88. */
/* some misc constants */
const Ca = 123
const Cb = 8
diff --git a/test/matchint.myr b/test/matchint.myr
index 63f6fc6..1cf607e 100644
--- a/test/matchint.myr
+++ b/test/matchint.myr
@@ -1,3 +1,4 @@
+/* checks that matching integers works. exits with 84. */
const main = {
var v
diff --git a/test/matchunion.myr b/test/matchunion.myr
index 9c01b72..683e985 100644
--- a/test/matchunion.myr
+++ b/test/matchunion.myr
@@ -1,3 +1,5 @@
+/* checks that union matching works, at least on the key.
+exits with 84. */
type u = union
`Foo
`Bar
diff --git a/test/mkunion.myr b/test/mkunion.myr
index 8d2f291..7d58f31 100644
--- a/test/mkunion.myr
+++ b/test/mkunion.myr
@@ -1,3 +1,4 @@
+/* checks that union creation works. exits with 0. */
type u = union
`Some int
`None
diff --git a/test/mod.myr b/test/mod.myr
index 842ab70..a4a8e9c 100644
--- a/test/mod.myr
+++ b/test/mod.myr
@@ -1,3 +1,4 @@
+/* should exit with status 6 */
const main = {
var a = 42
var b = 9
diff --git a/test/mul.myr b/test/mul.myr
index e0971e4..25e52e0 100644
--- a/test/mul.myr
+++ b/test/mul.myr
@@ -1,3 +1,4 @@
+/* should exit with status 42 */
const main = {
var a = 7
var b = 2
diff --git a/test/nestfn.myr b/test/nestfn.myr
index 0fa11e0..85787b1 100644
--- a/test/nestfn.myr
+++ b/test/nestfn.myr
@@ -1,3 +1,5 @@
+/* checks that nested functions without environment capture work. should
+* exit with 42. */
const main = {
const ret42 = {
-> 42
diff --git a/test/neststruct.myr b/test/neststruct.myr
index 1c5aefe..1631f70 100644
--- a/test/neststruct.myr
+++ b/test/neststruct.myr
@@ -1,3 +1,4 @@
+/* tests that nested structs work. should exit with 3 */
type s1 = struct
x : s2
;;
diff --git a/test/occur.myr b/test/occur.myr
index b4597b4..909ccb9 100644
--- a/test/occur.myr
+++ b/test/occur.myr
@@ -1,3 +1,9 @@
+/* checks that f is not an infinite type (ie, the type
+doesn't exist within itself). If 'f' typechecked,
+it's type would be:
+
+f : (-> (-> (-> ... ad infinitum ...)))
+*/
const f = {
-> f
}
diff --git a/test/outparam-sl.myr b/test/outparam-sl.myr
index 8e21c0c..73894cd 100644
--- a/test/outparam-sl.myr
+++ b/test/outparam-sl.myr
@@ -1,3 +1,4 @@
+/* should assign a slice through an out param, returning exiting with 2 */
const arr = [1,2,3,4]
const f = {out
*out = arr[1:3]
diff --git a/test/outparam.myr b/test/outparam.myr
index 61019b9..dce00e1 100644
--- a/test/outparam.myr
+++ b/test/outparam.myr
@@ -1,3 +1,4 @@
+/* should assign through an out pointer parameter, exiting with status 42 */
const f = {out
*out = 42
}
diff --git a/test/overlappingif.myr b/test/overlappingif.myr
index 4737118..ac1dab2 100644
--- a/test/overlappingif.myr
+++ b/test/overlappingif.myr
@@ -1,3 +1,5 @@
+/* checks that if multiple if conditions are valid, only the first is
+* selected. should exit with 2. */
const main = {
var v
var x
diff --git a/test/ptrpreinc.myr b/test/ptrpreinc.myr
index f8d246f..f60e6aa 100644
--- a/test/ptrpreinc.myr
+++ b/test/ptrpreinc.myr
@@ -1,3 +1,4 @@
+/* should preincrement through a pointer, exiting with status 9 */
const ppreinc = {p
-> ++*p
}
diff --git a/test/sizeof.myr b/test/sizeof.myr
index a9f00f0..7ef4f45 100644
--- a/test/sizeof.myr
+++ b/test/sizeof.myr
@@ -1,3 +1,4 @@
+/* checks that sizeof() works. exits with 4. */
const main = {
-> sizeof(int)
}
diff --git a/test/slalloc.myr b/test/slalloc.myr
index 1a6b13a..21035e2 100644
--- a/test/slalloc.myr
+++ b/test/slalloc.myr
@@ -1,8 +1,11 @@
+/* test the allocation of slices. should return 123 */
use std
const main = {
var sl : int[:]
sl = std.slalloc(123)
+ sl[0] = 42
+ sl[122] = 1
-> sl.len
}
diff --git a/test/slgrow.myr b/test/slgrow.myr
index e687a5d..6b6ae3a 100644
--- a/test/slgrow.myr
+++ b/test/slgrow.myr
@@ -1,3 +1,4 @@
+/* checks that our slice grow function works. exits with 42. */
use std
const main = {
diff --git a/test/slice.myr b/test/slice.myr
index 1f492a9..b1b4958 100644
--- a/test/slice.myr
+++ b/test/slice.myr
@@ -1,3 +1,4 @@
+/* checks that taking slices of arrays works. should exit with 7 */
const main = {
var a : int[3]
var s
diff --git a/test/slicelen.myr b/test/slicelen.myr
index 1b35cea..000cc6c 100644
--- a/test/slicelen.myr
+++ b/test/slicelen.myr
@@ -1,3 +1,5 @@
+/* checks that taking incomplete slices calculates the length correctly.
+* should exit with 5. */
const main = {
var a : int[8]
var s
diff --git a/test/str.myr b/test/str.myr
index f4ee027..70dc38b 100644
--- a/test/str.myr
+++ b/test/str.myr
@@ -1,3 +1,5 @@
+/* checks that string literals are compiled correctly.
+exits with ascii 'f', ie, 102. */
const main = {
var str
diff --git a/test/struct.myr b/test/struct.myr
index 94a7c21..8302245 100644
--- a/test/struct.myr
+++ b/test/struct.myr
@@ -1,3 +1,4 @@
+/* test reading and writing to struct members. exits with 42. */
type pair = struct
a : int
b : int
diff --git a/test/struct1.myr b/test/struct1.myr
index ed1d128..ae26ebd 100644
--- a/test/struct1.myr
+++ b/test/struct1.myr
@@ -1,3 +1,6 @@
+/*
+make sure assigning to a 1-element struct works; exit status should be 12
+*/
type val = struct
a : int
;;
diff --git a/test/structarray.myr b/test/structarray.myr
index 075a73f..0849b90 100644
--- a/test/structarray.myr
+++ b/test/structarray.myr
@@ -1,3 +1,4 @@
+/* tests a struct containing an array. exit status should be 42. */
type t = struct
a : int[42]
;;
diff --git a/test/structasn.myr b/test/structasn.myr
index 6940b50..6ed32fb 100644
--- a/test/structasn.myr
+++ b/test/structasn.myr
@@ -1,3 +1,4 @@
+/* tests block assignment of structs. exits with 42.*/
type pair = struct
a : int
b : int
diff --git a/test/structlit.myr b/test/structlit.myr
index e1515d1..f197a49 100644
--- a/test/structlit.myr
+++ b/test/structlit.myr
@@ -1,3 +1,5 @@
+/* checks that we can create struct literals with named initializers.
+ exits with 42. */
type t = struct
a : int
b : char
diff --git a/test/structptr.myr b/test/structptr.myr
index c6a94e3..df53a04 100644
--- a/test/structptr.myr
+++ b/test/structptr.myr
@@ -1,3 +1,4 @@
+/* tests reading and writing through a struct pointer. exits with 42. */
type pair = struct
a : int
b : int
diff --git a/test/structret.myr b/test/structret.myr
index d00582f..1f19aa8 100644
--- a/test/structret.myr
+++ b/test/structret.myr
@@ -1,3 +1,4 @@
+/* tests returning large structs. should exit with 42. */
type pair = struct
a : int
b : int
diff --git a/test/swidencast.myr b/test/swidencast.myr
index a24c116..b3ca205 100644
--- a/test/swidencast.myr
+++ b/test/swidencast.myr
@@ -1,8 +1,9 @@
+/* sign extending cast. should exit with status 99 */
const main = {
- var u : uint8
- var v : uint32
+ var u : int8
+ var v : int32
u = 99
- v = u castto(uint32)
+ v = u castto(int32)
-> v
}
diff --git a/test/tests b/test/tests
index 56faf63..f684505 100644
--- a/test/tests
+++ b/test/tests
@@ -47,16 +47,16 @@ B nestfn E 42
B closure E 55
B loop E 45
B condiftrue E 7
-B overlappingif E 2
B condiffalse E 9
B condifrel E 7
+B overlappingif E 2
B fib E 21
B float E 1
B log-and E 0
B log-or E 1
B str E 102
B generic E 42
-B cstr-builtin E 42
+B trait-builtin E 42
B genericcall E 42
B generictype E 0
B genericrec E 0
@@ -72,6 +72,7 @@ B arraylit E 3
B arraylit-ni E 2
B structlit E 42
B tuple E 42
+B slgrow E 42
B tyrec E 42
B slgrow E 42
B helloworld P Hello-世界
diff --git a/test/trait-builtin.myr b/test/trait-builtin.myr
new file mode 100644
index 0000000..ba7034b
--- /dev/null
+++ b/test/trait-builtin.myr
@@ -0,0 +1,26 @@
+/* checks that generic types with traits are compiled correctly.
+without the 'tcnum' trait on '@a', the '>' operator would not work
+within max. without the 'tctest' trait on '@a' in intlike_is42,
+comparing to 42 wouldn't work.
+
+exits with 42.
+*/
+
+generic max = {a:@a::tcnum, b:@a::tcnum
+ if a > b
+ -> a
+ else
+ -> b
+ ;;
+}
+
+generic intlike_is42 = {a : @a::(tcnum,tctest,tcint)
+ -> a == 42
+}
+const main = {
+ if intlike_is42(123)
+ -> 16
+ else
+ -> max(12, 42)
+ ;;
+}
diff --git a/test/trunccast.myr b/test/trunccast.myr
index e49b69a..16e9c24 100644
--- a/test/trunccast.myr
+++ b/test/trunccast.myr
@@ -1,3 +1,4 @@
+/* should truncate y when casting to x, exiting with status 15 */
const main = {
var x : int8
var y : int32
diff --git a/test/tuple.myr b/test/tuple.myr
index 706fab8..fc43aef 100644
--- a/test/tuple.myr
+++ b/test/tuple.myr
@@ -1,3 +1,4 @@
+/* checks that we can create tuples and destructure them. exits with 42. */
const main = {
var v
var x
diff --git a/test/tyoccur.myr b/test/tyoccur.myr
index 2a37aa6..c5bf213 100644
--- a/test/tyoccur.myr
+++ b/test/tyoccur.myr
@@ -1,3 +1,8 @@
+/* checks that types do not contain themselves
+inline, because that would lead to an infinite
+sized type.
+*/
+
type t = struct
memb : t
;;
diff --git a/test/union-extraarg.myr b/test/union-extraarg.myr
index f245b94..b34dc48 100644
--- a/test/union-extraarg.myr
+++ b/test/union-extraarg.myr
@@ -1,3 +1,8 @@
+/*
+should fail to compile becuse
+we're constructing a union that
+with too many arguments.
+*/
type u = union
`Foo
;;
diff --git a/test/usedef.myr b/test/usedef.myr
index 06ec691..547a046 100644
--- a/test/usedef.myr
+++ b/test/usedef.myr
@@ -1,3 +1,7 @@
+/*
+should fail to compile because 'a' is used
+before it is defined.
+*/
const main = {
var a : int
-> a
diff --git a/test/voidcall.myr b/test/voidcall.myr
index d9225cc..c0313fd 100644
--- a/test/voidcall.myr
+++ b/test/voidcall.myr
@@ -1,3 +1,5 @@
+/* checks that calling void functions works. should compile, and not die
+when running. the exit value is 12, but it's really a dummy. */
const f = {
var a
diff --git a/test/zwidencast.myr b/test/zwidencast.myr
index a24c116..fd960f0 100644
--- a/test/zwidencast.myr
+++ b/test/zwidencast.myr
@@ -1,3 +1,4 @@
+/* should zero-extend u when casting to v, returning 99 */
const main = {
var u : uint8
var v : uint32