summary refs log tree commit diff stats
path: root/tests/misc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/misc')
-rw-r--r--tests/misc/tidentconcatenations.nim32
-rw-r--r--tests/misc/tinc.nim2
-rw-r--r--tests/misc/tinout.nim2
-rw-r--r--tests/misc/tinvalidnewseq.nim2
-rw-r--r--tests/misc/tmemoization.nim2
-rw-r--r--tests/misc/tnolen.nim2
-rw-r--r--tests/misc/tparseopt.nim20
-rw-r--r--tests/misc/tsemfold.nim23
-rw-r--r--tests/misc/tsimplesort.nim10
-rw-r--r--tests/misc/tsimtych.nim2
-rw-r--r--tests/misc/tunsignedcmp.nim32
-rw-r--r--tests/misc/tunsignedmisc.nim2
-rw-r--r--tests/misc/åäö.nim8
13 files changed, 126 insertions, 13 deletions
diff --git a/tests/misc/tidentconcatenations.nim b/tests/misc/tidentconcatenations.nim
new file mode 100644
index 000000000..302c51d87
--- /dev/null
+++ b/tests/misc/tidentconcatenations.nim
@@ -0,0 +1,32 @@
+type
+  Hash*[bits: static[int]] = object
+    data*: array[bits div 8, uint8]
+
+{.emit: """
+
+void sha_256(void* input, int input_len, void* output, int output_len) {}
+void sha_512(void* input, int input_len, void* output, int output_len) {}
+
+void keccak_256(void* input, int input_len, void* output, int output_len) {}
+void keccak_512(void* input, int input_len, void* output, int output_len) {}
+
+""".}
+
+template defineKeccak(bits: untyped) =
+  proc `extKeccak bits`(output: pointer, outSize: csize, input: pointer, inputSize: csize) {.nodecl, importc: "keccak_" & astToStr(bits).}
+
+template defineSha(bits: static[int]) =
+  proc `extSha bits`(output: pointer, outSize: csize, input: pointer, inputSize: csize) {.nodecl, importc: "sha_" & astToStr(bits).}
+
+template defineHashProcs(bits) =
+  defineSha(bits)
+  defineKeccak(bits)
+
+defineHashProcs(256)
+defineHashProcs(512)
+
+extSha256(nil, 0, nil, 0)
+extSha512(nil, 0, nil, 0)
+extKeccak256(nil, 0, nil, 0)
+extKeccak512(nil, 0, nil, 0)
+
diff --git a/tests/misc/tinc.nim b/tests/misc/tinc.nim
index b74f85591..7819775e3 100644
--- a/tests/misc/tinc.nim
+++ b/tests/misc/tinc.nim
@@ -1,7 +1,7 @@
 discard """
   file: "tinc.nim"
   line: 8
-  errormsg: "type mismatch: got (int)"
+  errormsg: "type mismatch: got <int>"
 """
 var x = 0
 
diff --git a/tests/misc/tinout.nim b/tests/misc/tinout.nim
index 0b2a54d9f..46af2f5de 100644
--- a/tests/misc/tinout.nim
+++ b/tests/misc/tinout.nim
@@ -1,7 +1,7 @@
 discard """
   file: "tinout.nim"
   line: 12
-  errormsg: "type mismatch: got (int literal(3))"
+  errormsg: "type mismatch: got <int literal(3)>"
 """
 # Test in out checking for parameters
 
diff --git a/tests/misc/tinvalidnewseq.nim b/tests/misc/tinvalidnewseq.nim
index 89083d8b2..66e9388ef 100644
--- a/tests/misc/tinvalidnewseq.nim
+++ b/tests/misc/tinvalidnewseq.nim
@@ -1,7 +1,7 @@
 discard """
   file: "tinvalidnewseq.nim"
   line: 15
-  errormsg: "type mismatch: got (array[0..6, string], int literal(7))"
+  errormsg: "type mismatch: got <array[0..6, string], int literal(7)>"
 """
 import re, strutils
 
diff --git a/tests/misc/tmemoization.nim b/tests/misc/tmemoization.nim
index 180acd89b..840eb3b0d 100644
--- a/tests/misc/tmemoization.nim
+++ b/tests/misc/tmemoization.nim
@@ -8,7 +8,7 @@ import strutils
 proc foo(s: static[string]): string =
   static: echo s
 
