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