From f11a3b2324290cfebc328284c6f74287e7652e44 Mon Sep 17 00:00:00 2001 From: Grzegorz Adam Hankiewicz Date: Fri, 7 Jun 2013 21:24:45 +0200 Subject: [PATCH] Adds generic idetools api test case. At the moment three lines of the test case fail in proc mode. --- .gitignore | 1 + tests/caas/idetools_api.nim | 23 +++++++++++++++++++++ tests/caas/idetools_api.txt | 41 +++++++++++++++++++++++++++++++++++++ tests/caasdriver.nim | 6 +++++- 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 tests/caas/idetools_api.nim create mode 100644 tests/caas/idetools_api.txt diff --git a/.gitignore b/.gitignore index 93dae69ba7..025c4ca35c 100644 --- a/.gitignore +++ b/.gitignore @@ -167,6 +167,7 @@ examples/cross_calculator/android/tags /run.json /testresults.html /testresults.json +/tests/caas/idetools_api /tests/caas/imported /tests/caas/main /tests/caasdriver diff --git a/tests/caas/idetools_api.nim b/tests/caas/idetools_api.nim new file mode 100644 index 0000000000..930d264292 --- /dev/null +++ b/tests/caas/idetools_api.nim @@ -0,0 +1,23 @@ +import unicode, sequtils + +proc test_enums() = + var o: Tfile + if o.open("files " & "test.txt", fmWrite): + o.write("test") + o.close() + +proc test_iterators(filename = "tests.nim") = + let + input = readFile(filename) + letters = toSeq(runes(string(input))) + for letter in letters: echo int(letter) + +const SOME_SEQUENCE = @[1, 2] +type + bad_string = distinct string + TPerson = object of TObject + name*: bad_string + age: int + +proc adder(a, b: int): int = + result = a + b diff --git a/tests/caas/idetools_api.txt b/tests/caas/idetools_api.txt new file mode 100644 index 0000000000..eaa91cd5f6 --- /dev/null +++ b/tests/caas/idetools_api.txt @@ -0,0 +1,41 @@ +idetools_api.nim +> c +SuccessX +> idetools --track:idetools_api.nim,4,11 --def +def\tskType\tsystem.TFile\tTFile +> idetools --track:idetools_api.nim,5,7 --def +def\tskProc\tsystem.Open\tproc \(var TFile, string, TFileMode, int\): bool +> idetools --track:idetools_api.nim,5,21 --def +def\tskProc\tsystem.\&\tproc \(string, string\): string\{.noSideEffect.\} +> idetools --track:idetools_api.nim,5,38 --def +def\tskEnumField\tsystem.TFileMode.fmWrite\tTFileMode +> idetools --track:idetools_api.nim,7,6 --def +def\tskProc\tsystem.Close\tproc \(TFile\) +> idetools --track:idetools_api.nim,12,23 --def +def\tskIterator\tunicode.runes\titerator \(string\): TRune +> idetools --track:idetools_api.nim,12,15 --def +def\tskTemplate\tsequtils.toSeq\tproc \(expr\): expr +> idetools --track:idetools_api.nim,15,7 --def + +# ProcRun mode will fail the next line, because the type is returned empty. +def\tskConst\tidetools_api.SOME_SEQUENCE\tseq\[int\]\t +> idetools --track:idetools_api.nim,15,23 --def +def\tskProc\tsystem.@\tproc \(array\[IDX, T\]\): seq\[T\]\{.noSideEffect.\} +> idetools --track:idetools_api.nim,17,3 --def + +# ProcRun mode will fail the next line, because the type is returned empty. +def\tskType\tidetools_api.bad_string\tbad_string\t +> idetools --track:idetools_api.nim,11,24 --def +def\tskParam\tidetools_api.test_iterators.filename\tstring +> idetools --track:idetools_api.nim,6,5 --def +def\tskVar\tidetools_api.test_enums.o\tTFile +> idetools --track:idetools_api.nim,12,34 --def +def\tskLet\tidetools_api.test_iterators.input\tTaintedString +> idetools --track:idetools_api.nim,13,35 --def +def\tskForVar\tidetools_api.test_iterators.letter\tTRune +> idetools --track:idetools_api.nim,23,3 --def +def\tskResult\tidetools_api.adder.result\tint +> idetools --track:idetools_api.nim,19,6 --def + +# ProcRun mode will fail the next line, because the type is returned empty. +def\tskField\tidetools_api.TPerson.name\tbad_string\t diff --git a/tests/caasdriver.nim b/tests/caasdriver.nim index d6f4a8bd61..e1270f08a0 100644 --- a/tests/caasdriver.nim +++ b/tests/caasdriver.nim @@ -21,6 +21,9 @@ import osproc, streams, os, strutils, re ## modes, you can prefix a line with the mode and the line will be processed ## only in that mode. ## +## The rest of the line is treated as a regular expression, so be careful +## escaping metacharacters like parenthesis. +## ## You can optionally pass parameters at the command line to modify the ## behaviour of the test suite. By default only tests which fail will be echoed ## to stdout. If you want to see all the output pass the word "verbose" as a @@ -142,7 +145,8 @@ proc doScenario(script: string, output: PStream, mode: TRunMode): bool = pattern = line.substr(1).strip expectMatch = false - var actualMatch = s.lastOutput.find(re(pattern)) != -1 + let actualMatch = + s.lastOutput.find(re(pattern, flags = {reStudy})) != -1 if expectMatch == actualMatch: output.writeln "SUCCESS ", line