summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-04-21 15:54:09 -0700
committerOri Bernstein <ori@eigenstate.org>2015-04-21 15:54:09 -0700
commit2176941003e95b0c595fc37ca1a7a85e21f10d54 (patch)
tree117ebe3af04beb187ebe3226b052b912289c6237 /test
parentb77533cb3d625cd5bc7a8779a07f033d4b81b687 (diff)
downloadmc-2176941003e95b0c595fc37ca1a7a85e21f10d54.tar.gz
Move tests from test/ directory to libstd/test/
Use mbld to run this shit.
Diffstat (limited to 'test')
-rw-r--r--test/stdbigint.myr136
-rw-r--r--test/stdchartype.myr23
-rw-r--r--test/stdfmtpad.myr14
-rw-r--r--test/stdopt-mk.myr20
-rw-r--r--test/stdopt-none.myr13
-rw-r--r--test/stdopt-some.myr9
-rw-r--r--test/stdopt-struct.myr9
-rw-r--r--test/stdpathnorm.myr46
-rw-r--r--test/stdsearch.myr34
-rw-r--r--test/stdslcp.myr19
-rw-r--r--test/stdsort.myr40
-rw-r--r--test/stdtry.myr8
-rw-r--r--test/tests12
13 files changed, 0 insertions, 383 deletions
diff --git a/test/stdbigint.myr b/test/stdbigint.myr
deleted file mode 100644
index a8ea5a2..0000000
--- a/test/stdbigint.myr
+++ /dev/null
@@ -1,136 +0,0 @@
-use std
-
-type cmd = union
- `Add (cmd#, cmd#)
- `Sub (cmd#, cmd#)
- `Mul (cmd#, cmd#)
- `Div (cmd#, cmd#)
- `Mod (cmd#, cmd#)
- `Shl (cmd#, cmd#)
- `Shr (cmd#, cmd#)
- `Modpow (cmd#, cmd#, cmd#)
- `Val byte[:]
- `Res cmd#
-;;
-
-const main = {
- var a, b, c, d, e
- var buf : byte[64], n
-
- /* a few combined ops */
- a = std.mkbigint(1234)
- b = std.mkbigint(0x7fffffff)
- c = std.mkbigint(7919)
- d = std.mkbigint(113051)
- e = std.mkbigint(11)
-
- std.bigmul(a, b)
- std.bigmul(a, b)
- std.bigadd(a, c)
- std.bigsub(a, d)
- std.bigdiv(a, e)
-
- std.bigfree(b)
- std.bigfree(c)
- std.bigfree(d)
- std.bigfree(e)
-
- n = std.bigbfmt(buf[:], a, 0)
- std.put("%s\n", buf[:n])
-
- /* make sure we format '0' correctly */
- run(std.mk(`Res (std.mk(`Val "0"))))
- /* smoke test for division */
- run(std.mk(`Res \
- std.mk(`Div (\
- std.mk(`Val "1234_5678_1234_6789_6666_7777_8888"), \
- std.mk(`Val "1234_5678_1234_6789_6666_7777")))))
- run(std.mk(`Res \
- std.mk(`Div (\
- std.mk(`Val "0xffff_1234_1234_1234_1234"), \
- std.mk(`Val "0xf010_1234_2314")))))
- run(std.mk(`Res \
- std.mk(`Div (\
- std.mk(`Val "5192296858534810493479828944327220"), \
- std.mk(`Val "75557863709417659441940")))))
- run(std.mk(`Res \
- std.mk(`Div (\
- std.mk(`Val "75557863709417659441940"), \
- std.mk(`Val "5192296858534810493479828944327220")))))
-
- /* smoke test for mod */
- run(std.mk(`Res \
- std.mk(`Mod (\
- std.mk(`Val "5192296858534810493479828944327220"), \
- std.mk(`Val "75557863709417659441940")))))
-
- run(std.mk(`Res \
- std.mk(`Modpow (\
- std.mk(`Val "1"), \
- std.mk(`Val "3"), \
- std.mk(`Val "2")))))
-
- run(std.mk(`Res \
- std.mk(`Modpow (\
- std.mk(`Val "5192296858534810493479828944327220"), \
- std.mk(`Val "75557863709417659441940"), \
- std.mk(`Val "755578")))))
- run(std.mk(`Res \
- std.mk(`Modpow (\
- std.mk(`Val "7220"), \
- std.mk(`Val "755578"), \
- std.mk(`Val "75557863709417659441940")))))
-
-}
-
-const run = {e : cmd#
- var buf : byte[2048]
- var a, b, c /* scratch vars */
- var n /* buf len */
-
- match e#
- | `Add (x, y): -> binop("+", std.bigadd, x, y)
- | `Sub (x, y): -> binop("-", std.bigsub, x, y)
- | `Mul (x, y): -> binop("*", std.bigmul, x, y)
- | `Div (x, y): -> binop("/", std.bigdiv, x, y)
- | `Mod (x, y): -> binop("%", std.bigmod, x, y)
- | `Shl (x, y): -> binop("<<", std.bigshl, x, y)
- | `Shr (x, y): -> binop(">>", std.bigshr, x, y)
- | `Val x:
- a = try(std.bigparse(x))
- n = std.bigbfmt(buf[:], a, 0)
- std.put("%s", buf[:n])
- -> a
- | `Res r:
- a = run(r)
- n = std.bigbfmt(buf[:], a, 0)
- std.put(" == %s\n", buf[:n])
- -> a
- | `Modpow (x, y, z):
- std.put("(");
- a = run(x)
- std.put(" ^ ")
- b = run(y)
- std.put(") %% ")
- c = run(z)
- -> std.bigmodpow(a, b, c)
- ;;
-}
-
-const binop = {name, op, x, y
- var a, b
-
- a = run(x)
- std.put(" %s ", name)
- b = run(y)
- op(a, b)
- std.bigfree(b)
- -> a
-}
-
-generic try = {x : std.option(@a)
- match x
- | `std.Some v: -> v
- | `std.None: std.die("failed to get val")
- ;;
-}
diff --git a/test/stdchartype.myr b/test/stdchartype.myr
deleted file mode 100644
index d0df1d2..0000000
--- a/test/stdchartype.myr
+++ /dev/null
@@ -1,23 +0,0 @@
-use std
-
-const main = {
- std.assert(std.isalpha('a'), "a should be alpha\n")
- std.assert(std.isupper('A'), "A should be upper\n")
- std.assert(std.islower('a'), "a should be lower\n")
- std.assert(std.isdigit('0'), "0 should be isdigit\n")
- std.assert(std.isnum('\u{0c66}'), "\u{0c66} should be isnum\n")
- std.assert(std.isalnum('a'), "a should be isalnum\n")
- std.assert(std.isalnum('0'), "0 should be isalnum\n")
- std.assert(std.isspace(' '), "' ' should be isspace\n")
- std.assert(std.isblank(' '), "' ' should be isblank\n")
-
- std.assert(!std.isalpha('0'), "0 should not be alpha\n")
- std.assert(!std.isupper('a'), "a should not be upper\n")
- std.assert(!std.islower('A'), "A should not be lower\n")
- std.assert(!std.isdigit('a'), "a should not be isdigit\n")
- std.assert(!std.isnum('a'), " should not be isnum\n")
- std.assert(!std.isalnum('}'), "a should not be isalnum\n")
- std.assert(!std.isalnum('!'), "! should not be isalnum\n")
- std.assert(!std.isspace('@'), "@ should not be isspace\n")
- std.assert(!std.isblank('@'), "@ should not be isblank\n")
-}
diff --git a/test/stdfmtpad.myr b/test/stdfmtpad.myr
deleted file mode 100644
index f836611..0000000
--- a/test/stdfmtpad.myr
+++ /dev/null
@@ -1,14 +0,0 @@
-use std
-
-const main = {
- std.put("%10s\n", "abcd")
- std.put("%010s\n", "bdcae")
- std.put("%010s\n", "abcdefghijkl")
- std.put("%01s\n", "a")
- std.put("%10i\n", 10)
- std.put("%010i\n", 10)
- std.put("%010ui\n", -1)
- std.put("%010i\n", -1)
- std.put("%10i\n", -1)
- std.put("%3i\n", 100000)
-}
diff --git a/test/stdopt-mk.myr b/test/stdopt-mk.myr
deleted file mode 100644
index 4d576fa..0000000
--- a/test/stdopt-mk.myr
+++ /dev/null
@@ -1,20 +0,0 @@
-use std
-
-const f = {x
- if x == 123
- -> `std.Some 42
- else
- -> `std.None
- ;;
-}
-
-const main = {
- var v
-
- v = f(123)
- match v
- | `std.Some x: std.exit(x)
- | `std.None: std.exit(123)
- ;;
-}
-
diff --git a/test/stdopt-none.myr b/test/stdopt-none.myr
deleted file mode 100644
index 63f4d35..0000000
--- a/test/stdopt-none.myr
+++ /dev/null
@@ -1,13 +0,0 @@
-use std
-
-const f = {
- -> `std.None
-}
-
-const main = {
- match f()
- | `std.Some x: std.exit(x)
- | `std.None: std.exit(42)
- ;;
-}
-
diff --git a/test/stdopt-some.myr b/test/stdopt-some.myr
deleted file mode 100644
index 714222e..0000000
--- a/test/stdopt-some.myr
+++ /dev/null
@@ -1,9 +0,0 @@
-use std
-
-const main = {
- match `std.Some 42
- | `std.Some x: std.exit(x)
- | `std.None: std.exit(1)
- ;;
-}
-
diff --git a/test/stdopt-struct.myr b/test/stdopt-struct.myr
deleted file mode 100644
index cb02241..0000000
--- a/test/stdopt-struct.myr
+++ /dev/null
@@ -1,9 +0,0 @@
-use std
-
-type t = struct
- next : std.option(int)
-;;
-
-const main = {
- std.exit(42)
-}
diff --git a/test/stdpathnorm.myr b/test/stdpathnorm.myr
deleted file mode 100644
index caff027..0000000
--- a/test/stdpathnorm.myr
+++ /dev/null
@@ -1,46 +0,0 @@
-use std
-
-const main = {
- /* untouched */
- std.put("%s\n", std.pathnorm(""))
- std.put("%s\n", std.pathnorm("foo"))
- std.put("%s\n", std.pathnorm("foo/bar"))
- std.put("%s\n", std.pathnorm("/foo/bar"))
- std.put("%s\n", std.pathnorm("."))
-
- /* empty path becomes "." */
- std.put("%s\n", std.pathnorm("."))
-
- /* delete //, trailing / */
- std.put("%s\n", std.pathnorm("foo/"))
- std.put("%s\n", std.pathnorm("foo//bar/baz"))
- std.put("%s\n", std.pathnorm("//foo//bar/"))
-
- /* delete '.' */
- std.put("%s\n", std.pathnorm("foo/./bar"))
- std.put("%s\n", std.pathnorm("/foo/bar/."))
- std.put("%s\n", std.pathnorm("./foo/bar/."))
-
- /* elide '..' */
- std.put("%s\n", std.pathnorm("/../foo/bar"))
- std.put("%s\n", std.pathnorm("../../foo/bar"))
- std.put("%s\n", std.pathnorm("foo/bar/.."))
- std.put("%s\n", std.pathnorm("foo/bar/../.."))
- std.put("%s\n", std.pathnorm("foo/../bar/../.."))
- std.put("%s\n", std.pathnorm("/foo/../bar/../.."))
-
- /* mix all of the above */
- std.put("%s\n", std.pathnorm("/../foo//bar"))
- std.put("%s\n", std.pathnorm("..//../foo/bar"))
- std.put("%s\n", std.pathnorm("foo//./bar/.."))
- std.put("%s\n", std.pathnorm("foo/bar/.././.."))
- std.put("%s\n", std.pathnorm("//foo/../bar/../.."))
- std.put("%s\n", std.pathnorm("foo/../bar/../.."))
-
- /* vanilla pathjoin */
- std.put("%s\n", std.pathcat("a", "b"))
- std.put("%s\n", std.pathjoin(["a", "b", "c"][:]))
- /* pathjoin with empty dirs */
- std.put("%s\n", std.pathcat("", "foo"))
- std.put("%s\n", std.pathjoin(["", "foo", "bar"][:]))
-}
diff --git a/test/stdsearch.myr b/test/stdsearch.myr
deleted file mode 100644
index 3e3ac53..0000000
--- a/test/stdsearch.myr
+++ /dev/null
@@ -1,34 +0,0 @@
-use std
-
-const sl = [1, 3, 5, 8, 9, 33]
-
-const main = {
-
- expect(std.lsearch(sl[:], 1, std.numcmp), `std.Some 0)
- expect(std.lsearch(sl[:], 33, std.numcmp), `std.Some sl.len - 1)
- expect(std.lsearch(sl[:], 5, std.numcmp), `std.Some 2)
- expect(std.lsearch(sl[:], 6, std.numcmp), `std.None)
-
- expect(std.bsearch(sl[:], 1, std.numcmp), `std.Some 0)
- expect(std.bsearch(sl[:], 33, std.numcmp), `std.Some sl.len - 1)
- expect(std.bsearch(sl[:], 5, std.numcmp), `std.Some 2)
- expect(std.bsearch(sl[:], 6, std.numcmp), `std.None)
-}
-
-const expect = {a, b
- match a
- | `std.None:
- match b
- | `std.Some x: std.fatal(1, "Expected `std.None, `std.None, got `std.None, `std.Some %i\n", x)
- | `std.None: /* nothing */
- ;;
- | `std.Some x:
- match b
- | `std.None: std.fatal(1, "Expected `std.Some %i, `std.Some %i, got `std.Some %i, `std.None\n", x, x, x)
- | `std.Some y:
- if x != y
- std.fatal(1, "Expected `std.Some %i, `std.Some %i, got `std.Some %i, `std.Some %i\n", x, x, x, y)
- ;;
- ;;
- ;;
-}
diff --git a/test/stdslcp.myr b/test/stdslcp.myr
deleted file mode 100644
index 92efbf8..0000000
--- a/test/stdslcp.myr
+++ /dev/null
@@ -1,19 +0,0 @@
-use std
-
-const main = {
- var a = [1,2,3,4,5]
- var b = [6,7,8,9,10]
-
-
- std.slcp(a[:a.len-2], a[2:])
- std.slcp(b[2:], b[:b.len-2])
-
- for x in a
- std.put("%i ", x)
- ;;
- std.put("\n")
- for x in b
- std.put("%i ", x)
- ;;
- std.put("\n")
-}
diff --git a/test/stdsort.myr b/test/stdsort.myr
deleted file mode 100644
index 8c8f181..0000000
--- a/test/stdsort.myr
+++ /dev/null
@@ -1,40 +0,0 @@
-use std
-
-const main = {
- var a = [
- 3, 5, 4, 9, 7, 2, 6, 0, 1, 8,
- ]
- var b = [
- 3, 4, 5, 1, 2, 6, 7, 8, 9, 10
- ]
- var c = [
- "a", "aa", "b", "C", "Cc", "cC", "d", "f", "fuckit", "go",
- ]
-
- std.sort(a[:], intcmp)
- for v in a
- std.put("%i\n", v)
- ;;
- std.put("---\n")
- std.sort(b[:], std.numcmp)
- for v in b
- std.put("%i\n", v)
- ;;
- std.put("---\n")
- std.sort(c[:], std.strcmp)
- for v in c
- std.put("%s\n", v)
- ;;
-}
-
-const intcmp = {a, b
- if a < b
- -> `std.Before
- elif a == b
- -> `std.Equal
- else
- -> `std.After
- ;;
-}
-
-
diff --git a/test/stdtry.myr b/test/stdtry.myr
deleted file mode 100644
index 4ec3504..0000000
--- a/test/stdtry.myr
+++ /dev/null
@@ -1,8 +0,0 @@
-use std
-
-const main = {
- var x = `std.Some 123
- std.try(x)
- x = `std.None
- std.try(x)
-}
diff --git a/test/tests b/test/tests
index aadc60e..8db19fe 100644
--- a/test/tests
+++ b/test/tests
@@ -92,10 +92,6 @@ B genericrec E 0
# B genericchain P 'val = 123' ## BUGGERED
B genericmake P 'val = 123'
B genericuret E 42
-B stdopt-some E 42
-B stdopt-none E 42
-B stdopt-mk E 42
-B stdopt-struct E 42
B sizeof E 4
B gsizeof E 5
B matchint E 84
@@ -125,20 +121,12 @@ B exportcycle E 0
B import-type E 0
B helloworld P Hello-世界
B encodechar P 1世界äa
-B stdsearch E 0
-B stdchartype E 0
-B stdtry C
B strtab C
B catfile C
-B stdsort C
B strstrip C
B strsplit C
B strfind C
B strjoin C
-B stdslcp C
-B stdfmtpad C
-B stdpathnorm C
-B stdbigint C
B exporttrait
# B local-labels E 10 ## BUGGERED
F declmismatch