mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-07 05:23:20 +00:00
Adjust some tests to make them pass
The non-scoped behaviour of static blocks was exploited by those tests, replace all the variables declared whithin one with compileTime marked ones.
This commit is contained in:
@@ -71,5 +71,4 @@ macro make(arg: untyped): untyped =
|
||||
proc first(i: int): void =
|
||||
make(second)
|
||||
|
||||
static:
|
||||
var ss: string = ""
|
||||
var ss {.compileTime.}: string = ""
|
||||
@@ -4,14 +4,12 @@ proc assertEq(arg0,arg1: string): void =
|
||||
if arg0 != arg1:
|
||||
raiseAssert("strings not equal:\n" & arg0 & "\n" & arg1)
|
||||
|
||||
static:
|
||||
# a simple assignment of stmtList to another variable
|
||||
var node: NimNode
|
||||
# an assignment of stmtList into an array
|
||||
var nodeArray: array[1, NimNode]
|
||||
# an assignment of stmtList into a seq
|
||||
var nodeSeq = newSeq[NimNode](2)
|
||||
|
||||
# a simple assignment of stmtList to another variable
|
||||
var node {.compileTime.}: NimNode
|
||||
# an assignment of stmtList into an array
|
||||
var nodeArray {.compileTime.}: array[1, NimNode]
|
||||
# an assignment of stmtList into a seq
|
||||
var nodeSeq {.compileTime.} = newSeq[NimNode](2)
|
||||
|
||||
proc checkNode(arg: NimNode; name: string): void {. compileTime .} =
|
||||
echo "checking ", name
|
||||
@@ -35,10 +33,10 @@ proc checkNode(arg: NimNode; name: string): void {. compileTime .} =
|
||||
|
||||
echo "OK"
|
||||
|
||||
static:
|
||||
# the root node that is used to generate the Ast
|
||||
var stmtList: NimNode
|
||||
# the root node that is used to generate the Ast
|
||||
var stmtList {.compileTime.}: NimNode
|
||||
|
||||
static:
|
||||
stmtList = newStmtList(nnkDiscardStmt.newTree(newEmptyNode()))
|
||||
|
||||
checkNode(stmtList, "direct construction")
|
||||
|
||||
@@ -19,9 +19,9 @@ block:
|
||||
var x = default(type(0))
|
||||
|
||||
# #6379
|
||||
static:
|
||||
import algorithm
|
||||
import algorithm
|
||||
|
||||
static:
|
||||
var numArray = [1, 2, 3, 4, -1]
|
||||
numArray.sort(cmp)
|
||||
assert numArray == [-1, 1, 2, 3, 4]
|
||||
|
||||
Reference in New Issue
Block a user