mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 08:54:53 +00:00
lots of small changes
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -66,3 +66,6 @@ testresults/
|
||||
test.txt
|
||||
/test.ini
|
||||
|
||||
tweeter.db
|
||||
tweeter_test.db
|
||||
megatest.nim
|
||||
|
||||
@@ -579,7 +579,8 @@ const specialCategories = [
|
||||
"niminaction",
|
||||
"rodfiles",
|
||||
"threads",
|
||||
"untestable"
|
||||
"untestable",
|
||||
"stdlib",
|
||||
]
|
||||
|
||||
|
||||
@@ -598,9 +599,18 @@ const specialDisabedTests = [
|
||||
"tests/system/t7894.nim", # causes out of memory in later tests
|
||||
"tests/types/tissues_types.nim", # causes out of memory with --gc:boehm
|
||||
"tests/pragmas/tused.nim", # paths in nimout differ when imported
|
||||
"tests/generics/trtree.nim", # very very ugly test
|
||||
"tests/array/tarray.nim", #
|
||||
"tests/osproc/texecps.nim", # uses getAppFileName() to start itself with arguments
|
||||
"tests/destructor/turn_destroy_into_finalizer.nim", # fails when imported
|
||||
"tests/osproc/texitsignal.nim", # uses getAppFileName() to start itself with arguments
|
||||
]
|
||||
|
||||
proc isJoinableSpec(spec: TSpec): bool =
|
||||
|
||||
if spec.sortoutput:
|
||||
return false
|
||||
|
||||
if spec.action != actionRun:
|
||||
return false
|
||||
|
||||
@@ -678,24 +688,63 @@ proc runJoinedTest(): bool =
|
||||
else:
|
||||
echo "nimout FAIL"
|
||||
|
||||
(buf, exitCode) = execCmdEx2("./megatest", [], {}, "")
|
||||
(buf, exitCode) = execCmdEx2("./megatest", [], {poStdErrToStdOut}, "")
|
||||
if exitCode != 0:
|
||||
quit("megatest execution failed")
|
||||
|
||||
echo "run ok"
|
||||
|
||||
var outputOK = true
|
||||
for runSpec in specs:
|
||||
|
||||
writeFile("outputGotten.txt", buf)
|
||||
var outputExpected = ""
|
||||
|
||||
var outputErrorCount = 0
|
||||
var currentPos = 0
|
||||
|
||||
var lastLine = ""
|
||||
|
||||
# when a lot of output is skipped, this can be the cause why a later test fails.
|
||||
var warnings = ""
|
||||
|
||||
for i, runSpec in specs:
|
||||
outputExpected.add runSpec.output
|
||||
if outputExpected[^1] != '\n':
|
||||
outputExpected.add '\n'
|
||||
|
||||
for line in runSpec.output.splitLines:
|
||||
if buf.find(line) < 0:
|
||||
echo "could not find: ", line
|
||||
echo runSpec.file
|
||||
outputOK = false
|
||||
if outputOK:
|
||||
if line != "":
|
||||
#if line == "2":
|
||||
# echo "found the test: ", runSpec.file
|
||||
let newPos = buf.find(line, currentPos)
|
||||
if newPos < 0:
|
||||
if outputErrorCount < 5:
|
||||
echo "could not find: ", line
|
||||
echo "it could be, because the test failed, or too much output is discarded by a previous search in the output."
|
||||
echo warnings
|
||||
warnings.setLen 0
|
||||
|
||||
# don't spam too much of this
|
||||
if outputErrorCount == 0:
|
||||
echo "############"
|
||||
echo buf[currentPos-200 ..< currentPos]
|
||||
echo "| (", current_pos, ")"
|
||||
echo buf[currentPos ..< min(currentPos+200, buf.len)]
|
||||
echo "############"
|
||||
|
||||
inc outputErrorCount
|
||||
else:
|
||||
if currentPos + lastLine.len * 2 < newPos:
|
||||
warnings.addLine "Warning long skip in search for: ", line
|
||||
warnings.addLine "in test: ", runSpec.file
|
||||
currentPos = newPos + line.len
|
||||
|
||||
lastLine = line
|
||||
if outputErrorCount == 0:
|
||||
echo "output OK"
|
||||
else:
|
||||
echo "output FAIL"
|
||||
echo "output FAIL (", outputErrorCount, " errors)"
|
||||
|
||||
removeFile("megatest.nim")
|
||||
writeFile("outputExpected.txt", outputExpected)
|
||||
|
||||
return nimoutOK and outputOK
|
||||
# removeFile("megatest.nim")
|
||||
return nimoutOK and outputErrorCount == 0
|
||||
|
||||
@@ -109,12 +109,11 @@ proc parseTargets*(value: string): set[TTarget] =
|
||||
of "js": result.incl(targetJS)
|
||||
else: echo "target ignored: " & v
|
||||
|
||||
|
||||
proc addLine(self: var string; a: string) =
|
||||
proc addLine*(self: var string; a: string) =
|
||||
self.add a
|
||||
self.add "\n"
|
||||
|
||||
proc addLine(self: var string; a,b: string) =
|
||||
proc addLine*(self: var string; a,b: string) =
|
||||
self.add a
|
||||
self.add b
|
||||
self.add "\n"
|
||||
|
||||
@@ -497,6 +497,9 @@ else:
|
||||
# array of modules disabled from compilation test of stdlib.
|
||||
disabledFiles = ["-"]
|
||||
|
||||
|
||||
|
||||
|
||||
include categories
|
||||
|
||||
# proc runCaasTests(r: var TResults) =
|
||||
|
||||
@@ -9,6 +9,6 @@ import asyncdispatch
|
||||
proc testCallback() =
|
||||
echo "testCallback()"
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
callSoon(testCallback)
|
||||
poll()
|
||||
|
||||
@@ -27,7 +27,7 @@ proc serve() {.async.} =
|
||||
var fut = await accept()
|
||||
await processClient(fut)
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
proc main =
|
||||
var fut = serve()
|
||||
fut.callback =
|
||||
|
||||
@@ -15,7 +15,7 @@ proc asyncRecursionTest*(): Future[int] {.async.} =
|
||||
inc(result, await asyncRecursionCycle(i))
|
||||
inc(i)
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
setGlobalDispatcher(newDispatcher())
|
||||
var i = waitFor asyncRecursionTest()
|
||||
echo i
|
||||
|
||||
@@ -74,7 +74,7 @@ proc propertyBind*[T](p1: var TProperty[T], p2: var TProperty[T]) =
|
||||
proc `->`[T](p1: var TProperty[T], p2: var TProperty[T]) =
|
||||
propertyBind(p2,p1)
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
# Initial value testing
|
||||
var myProp = newProperty(5)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import pkg8616 / scheduler
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
init()
|
||||
|
||||
@@ -18,7 +18,7 @@ type
|
||||
of false:
|
||||
region: float
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
let r = 1.5
|
||||
let a = TypeOne(animatedU: true,
|
||||
animated: false,
|
||||
|
||||
@@ -15,7 +15,7 @@ type
|
||||
proc mult(x:int, y:var int) =
|
||||
y = 2 * x
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
|
||||
var input = 1
|
||||
var output = 0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
output: '''false'''
|
||||
output: "done generic smallobj asgn opt"
|
||||
"""
|
||||
|
||||
# bug #5402
|
||||
@@ -23,4 +23,5 @@ proc newListOfContainers[T](): ListOfContainers[T] =
|
||||
result.list = initDoublyLinkedList[Container[T]]()
|
||||
|
||||
let q = newListOfContainers[int64]()
|
||||
echo q.contains(123)
|
||||
if not q.contains(123):
|
||||
echo "done generic smallobj asgn opt"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
output: "done"
|
||||
output: "done markerproc regression"
|
||||
"""
|
||||
|
||||
type
|
||||
@@ -42,6 +42,6 @@ proc main =
|
||||
let expected = $i & "some longer text here " & $i
|
||||
if a[i].ver.string != expected:
|
||||
quit "bug!"
|
||||
echo "done"
|
||||
echo "done markerproc regression"
|
||||
|
||||
main()
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
discard """
|
||||
output: '''Subobject test called
|
||||
5'''
|
||||
output: '''
|
||||
Subobject test called
|
||||
5
|
||||
'''
|
||||
"""
|
||||
|
||||
type
|
||||
@@ -49,4 +51,3 @@ var a: SubObject
|
||||
|
||||
a.test()
|
||||
echo a.t
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
discard """
|
||||
output: '''
|
||||
done
|
||||
done tableadds
|
||||
And we get here
|
||||
1
|
||||
2
|
||||
@@ -17,7 +17,7 @@ block tableadds:
|
||||
tab.add "key", "value " & $i
|
||||
|
||||
main()
|
||||
echo "done"
|
||||
echo "done tableadds"
|
||||
|
||||
|
||||
block tcounttable:
|
||||
|
||||
@@ -120,7 +120,7 @@ proc match*(pattern: Pattern, s: string):
|
||||
if s.len != i:
|
||||
result.matched = false
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
let f = parsePattern("/show/@id/test/@show?/?")
|
||||
doAssert match(f, "/show/12/test/hallo/").matched
|
||||
doAssert match(f, "/show/2131726/test/jjjuuwąąss").matched
|
||||
|
||||
@@ -188,7 +188,7 @@ when not declared(normalizePath) and not declared(normalizedPath):
|
||||
result = path
|
||||
normalizePath(result)
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
var r = {:}.newStringTable
|
||||
parseUrlQuery("FirstName=Mickey", r)
|
||||
echo r
|
||||
|
||||
@@ -186,7 +186,7 @@ proc extractAll*(z: var ZipArchive, dest: string) =
|
||||
createDir(dest / file[0..file.rfind("/")])
|
||||
extractFile(z, file, dest / file)
|
||||
|
||||
when not defined(testing) and isMainModule:
|
||||
when not defined(testing) and true:
|
||||
var zip: ZipArchive
|
||||
if not zip.open("nim-0.11.0.zip"):
|
||||
raise newException(IOError, "opening zip failed")
|
||||
|
||||
@@ -36,7 +36,7 @@ proc pointlessWrapper(s: string): Data =
|
||||
proc main =
|
||||
var x = pointlessWrapper"test"
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
main()
|
||||
|
||||
# bug #985
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
output: '''true'''
|
||||
output: "turn_destroy_into_finalizer works"
|
||||
"""
|
||||
|
||||
type
|
||||
@@ -17,6 +17,9 @@ proc main =
|
||||
for i in 1..50_000:
|
||||
new(r)
|
||||
r.id = i
|
||||
echo destroyed > 30_000
|
||||
if destroyed > 30_000:
|
||||
echo "turn_destroy_into_finalizer works"
|
||||
else:
|
||||
echo "turn_destroy_into_finalizer failed: ", destroyed
|
||||
|
||||
main()
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
discard """
|
||||
output: '''
|
||||
tdiscardable
|
||||
1
|
||||
1
|
||||
'''
|
||||
"""
|
||||
|
||||
echo "tdiscardable"
|
||||
|
||||
# Test the discardable pragma
|
||||
|
||||
proc p(x, y: int): int {.discardable.} =
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
discard """
|
||||
output: '''
|
||||
tdistinct
|
||||
25
|
||||
'''
|
||||
"""
|
||||
|
||||
echo "tdistinct"
|
||||
|
||||
block tborrowdot:
|
||||
type
|
||||
@@ -18,8 +20,6 @@ block tborrowdot:
|
||||
bb.a = 90
|
||||
bb.s = "abc"
|
||||
|
||||
|
||||
|
||||
block tcurrncy:
|
||||
template Additive(typ: untyped) =
|
||||
proc `+`(x, y: typ): typ {.borrow.}
|
||||
@@ -53,8 +53,6 @@ block tcurrncy:
|
||||
DefineCurrency(TEuro, int)
|
||||
echo($( 12.TDollar + 13.TDollar )) #OUT 25
|
||||
|
||||
|
||||
|
||||
block tconsts:
|
||||
# bug #2641
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ type
|
||||
variables: seq[VarItem]
|
||||
children: seq[VarScope]
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
var scope1 = VarScope(
|
||||
variables: newSeq[VarItem](),
|
||||
children: newSeq[VarScope]()
|
||||
|
||||
@@ -66,7 +66,7 @@ template verifyStackTrace*(expectedStackTrace: string, body: untyped) =
|
||||
|
||||
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
# <-- Align with line 70 in the text editor
|
||||
block:
|
||||
proc bar() =
|
||||
|
||||
@@ -16,7 +16,6 @@ action: compile
|
||||
"""
|
||||
|
||||
# bug #9764
|
||||
|
||||
iterator s1(a:string): int = discard
|
||||
iterator s2(): int = discard
|
||||
template s3(): untyped = 123
|
||||
|
||||
@@ -81,7 +81,7 @@ proc debug[T](a: PBinaryTree[T]) =
|
||||
echo a.data
|
||||
debug(a.ri)
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
var
|
||||
root: PBinaryTree[string]
|
||||
x = newNode("hello")
|
||||
|
||||
@@ -10,7 +10,7 @@ type
|
||||
LBar = object
|
||||
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
doAssert FBar.new() == 3
|
||||
|
||||
proc new(_: typedesc[LFoo]): int = 0
|
||||
|
||||
@@ -26,7 +26,7 @@ proc `@||->`*[T](fn: proc(): T {.thread.},
|
||||
proc `||->`*[T](fn: proc(): T{.thread.}, callback: proc(val: T){.thread.}) =
|
||||
discard fn @||-> callback
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
import os
|
||||
proc testFunc(): int {.thread.} =
|
||||
return 1
|
||||
|
||||
@@ -108,7 +108,7 @@ proc `/`*[S](a, b: Vector2D[S]): Vector2D[S] =
|
||||
proc vec[S](x, y: S): Vector2D[S] =
|
||||
Vector2D[S](x: x, y: y)
|
||||
|
||||
if isMainModule:
|
||||
if true:
|
||||
# Comment out this let, and the program will fail to
|
||||
# compile with a type mismatch, as expected.
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ discard """
|
||||
4
|
||||
2
|
||||
88
|
||||
timplicit done
|
||||
'''
|
||||
"""
|
||||
|
||||
@@ -43,4 +44,6 @@ block:
|
||||
var indirect = p
|
||||
x.indirect(44)
|
||||
|
||||
echo x[]
|
||||
echo x[]
|
||||
|
||||
echo "timplicit done"
|
||||
|
||||
@@ -23,7 +23,7 @@ when true:
|
||||
for val in sortable:
|
||||
yield val
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
proc main =
|
||||
for val in byDistance([2, 3, 5, 1], 3):
|
||||
echo val
|
||||
|
||||
@@ -11,5 +11,5 @@ type
|
||||
|
||||
var console* {.importc.}: Console
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
console.log "Hello, world"
|
||||
|
||||
@@ -11,7 +11,7 @@ macro test_macro*(s: string, n: untyped): untyped =
|
||||
add(ass, newIdentNode("str"))
|
||||
add(ass, newStrLitNode("after"))
|
||||
add(result, ass)
|
||||
when isMainModule:
|
||||
when true:
|
||||
var str: string = "before"
|
||||
test_macro(str):
|
||||
var i : integer = 123
|
||||
|
||||
@@ -486,7 +486,7 @@ proc echo_help*(expected: seq[Tparameter_specification] = @[],
|
||||
echo line
|
||||
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
# Simply tests code embedded in docs.
|
||||
let
|
||||
parsed_param1 = new_parsed_parameter(PK_FLOAT, 3.41)
|
||||
|
||||
@@ -81,7 +81,7 @@ proc process_commandline(): Tcommandline_results =
|
||||
echo "Will use progress type $1" % [result.options[PARAM_PROGRESS[0]].str_val]
|
||||
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
let args = process_commandline()
|
||||
for param in args.positional_parameters:
|
||||
echo "Downloading $1" % param.str_val
|
||||
|
||||
@@ -252,7 +252,7 @@ template forwardPacketT*(typeName: expr): stmt {.dirty, immediate.} =
|
||||
proc `pack typeName`*(p: var typeName; s: PStream) =
|
||||
writeData(s, addr p, sizeof(p))
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
type
|
||||
SomeEnum = enum
|
||||
A = 0'i8,
|
||||
|
||||
@@ -244,7 +244,7 @@ template forwardPacketT*(typeName: untyped; underlyingType: untyped) {.dirty.} =
|
||||
#writeData(s, addr p, sizeof(p))
|
||||
buffer.write(underlyingType(ord))
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
type
|
||||
SomeEnum = enum
|
||||
A = 0'i8,
|
||||
|
||||
@@ -50,7 +50,7 @@ macro `?`(a: untyped): untyped =
|
||||
result = ($a[1].ident)[0].lit
|
||||
## echo(?F,?a,?t,?t,?y)
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
macro foo(x: untyped) =
|
||||
result = newNimNode(nnkStmtList)
|
||||
result.add(newNimNode(nnkCall).und(!!"echo", "Hello thar".lit))
|
||||
|
||||
@@ -24,7 +24,7 @@ proc writeLEStr*(s: PStream, str: string) =
|
||||
s.write(str.len.int16)
|
||||
s.write(str)
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
var testStream = newStringStream()
|
||||
|
||||
testStream.writeLEStr("Hello")
|
||||
|
||||
@@ -50,7 +50,7 @@ template withDir*(dir: string; body: stmt): stmt =
|
||||
body
|
||||
cd(curDir)
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
if not existsFile("nakefile.nim"):
|
||||
echo "No nakefile.nim found. Current working dir is ", getCurrentDir()
|
||||
quit 1
|
||||
|
||||
@@ -102,7 +102,7 @@ handlers[HZoneJoinReq] = proc(client: PClient; buffer: PBuffer) =
|
||||
|
||||
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
import parseopt, matchers, os, json
|
||||
|
||||
|
||||
|
||||
@@ -663,7 +663,7 @@ proc mainRender() =
|
||||
proc readyMainState() =
|
||||
specInputClient.setActive()
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
import parseopt
|
||||
|
||||
localPlayer = newPlayer()
|
||||
|
||||
@@ -106,7 +106,7 @@ proc readChar*(buffer: PBuffer): char {.inline.} = return readInt8(buffer).char
|
||||
proc readBool*(buffer: PBuffer): bool {.inline.} = return readInt8(buffer).bool
|
||||
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
var b = newBuffer(100)
|
||||
var str = "hello there"
|
||||
b.write str
|
||||
|
||||
@@ -17,7 +17,7 @@ template unless*(condition: untyped; body: untyped) {.dirty.} =
|
||||
if not condition:
|
||||
body
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
proc dumpSeq[T](x: seq[T]) =
|
||||
for index, item in x.pairs:
|
||||
echo index, " ", item
|
||||
|
||||
@@ -92,7 +92,7 @@ defPacket(DsMsg, tuple[msg: string])
|
||||
let HVerifyClient* = 'v'
|
||||
defPacket(SdVerifyClient, tuple[session: ScLogin])
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
|
||||
var buf = newBuffer(100)
|
||||
var m = toMd5("hello there")
|
||||
|
||||
@@ -20,7 +20,7 @@ proc uncompress*(source: string, destLen: var int): string =
|
||||
echo "Error occurred: ", res
|
||||
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
import strutils
|
||||
var r = compress("Hello")
|
||||
echo repr(r)
|
||||
|
||||
@@ -156,7 +156,7 @@ proc poll*(timeout: int = 250) =
|
||||
echo("Write ", c, " result: ", res, " data: ", repr(c.outputBuf.data))
|
||||
c.outputBuf.flush()
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
import parseopt, matchers, strutils
|
||||
var cfgFile = "dirserver_settings.json"
|
||||
for kind, key, val in getOpt():
|
||||
|
||||
@@ -141,7 +141,7 @@ proc poll*(timeout: int = 250) =
|
||||
echo("Write ", c, " result: ", res, " data: ", c.outputBuf.data)
|
||||
c.outputBuf.flush()
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
import parseopt, matchers, strutils
|
||||
var zoneCfgFile = "./server_settings.json"
|
||||
for kind, key, val in getOpt():
|
||||
|
||||
@@ -50,7 +50,7 @@ template withDir*(dir: string; body: untyped) =
|
||||
body
|
||||
cd(curDir)
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
if not existsFile("nakefile.nim"):
|
||||
echo "No nakefile.nim found. Current working dir is ", getCurrentDir()
|
||||
quit 1
|
||||
|
||||
@@ -11,7 +11,7 @@ type
|
||||
TMyEnum = enum
|
||||
meA, meB, meC, meD
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
{.hint: "this is the main file".}
|
||||
|
||||
proc fac[T](x: T): T =
|
||||
@@ -84,5 +84,5 @@ for i in 2..6:
|
||||
for j in countdown(i+4, 2):
|
||||
echo(fac(i * j))
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
{.hint: "this is the main file".}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
discard """
|
||||
output: '''
|
||||
start tradix.nim
|
||||
false
|
||||
false
|
||||
false
|
||||
@@ -29,6 +30,8 @@ false
|
||||
## We use a radix tree with node compression.
|
||||
## There are two node kinds:
|
||||
|
||||
echo "start tradix.nim"
|
||||
|
||||
const BitsPerUnit = 8*sizeof(int)
|
||||
|
||||
type
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
output: "done"
|
||||
output: "done tsortdev"
|
||||
"""
|
||||
|
||||
import algorithm, strutils
|
||||
@@ -55,5 +55,4 @@ proc main() =
|
||||
for i in 0..1_000:
|
||||
main()
|
||||
|
||||
echo "done"
|
||||
|
||||
echo "done tsortdev"
|
||||
|
||||
@@ -37,7 +37,7 @@ proc createMessage*(username, message: string): string =
|
||||
"message": %message
|
||||
}) & "\c\l"
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
block:
|
||||
let data = """{"username": "dom", "message": "hello"}"""
|
||||
let parsed = parseMessage(data)
|
||||
|
||||
@@ -79,7 +79,7 @@ proc loop(server: Server, port = 7687) {.async.} =
|
||||
|
||||
# Check whether this module has been imported as a dependency to another
|
||||
# module, or whether this module is the main module.
|
||||
when isMainModule:
|
||||
when true:
|
||||
# Initialise a new server.
|
||||
var server = newServer()
|
||||
echo("Server initialised!")
|
||||
|
||||
@@ -79,5 +79,5 @@ proc readChunks(filename: string, chunksize = 1000000): Stats =
|
||||
file.close()
|
||||
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
echo readChunks(filename)
|
||||
|
||||
@@ -64,5 +64,5 @@ proc readChunks(filename: string, chunksize = 1000000): Stats =
|
||||
file.close()
|
||||
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
echo readChunks(filename)
|
||||
|
||||
@@ -29,5 +29,5 @@ proc parse(filename: string): tuple[projectName, pageTitle: string,
|
||||
|
||||
file.close()
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
echo parse(filename)
|
||||
|
||||
@@ -70,7 +70,7 @@ proc readPageCounts(filename: string, chunkSize = 1_000_000) =
|
||||
|
||||
echo("Most popular is: ", mostPopular)
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
const file = "pagecounts-20160101-050000"
|
||||
let filename = getCurrentDir() / file
|
||||
readPageCounts(filename)
|
||||
|
||||
@@ -32,7 +32,7 @@ proc readPageCounts(filename: string) =
|
||||
|
||||
echo("Most popular is: ", mostPopular)
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
const file = "pagecounts-20160101-050000"
|
||||
let filename = getCurrentDir() / file
|
||||
readPageCounts(filename)
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
</div>
|
||||
#end proc
|
||||
#
|
||||
#when isMainModule:
|
||||
#when true:
|
||||
# echo renderUser(User(username: "d0m96<>", following: @[]))
|
||||
# echo renderMessages(@[
|
||||
# Message(username: "d0m96", time: getTime(), msg: "Hello World!"),
|
||||
|
||||
@@ -4,7 +4,7 @@ outputsub: "All tests finished successfully!"
|
||||
|
||||
import database, os, times
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
removeFile("tweeter_test.db")
|
||||
var db = newDatabase("tweeter_test.db")
|
||||
db.setup()
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
discard """
|
||||
output: '''
|
||||
start ta_out
|
||||
to stdout
|
||||
to stdout
|
||||
to stderr
|
||||
to stderr
|
||||
to stdout
|
||||
to stdout
|
||||
end ta_out
|
||||
'''
|
||||
"""
|
||||
|
||||
echo "start ta_out"
|
||||
|
||||
# This file is prefixed with an "a", because other tests
|
||||
# depend on it and it must be compiled first.
|
||||
stdout.writeLine("to stdout")
|
||||
@@ -25,3 +29,5 @@ stdout.writeLine("to stdout")
|
||||
stdout.flushFile()
|
||||
stdout.writeLine("to stdout")
|
||||
stdout.flushFile()
|
||||
|
||||
echo "end ta_out"
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
discard """
|
||||
output: ""
|
||||
"""
|
||||
|
||||
import osproc, streams, strutils, os
|
||||
|
||||
const NumberOfProcesses = 13
|
||||
@@ -13,8 +9,7 @@ proc execCb(idx: int, p: Process) =
|
||||
if exitCode < len(gResults):
|
||||
gResults[exitCode] = p.outputStream.readAll.strip
|
||||
|
||||
when isMainModule:
|
||||
|
||||
when true:
|
||||
if paramCount() == 0:
|
||||
gResults = newSeq[string](NumberOfProcesses)
|
||||
var checks = newSeq[string](NumberOfProcesses)
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
discard """
|
||||
output: '''--------------------------------------
|
||||
output: '''
|
||||
start tstderr
|
||||
--------------------------------------
|
||||
to stderr
|
||||
to stderr
|
||||
--------------------------------------
|
||||
'''
|
||||
"""
|
||||
|
||||
echo "start tstderr"
|
||||
|
||||
import osproc, os, streams
|
||||
|
||||
const filename = "ta_out".addFileExt(ExeExt)
|
||||
|
||||
@@ -34,5 +34,5 @@ proc main =
|
||||
sync()
|
||||
for ix in 1..3: channels[ix].close()
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
main()
|
||||
|
||||
@@ -28,5 +28,5 @@ proc main =
|
||||
sync()
|
||||
for ix in 1..3: channels[ix].close()
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
main()
|
||||
|
||||
@@ -35,5 +35,5 @@ proc main =
|
||||
sync()
|
||||
for ix in 1..3: channels[ix].close()
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
main()
|
||||
|
||||
@@ -36,6 +36,6 @@ proc update =
|
||||
for i in 0 .. people.high:
|
||||
spawn people[i].greet()
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
setup()
|
||||
update()
|
||||
|
||||
@@ -59,5 +59,5 @@ proc maino =
|
||||
|
||||
maino() # Doesn't work outside a proc
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
main()
|
||||
|
||||
@@ -48,6 +48,6 @@ proc update =
|
||||
|
||||
# ---
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
setup()
|
||||
update()
|
||||
|
||||
@@ -8,6 +8,6 @@ type mismatch: got <static[proc (a0: int): string{.noSideEffect, gcsafe, locks:
|
||||
macro fun(a: static float): untyped =
|
||||
discard
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
proc bar(a0: int): string = discard
|
||||
fun(bar)
|
||||
|
||||
@@ -3,7 +3,7 @@ discard """
|
||||
"""
|
||||
import json, strutils, options, tables
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
# Tests inspired by own use case (with some additional tests).
|
||||
# This should succeed.
|
||||
type
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
when isMainModule:
|
||||
when true:
|
||||
echo(stdin.readAll)
|
||||
|
||||
@@ -65,7 +65,7 @@ proc reindent*(value: string, preset_indent = 0): string =
|
||||
make([ html, xml, glsl, js, css, rst ])
|
||||
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
## Test tags
|
||||
|
||||
const script = js"""
|
||||
|
||||
@@ -340,6 +340,6 @@ macro tmpl*(body: untyped): untyped =
|
||||
|
||||
|
||||
# Run tests
|
||||
when isMainModule:
|
||||
when true:
|
||||
include otests
|
||||
echo "Success"
|
||||
|
||||
@@ -43,7 +43,7 @@ block t2629:
|
||||
|
||||
let rst_files = concat(glob_rst(), glob_rst("docs"))
|
||||
|
||||
when isMainModule: echo rst_files
|
||||
when true: echo rst_files
|
||||
|
||||
|
||||
block t5417:
|
||||
|
||||
@@ -15,7 +15,7 @@ template mathPerComponent(op: untyped): untyped =
|
||||
mathPerComponent(`***`)
|
||||
# bug #5285
|
||||
when true:
|
||||
if isMainModule:
|
||||
if true:
|
||||
var v1: array[3, float64]
|
||||
var v2: array[3, float64]
|
||||
echo repr(v1 *** v2)
|
||||
|
||||
@@ -18,5 +18,5 @@ template test_in(a, b, c: untyped): bool {.dirty.} =
|
||||
var result {.gensym.}: bool = false
|
||||
false
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
assert test_in(ret2, "test", str_val)
|
||||
|
||||
@@ -20,5 +20,5 @@ proc main =
|
||||
var f = Foo.new()
|
||||
echo f.b
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
main()
|
||||
|
||||
@@ -12,5 +12,5 @@ type
|
||||
|
||||
var foo {.threadvar.}: CircAlloc[1,Job]
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
echo foo.index
|
||||
|
||||
@@ -121,7 +121,7 @@ block tuple_with_seq:
|
||||
proc g(t: tuple[n:int, xs:seq[int]]) =
|
||||
discard
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
f(@[]) # OK
|
||||
g((1,@[1])) # OK
|
||||
g((0,@[])) # NG
|
||||
|
||||
@@ -16,7 +16,7 @@ proc foldRight[T,U](lst: seq[T], v: U, f: (T, U) -> U): U =
|
||||
proc mean[T: SomeNumber](xs: seq[T]): T =
|
||||
xs.foldRight(0.T, (xBAZ: auto, yBAZ: auto) => xBAZ + yBAZ) / T(xs.len)
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
let x = mean(@[1.float, 2, 3])
|
||||
echo x
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ proc Connect*(irc: var TIRC, nick: string, host: string, port: int = 6667) =
|
||||
|
||||
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
var irc = initIRC()
|
||||
irc.Connect("AmryBot[Nim]","irc.freenode.net",6667)
|
||||
irc.sendRaw("JOIN #nim")
|
||||
|
||||
@@ -20,7 +20,7 @@ from strutils import contains, toHex
|
||||
|
||||
from openssl import getOpenSSLVersion
|
||||
|
||||
when isMainModule:
|
||||
when true:
|
||||
echo "version: 0x" & $getOpenSSLVersion().toHex()
|
||||
|
||||
let client = newHttpClient()
|
||||
|
||||
@@ -14,4 +14,4 @@ proc initArray(): array[10, int] =
|
||||
for f in 0..<10:
|
||||
result[f] = 3
|
||||
|
||||
when isMainModule: echo repr(someTable)
|
||||
when true: echo repr(someTable)
|
||||
|
||||
Reference in New Issue
Block a user