diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2009-04-22 15:55:27 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2009-04-22 15:55:27 +0200 |
commit | e792940f5273bf8f8761c4cb29b241445e8b1d0b (patch) | |
tree | 8a6b224b8c0b3db14dbc20d89b7ca9ccb19b1f56 /tests | |
parent | 439aa2d04d5528b5aed288f70895515d1da2dc3d (diff) | |
download | Nim-e792940f5273bf8f8761c4cb29b241445e8b1d0b.tar.gz |
version 0.7.6
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tcasestm.nim | 14 | ||||
-rw-r--r-- | tests/tlibs.nim | 3 | ||||
-rw-r--r-- | tests/tprocvar.nim | 14 | ||||
-rw-r--r-- | tests/trectype.nim | 4 | ||||
-rw-r--r-- | tests/tregex.nim | 9 |
5 files changed, 40 insertions, 4 deletions
diff --git a/tests/tcasestm.nim b/tests/tcasestm.nim index ef3f2dfc9..16051ceb8 100644 --- a/tests/tcasestm.nim +++ b/tests/tcasestm.nim @@ -1,4 +1,4 @@ -# Test the case statment +# Test the case statement type tenum = enum eA, eB, eC @@ -6,6 +6,7 @@ type var x: string y: Tenum = eA + i: int case y of eA: write(stdout, "a\n") @@ -18,3 +19,14 @@ of "aa", "bb": write(stdout, "Du bist nicht mein Meister\n") of "cc", "hash", "when": nil of "will", "it", "finally", "be", "generated": nil else: write(stdout, "das sollte nicht passieren!\N") + +case i +of 0..5, 8, 9: nil +of 6, 7: nil +elif x == "Ha": + nil +elif x == "Ho": + nil +else: + nil + diff --git a/tests/tlibs.nim b/tests/tlibs.nim index 2326fba64..b5c4036a6 100644 --- a/tests/tlibs.nim +++ b/tests/tlibs.nim @@ -1,7 +1,8 @@ # Test wether the bindings at least compile... import - unicode, + unicode, cgi, terminal, libcurl, web, + parsexml, parseopt, parsecfg, osproc, zipfiles, sdl, smpeg, sdl_gfx, sdl_net, sdl_mixer, sdl_ttf, sdl_image, sdl_mixer_nosmpeg, diff --git a/tests/tprocvar.nim b/tests/tprocvar.nim index ec23dcb1d..f51543dfa 100644 --- a/tests/tprocvar.nim +++ b/tests/tprocvar.nim @@ -1,4 +1,13 @@ # test variables of type proc + +proc pa() {.cdecl.} = write(stdout, "pa") +proc pb() {.cdecl.} = write(stdout, "pb") +proc pc() {.cdecl.} = write(stdout, "pc") +proc pd() {.cdecl.} = write(stdout, "pd") +proc pe() {.cdecl.} = write(stdout, "pe") + +const + algos = [pa, pb, pc, pd, pe] var x: proc (a, b: int): int {.cdecl.} @@ -6,9 +15,12 @@ var proc ha(c, d: int): int {.cdecl.} = echo(c + d) result = c + d + +for a in items(algos): + a() x = ha discard x(3, 4) -#OUT 7 +#OUT papbpcpdpe7 diff --git a/tests/trectype.nim b/tests/trectype.nim index 3161b0255..a7a6f56e0 100644 --- a/tests/trectype.nim +++ b/tests/trectype.nim @@ -13,5 +13,9 @@ type PB = ref TB TB = array [0..3, P1] T1 = array [0..6, PB] + +var + x: PA +new(x) #ERROR_MSG internal error: cannot generate C type for: PA diff --git a/tests/tregex.nim b/tests/tregex.nim index aa32ca847..d9d22d603 100644 --- a/tests/tregex.nim +++ b/tests/tregex.nim @@ -3,10 +3,17 @@ import regexprs + +if "keyA = valueA" =~ r"\s*(\w+)\s*\=\s*(\w+)": + write(stdout, "key: ", matches[1]) +elif "# comment!" =~ r"\s*(\#.*)": + echo("comment: ", matches[1]) +else: + echo("Bug!") if "Username".match("[A-Za-z]+"): echo("Yes!") else: echo("Bug!") -#OUT Yes! +#OUT key: keyAYes! |