-  const R = s.toUpper
+  const R = s.toUpperAscii
   return R
 
 echo foo("test 1")
diff --git a/tests/misc/tnolen.nim b/tests/misc/tnolen.nim
index dcf6811eb..2831e5048 100644
--- a/tests/misc/tnolen.nim
+++ b/tests/misc/tnolen.nim
@@ -1,6 +1,6 @@
 discard """
   line: 8
-  errormsg: "type mismatch: got (int literal(3))"
+  errormsg: "type mismatch: got <int literal(3)>"
 """
 
 # please finally disallow Len(3)
diff --git a/tests/misc/tparseopt.nim b/tests/misc/tparseopt.nim
index 1f8375dfd..badbc59ad 100644
--- a/tests/misc/tparseopt.nim
+++ b/tests/misc/tparseopt.nim
@@ -9,6 +9,17 @@ kind: cmdLongOption	key:val  --  left:
 kind: cmdLongOption	key:val  --  debug:3
 kind: cmdShortOption	key:val  --  l:4
 kind: cmdShortOption	key:val  --  r:2
+parseoptNoVal
+kind: cmdLongOption	key:val  --  left:
+kind: cmdLongOption	key:val  --  debug:3
+kind: cmdShortOption	key:val  --  l:
+kind: cmdShortOption	key:val  --  r:2
+kind: cmdLongOption	key:val  --  debug:2
+kind: cmdLongOption	key:val  --  debug:1
+kind: cmdShortOption	key:val  --  r:1
+kind: cmdShortOption	key:val  --  r:0
+kind: cmdShortOption	key:val  --  l:
+kind: cmdShortOption	key:val  --  r:4
 parseopt2
 first round
 kind: cmdLongOption	key:val  --  left:
@@ -40,6 +51,15 @@ block:
       echo "kind: ", kind, "\tkey:val  --  ", key, ":", val
 
 block:
+    echo "parseoptNoVal"
+    # test NoVal mode with custom cmdline arguments
+    var argv = "--left --debug:3 -l -r:2 --debug 2 --debug=1 -r1 -r=0 -lr4"
+    var p = parseopt.initOptParser(argv,
+                                   shortNoVal = {'l'}, longNoVal = @["left"])
+    for kind, key, val in parseopt.getopt(p):
+      echo "kind: ", kind, "\tkey:val  --  ", key, ":", val
+
+block:
     echo "parseopt2"
     for kind, key, val in parseopt2.getopt():
       echo "kind: ", kind, "\tkey:val  --  ", key, ":", val
diff --git a/tests/misc/tsemfold.nim b/tests/misc/tsemfold.nim
new file mode 100644
index 000000000..18c282d9e
--- /dev/null
+++ b/tests/misc/tsemfold.nim
@@ -0,0 +1,23 @@
+discard """
+  action: run
+"""
+
+doAssertRaises(OverflowError): discard low(int8) - 1'i8
+doAssertRaises(OverflowError): discard high(int8) + 1'i8
+doAssertRaises(OverflowError): discard abs(low(int8))
+doAssertRaises(DivByZeroError): discard 1 mod 0
+doAssertRaises(DivByZeroError): discard 1 div 0
+doAssertRaises(OverflowError): discard low(int8) div -1'i8
+
+doAssertRaises(OverflowError): discard low(int64) - 1'i64
+doAssertRaises(OverflowError): discard high(int64) + 1'i64
+
+type E = enum eA, eB
+doAssertRaises(OverflowError): discard eA.pred
+doAssertRaises(OverflowError): discard eB.succ
+
+doAssertRaises(OverflowError): discard low(int8) * -1
+doAssertRaises(OverflowError): discard low(int64) * -1
+doAssertRaises(OverflowError): discard high(int8) * 2
+doAssertRaises(OverflowError): discard high(int64) * 2
+
diff --git a/tests/misc/tsimplesort.nim b/tests/misc/tsimplesort.nim
index 3115863d5..e4a8e0b37 100644
--- a/tests/misc/tsimplesort.nim
+++ b/tests/misc/tsimplesort.nim
@@ -40,11 +40,11 @@ proc mustRehash(length, counter: int): bool {.inline.} =
   assert(length > counter)
   result = (length * 2 < counter * 3) or (length - counter < 4)
 
