some love for the testsuite; fixed regressions
This commit is contained in:
parent
566ee874cd
commit
24ae0c387f
19 changed files with 133 additions and 51 deletions
|
|
@ -1,6 +1,5 @@
|
|||
discard """
|
||||
line: 21
|
||||
errormsg: "invalid type: 'Table[string, proc (string){.gcsafe.}]'"
|
||||
output: "action 3 arg"
|
||||
"""
|
||||
|
||||
import tables
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ discard """
|
|||
WARNING: false first assertion from bar
|
||||
ERROR: false second assertion from bar
|
||||
-1
|
||||
tests/assert/tfailedassert.nim:27 false assertion from foo
|
||||
tfailedassert.nim:27 false assertion from foo
|
||||
'''
|
||||
"""
|
||||
|
||||
type
|
||||
TLineInfo = tuple[filename: string, line: int]
|
||||
|
||||
TMyError = object of E_Base
|
||||
TMyError = object of Exception
|
||||
lineinfo: TLineInfo
|
||||
|
||||
EMyError = ref TMyError
|
||||
|
|
|
|||
30
tests/ccgbugs/tmissingderef.nim
Normal file
30
tests/ccgbugs/tmissingderef.nim
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
discard """
|
||||
output: '''255
|
||||
1 1
|
||||
0.5'''
|
||||
"""
|
||||
|
||||
# bug #1181
|
||||
|
||||
type
|
||||
TFoo = object
|
||||
x: int32
|
||||
|
||||
proc mainowar =
|
||||
var foo: TFoo
|
||||
foo.x = 0xff
|
||||
var arr1 = cast[ptr array[4, uint8]](addr foo)[] # Fails.
|
||||
echo arr1[when cpuEndian == littleEndian: 0 else: 3]
|
||||
|
||||
var i = 1i32
|
||||
let x = addr i
|
||||
var arr2 = cast[ptr array[4, uint8]](x)[] # Fails.
|
||||
echo arr2[when cpuEndian == littleEndian: 0 else: 3], " ", i
|
||||
|
||||
# bug #1715
|
||||
var a: array[2, float32] = [0.5'f32, 0.7]
|
||||
let p = addr a
|
||||
var b = p[]
|
||||
echo b[0]
|
||||
|
||||
mainowar()
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
discard """
|
||||
cmd: "nim cpp $target"
|
||||
cmd: "nim cpp $file"
|
||||
"""
|
||||
|
||||
import rawsockets
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
discard """
|
||||
cmd: "nim cpp $target"
|
||||
cmd: "nim cpp $file"
|
||||
"""
|
||||
|
||||
import typeinfo
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
discard """
|
||||
line: 9
|
||||
errormsg: "'a' is deprecated [Deprecated]"
|
||||
nimout: "'a' is deprecated [Deprecated]"
|
||||
"""
|
||||
|
||||
var
|
||||
|
|
@ -8,4 +7,3 @@ var
|
|||
|
||||
a[8] = 1
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
discard """
|
||||
line: 20
|
||||
errormsg: " usage of a type with a destructor in a non destructible context"
|
||||
line: 23
|
||||
nimout: " usage of a type with a destructor in a non destructible context"
|
||||
"""
|
||||
|
||||
{.experimental.}
|
||||
|
|
@ -19,5 +19,9 @@ proc open: TMyObj =
|
|||
|
||||
proc `$`(x: TMyObj): string = $x.y
|
||||
|
||||
echo open()
|
||||
proc foo =
|
||||
discard open()
|
||||
|
||||
# XXX doesn't trigger this yet:
|
||||
#echo open()
|
||||
|
||||
|
|
|
|||
18
tests/exception/tdefer1.nim
Normal file
18
tests/exception/tdefer1.nim
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
discard """
|
||||
output: '''hi
|
||||
hi'''
|
||||
"""
|
||||
|
||||
# bug #1742
|
||||
|
||||
template test(): expr =
|
||||
let a = 0
|
||||
defer: echo "hi"
|
||||
a
|
||||
|
||||
let i = test()
|
||||
|
||||
import strutils
|
||||
let x = try: parseInt("133a")
|
||||
except: -1
|
||||
finally: echo "hi"
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
discard """
|
||||
file: "toop1.nim"
|
||||
output: "in globalaux2: 10\ntotal globals: 2\nint value: 100\nstring value: second"
|
||||
disabled: "true"
|
||||
"""
|
||||
|
||||
import globalaux, globalaux2
|
||||
|
|
|
|||
|
|
@ -7,8 +7,11 @@ discard """
|
|||
1
|
||||
2
|
||||
3'''
|
||||
disabled: "true"
|
||||
"""
|
||||
|
||||
# Disabled since some versions of GCC ignore the 'packed' attribute
|
||||
|
||||
# Test
|
||||
|
||||
type
|
||||
|
|
|
|||
17
tests/overload/tprefer_tygenericinst.nim
Normal file
17
tests/overload/tprefer_tygenericinst.nim
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
discard """
|
||||
output: "Version 2 was called."
|
||||
disabled: true
|
||||
"""
|
||||
|
||||
# bug #2220
|
||||
|
||||
type A[T] = object
|
||||
type B = A[int]
|
||||
|
||||
proc p[X](x: X) =
|
||||
echo "Version 1 was called."
|
||||
|
||||
proc p(x: B) =
|
||||
echo "Version 2 was called."
|
||||
|
||||
p(B()) # This call reported as ambiguous.
|
||||
|
|
@ -6,11 +6,11 @@ import marshal
|
|||
|
||||
template testit(x: expr) = discard $$to[type(x)]($$x)
|
||||
|
||||
var x: array[0..4, array[0..4, string]] = [
|
||||
["test", "1", "2", "3", "4"], ["test", "1", "2", "3", "4"],
|
||||
["test", "1", "2", "3", "4"], ["test", "1", "2", "3", "4"],
|
||||
["test", "1", "2", "3", "4"]]
|
||||
testit(x)
|
||||
var x: array[0..4, array[0..4, string]] = [
|
||||
["test", "1", "2", "3", "4"], ["test", "1", "2", "3", "4"],
|
||||
["test", "1", "2", "3", "4"], ["test", "1", "2", "3", "4"],
|
||||
["test", "1", "2", "3", "4"]]
|
||||
testit(x)
|
||||
var test2: tuple[name: string, s: int] = ("tuple test", 56)
|
||||
testit(test2)
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ type
|
|||
of blah:
|
||||
help: string
|
||||
else:
|
||||
nil
|
||||
discard
|
||||
|
||||
PNode = ref TNode
|
||||
TNode = object
|
||||
|
|
|
|||
|
|
@ -230,17 +230,17 @@ proc testStdlib(r: var TResults, pattern, options: string, cat: Category) =
|
|||
else:
|
||||
testNoSpec r, makeTest(test, options, cat, actionCompile)
|
||||
|
||||
# ----------------------------- babel ----------------------------------------
|
||||
# ----------------------------- nimble ----------------------------------------
|
||||
type PackageFilter = enum
|
||||
pfCoreOnly
|
||||
pfExtraOnly
|
||||
pfAll
|
||||
|
||||
let
|
||||
babelExe = findExe("babel")
|
||||
babelDir = getHomeDir() / ".babel"
|
||||
packageDir = babelDir / "pkgs"
|
||||
packageIndex = babelDir / "packages.json"
|
||||
nimbleExe = findExe("nimble")
|
||||
nimbleDir = getHomeDir() / ".nimble"
|
||||
packageDir = nimbleDir / "pkgs"
|
||||
packageIndex = nimbleDir / "packages.json"
|
||||
|
||||
proc waitForExitEx(p: Process): int =
|
||||
var outp = outputStream(p)
|
||||
|
|
@ -255,7 +255,7 @@ proc waitForExitEx(p: Process): int =
|
|||
|
||||
proc getPackageDir(package: string): string =
|
||||
## TODO - Replace this with dom's version comparison magic.
|
||||
var commandOutput = execCmdEx("babel path $#" % package)
|
||||
var commandOutput = execCmdEx("nimble path $#" % package)
|
||||
if commandOutput.exitCode != QuitSuccess:
|
||||
return ""
|
||||
else:
|
||||
|
|
@ -268,7 +268,7 @@ iterator listPackages(filter: PackageFilter): tuple[name, url: string] =
|
|||
let
|
||||
name = package["name"].str
|
||||
url = package["url"].str
|
||||
isCorePackage = "nimrod-code" in normalize(url)
|
||||
isCorePackage = "nim-lang" in normalize(url)
|
||||
case filter:
|
||||
of pfCoreOnly:
|
||||
if isCorePackage:
|
||||
|
|
@ -279,13 +279,13 @@ iterator listPackages(filter: PackageFilter): tuple[name, url: string] =
|
|||
of pfAll:
|
||||
yield (name, url)
|
||||
|
||||
proc testBabelPackages(r: var TResults, cat: Category, filter: PackageFilter) =
|
||||
if babelExe == "":
|
||||
echo("[Warning] - Cannot run babel tests: Babel binary not found.")
|
||||
proc testNimblePackages(r: var TResults, cat: Category, filter: PackageFilter) =
|
||||
if nimbleExe == "":
|
||||
echo("[Warning] - Cannot run nimble tests: Nimble binary not found.")
|
||||
return
|
||||
|
||||
if execCmd("$# update" % babelExe) == QuitFailure:
|
||||
echo("[Warning] - Cannot run babel tests: Babel update failed.")
|
||||
if execCmd("$# update" % nimbleExe) == QuitFailure:
|
||||
echo("[Warning] - Cannot run nimble tests: Nimble update failed.")
|
||||
return
|
||||
|
||||
let packageFileTest = makeTest("PackageFileParsed", "", cat)
|
||||
|
|
@ -294,7 +294,7 @@ proc testBabelPackages(r: var TResults, cat: Category, filter: PackageFilter) =
|
|||
var test = makeTest(name, "", cat)
|
||||
echo(url)
|
||||
let
|
||||
installProcess = startProcess(babelExe, "", ["install", "-y", name])
|
||||
installProcess = startProcess(nimbleExe, "", ["install", "-y", name])
|
||||
installStatus = waitForExitEx(installProcess)
|
||||
installProcess.close
|
||||
if installStatus != QuitSuccess:
|
||||
|
|
@ -304,7 +304,7 @@ proc testBabelPackages(r: var TResults, cat: Category, filter: PackageFilter) =
|
|||
let
|
||||
buildPath = getPackageDir(name)[0.. -3]
|
||||
let
|
||||
buildProcess = startProcess(babelExe, buildPath, ["build"])
|
||||
buildProcess = startProcess(nimbleExe, buildPath, ["build"])
|
||||
buildStatus = waitForExitEx(buildProcess)
|
||||
buildProcess.close
|
||||
if buildStatus != QuitSuccess:
|
||||
|
|
@ -312,13 +312,13 @@ proc testBabelPackages(r: var TResults, cat: Category, filter: PackageFilter) =
|
|||
r.addResult(test, "", "", reSuccess)
|
||||
r.addResult(packageFileTest, "", "", reSuccess)
|
||||
except JsonParsingError:
|
||||
echo("[Warning] - Cannot run babel tests: Invalid package file.")
|
||||
echo("[Warning] - Cannot run nimble tests: Invalid package file.")
|
||||
r.addResult(packageFileTest, "", "", reBuildFailed)
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
const AdditionalCategories = ["debugger", "examples", "lib", "babel-core"]
|
||||
const AdditionalCategories = ["debugger", "examples", "lib", "nimble-core"]
|
||||
|
||||
proc `&.?`(a, b: string): string =
|
||||
# candidate for the stdlib?
|
||||
|
|
@ -356,12 +356,12 @@ proc processCategory(r: var TResults, cat: Category, options: string) =
|
|||
compileExample(r, "examples/*.nim", options, cat)
|
||||
compileExample(r, "examples/gtk/*.nim", options, cat)
|
||||
compileExample(r, "examples/talk/*.nim", options, cat)
|
||||
of "babel-core":
|
||||
testBabelPackages(r, cat, pfCoreOnly)
|
||||
of "babel-extra":
|
||||
testBabelPackages(r, cat, pfExtraOnly)
|
||||
of "babel-all":
|
||||
testBabelPackages(r, cat, pfAll)
|
||||
of "nimble-core":
|
||||
testNimblePackages(r, cat, pfCoreOnly)
|
||||
of "nimble-extra":
|
||||
testNimblePackages(r, cat, pfExtraOnly)
|
||||
of "nimble-all":
|
||||
testNimblePackages(r, cat, pfAll)
|
||||
else:
|
||||
for name in os.walkFiles("tests" & DirSep &.? cat.string / "t*.nim"):
|
||||
testSpec r, makeTest(name, options, cat)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
discard """
|
||||
output: '''3060
|
||||
output: '''3030
|
||||
true
|
||||
3'''
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue