This commit is contained in:
Araq 2015-03-12 01:44:57 +01:00
commit f514be0772
4 changed files with 77 additions and 22 deletions

View file

@ -6,7 +6,7 @@ true
true
true'''
ccodeCheck: "!'deepcopy('"
ccodeCheck: "\\i ! @'deepCopy(' .*"
"""
# parallel convex hull for Nim bigbreak

View file

@ -0,0 +1,40 @@
discard """
ccodeCheck: "\\i @'deepCopy(' .*"
"""
# bug #2286
import threadPool
type
Person = ref object
name: string
friend: Person
var
people: seq[Person] = @[]
proc newPerson(name:string): Person =
result.new()
result.name = name
proc greet(p:Person) =
p.friend.name &= "-MUT" # this line crashes the program
echo "Person {",
" name:", p.name, "(", cast[int](addr p.name),"),",
" friend:", p.friend.name, "(", cast[int](addr p.friend.name),") }"
proc setup =
for i in 0 .. <20:
people.add newPerson("Person" & $(i + 1))
for i in 0 .. <20:
people[i].friend = people[19-i]
proc update =
parallel:
for i in 0 .. people.high:
spawn people[i].greet()
when isMainModule:
setup()
update()

View file

@ -148,7 +148,11 @@ proc codegenCheck(test: TTest, check: string, given: var TSpec) =
let genFile = generatedFile(path, name, test.target)
echo genFile
let contents = readFile(genFile).string
if contents.find(check.peg) < 0:
if check[0] == '\\':
# little hack to get 'match' support:
if not contents.match(check.peg):
given.err = reCodegenFailure
elif contents.find(check.peg) < 0:
given.err = reCodegenFailure
except ValueError:
given.err = reInvalidPeg