Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #16693: testament spec nimout too lax #16698

Merged
merged 21 commits into from
Apr 4, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 38 additions & 5 deletions testament/lib/stdtest/testutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,43 @@ template flakyAssert*(cond: untyped, msg = "", notifySuccess = true) =

proc greedyOrderedSubsetLines*(lhs, rhs: string): bool =
## returns true if each stripped line in `lhs` appears in rhs, using a greedy matching.
let rhs = rhs.strip
var currentPos = 0
for line in lhs.strip.splitLines:
currentPos = rhs.find(line.strip, currentPos)
if currentPos < 0:
iterator splitLinesLhs(): string {.closure.} =
ringabout marked this conversation as resolved.
Show resolved Hide resolved
for line in splitLines(lhs.strip):
yield line

var lhsIter = splitLinesLhs
var currentLhs: string = strip(lhsIter())

while currentLhs.len == 0 and not lhsIter.finished:
currentLhs = strip(lhsIter())

if lhsIter.finished:
return true

var rhs = rhs
var pos = find(rhs, currentLhs)
if pos < 0:
return false
else:
inc(pos, currentLhs.len)
rhs = rhs[pos .. ^1]

iterator splitLinesRhs(): string {.closure.} =
for line in splitLines(rhs.strip):
yield line

var rhsIter = splitLinesRhs

var currentLine = strip(rhsIter())

for line in lhsIter():
let line = line.strip
if line.len != 0:
while line != currentLine:
currentLine = strip(rhsIter())
if rhsIter.finished:
return false

if rhsIter.finished:
return false
return true
10 changes: 10 additions & 0 deletions tests/test/test.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
discard """
ringabout marked this conversation as resolved.
Show resolved Hide resolved
nimout: '''
foobar1
foobar2
'''
"""


static: echo "foobar1"
static: echo "foobar2"
8 changes: 6 additions & 2 deletions tests/vm/tcompiletimetable.nim
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
discard """
nimout: '''2
nimout: '''
2
3
4:2
Got Hi
Got Hey
'''
output:'''
ringabout marked this conversation as resolved.
Show resolved Hide resolved
a
b
c'''
c
'''
"""

# bug #404
Expand Down
3 changes: 1 addition & 2 deletions tests/vm/tmisc_vm.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ foo4
(a: 0, b: 0)
'''
"""
import std/sets
ringabout marked this conversation as resolved.
Show resolved Hide resolved

#bug #1009
type
Expand Down Expand Up @@ -95,8 +96,6 @@ static: simpleTryFinally()

# bug #10981

import sets

proc main =
for i in 0..<15:
var someSets = @[initHashSet[int]()]
Expand Down