summaryrefslogtreecommitdiff
path: root/test/trait-builtin.myr
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 /test/trait-builtin.myr
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.
Diffstat (limited to 'test/trait-builtin.myr')
-rw-r--r--test/trait-builtin.myr26
1 files changed, 26 insertions, 0 deletions
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)
+ ;;
+}