Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
This commit is contained in:
parent
f02e159b56
commit
70a30317f7
28 changed files with 103 additions and 52 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
import std/private/miscdollars
|
import std/private/miscdollars
|
||||||
import std/strutils
|
|
||||||
from std/os import getEnv
|
from std/os import getEnv
|
||||||
|
|
||||||
template flakyAssert*(cond: untyped, msg = "", notifySuccess = true) =
|
template flakyAssert*(cond: untyped, msg = "", notifySuccess = true) =
|
||||||
|
|
@ -26,13 +25,27 @@ template flakyAssert*(cond: untyped, msg = "", notifySuccess = true) =
|
||||||
msg2.add $expr & " " & msg
|
msg2.add $expr & " " & msg
|
||||||
echo msg2
|
echo msg2
|
||||||
|
|
||||||
proc greedyOrderedSubsetLines*(lhs, rhs: string): bool =
|
when not defined(js):
|
||||||
## returns true if each stripped line in `lhs` appears in rhs, using a greedy matching.
|
import std/strutils
|
||||||
let rhs = rhs.strip
|
|
||||||
var currentPos = 0
|
proc greedyOrderedSubsetLines*(lhs, rhs: string): bool =
|
||||||
|
## Returns true if each stripped line in `lhs` appears in rhs, using a greedy matching.
|
||||||
|
iterator splitLinesClosure(): string {.closure.} =
|
||||||
|
for line in splitLines(rhs.strip):
|
||||||
|
yield line
|
||||||
|
|
||||||
|
var rhsIter = splitLinesClosure
|
||||||
|
var currentLine = strip(rhsIter())
|
||||||
|
|
||||||
for line in lhs.strip.splitLines:
|
for line in lhs.strip.splitLines:
|
||||||
currentPos = rhs.find(line.strip, currentPos)
|
let line = line.strip
|
||||||
if currentPos < 0:
|
if line.len != 0:
|
||||||
|
while line != currentLine:
|
||||||
|
currentLine = strip(rhsIter())
|
||||||
|
if rhsIter.finished:
|
||||||
|
return false
|
||||||
|
|
||||||
|
if rhsIter.finished:
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
ccodecheck: "baz"
|
targets: "c"
|
||||||
|
ccodecheck: "baz"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc foo(): void {.exportc: "bar".}=
|
proc foo(): void {.exportc: "bar".}=
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "undeclared identifier: 'undeclared'"
|
errormsg: "undeclared identifier: 'undeclared'"
|
||||||
line: 8
|
targets: "c"
|
||||||
column: 7
|
line: 9
|
||||||
|
column: 7
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# test should fail because the line directive is wrong
|
# test should fail because the line directive is wrong
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "wrong error message"
|
errormsg: "wrong error message"
|
||||||
line: 8
|
targets: "c"
|
||||||
column: 6
|
line: 9
|
||||||
|
column: 6
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# test should fail because the line directive is wrong
|
# test should fail because the line directive is wrong
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
discard """
|
discard """
|
||||||
exitcode: 1
|
targets: "c"
|
||||||
|
exitcode: 1
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "undeclared identifier: 'undefined'"
|
targets: "c"
|
||||||
file: "notthisfile.nim"
|
errormsg: "undeclared identifier: 'undefined'"
|
||||||
|
file: "notthisfile.nim"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
echo undefined
|
echo undefined
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "undeclared identifier: 'undeclared'"
|
targets: "c"
|
||||||
line: 9
|
errormsg: "undeclared identifier: 'undeclared'"
|
||||||
column: 6
|
line: 10
|
||||||
|
column: 6
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# test should fail because the line directive is wrong
|
# test should fail because the line directive is wrong
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
maxcodesize: 1
|
targets: "c"
|
||||||
|
maxcodesize: 1
|
||||||
"""
|
"""
|
||||||
|
|
||||||
echo "Hello World"
|
echo "Hello World"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
nimout: "Hello World!"
|
targets: "c"
|
||||||
action: compile
|
nimout: "Hello World!"
|
||||||
|
action: compile
|
||||||
"""
|
"""
|
||||||
|
|
||||||
static:
|
static:
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''
|
targets: "c"
|
||||||
done
|
output: '''
|
||||||
'''
|
done
|
||||||
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
echo "broken"
|
echo "broken"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
outputsub: "something else"
|
outputsub: "something else"
|
||||||
|
targets: "c"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
echo "Hello World!"
|
echo "Hello World!"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
action: "reject"
|
action: "reject"
|
||||||
|
targets: "c"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Because we set action="reject", we expect this line not to compile. But the
|
# Because we set action="reject", we expect this line not to compile. But the
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
discard """
|
discard """
|
||||||
sortoutput: true
|
sortoutput: true
|
||||||
output: '''
|
targets: "c"
|
||||||
2
|
output: '''
|
||||||
1
|
2
|
||||||
'''
|
1
|
||||||
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# this test should ensure that the output is actually sorted
|
# this test should ensure that the output is actually sorted
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
timeout: "0.1"
|
timeout: "0.1"
|
||||||
|
targets: "c"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
valgrind: true
|
valgrind: true
|
||||||
cmd: "nim $target --gc:arc -d:useMalloc $options $file"
|
targets: "c"
|
||||||
|
cmd: "nim $target --gc:arc -d:useMalloc $options $file"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# this is the same check used by testament/specs.nim whether or not valgrind
|
# this is the same check used by testament/specs.nim whether or not valgrind
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
cmd: "nim c --expandMacro:foo $file"
|
cmd: "nim c --expandMacro:foo $file"
|
||||||
nimout: '''Hint: expanded macro:
|
nimout: '''texpandmacro.nim(17, 1) Hint: expanded macro:
|
||||||
echo ["injected echo"]
|
echo ["injected echo"]
|
||||||
var x = 4 [ExpandMacro]
|
var x = 4 [ExpandMacro]
|
||||||
'''
|
'''
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ discard """
|
||||||
cmd: "nim check $file"
|
cmd: "nim check $file"
|
||||||
errormsg: "type mismatch: got <AsyncHttpServer, Port, proc (req: Request): Future[system.void]{.locks: <unknown>.}>"
|
errormsg: "type mismatch: got <AsyncHttpServer, Port, proc (req: Request): Future[system.void]{.locks: <unknown>.}>"
|
||||||
nimout: '''
|
nimout: '''
|
||||||
type mismatch: got <AsyncHttpServer, Port, proc (req: Request): Future[system.void]{.locks: <unknown>.}>
|
tgcsafety.nim(30, 18) Error: type mismatch: got <AsyncHttpServer, Port, proc (req: Request): Future[system.void]{.locks: <unknown>.}>
|
||||||
but expected one of:
|
but expected one of:
|
||||||
proc serve(server: AsyncHttpServer; port: Port;
|
proc serve(server: AsyncHttpServer; port: Port;
|
||||||
callback: proc (request: Request): Future[void] {.closure, gcsafe.};
|
callback: proc (request: Request): Future[void] {.closure, gcsafe.};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "in expression ' do:"
|
errormsg: "in expression ' do:"
|
||||||
nimout: '''
|
nimout: '''
|
||||||
Error: in expression ' do:
|
twrongcolon.nim(11, 12) Error: in expression ' do:
|
||||||
890': identifier expected, but found ''
|
890': identifier expected, but found ''
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
nimout: "Special variable 'result' is shadowed. [ResultShadowed]"
|
nimout: "tresultwarning.nim(6, 7) Warning: Special variable 'result' is shadowed. [ResultShadowed]"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc test(): string =
|
proc test(): string =
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
nimout: "Warning: use explicit initialization of 'y' for clarity [Uninit]"
|
nimout: "tuninit1.nim(35, 11) Warning: use explicit initialization of 'y' for clarity [Uninit]"
|
||||||
line:34
|
line:34
|
||||||
action: compile
|
action: compile
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
nimout: "Warning: cannot prove that field 'x.s' is accessible [ProveField]"
|
nimout: "tcheckedfield1.nim(40, 6) Warning: cannot prove that field 'x.s' is accessible [ProveField]"
|
||||||
line:51
|
line:51
|
||||||
action: run
|
action: run
|
||||||
output: "abc abc"
|
output: "abc abc"
|
||||||
|
|
|
||||||
18
tests/pragmas/thintprocessing.nim
Normal file
18
tests/pragmas/thintprocessing.nim
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
discard """
|
||||||
|
disabled: windows
|
||||||
|
matrix: "--hint:processing"
|
||||||
|
nimout: '''
|
||||||
|
compile start
|
||||||
|
..
|
||||||
|
warn_module.nim(6, 6) Hint: 'test' is declared but not used [XDeclaredButNotUsed]
|
||||||
|
compile end
|
||||||
|
'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
static:
|
||||||
|
echo "compile start"
|
||||||
|
|
||||||
|
import warn_module
|
||||||
|
|
||||||
|
static:
|
||||||
|
echo "compile end"
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
matrix: "--hint:processing"
|
|
||||||
nimout: '''
|
nimout: '''
|
||||||
compile start
|
compile start
|
||||||
..
|
|
||||||
warn_module.nim(6, 6) Hint: 'test' is declared but not used [XDeclaredButNotUsed]
|
warn_module.nim(6, 6) Hint: 'test' is declared but not used [XDeclaredButNotUsed]
|
||||||
compile end
|
compile end
|
||||||
'''
|
'''
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
targets: "c cpp js"
|
targets: "c cpp js"
|
||||||
matrix: "; --gc:arc"
|
matrix: "--gc:refc; --gc:arc"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from std/sugar import collect
|
from std/sugar import collect
|
||||||
|
|
|
||||||
|
|
@ -4,3 +4,8 @@ block: # greedyOrderedSubsetLines
|
||||||
doAssert greedyOrderedSubsetLines("a1\na3", "a0\na1\na2\na3\na4")
|
doAssert greedyOrderedSubsetLines("a1\na3", "a0\na1\na2\na3\na4")
|
||||||
doAssert not greedyOrderedSubsetLines("a3\na1", "a0\na1\na2\na3\na4") # out of order
|
doAssert not greedyOrderedSubsetLines("a3\na1", "a0\na1\na2\na3\na4") # out of order
|
||||||
doAssert not greedyOrderedSubsetLines("a1\na5", "a0\na1\na2\na3\na4") # a5 not in lhs
|
doAssert not greedyOrderedSubsetLines("a1\na5", "a0\na1\na2\na3\na4") # a5 not in lhs
|
||||||
|
|
||||||
|
doAssert not greedyOrderedSubsetLines("a1\na5", "a0\na1\na2\na3\na4\nprefix:a5")
|
||||||
|
doAssert not greedyOrderedSubsetLines("a1\na5", "a0\na1\na2\na3\na4\na5:suffix")
|
||||||
|
doAssert not greedyOrderedSubsetLines("a5", "a0\na1\na2\na3\na4\nprefix:a5")
|
||||||
|
doAssert not greedyOrderedSubsetLines("a5", "a0\na1\na2\na3\na4\na5:suffix")
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "type mismatch: got <int>"
|
errormsg: "type mismatch: got <int>"
|
||||||
line: 17
|
line: 17
|
||||||
nimout: '''type mismatch: got <int>
|
nimout: '''tprevent_forloopvar_mutations.nim(17, 7) Error: type mismatch: got <int>
|
||||||
but expected one of:
|
but expected one of:
|
||||||
proc inc[T: Ordinal](x: var T; y = 1)
|
proc inc[T: Ordinal](x: var T; y = 1)
|
||||||
first type mismatch at position: 1
|
first type mismatch at position: 1
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,16 @@
|
||||||
discard """
|
discard """
|
||||||
nimout: '''2
|
nimout: '''
|
||||||
|
2
|
||||||
3
|
3
|
||||||
4:2
|
4:2
|
||||||
Got Hi
|
Got Hi
|
||||||
Got Hey
|
Got Hey
|
||||||
|
'''
|
||||||
|
output:'''
|
||||||
a
|
a
|
||||||
b
|
b
|
||||||
c'''
|
c
|
||||||
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# bug #404
|
# bug #404
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ foo4
|
||||||
(a: 0, b: 0)
|
(a: 0, b: 0)
|
||||||
'''
|
'''
|
||||||
"""
|
"""
|
||||||
|
import std/sets
|
||||||
|
|
||||||
#bug #1009
|
#bug #1009
|
||||||
type
|
type
|
||||||
|
|
@ -95,8 +96,6 @@ static: simpleTryFinally()
|
||||||
|
|
||||||
# bug #10981
|
# bug #10981
|
||||||
|
|
||||||
import sets
|
|
||||||
|
|
||||||
proc main =
|
proc main =
|
||||||
for i in 0..<15:
|
for i in 0..<15:
|
||||||
var someSets = @[initHashSet[int]()]
|
var someSets = @[initHashSet[int]()]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue