summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2017-05-16 20:51:50 +0200
committerAraq <rumpf_a@web.de>2017-05-16 20:51:50 +0200
commit0f2648c56dec3681bb6e3b0d53c8a75f901c6b96 (patch)
treebf5d0761f2e9918e0082a8898624cb760204ec0b /tests
parent321d1f8b65c1cb41995ad033ea1a6a11bb22df8d (diff)
parent0613f08b2461c5ecb64518a65e20c3769938d21e (diff)
downloadNim-0f2648c56dec3681bb6e3b0d53c8a75f901c6b96.tar.gz
Merge branch 'devel' of github.com:nim-lang/Nim into devel
Diffstat (limited to 'tests')
-rw-r--r--tests/async/tasyncall.nim77
-rw-r--r--tests/async/tasyncfilewrite.nim17
-rw-r--r--tests/macros/tgettypeinst.nim65
-rw-r--r--tests/stdlib/tjsontestsuite.nim384
-rw-r--r--tests/testament/specs.nim11
-rw-r--r--tests/testament/tester.nim6
6 files changed, 498 insertions, 62 deletions
diff --git a/tests/async/tasyncall.nim b/tests/async/tasyncall.nim
index 63b2945a6..7daecd9ef 100644
--- a/tests/async/tasyncall.nim
+++ b/tests/async/tasyncall.nim
@@ -2,19 +2,19 @@ discard """
   file: "tasyncall.nim"
   exitcode: 0
 """
-import times, sequtils
+import times, sequtils, unittest
 import asyncdispatch
 
 const
   taskCount = 10
-  sleepDuration = 500
+  sleepDuration = 50
 
 proc futureWithValue(x: int): Future[int] {.async.} =
   await sleepAsync(sleepDuration)
   return x
 
 proc futureWithoutValue() {.async.} =
-  await sleepAsync(1000)
+  await sleepAsync(sleepDuration)
 
 proc testFuturesWithValue(x: int): seq[int] =
   var tasks = newSeq[Future[int]](taskCount)
@@ -40,38 +40,39 @@ proc testVarargs(x, y, z: int): seq[int] =
 
   result = waitFor all(a, b, c)
 
-block:
-  let
-    startTime = cpuTime()
-    results = testFuturesWithValue(42)
-    expected = repeat(42, taskCount)
-    execTime = cpuTime() - startTime
-
-  doAssert execTime * 1000 < taskCount * sleepDuration
-  doAssert results == expected
-
-block:
-  let startTime = cpuTime()
-  testFuturesWithoutValues()
-  let execTime = cpuTime() - startTime
-
-  doAssert execTime * 1000 < taskCount * sleepDuration
-
-block:
-  let
-    startTime = cpuTime()
-    results = testVarargs(1, 2, 3)
-    expected = @[1, 2, 3]
-    execTime = cpuTime() - startTime
-
-  doAssert execTime * 100 < taskCount * sleepDuration
-  doAssert results == expected
-
-block:
-  let
-    noIntFuturesFut = all(newSeq[Future[int]]())
-    noVoidFuturesFut = all(newSeq[Future[void]]())
-
-  doAssert noIntFuturesFut.finished and not noIntFuturesFut.failed
-  doAssert noVoidFuturesFut.finished and not noVoidFuturesFut.failed
-  doAssert noIntFuturesFut.read() == @[]
+suite "tasyncall":
+  test "testFuturesWithValue":
+    let
+      startTime = cpuTime()
+      results = testFuturesWithValue(42)
+      expected = repeat(42, taskCount)
+      execTime = cpuTime() - startTime
+
+    doAssert execTime * 1000 < taskCount * sleepDuration
+    doAssert results == expected
+
+  test "testFuturesWithoutValues":
+    let startTime = cpuTime()
+    testFuturesWithoutValues()
+    let execTime = cpuTime() - startTime
+
+    doAssert execTime * 1000 < taskCount * sleepDuration
+
+  test "testVarargs":
+    let
+      startTime = cpuTime()
+      results = testVarargs(1, 2, 3)
+      expected = @[1, 2, 3]
+      execTime = cpuTime() - startTime
+
+    doAssert execTime * 100 < taskCount * sleepDuration
+    doAssert results == expected
+
+  test "all on seq[Future]":
+    let
+      noIntFuturesFut = all(newSeq[Future[int]]())
+      noVoidFuturesFut = all(newSeq[Future[void]]())
+
+    doAssert noIntFuturesFut.finished and not noIntFuturesFut.failed
+    doAssert noVoidFuturesFut.finished and not noVoidFuturesFut.failed
+    doAssert noIntFuturesFut.read() == @[]
diff --git a/tests/async/tasyncfilewrite.nim b/tests/async/tasyncfilewrite.nim
new file mode 100644
index 000000000..cda612bae
--- /dev/null
+++ b/tests/async/tasyncfilewrite.nim
@@ -0,0 +1,17 @@
+discard """
+  output: '''string 1
+string 2
+string 3'''
+"""
+# bug #5532
+import os, asyncfile, asyncdispatch
+
+removeFile("test.txt")
+let f = openAsync("test.txt", fmWrite)
+var futs = newSeq[Future[void]]()
+for i in 1..3:
+  futs.add(f.write("string " & $i & "\n"))
+waitFor(all(futs))
+f.close()
+echo readFile("test.txt")
+
diff --git a/tests/macros/tgettypeinst.nim b/tests/macros/tgettypeinst.nim
index 255eff949..f89aa5e0b 100644
--- a/tests/macros/tgettypeinst.nim
+++ b/tests/macros/tgettypeinst.nim
@@ -21,49 +21,67 @@ proc symToIdent(x: NimNode): NimNode =
       for c in x:
         result.add symToIdent(c)
 
