mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 14:00:35 +00:00
megatest can be executed
This commit is contained in:
@@ -356,7 +356,7 @@ block troofregression:
|
||||
echo testStr[testStr.len - 8 .. testStr.len - 1] & "__" & testStr[0 .. testStr.len - pred(rot)]
|
||||
|
||||
var
|
||||
instructions = readFile(getAppDir() / "troofregression2.txt").split(',')
|
||||
instructions = readFile(parentDir(currentSourcePath) / "troofregression2.txt").split(',')
|
||||
programs = "abcdefghijklmnop"
|
||||
|
||||
proc dance(dancers: string): string =
|
||||
|
||||
@@ -53,8 +53,7 @@ proc main() {.async.} =
|
||||
|
||||
# Issue #7347
|
||||
block:
|
||||
let appDir = getAppDir()
|
||||
var file = openAsync(appDir & DirSep & "hello.txt")
|
||||
var file = openAsync( parentDir(currentSourcePath) / "hello.txt")
|
||||
echo file.getFileSize()
|
||||
echo await file.readAll()
|
||||
echo file.getFilePos()
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
discard """
|
||||
output: '''(FirstName: "James", LastName: "Franco")'''
|
||||
"""
|
||||
|
||||
# bug #1547
|
||||
import tables
|
||||
|
||||
type Person* = object
|
||||
FirstName*: string
|
||||
LastName*: string
|
||||
|
||||
let people = {
|
||||
"001": Person(FirstName: "James", LastName: "Franco")
|
||||
}.toTable()
|
||||
|
||||
echo people["001"]
|
||||
@@ -15,7 +15,7 @@ import std / [os]
|
||||
|
||||
proc main() =
|
||||
let std = findNimStdLibCompileTime()
|
||||
var intr = createInterpreter("myscript.nim", [std, getAppDir()])
|
||||
var intr = createInterpreter("myscript.nim",[std, parentDir(currentSourcePath)])
|
||||
intr.implementRoutine("*", "exposed", "addFloats", proc (a: VmArgs) =
|
||||
setResult(a, getFloat(a, 0) + getFloat(a, 1) + getFloat(a, 2))
|
||||
)
|
||||
@@ -51,4 +51,3 @@ block issue9180:
|
||||
|
||||
evalString("echo 10+1")
|
||||
evalString("echo 10+2")
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ proc excl*(r: PRadixNode, a: ByteAddress): bool =
|
||||
proc addLeaf(r: var PRadixNode, a: int): bool =
|
||||
if r == nil:
|
||||
# a linear node:
|
||||
var x = cast[ptr TRadixNodeLinear](alloc(sizeof(TRadixNodeLinear)))
|
||||
var x = cast[ptr TRadixNodeLinear](alloc0(sizeof(TRadixNodeLinear)))
|
||||
x.kind = rnLeafLinear
|
||||
x.len = 1'i8
|
||||
x.keys[0] = toU8(a)
|
||||
@@ -162,7 +162,7 @@ proc addInner(r: var PRadixNode, a: int, d: int): bool =
|
||||
var k = a shr d and 0xff
|
||||
if r == nil:
|
||||
# a linear node:
|
||||
var x = cast[ptr TRadixNodeLinear](alloc(sizeof(TRadixNodeLinear)))
|
||||
var x = cast[ptr TRadixNodeLinear](alloc0(sizeof(TRadixNodeLinear)))
|
||||
x.kind = rnLinear
|
||||
x.len = 1'i8
|
||||
x.keys[0] = toU8(k)
|
||||
@@ -246,99 +246,3 @@ proc main() =
|
||||
for x in elements(r): echo(x)
|
||||
|
||||
main()
|
||||
|
||||
|
||||
when false:
|
||||
proc traverse(r: PRadixNode, prefix: int, d: int) =
|
||||
if r == nil: return
|
||||
case r.kind
|
||||
of rnLeafBits:
|
||||
assert(d == 0)
|
||||
var x = cast[ptr TRadixNodeLeafBits](r)
|
||||
# iterate over any bit:
|
||||
for i in 0..high(x.b):
|
||||
if x.b[i] != 0: # test all bits for zero
|
||||
for j in 0..BitsPerUnit-1:
|
||||
if testBit(x.b[i], j):
|
||||
visit(prefix or i*BitsPerUnit+j)
|
||||
of rnLeafLinear:
|
||||
assert(d == 0)
|
||||
var x = cast[ptr TRadixNodeLeafLinear](r)
|
||||
for i in 0..ze(x.len)-1:
|
||||
visit(prefix or ze(x.keys[i]))
|
||||
of rnFull:
|
||||
var x = cast[ptr TRadixNodeFull](r)
|
||||
for i in 0..high(r.b):
|
||||
if r.b[i] != nil:
|
||||
traverse(r.b[i], prefix or (i shl d), d-8)
|
||||
of rnLinear:
|
||||
var x = cast[ptr TRadixNodeLinear](r)
|
||||
for i in 0..ze(x.len)-1:
|
||||
traverse(x.vals[i], prefix or (ze(x.keys[i]) shl d), d-8)
|
||||
|
||||
type
|
||||
TRadixIter {.final.} = object
|
||||
r: PRadixNode
|
||||
p: int
|
||||
x: int
|
||||
|
||||
proc init(i: var TRadixIter, r: PRadixNode) =
|
||||
i.r = r
|
||||
i.x = 0
|
||||
i.p = 0
|
||||
|
||||
proc nextr(i: var TRadixIter): PRadixNode =
|
||||
if i.r == nil: return nil
|
||||
case i.r.kind
|
||||
of rnFull:
|
||||
var r = cast[ptr TRadixNodeFull](i.r)
|
||||
while i.x <= high(r.b):
|
||||
if r.b[i.x] != nil:
|
||||
i.p = i.x
|
||||
return r.b[i.x]
|
||||
inc(i.x)
|
||||
of rnLinear:
|
||||
var r = cast[ptr TRadixNodeLinear](i.r)
|
||||
if i.x < ze(r.len):
|
||||
i.p = ze(r.keys[i.x])
|
||||
result = r.vals[i.x]
|
||||
inc(i.x)
|
||||
else: assert(false)
|
||||
|
||||
proc nexti(i: var TRadixIter): int =
|
||||
result = -1
|
||||
case i.r.kind
|
||||
of rnLeafBits:
|
||||
var r = cast[ptr TRadixNodeLeafBits](i.r)
|
||||
# iterate over any bit:
|
||||
for i in 0..high(r.b):
|
||||
if x.b[i] != 0: # test all bits for zero
|
||||
for j in 0..BitsPerUnit-1:
|
||||
if testBit(x.b[i], j):
|
||||
visit(prefix or i*BitsPerUnit+j)
|
||||
of rnLeafLinear:
|
||||
var r = cast[ptr TRadixNodeLeafLinear](i.r)
|
||||
if i.x < ze(r.len):
|
||||
result = ze(r.keys[i.x])
|
||||
inc(i.x)
|
||||
|
||||
iterator elements(r: PRadixNode): ByteAddress {.inline.} =
|
||||
var
|
||||
a, b, c, d: TRadixIter
|
||||
init(a, r)
|
||||
while true:
|
||||
var x = nextr(a)
|
||||
if x != nil:
|
||||
init(b, x)
|
||||
while true:
|
||||
var y = nextr(b)
|
||||
if y != nil:
|
||||
init(c, y)
|
||||
while true:
|
||||
var z = nextr(c)
|
||||
if z != nil:
|
||||
init(d, z)
|
||||
while true:
|
||||
var q = nexti(d)
|
||||
if q != -1:
|
||||
yield a.p shl 24 or b.p shl 16 or c.p shl 8 or q
|
||||
|
||||
@@ -6,7 +6,7 @@ discard """
|
||||
|
||||
import parsesql, streams, os
|
||||
|
||||
var tree = parseSql(newFileStream(getAppDir() / "somesql.sql"), "somesql")
|
||||
var tree = parseSql(newFileStream(parentDir(currentSourcePath) / "somesql.sql"), "somesql")
|
||||
discard renderSql(tree)
|
||||
|
||||
echo "true"
|
||||
|
||||
@@ -219,7 +219,7 @@ block tsplit2:
|
||||
|
||||
block tsqlparser:
|
||||
# Just check that we can parse 'somesql' and render it without crashes.
|
||||
var tree = parseSql(newFileStream(getAppDir() / "somesql.sql"), "somesql")
|
||||
var tree = parseSql(newFileStream( parentDir(currentSourcePath) / "somesql.sql"), "somesql")
|
||||
discard renderSql(tree)
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
output: ""
|
||||
output: "DONE: tostring.nim"
|
||||
"""
|
||||
|
||||
doAssert "@[23, 45]" == $(@[23, 45])
|
||||
@@ -115,3 +115,6 @@ block:
|
||||
var s: string
|
||||
s.addQuoted a2
|
||||
doAssert s == "\"fo\\\"o2\""
|
||||
|
||||
|
||||
echo "DONE: tostring.nim"
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
discard """
|
||||
output: '''(name: "hello")
|
||||
(-1, 0)'''
|
||||
output: '''
|
||||
(name: "hello")
|
||||
(-1, 0)
|
||||
(FirstName: "James", LastName: "Franco")
|
||||
'''
|
||||
"""
|
||||
|
||||
# bug #2774, bug #3195
|
||||
|
||||
type Foo = object
|
||||
name: string
|
||||
|
||||
@@ -14,7 +16,6 @@ const fooArray = [
|
||||
|
||||
echo fooArray[0]
|
||||
|
||||
|
||||
type
|
||||
Position = object
|
||||
x, y: int
|
||||
@@ -34,3 +35,16 @@ const
|
||||
]
|
||||
|
||||
echo offset[1]
|
||||
|
||||
# bug #1547
|
||||
import tables
|
||||
|
||||
type Person* = object
|
||||
FirstName*: string
|
||||
LastName*: string
|
||||
|
||||
let people = {
|
||||
"001": Person(FirstName: "James", LastName: "Franco")
|
||||
}.toTable()
|
||||
|
||||
echo people["001"]
|
||||
|
||||
@@ -70,7 +70,8 @@ block:
|
||||
# Tests for VM ops
|
||||
block:
|
||||
static:
|
||||
assert "vm" in getProjectPath()
|
||||
# for joint test, the project path is different
|
||||
assert "vm" in getProjectPath() or "Nim" in getProjectPath()
|
||||
|
||||
let b = getEnv("UNSETENVVAR")
|
||||
assert b == ""
|
||||
|
||||
Reference in New Issue
Block a user