mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-31 02:43:41 +00:00
Merge branch 'devel' of https://github.com/Araq/Nimrod into devel
This commit is contained in:
@@ -1,16 +1,21 @@
|
||||
discard """
|
||||
output: '''0
|
||||
output: '''8 5 0 0
|
||||
pre test a:test b:1 c:2 haha:3
|
||||
assignment test a:test b:1 c:2 haha:3
|
||||
'''
|
||||
"""
|
||||
|
||||
type TSomeObj = object of TObject
|
||||
Variable: int
|
||||
# bug #1005
|
||||
|
||||
type
|
||||
TSomeObj = object of TObject
|
||||
a, b: int
|
||||
PSomeObj = ref object
|
||||
a, b: int
|
||||
|
||||
var a = TSomeObj()
|
||||
|
||||
echo a.Variable.`$`
|
||||
var a = TSomeObj(a: 8)
|
||||
var b = PSomeObj(a: 5)
|
||||
echo a.a, " ", b.a, " ", a.b, " ", b.b
|
||||
|
||||
# bug #575
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
discard """
|
||||
file: "tasyncawait.nim"
|
||||
cmd: "nimrod cc --hints:on $# $#"
|
||||
output: "5000"
|
||||
"""
|
||||
import asyncdispatch, rawsockets, net, strutils, os
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
discard """
|
||||
file: "tasynciossl.nim"
|
||||
cmd: "nimrod cc --hints:on --define:ssl $# $#"
|
||||
cmd: "nimrod $target --hints:on --define:ssl $options $file"
|
||||
output: "20000"
|
||||
"""
|
||||
import sockets, asyncio, strutils, times
|
||||
@@ -88,4 +88,4 @@ while true:
|
||||
break
|
||||
|
||||
assert msgCount == (swarmSize * messagesToSend) * serverCount
|
||||
echo(msgCount)
|
||||
echo(msgCount)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
discard """
|
||||
outputsub: "101"
|
||||
cmd: "nimrod cc --hints:on --threads:on $# $#"
|
||||
cmd: "nimrod $target --hints:on --threads:on $options $file"
|
||||
"""
|
||||
|
||||
import os, locks
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
discard """
|
||||
output: "Done"
|
||||
cmd: "nimrod cc --debuginfo --hints:on --define:useNimRtl $# $#"
|
||||
cmd: "nimrod $target --debuginfo --hints:on --define:useNimRtl $options $file"
|
||||
"""
|
||||
|
||||
type
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
cmd: "nimrod cc --debuginfo --hints:on --define:useNimRtl --app:lib $# $#"
|
||||
cmd: "nimrod $target --debuginfo --hints:on --define:useNimRtl --app:lib $options $file"
|
||||
"""
|
||||
|
||||
type
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
cmd: "nimrod check $# $#"
|
||||
cmd: "nimrod check $options $file"
|
||||
errormsg: "'proc' is not a concrete type"
|
||||
errormsg: "'Foo' is not a concrete type."
|
||||
errormsg: "invalid type: 'TBaseMed'"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
cmd: "nimrod cc --hints:on --threads:on $# $#"
|
||||
cmd: "nimrod $target --hints:on --threads:on $options $file"
|
||||
"""
|
||||
|
||||
type
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
discard """
|
||||
output: '''true'''
|
||||
cmd: "nimrod cc --gc:none --hints:on --warnings:off $# $#"
|
||||
cmd: "nimrod $target --gc:none --hints:on --warnings:off $options $file"
|
||||
"""
|
||||
|
||||
import hashes
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
cmd: "nimrod js --hints:on $# $#"
|
||||
cmd: "nimrod js --hints:on $options $file"
|
||||
"""
|
||||
|
||||
# This file tests the JavaScript generator
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
discard """
|
||||
cmd: "nimrod js --hints:on $# $#"
|
||||
output: "1261129"
|
||||
"""
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
discard """
|
||||
cmd: "nimrod js --hints:on -r $# $#"
|
||||
output: '''foo
|
||||
js 3.14'''
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
discard """
|
||||
cmd: "nimrod js --hints:on -r $# $#"
|
||||
output: '''true'''
|
||||
"""
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
|
||||
discard """
|
||||
disabled: true
|
||||
"""
|
||||
import
|
||||
gtk2, glib2, atk, gdk2, gdk2pixbuf, libglade2, pango,
|
||||
pangoutils
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
cmd: "nimrod cc --hints:on -d:release $# $#"
|
||||
cmd: "nimrod $target --hints:on -d:release $options $file"
|
||||
"""
|
||||
|
||||
# -*- nimrod -*-
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
discard """
|
||||
output: '''true'''
|
||||
cmd: "nimrod cc --hints:on $# $#"
|
||||
"""
|
||||
|
||||
import hashes, sets
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import sockets
|
||||
import sockets, os
|
||||
var s: TSocket
|
||||
s = socket()
|
||||
if s == InvalidSocket: osError(osLastError())
|
||||
|
||||
s.connect("www.google.com", TPort(80))
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
cmd: "nimrod cc --hints:on -d:embedUnidecodeTable $# $#"
|
||||
cmd: "nimrod $target --hints:on -d:embedUnidecodeTable $options $file"
|
||||
output: "Ausserst"
|
||||
"""
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
discard """
|
||||
output: '''true'''
|
||||
cmd: "nimrod cc --hints:on $# $#"
|
||||
"""
|
||||
|
||||
import hashes, tables
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
discard """
|
||||
output: '''true'''
|
||||
cmd: "nimrod cc --hints:on $# $#"
|
||||
"""
|
||||
|
||||
import tables
|
||||
|
||||
@@ -179,10 +179,12 @@ proc jsTests(r: var TResults, cat: Category, options: string) =
|
||||
|
||||
for t in os.walkFiles("tests/js/t*.nim"):
|
||||
test(t)
|
||||
for testfile in ["texceptions", "texcpt1", "texcsub", "tfinally",
|
||||
"tfinally2", "tfinally3", "tactiontable", "tmultim1",
|
||||
"tmultim3", "tmultim4"]:
|
||||
test "tests/run/" & testfile & ".nim"
|
||||
for testfile in ["exception/texceptions", "exception/texcpt1",
|
||||
"exception/texcsub", "exception/tfinally",
|
||||
"exception/tfinally2", "exception/tfinally3",
|
||||
"actiontable/tactiontable", "method/tmultim1",
|
||||
"method/tmultim3", "method/tmultim4"]:
|
||||
test "tests/" & testfile & ".nim"
|
||||
|
||||
# ------------------------- manyloc -------------------------------------------
|
||||
#proc runSpecialTests(r: var TResults, options: string) =
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
import parseutils, strutils, os, osproc, streams, parsecfg
|
||||
|
||||
const
|
||||
cmdTemplate* = r"nimrod cc --hints:on $# $#"
|
||||
cmdTemplate* = r"nimrod $target --hints:on $options $file"
|
||||
|
||||
type
|
||||
TTestAction* = enum
|
||||
@@ -51,6 +51,7 @@ type
|
||||
|
||||
const
|
||||
targetToExt*: array[TTarget, string] = ["c", "cpp", "m", "js"]
|
||||
targetToCmd*: array[TTarget, string] = ["c", "cpp", "objc", "js"]
|
||||
|
||||
when not defined(parseCfgBool):
|
||||
# candidate for the stdlib:
|
||||
|
||||
@@ -53,8 +53,10 @@ let
|
||||
pegSuccess = peg"'Hint: operation successful'.*"
|
||||
pegOfInterest = pegLineError / pegOtherError
|
||||
|
||||
proc callCompiler(cmdTemplate, filename, options: string): TSpec =
|
||||
let c = parseCmdLine(cmdTemplate % [options, filename])
|
||||
proc callCompiler(cmdTemplate, filename, options: string,
|
||||
target: TTarget): TSpec =
|
||||
let c = parseCmdLine(cmdTemplate % ["target", targetToCmd[target],
|
||||
"options", options, "file", filename])
|
||||
var p = startProcess(command=c[0], args=c[1.. -1],
|
||||
options={poStdErrToStdOut, poUseShell})
|
||||
let outp = p.outputStream
|
||||
@@ -111,10 +113,10 @@ proc addResult(r: var TResults, test: TTest,
|
||||
r.data.addf("$#\t$#\t$#\t$#", name, expected, given, $success)
|
||||
if success notin {reSuccess, reIgnored}:
|
||||
styledEcho styleBright, name, fgRed, " [", $success, "]"
|
||||
styledEcho styleDim, "EXPECTED:"
|
||||
echo expected
|
||||
styledEcho styleDim, "GIVEN:"
|
||||
echo given
|
||||
echo"Expected:"
|
||||
styledEcho styleBright, expected
|
||||
echo"Given:"
|
||||
styledEcho styleBright, given
|
||||
|
||||
proc cmpMsgs(r: var TResults, expected, given: TSpec, test: TTest) =
|
||||
if strip(expected.msg) notin strip(given.msg):
|
||||
@@ -152,7 +154,7 @@ proc testSpec(r: var TResults, test: TTest) =
|
||||
# major entry point for a single test
|
||||
let tname = test.name.addFileExt(".nim")
|
||||
inc(r.total)
|
||||
echo extractFilename(tname)
|
||||
styledEcho "Processing ", fgCyan, extractFilename(tname)
|
||||
var expected = parseSpec(tname)
|
||||
if expected.err == reIgnored:
|
||||
r.addResult(test, "", "", reIgnored)
|
||||
@@ -160,13 +162,15 @@ proc testSpec(r: var TResults, test: TTest) =
|
||||
else:
|
||||
case expected.action
|
||||
of actionCompile:
|
||||
var given = callCompiler(expected.cmd, test.name, test.options)
|
||||
var given = callCompiler(expected.cmd, test.name, test.options,
|
||||
test.target)
|
||||
if given.err == reSuccess:
|
||||
codegenCheck(test, expected.ccodeCheck, given)
|
||||
r.addResult(test, "", given.msg, given.err)
|
||||
if given.err == reSuccess: inc(r.passed)
|
||||
of actionRun:
|
||||
var given = callCompiler(expected.cmd, test.name, test.options)
|
||||
var given = callCompiler(expected.cmd, test.name, test.options,
|
||||
test.target)
|
||||
if given.err != reSuccess:
|
||||
r.addResult(test, "", given.msg, given.err)
|
||||
else:
|
||||
@@ -176,10 +180,13 @@ proc testSpec(r: var TResults, test: TTest) =
|
||||
exeFile = dir / "nimcache" / file & ".js"
|
||||
else:
|
||||
exeFile = changeFileExt(tname, ExeExt)
|
||||
|
||||
if existsFile(exeFile):
|
||||
if test.target == targetJS and findExe("nodejs") == "":
|
||||
r.addResult(test, expected.outp, "nodejs binary not in PATH",
|
||||
reExeNotFound)
|
||||
return
|
||||
var (buf, exitCode) = execCmdEx(
|
||||
(if test.target==targetJS: "node " else: "") & exeFile)
|
||||
(if test.target == targetJS: "nodejs " else: "") & exeFile)
|
||||
if exitCode != expected.ExitCode:
|
||||
r.addResult(test, "exitcode: " & $expected.exitCode,
|
||||
"exitcode: " & $exitCode, reExitCodesDiffer)
|
||||
@@ -194,7 +201,8 @@ proc testSpec(r: var TResults, test: TTest) =
|
||||
else:
|
||||
r.addResult(test, expected.outp, "executable not found", reExeNotFound)
|
||||
of actionReject:
|
||||
var given = callCompiler(expected.cmd, test.name, test.options)
|
||||
var given = callCompiler(expected.cmd, test.name, test.options,
|
||||
test.target)
|
||||
cmpMsgs(r, expected, given, test)
|
||||
|
||||
proc testNoSpec(r: var TResults, test: TTest) =
|
||||
@@ -202,7 +210,7 @@ proc testNoSpec(r: var TResults, test: TTest) =
|
||||
let tname = test.name.addFileExt(".nim")
|
||||
inc(r.total)
|
||||
echo extractFilename(tname)
|
||||
let given = callCompiler(cmdTemplate, test.name, test.options)
|
||||
let given = callCompiler(cmdTemplate, test.name, test.options, test.target)
|
||||
r.addResult(test, "", given.msg, given.err)
|
||||
if given.err == reSuccess: inc(r.passed)
|
||||
|
||||
@@ -223,7 +231,7 @@ proc main() =
|
||||
os.putenv "NIMTEST_NO_COLOR", "1"
|
||||
os.putenv "NIMTEST_OUTPUT_LVL", "PRINT_FAILURES"
|
||||
|
||||
backend.open()
|
||||
backend.open()
|
||||
var optPrintResults = false
|
||||
var p = initOptParser()
|
||||
p.next()
|
||||
@@ -238,9 +246,12 @@ proc main() =
|
||||
var r = initResults()
|
||||
case action
|
||||
of "all":
|
||||
for kind, dir in walkDir("tests"):
|
||||
if kind == pcDir and dir notin ["testament", "testdata", "nimcache"]:
|
||||
processCategory(r, Category(dir), p.cmdLineRest.string)
|
||||
let testsDir = "tests" & dirSep
|
||||
for kind, dir in walkDir(testsDir):
|
||||
assert testsDir.startsWith(testsDir)
|
||||
let cat = dir[testsDir.len .. -1]
|
||||
if kind == pcDir and cat notin ["testament", "testdata", "nimcache"]:
|
||||
processCategory(r, Category(cat), p.cmdLineRest.string)
|
||||
for a in AdditionalCategories:
|
||||
processCategory(r, Category(a), p.cmdLineRest.string)
|
||||
of "c", "cat", "category":
|
||||
@@ -255,11 +266,11 @@ proc main() =
|
||||
else:
|
||||
quit usage
|
||||
|
||||
if optPrintResults:
|
||||
if optPrintResults:
|
||||
if action == "html": openDefaultBrowser(resultsFile)
|
||||
else: echo r, r.data
|
||||
backend.close()
|
||||
|
||||
|
||||
if paramCount() == 0:
|
||||
quit usage
|
||||
main()
|
||||
|
||||
@@ -2,7 +2,7 @@ discard """
|
||||
outputsub: "101"
|
||||
msg: "Warning: write to foreign heap"
|
||||
line: 37
|
||||
cmd: "nimrod cc --hints:on --threads:on $# $#"
|
||||
cmd: "nimrod $target --hints:on --threads:on $options $file"
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
@@ -2,7 +2,7 @@ discard """
|
||||
file: "tthreadanalysis2.nim"
|
||||
line: 42
|
||||
errormsg: "write to foreign heap"
|
||||
cmd: "nimrod cc --hints:on --threads:on $# $#"
|
||||
cmd: "nimrod $target --hints:on --threads:on $options $file"
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
@@ -2,7 +2,7 @@ discard """
|
||||
file: "tthreadanalysis3.nim"
|
||||
line: 35
|
||||
errormsg: "write to foreign heap"
|
||||
cmd: "nimrod cc --hints:on --threads:on $# $#"
|
||||
cmd: "nimrod $target --hints:on --threads:on $options $file"
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
discard """
|
||||
line: 12
|
||||
errormsg: "write to foreign heap"
|
||||
cmd: "nimrod cc --hints:on --threads:on $# $#"
|
||||
cmd: "nimrod $target --hints:on --threads:on $options $file"
|
||||
"""
|
||||
|
||||
var
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
cmd: "nimrod c --threads:on $# $#"
|
||||
cmd: "nimrod $target --threads:on $options $file"
|
||||
errormsg: "illegal recursion in type 'TIRC'"
|
||||
line: 16
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user