-proc nextTry(h, maxHash: THash): THash {.inline.} =
+proc nextTry(h, maxHash: Hash): Hash {.inline.} =
   result = ((5 * h) + 1) and maxHash
 
 template rawGetImpl() =
-  var h: THash = hash(key) and high(t.data) # start with real hash value
+  var h: Hash = hash(key) and high(t.data) # start with real hash value
   while t.data[h].slot != seEmpty:
     if t.data[h].key == key and t.data[h].slot == seFilled:
       return h
@@ -52,7 +52,7 @@ template rawGetImpl() =
   result = -1
 
 template rawInsertImpl() =
-  var h: THash = hash(key) and high(data)
+  var h: Hash = hash(key) and high(data)
   while data[h].slot == seFilled:
     h = nextTry(h, high(data))
   data[h].key = key
@@ -162,7 +162,7 @@ iterator values*[A](t: TCountTable[A]): int =
     if t.data[h].val != 0: yield t.data[h].val
 
 proc RawGet[A](t: TCountTable[A], key: A): int =
-  var h: THash = hash(key) and high(t.data) # start with real hash value
+  var h: Hash = hash(key) and high(t.data) # start with real hash value
   while t.data[h].val != 0:
     if t.data[h].key == key: return h
     h = nextTry(h, high(t.data))
@@ -181,7 +181,7 @@ proc hasKey*[A](t: TCountTable[A], key: A): bool =
 
 proc rawInsert[A](t: TCountTable[A], data: var seq[tuple[key: A, val: int]],
                   key: A, val: int) =
-  var h: THash = hash(key) and high(data)
+  var h: Hash = hash(key) and high(data)
   while data[h].val != 0: h = nextTry(h, high(data))
   data[h].key = key
   data[h].val = val
diff --git a/tests/misc/tsimtych.nim b/tests/misc/tsimtych.nim
index 27a922f6a..037172bd5 100644
--- a/tests/misc/tsimtych.nim
+++ b/tests/misc/tsimtych.nim
@@ -1,7 +1,7 @@
 discard """
   file: "tsimtych.nim"
   line: 10
-  errormsg: "type mismatch: got (bool) but expected \'string\'"
+  errormsg: "type mismatch: got <bool> but expected \'string\'"
 """
 # Test 2
 # Simple type checking
diff --git a/tests/misc/tunsignedcmp.nim b/tests/misc/tunsignedcmp.nim
index 9ffc0d119..11b67ac5f 100644
--- a/tests/misc/tunsignedcmp.nim
+++ b/tests/misc/tunsignedcmp.nim
@@ -1,7 +1,17 @@
 discard """
   output: '''true
 true
-true'''
+true
+5
+4
+3
+2
+1
+0
+it should stop now
+18446744073709551615
+4294967295
+'''
 """
 
 # bug 1420
@@ -11,3 +21,23 @@ echo x > y # works
 
 echo((40'i32) > (30'i32))
 echo((40'u32) > (30'u32)) # Error: ordinal type expected
+
+# bug #4220
+
+const count: uint = 5
+var stop_me = false
+
+for i in countdown(count, 0):
+  echo i
+  if stop_me: break
+  if i == 0:
+    echo "it should stop now"
+    stop_me = true
+
+# bug #3985
+const
+  HIGHEST_64BIT_UINT = 0xFFFFFFFFFFFFFFFF'u
+  HIGHEST_32BIT_UINT = 0xFFFFFFFF'u
+
+echo($HIGHEST_64BIT_UINT)
+echo($HIGHEST_32BIT_UINT)
diff --git a/tests/misc/tunsignedmisc.nim b/tests/misc/tunsignedmisc.nim
index 4b8157ddd..fc02eee19 100644
--- a/tests/misc/tunsignedmisc.nim
+++ b/tests/misc/tunsignedmisc.nim
@@ -1,5 +1,5 @@
 discard """
-  errormsg: "number 0x123'u8 out of valid range"
+  errormsg: "number out of range: '0x123'u8'"
 """
 
 # Bug #1179
diff --git a/tests/misc/åäö.nim b/tests/misc/åäö.nim
new file mode 100644
index 000000000..69bb3e22c
--- /dev/null
+++ b/tests/misc/åäö.nim
@@ -0,0 +1,8 @@
+discard """
+    action: run
+"""
+
+# Tests that module names can contain multi byte characters
+
+let a = 1
+doAssert åäö.a == 1
\ No newline at end of file