+# check getTypeInst and getTypeImpl for given symbol x
 macro testX(x,inst0: typed; recurse: static[bool]; implX: stmt): typed =
+  # check that getTypeInst(x) equals inst0
   let inst = x.getTypeInst
-  let impl = x.getTypeImpl
-  let inst0r = inst0.symToIdent.treeRepr
   let instr = inst.symToIdent.treeRepr
-  #echo inst0r
+  let inst0r = inst0.symToIdent.treeRepr
   #echo instr
+  #echo inst0r
   doAssert(instr == inst0r)
+
+  # check that getTypeImpl(x) is correct
+  #  if implX is nil then compare to inst0
+  #  else we expect implX to be a type definition
+  #       and we extract the implementation from that
+  let impl = x.getTypeImpl
   var impl0 =
     if implX.kind == nnkNilLit: inst0
     else: implX[0][2]
-  let impl0r = impl0.symToIdent.treerepr
   let implr = impl.symToIdent.treerepr
-  #echo impl0r
+  let impl0r = impl0.symToIdent.treerepr
   #echo implr
+  #echo impl0r
   doAssert(implr == impl0r)
-  template echoString(s:string) = echo s.replace("\n","\n  ")
+
   result = newStmtList()
+  #template echoString(s: string) = echo s.replace("\n","\n  ")
   #result.add getAst(echoString("  " & inst0.repr))
   #result.add getAst(echoString("  " & inst.repr))
   #result.add getAst(echoString("  " & impl0.repr))
   #result.add getAst(echoString("  " & impl.repr))
+
   if recurse:
-    template testDecl(n, m :typed) =
+    # now test using a newly formed variable of type getTypeInst(x)
+    template testDecl(n,m: typed) =
       testV(n, false):
         type _ = m
     result.add getAst(testDecl(inst.symToIdent, impl.symToIdent))
 
+# test with a variable (instance) of type
 template testV(inst, recurse, impl) =
   block:
     #echo "testV(" & astToStr(inst) & ", " & $recurse & "):" & astToStr(impl)
     var x: inst
     testX(x, inst, recurse, impl)
-template testT(inst, recurse) =
+
+# test with a newly created typedesc (myType)
+# using the passed type as the implementation
+template testT(impl, recurse) =
   block:
-    type myType = inst
+    type myType = impl
     testV(myType, recurse):
-      type _ = inst
+      type _ = impl
 
+# test a built-in type whose instance is equal to the implementation
 template test(inst) =
   testT(inst, false)
   testV(inst, true, nil)
-template test(inst, impl) = testV(inst, true, impl)
+
+# test a custom type with provided implementation
+template test(inst, impl) =
+  testV(inst, true, impl)
 
 type
   Model = object of RootObj
@@ -87,9 +105,12 @@ type
     value:T
   Foo[N:static[int],T] = object
   Bar[N:static[int],T] = object
-    #baz:Foo[N+1,GenericObject[T]]
+    #baz:Foo[N+1,GenericObject[T]]  # currently fails
     baz:Foo[N,GenericObject[T]]
 
+  Generic[T] = seq[int]
+  Concrete = Generic[int]
+
 test(bool)
 test(char)
 test(int)
@@ -97,13 +118,17 @@ test(float)
 test(ptr int)
 test(ref int)
 test(array[1..10,Bar[2,Foo[3,float]]])
