mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-18 00:48:35 +00:00
Adds generic idetools api test case.
At the moment three lines of the test case fail in proc mode.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -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
|
||||
|
||||
23
tests/caas/idetools_api.nim
Normal file
23
tests/caas/idetools_api.nim
Normal file
@@ -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
|
||||
41
tests/caas/idetools_api.txt
Normal file
41
tests/caas/idetools_api.txt
Normal file
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user