summary refs log tree commit diff stats
path: root/tests/system
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-11-02 10:46:30 +0100
committerAndreas Rumpf <rumpf_a@web.de>2017-11-02 10:46:30 +0100
commit1eaeccc15d15d15d2f62ea1648f7dd64722dbd37 (patch)
treeb922cdabc780fa3a8837a6804d2df31793d9e2ca /tests/system
parente9243a16167b24899d4fcf051f3252b3a5804811 (diff)
parentbd19b5f4d36bb40b4af93d7e15fdfa582e9fe3b7 (diff)
downloadNim-1eaeccc15d15d15d2f62ea1648f7dd64722dbd37.tar.gz
Merge branch 'devel' into araq
Diffstat (limited to 'tests/system')
-rw-r--r--tests/system/toString.nim77
-rw-r--r--tests/system/tsystem_misc.nim18
2 files changed, 62 insertions, 33 deletions
diff --git a/tests/system/toString.nim b/tests/system/toString.nim
index a2337f5dd..3e7fc7ddb 100644
--- a/tests/system/toString.nim
+++ b/tests/system/toString.nim
@@ -1,42 +1,53 @@
 discard """
-  output:'''@[23, 45]
-@[, foo, bar]
-{a, b, c}
-2.3242
-2.982
-123912.1
-123912.1823
-5.0
-1e+100
-inf
--inf
-nan
-nil
-nil'''
+  output:""
 """
 
-echo($(@[23, 45]))
-echo($(@["", "foo", "bar"]))
-#echo($(["", "foo", "bar"]))
-#echo($([23, 45]))
+doAssert "@[23, 45]" == $(@[23, 45])
+doAssert "[32, 45]" == $([32, 45])
+doAssert "@[, foo, bar]" == $(@["", "foo", "bar"])
+doAssert "[, foo, bar]" ==  $(["", "foo", "bar"])
 
 # bug #2395
-
 let alphaSet: set[char] = {'a'..'c'}
-echo alphaSet
-
-echo($(2.3242))
-echo($(2.982))
-echo($(123912.1))
-echo($(123912.1823))
-echo($(5.0))
-echo($(1e100))
-echo($(1e1000000))
-echo($(-1e1000000))
-echo($(0.0/0.0))
+doAssert "{a, b, c}" == $alphaSet
+doAssert "2.3242" == $(2.3242)
+doAssert "2.982" == $(2.982)
+doAssert "123912.1" == $(123912.1)
+doAssert "123912.1823" == $(123912.1823)
+doAssert "5.0" == $(5.0)
+doAssert "1e+100" == $(1e100)
+doAssert "inf" == $(1e1000000)
+doAssert "-inf" == $(-1e1000000)
+doAssert "nan" == $(0.0/0.0)
 
 # nil tests
+# maybe a bit inconsistent in types
 var x: seq[string]
-var y: string
-echo(x)
-echo(y)
+doAssert "nil" == $(x)
+
+var y: string = nil
+doAssert nil == $(y)
+
+type
+  Foo = object
+    a: int
+    b: string
+
+var foo1: Foo
+
+# nil string should be an some point in time equal to the empty string
+doAssert(($foo1)[0..9] == "(a: 0, b: ")
+
+const
+  data = @['a','b', '\0', 'c','d']
+  dataStr = $data
+
+# ensure same result when on VM or when at program execution
+doAssert dataStr == $data
+
+import strutils
+# array test
+
+let arr = ['H','e','l','l','o',' ','W','o','r','l','d','!','\0']
+doAssert $arr == "[H, e, l, l, o,  , W, o, r, l, d, !, \0]"
+doAssert $cstring(unsafeAddr arr) == "Hello World!"
diff --git a/tests/system/tsystem_misc.nim b/tests/system/tsystem_misc.nim
new file mode 100644
index 000000000..66b789ee9
--- /dev/null
+++ b/tests/system/tsystem_misc.nim
@@ -0,0 +1,18 @@
+discard """
+  output:""
+"""
+
+# check high/low implementations
+doAssert high(int) > low(int)
+doAssert high(int8) > low(int8)
+doAssert high(int16) > low(int16)
+doAssert high(int32) > low(int32)
+doAssert high(int64) > low(int64)
+# doAssert high(uint) > low(uint) # reconsider depending on issue #6620
+doAssert high(uint8) > low(uint8)
+doAssert high(uint16) > low(uint16)
+doAssert high(uint32) > low(uint32)
+# doAssert high(uint64) > low(uint64) # reconsider depending on issue #6620
+doAssert high(float) > low(float)
+doAssert high(float32) > low(float32)
+doAssert high(float64) > low(float64)