+test(array[MyEnum,Bar[2,Foo[3,float]]])
 test(distinct Bar[2,Foo[3,float]])
 test(tuple[a:int,b:Foo[-1,float]])
-#test(MyEnum):
-#  type _ = enum
-#    valueA, valueB, valueC
-test(set[MyEnum])
 test(seq[int])
+test(set[MyEnum])
+test(proc (a: int, b: Foo[2,float]))
+test(proc (a: int, b: Foo[2,float]): Bar[3,int])
+
+test(MyEnum):
+  type _ = enum
+    valueA, valueB, valueC
 test(Bar[2,Foo[3,float]]):
   type _ = object
     baz: Foo[2, GenericObject[Foo[3, float]]]
@@ -118,8 +143,12 @@ test(Tree):
     value: int
     left: ref Tree
     right: ref Tree
-test(proc (a: int, b: Foo[2,float]))
-test(proc (a: int, b: Foo[2,float]): Bar[3,int])
+test(Concrete):
+  type _ = Generic[int]
+test(Generic[int]):
+  type _ = seq[int]
+test(Generic[float]):
+  type _ = seq[int]
 
 # bug #4862
 static:
diff --git a/tests/stdlib/tjsontestsuite.nim b/tests/stdlib/tjsontestsuite.nim
new file mode 100644
index 000000000..06f783a73
--- /dev/null
+++ b/tests/stdlib/tjsontestsuite.nim
@@ -0,0 +1,384 @@
+## JSON tests based on https://github.com/nst/JSONTestSuite
+
+import unittest,
+  json,
+  strutils
+
+let parsing_testdata = {
+  "i_number_neg_int_huge_exp": """[-1e+9999]""",
+  "i_number_pos_double_huge_exp": """[1.5e+9999]""",
+  "i_object_key_lone_2nd_surrogate": """{"\uDFAA":0}""",
+  "i_string_1st_surrogate_but_2nd_missing": """["\uDADA"]""",
+  "i_string_1st_valid_surrogate_2nd_invalid": """["\uD888\u1234"]""",
+  "i_string_incomplete_surrogate_and_escape_valid": """["\uD800\n"]""",
+  "i_string_incomplete_surrogate_pair": """["\uDd1ea"]""",
+  "i_string_incomplete_surrogates_escape_valid": """["\uD800\uD800\n"]""",
+  "i_string_inverted_surrogates_U+1D11E": """["\uDd1e\uD834"]""",
+  "i_string_lone_second_surrogate": """["\uDFAA"]""",
+  "i_string_not_in_unicode_range": """[""]""",
+  "i_string_truncated-utf-8": """[""]""",
+  "i_string_unicode_U+10FFFE_nonchar": """["\uDBFF\uDFFE"]""",
+  "i_string_unicode_U+1FFFE_nonchar": """["\uD83F\uDFFE"]""",
+  "i_string_unicode_U+FDD0_nonchar": """["\uFDD0"]""",
+  "i_string_unicode_U+FFFE_nonchar": """["\uFFFE"]""",
+  "i_string_UTF-16_invalid_lonely_surrogate": """["\ud800"]""",
+  "i_string_UTF-16_invalid_surrogate": """["\ud800abc"]""",
+  "i_string_UTF-8_invalid_sequence": """["日ш"]""",
+  "i_structure_500_nested_arrays": """[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]""",
+  "i_structure_UTF-8_BOM_empty_object": """{}""",
+  "n_array_1_true_without_comma": """[1 true]""",
+  "n_array_a_invalid_utf8": """[a]""",
+  "n_array_colon_instead_of_comma": """["": 1]""",
+  "n_array_comma_after_close": """[""],""",
+  "n_array_comma_and_number": """[,1]""",
+  "n_array_double_comma": """[1,,2]""",
+  "n_array_double_extra_comma": """["x",,]""",
+  "n_array_extra_close": """["x"]]""",
+  "n_array_extra_comma": """["",]""",
+  "n_array_incomplete_invalid_value": """[x""",
+  "n_array_incomplete": """["x"""",
+  "n_array_inner_array_no_comma": """[3[4]]""",
+  "n_array_invalid_utf8": """[]""",
+  "n_array_items_separated_by_semicolon": """[1:2]""",
+  "n_array_just_comma": """[,]""",
+  "n_array_just_minus": """[-]""",
+  "n_array_missing_value": """[   , ""]""",
+  "n_array_newlines_unclosed": """["a",""",
+  "n_array_newlines_unclosed": """4""",
+  "n_array_newlines_unclosed": """,1,""",
+  "n_array_number_and_comma": """[1,]""",
+  "n_array_number_and_several_commas": """[1,,]""",
+  "n_array_spaces_vertical_tab_formfeed": """["a"\f]""",
+  "n_array_star_inside": """[*]""",
+  "n_array_unclosed": """[""""",
+  "n_array_unclosed_trailing_comma": """[1,""",
+  "n_array_unclosed_with_new_lines": """[1,""",
+  "n_array_unclosed_with_new_lines": """1""",
+  "n_array_unclosed_with_new_lines": """,1""",
+  "n_array_unclosed_with_object_inside": """[{}""",
+  "n_incomplete_false": """[fals]""",
+  "n_incomplete_null": """[nul]""",
+  "n_incomplete_true": """[tru]""",
+  "n_number_0.1.2": """[0.1.2]""",
+  "n_number_-01": """[-01]""",
+  "n_number_0.3e": """[0.3e]""",
+  "n_number_0.3e+": """[0.3e+]""",
+  "n_number_0_capital_E": """[0E]""",
+  "n_number_0_capital_E+": """[0E+]""",
+  "n_number_0.e1": """[0.e1]""",
+  "n_number_0e": """[0e]""",
+  "n_number_0e+": """[0e+]""",
+  "n_number_1_000": """[1 000.0]""",
+  "n_number_1.0e-": """[1.0e-]""",
+  "n_number_1.0e": """[1.0e]""",
+  "n_number_1.0e+": """[1.0e+]""",
+  "n_number_-1.0.": """[-1.0.]""",
+  "n_number_1eE2": """[1eE2]""",
+  "n_number_.-1": """[.-1]""",
+  "n_number_+1": """[+1]""",
+  "n_number_.2e-3": """[.2e-3]""",
+  "n_number_2.e-3": """[2.e-3]""",
+  "n_number_2.e+3": """[2.e+3]""",
+  "n_number_2.e3": """[2.e3]""",
+  "n_number_-2.": """[-2.]""",
+  "n_number_9.e+": """[9.e+]""",
+  "n_number_expression": """[1+2]""",
+  "n_number_hex_1_digit": """[0x1]""",
+  "n_number_hex_2_digits": """[0x42]""",
+  "n_number_infinity": """[Infinity]""",
+  "n_number_+Inf": """[+Inf]""",
+  "n_number_Inf": """[Inf]""",
+  "n_number_invalid+-": """[0e+-1]""",
+  "n_number_invalid-negative-real": """[-123.123foo]""",
+  "n_number_invalid-utf-8-in-bigger-int": """[123]""",
+  "n_number_invalid-utf-8-in-exponent": """[1e1]""",
+  "n_number_invalid-utf-8-in-int": """[0]""",
+  "n_number_++": """[++1234]""",
+  "n_number_minus_infinity": """[-Infinity]""",
+  "n_number_minus_sign_with_trailing_garbage": """[-foo]""",
+  "n_number_minus_space_1": """[- 1]""",
+  "n_number_-NaN": """[-NaN]""",
+  "n_number_NaN": """[NaN]""",
+  "n_number_neg_int_starting_with_zero": """[-012]""",
+  "n_number_neg_real_without_int_part": """[-.123]""",
+  "n_number_neg_with_garbage_at_end": """[-1x]""",
+  "n_number_real_garbage_after_e": """[1ea]""",
+  "n_number_real_with_invalid_utf8_after_e": """[1e]""",
+  "n_number_real_without_fractional_part": """[1.]""",
+  "n_number_starting_with_dot": """[.123]""",
+  "n_number_then_00": """1\x00""",
+  "n_number_U+FF11_fullwidth_digit_one": """[1]""",
+  "n_number_with_alpha_char": """[1.8011670033376514H-308]""",
+  "n_number_with_alpha": """[1.2a-3]""",
+  "n_number_with_leading_zero": """[012]""",
+  "n_object_bad_value": """["x", truth]""",
+  "n_object_bracket_key": """{[: "x"}""",
+  "n_object_comma_instead_of_colon": """{"x", null}""",
+  "n_object_double_colon": """{"x"::"b"}""",
+  "n_object_emoji": """{🇨🇭}""",
+  "n_object_garbage_at_end": """{"a":"a" 123}""",
+  "n_object_key_with_single_quotes": """{key: 'value'}""",
+  "n_object_missing_colon": """{"a" b}""",
+  "n_object_missing_key": """{:"b"}""",
+  "n_object_missing_semicolon": """{"a" "b"}""",
+  "n_object_missing_value": """{"a":""",
+  "n_object_no-colon": """{"a"""",
+  "n_object_non_string_key_but_huge_number_instead": """{9999E9999:1}""",
+  "n_object_non_string_key": """{1:1}""",
+  "n_object_pi_in_key_and_trailing_comma": """{"":"0",}""",
+  "n_object_repeated_null_null": """{null:null,null:null}""",
+  "n_object_several_trailing_commas": """{"id":0,,,,,}""",
+  "n_object_single_quote": """{'a':0}""",
+  "n_object_trailing_comma": """{"id":0,}""",
+  "n_object_trailing_comment": """{"a":"b"}/**/""",
+  "n_object_trailing_comment_open": """{"a":"b"}/**//""",
+  "n_object_trailing_comment_slash_open_incomplete": """{"a":"b"}/""",
+  "n_object_trailing_comment_slash_open": """{"a":"b"}//""",
+  "n_object_two_commas_in_a_row": """{"a":"b",,"c":"d"}""",
+  "n_object_unquoted_key": """{a: "b"}""",
+  "n_object_unterminated-value": """{"a":"a""",
+  "n_object_with_single_string": """{ "foo" : "bar", "a" }""",
+  "n_object_with_trailing_garbage": """{"a":"b"}#""",
+  "n_single_space": """ """,
+  "n_string_1_surrogate_then_escape": """["\uD800\"]""",
+  "n_string_1_surrogate_then_escape u1": """["\uD800\u1"]""",
+  "n_string_1_surrogate_then_escape u1x": """["\uD800\u1x"]""",
+  "n_string_1_surrogate_then_escape u": """["\uD800\u"]""",
+  "n_string_accentuated_char_no_quotes": """[é]""",
+  "n_string_backslash_00": """["\\x00"]""",
+  "n_string_escaped_backslash_bad": """["\\\"]""",
+  "n_string_escaped_ctrl_char_tab": """["\	"]""",
+  "n_string_escaped_emoji": """["\🌀"]""",
+  "n_string_escape_x": """["\x00"]""",
+  "n_string_incomplete_escaped_character": """["\u00A"]""",
+  "n_string_incomplete_escape": """["\"]""",
+  "n_string_incomplete_surrogate_escape_invalid": """["\uD800\uD800\x"]""",
+  "n_string_invalid_backslash_esc": """["\a"]""",
+  "n_string_invalid_unicode_escape": """["\uqqqq"]""",
+  "n_string_invalid_utf8_after_escape": """["\"]""",
+  "n_string_invalid-utf-8-in-escape": """["\u"]""",
+  "n_string_invalid_utf-8": """[""]""",
+  "n_string_iso_latin_1": """[""]""",
+  "n_string_leading_uescaped_thinspace": """[\u0020"asd"]""",
+  "n_string_lone_utf8_continuation_byte": """[""]""",
+  "n_string_no_quotes_with_bad_escape": """[\n]""",
+  "n_string_overlong_sequence_2_bytes": """[""]""",
+  "n_string_overlong_sequence_6_bytes": """[""]""",
+  "n_string_overlong_sequence_6_bytes_null": """[""]""",
+  "n_string_single_doublequote": """"""",
+  "n_string_single_quote": """['single quote']""",
+  "n_string_single_string_no_double_quotes": """abc""",
+  "n_string_start_escape_unclosed": """["\""",
+  "n_string_unescaped_ctrl_char": """["a\x00a"]""",
+  "n_string_unescaped_newline": """["new
+line"]""",
+  "n_string_unescaped_tab": """["	"]""",
+  "n_string_unicode_CapitalU": """"\UA66D"""",
+  "n_string_UTF-16_incomplete_surrogate": """["\uD834\uDd"]""",
+  "n_string_UTF8_surrogate_U+D800": """[""]""",
+  "n_string_with_trailing_garbage": """""x""",
+  "n_structure_array_trailing_garbage": """[1]x""",
+  "n_structure_array_with_extra_array_close": """[1]]""",
+  "n_structure_array_with_unclosed_string": """["asd]""",
+  "n_structure_ascii-unicode-identifier": """aå""",
+  "n_structure_capitalized_True": """[True]""",
+  "n_structure_close_unopened_array": """1]""",
+  "n_structure_comma_instead_of_closing_brace": """{"x": true,""",
+  "n_structure_double_array": """[][]""",
+  "n_structure_end_array": """]""",
+  "n_structure_incomplete_UTF8_BOM": """{}""",
+  "n_structure_<.>": """<.>""",
+  "n_structure_lone-invalid-utf-8": """""",
+  "n_structure_lone-open-bracket": """[""",
+  "n_structure_null-byte-outside-string": """[\00]""",
+  "n_structure_<null>": """[<null>]""",
+  "n_structure_number_with_trailing_garbage": """2@""",
+  "n_structure_object_followed_by_closing_object": """{}}""",
+  "n_structure_object_unclosed_no_value": """{"":""",
+  "n_structure_object_with_comment": """{"a":/*comment*/"b"}""",
+  "n_structure_object_with_trailing_garbage": """{"a": true} "x"""",
+  "n_structure_open_array_apostrophe": """['""",
+  "n_structure_open_array_comma": """[,""",
+  "n_structure_open_array_open_object": """[{""",
+  "n_structure_open_array_open_string": """["a""",
+  "n_structure_open_array_string": """["a"""",
+  "n_structure_open_object_close_array": """{]""",
+  "n_structure_open_object_comma": """{,""",
+  "n_structure_open_object": """{""",
+  "n_structure_open_object_open_array": """{[""",
+  "n_structure_open_object_open_string": """{"a""",
+  "n_structure_open_object_string_with_apostrophes": """{'a'""",
+  "n_structure_open_open": """["\{["\{["\{["\{""",
+  "n_structure_single_point": """""",
+  "n_structure_single_star": """*""",
+  "n_structure_trailing_#": """{"a":"b"}#{}""",
+  "n_structure_U+2060_word_joined": """[⁠]""",
+  "n_structure_uescaped_LF_before_string": """[\u000A""]""",
+  "n_structure_unclosed_array": """[1""",
+  "n_structure_unclosed_array_partial_null": """[ false, nul""",
+  "n_structure_unclosed_array_unfinished_false": """[ true, fals""",
+  "n_structure_unclosed_array_unfinished_true": """[ false, tru""",
+  "n_structure_unclosed_object": """{"asd":"asd"""",
+  "n_structure_unicode-identifier": """å""",
+  "n_structure_UTF8_BOM_no_data": """""",
+  "n_structure_whitespace_formfeed": """[]""",
+  "n_structure_whitespace_U+2060_word_joiner": """[⁠]""",
+  "y_array_arraysWithSpaces": """[[]   ]""",
+  "y_array_empty": """[]""",
+  "y_array_empty-string": """[""]""",
+  "y_array_ending_with_newline": """["a"]""",
+  "y_array_false": """[false]""",
+  "y_array_heterogeneous": """[null, 1, "1", {}]""",
+  "y_array_null": """[null]""",
+  "y_array_with_1_and_newline": """[1
+]""",
+  "y_array_with_leading_space": """ [1]""",
+  "y_array_with_several_null": """[1,null,null,null,2]""",
+  "y_array_with_trailing_space": """[2] """,
+  "y_number_0e+1": """[0e+1]""",
+  "y_number_0e1": """[0e1]""",
+  "y_number_after_space": """[ 4]""",
+  "y_number_double_close_to_zero": """[-0.000000000000000000000000000000000000000000000000000000000000000000000000000001]""",
+  "y_number_double_huge_neg_exp": """[123.456e-789]""",
+  "y_number_huge_exp": """[0.4e00669999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999969999999006]""",
+  "y_number_int_with_exp": """[20e1]""",
+  "y_number": """[123e65]""",
+  "y_number_minus_zero": """[-0]""",
+  "y_number_negative_int": """[-123]""",
+  "y_number_negative_one": """[-1]""",
+  "y_number_negative_zero": """[-0]""",
+  "y_number_real_capital_e": """[1E22]""",
+  "y_number_real_capital_e_neg_exp": """[1E-2]""",
+  "y_number_real_capital_e_pos_exp": """[1E+2]""",
+  "y_number_real_exponent": """[123e45]""",
+  "y_number_real_fraction_exponent": """[123.456e78]""",
+  "y_number_real_neg_exp": """[1e-2]""",
+  "y_number_real_neg_overflow": """[-123123e100000]""",
+  "y_number_real_pos_exponent": """[1e+2]""",
+  "y_number_real_pos_overflow": """[123123e100000]""",
+  "y_number_real_underflow": """[123e-10000000]""",
+  "y_number_simple_int": """[123]""",
+  "y_number_simple_real": """[123.456789]""",
+  "y_number_too_big_neg_int": """[-123123123123123123123123123123]""",
+  "y_number_too_big_pos_int": """[100000000000000000000]""",
+  "y_number_very_big_negative_int": """[-237462374673276894279832749832423479823246327846]""",
+  "y_object_basic": """{"asd":"sdf"}""",
+  "y_object_duplicated_key_and_value": """{"a":"b","a":"b"}""",
+  "y_object_duplicated_key": """{"a":"b","a":"c"}""",
+  "y_object_empty": """{}""",
+  "y_object_empty_key": """{"":0}""",
+  "y_object_escaped_null_in_key": """{"foo\u0000bar": 42}""",
+  "y_object_extreme_numbers": """{ "min": -1.0e+28, "max": 1.0e+28 }""",
+  "y_object": """{"asd":"sdf", "dfg":"fgh"}""",
+  "y_object_long_strings": """{"x":[{"id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}], "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}""",
+  "y_object_simple": """{"a":[]}""",
+  "y_object_string_unicode": """{"title":"\u041f\u043e\u043b\u0442\u043e\u0440\u0430 \u0417\u0435\u043c\u043b\u0435\u043a\u043e\u043f\u0430" }""",
+  "y_object_with_newlines": """{
+"a": "b"
+}""",
+  "y_string_1_2_3_bytes_UTF-8_sequences": """["\u0060\u012a\u12AB"]""",
+  "y_string_accepted_surrogate_pair": """["\uD801\udc37"]""",
+  "y_string_accepted_surrogate_pairs": """["\ud83d\ude39\ud83d\udc8d"]""",
+  "y_string_allowed_escapes": """["\"\\\/\b\f\n\r\t"]""",
+  "y_string_backslash_and_u_escaped_zero": """["\\u0000"]""",
+  "y_string_backslash_doublequotes": """["\""]""",
+  "y_string_comments": """["a/*b*/c/*d//e"]""",
+  "y_string_double_escape_a": """["\\a"]""",
+  "y_string_double_escape_n": """["\\n"]""",
+  "y_string_escaped_control_character": """["\u0012"]""",
+  "y_string_escaped_noncharacter": """["\uFFFF"]""",
+  "y_string_in_array": """["asd"]""",
+  "y_string_in_array_with_leading_space": """[ "asd"]""",
+  "y_string_last_surrogates_1_and_2": """["\uDBFF\uDFFF"]""",
+  "y_string_newline_uescaped": """["new\u00A0line"]""",
+  "y_string_nonCharacterInUTF-8_U+10FFFF": """["􏿿"]""",
+  "y_string_nonCharacterInUTF-8_U+1FFFF": """["𛿿"]""",
+  "y_string_nonCharacterInUTF-8_U+FFFF": """["￿"]""",
+  "y_string_null_escape": """["\u0000"]""",
+  "y_string_one-byte-utf-8": """["\u002c"]""",
+  "y_string_pi": """["π"]""",
+  "y_string_simple_ascii": """["asd "]""",
+  "y_string_space": """" """",
+  "y_string_three-byte-utf-8": """["\u0821"]""",
+  "y_string_two-byte-utf-8": """["\u0123"]""",
+  "y_string_u+2028_line_sep": """["
"]""",
+  "y_string_u+2029_par_sep": """["
"]""",
+  "y_string_uEscape": """["\u0061\u30af\u30EA\u30b9"]""",
+  "y_string_unescaped_char_delete": """[""]""",
+  "y_string_unicode_2": """["⍂㈴⍂"]""",
+  "y_string_unicodeEscapedBackslash": """["\u005C"]""",
+  "y_string_unicode_escaped_double_quote": """["\u0022"]""",
+  "y_string_unicode": """["\uA66D"]""",
+  "y_string_unicode_U+200B_ZERO_WIDTH_SPACE": """["\u200B"]""",
+  "y_string_unicode_U+2064_invisible_plus": """["\u2064"]""",
+  "y_string_UTF-16_Surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF": """["\uD834\uDd1e"]""",
+  "y_string_utf8": """["€𝄞"]""",
+  "y_string_with_del_character": """["aa"]""",
+  "y_structure_lonely_false": """false""",
+  "y_structure_lonely_int": """42""",
+  "y_structure_lonely_negative_real": """-0.1""",
+  "y_structure_lonely_null": """null""",
+  "y_structure_lonely_string": """"asd"""",
+  "y_structure_lonely_true": """true""",
+  "y_structure_string_empty": """""""",
+  "y_structure_trailing_newline": """["a"]""",
+  "y_structure_true_in_array": """[true]""",
+  "y_structure_whitespace_array": """ [] """,
+}
+
+
+suite "JSON":
+
+  test "Multiple parsing tests":
+    var test_is_failed = false
+    for test_item in parsing_testdata:
+
+      let name = test_item[0]
+      let data = test_item[1]
+      var
+        parsed_successfully = false
+        parsed: JsonNode
+        exception_while_parsing = ""
+        exception_while_rendering = ""
+
+      try:
+        parsed = parseJson(data)
+        parsed_successfully = true
+      except:
+        exception_while_parsing = getCurrentExceptionMsg()
+
+
+      proc echo_summary(msg: string) =
+        var rendered = ""
+        var render_successfully = false
+        if parsed_successfully:
+          try:
+            rendered = $parsed
+            render_successfully = true
+          except:
+            rendered = "[Fail to render:<$#>]" % getCurrentExceptionMsg()
+        else:
+          rendered = "<$#>" % exception_while_parsing
+
+        echo name, repeat(' ', 60 - name.len), "[$#]" % msg, " ", rendered
+
+      case name[0]
+      of 'y':
+        # Tests starting with y_ must parse
+        if not parsed_successfully:
+          echo_summary "Failed to parse"
+          test_is_failed = true
+      of 'n':
+        # Tests starting with n_ should not parse
+        if parsed_successfully:
+          echo_summary "Failed to raise exception"
+      of 'i':
+        if parsed_successfully:
+          echo_summary "OK"
+        else:
+          echo_summary "Not parsed"
+
+      else: discard
+
+    # FIXME: temporarily disabled until "y_" tests will succeed
+    # if test_is_failed: fail()
diff --git a/tests/testament/specs.nim b/tests/testament/specs.nim
index 91e8b2ec7..ab24acc70 100644
--- a/tests/testament/specs.nim
+++ b/tests/testament/specs.nim
@@ -9,8 +9,11 @@
 
 import parseutils, strutils, os, osproc, streams, parsecfg
 
-const
-  cmdTemplate* = r"compiler" / "nim $target --lib:lib --hints:on -d:testing $options $file"
+
+var compilerPrefix* = "compiler" / "nim "
+
+proc cmdTemplate*(): string =
+  compilerPrefix & "$target --lib:lib --hints:on -d:testing $options $file"
 
 type
   TTestAction* = enum
@@ -100,7 +103,7 @@ proc specDefaults*(result: var TSpec) =
   result.outp = ""
   result.nimout = ""
   result.ccodeCheck = ""
-  result.cmd = cmdTemplate
+  result.cmd = cmdTemplate()
   result.line = 0
   result.column = 0
   result.tfile = ""
@@ -173,7 +176,7 @@ proc parseSpec*(filename: string): TSpec =
         raise newException(ValueError, "cannot interpret as a bool: " & e.value)
     of "cmd":
       if e.value.startsWith("nim "):
-        result.cmd = "compiler" / e.value
+        result.cmd = compilerPrefix & e.value[4..^1]
       else:
         result.cmd = e.value
     of "ccodecheck": result.ccodeCheck = e.value
diff --git a/tests/testament/tester.nim b/tests/testament/tester.nim
index 2d758ef0d..0f74de013 100644
--- a/tests/testament/tester.nim
+++ b/tests/testament/tester.nim
@@ -34,6 +34,7 @@ Options:
   --failing                 only show failing/ignored tests
   --pedantic                return non-zero status code if there are failures
   --targets:"c c++ js objc" run tests for specified targets (default: all)
+  --nim:path                use a particular nim executable (default: compiler/nim)
 """ % resultsFile
 
 type
@@ -367,7 +368,7 @@ proc testNoSpec(r: var TResults, test: TTest) =
   # does not extract the spec because the file is not supposed to have any
   #let tname = test.name.addFileExt(".nim")
   inc(r.total)
-  let given = callCompiler(cmdTemplate, test.name, test.options, test.target)
+  let given = callCompiler(cmdTemplate(), test.name, test.options, test.target)
   r.addResult(test, "", given.msg, given.err)
   if given.err == reSuccess: inc(r.passed)
 
@@ -376,7 +377,7 @@ proc testC(r: var TResults, test: TTest) =
   let tname = test.name.addFileExt(".c")
   inc(r.total)
   styledEcho "Processing ", fgCyan, extractFilename(tname)
-  var given = callCCompiler(cmdTemplate, test.name & ".c", test.options, test.target)
+  var given = callCCompiler(cmdTemplate(), test.name & ".c", test.options, test.target)
   if given.err != reSuccess:
     r.addResult(test, "", given.msg, given.err)
   elif test.action == actionRun:
@@ -424,6 +425,7 @@ proc main() =
     of "failing": optFailing = true
     of "pedantic": optPedantic = true
     of "targets": targets = parseTargets(p.val.string)
+    of "nim": compilerPrefix = p.val.string
     else: quit Usage
     p.next()
   if p.kind != cmdArgument: quit Usage