updated tests to be executed

This commit is contained in:
Arne Döring 2018-11-14 23:14:16 +01:00 • committed by Araq
commit e012eb1001
57 changed files with 341 additions and 90 deletions

View file

@ -1,3 +1,4 @@
import import
unittest, macros unittest, macros
@ -44,4 +45,3 @@ test "arithmetic failure":
expect(ArithmeticError, CatchableError): expect(ArithmeticError, CatchableError):
discard foo() discard foo()

View file

@ -231,4 +231,8 @@ when isMainModule:
except RangeError: except RangeError:
discard discard
# don't use causes integer overflow
doAssert compiles(random[int](low(int) .. high(int)))
main() main()

View file

@ -839,6 +839,11 @@ proc `$`*(zone: Timezone): string =
proc `==`*(zone1, zone2: Timezone): bool = proc `==`*(zone1, zone2: Timezone): bool =
## Two ``Timezone``'s are considered equal if their name is equal. ## Two ``Timezone``'s are considered equal if their name is equal.
if system.`==`(zone1, zone2):
return true
if zone1.isNil or zone2.isNil:
return false
runnableExamples: runnableExamples:
doAssert local() == local() doAssert local() == local()
doAssert local() != utc() doAssert local() != utc()
@ -1799,7 +1804,7 @@ proc formatPattern(dt: DateTime, pattern: FormatPattern, result: var string) =
of UUUU: of UUUU:
result.add $dt.year result.add $dt.year
of z, zz, zzz, zzzz: of z, zz, zzz, zzzz:
if dt.timezone.name == "Etc/UTC": if dt.timezone != nil and dt.timezone.name == "Etc/UTC":
result.add 'Z' result.add 'Z'
else: else:
result.add if -dt.utcOffset >= 0: '+' else: '-' result.add if -dt.utcOffset >= 0: '+' else: '-'

View file

@ -358,7 +358,7 @@ proc testSpec(r: var TResults, test: TTest, target = targetC) =
reExeNotFound) reExeNotFound)
continue continue
let exeCmd = (if isJsTarget: nodejs & " " else: "") & exeFile let exeCmd = nodejs & " " & quoteShell(exeFile)
var (buf, exitCode) = execCmdEx(exeCmd, options = {poStdErrToStdOut}) var (buf, exitCode) = execCmdEx(exeCmd, options = {poStdErrToStdOut})
# Treat all failure codes from nodejs as 1. Older versions of nodejs used # Treat all failure codes from nodejs as 1. Older versions of nodejs used

View file

@ -2,7 +2,7 @@ discard """
file: "tasyncall.nim" file: "tasyncall.nim"
exitcode: 0 exitcode: 0
""" """
import times, sequtils, unittest import times, sequtils
import asyncdispatch import asyncdispatch
const const

View file

@ -3,7 +3,12 @@ discard """
cmd: "nim $target --hints:on --define:ssl $options $file" cmd: "nim $target --hints:on --define:ssl $options $file"
output: "500" output: "500"
disabled: "windows" disabled: "windows"
target: c
action: compile
""" """
# XXX, deactivated
import asyncdispatch, asyncnet, net, strutils, os import asyncdispatch, asyncnet, net, strutils, os
when defined(ssl): when defined(ssl):

View file

@ -1,3 +1,6 @@
discard """
action: compile
"""
import strutils import strutils
@ -21,4 +24,3 @@ of 21: echo "21"
else: else:
{.linearScanEnd.} {.linearScanEnd.}
echo "default" echo "default"

View file

@ -1,8 +1,12 @@
discard """
output: ""
"""
import macros, strutils import macros, strutils
# https://github.com/nim-lang/Nim/issues/1512 # https://github.com/nim-lang/Nim/issues/1512
proc macrobust0(raw_input: string) = proc macrobust0(input: string): string =
var output = "" var output = ""
proc p1(a:string) = proc p1(a:string) =
output.add(a) output.add(a)
@ -27,13 +31,9 @@ proc macrobust0(raw_input: string) =
proc p19(a:string) = p18(a) proc p19(a:string) = p18(a)
proc p20(a:string) = p19(a) proc p20(a:string) = p19(a)
let input = $raw_input
for a in input.split(): for a in input.split():
p20(a) p20(a)
p19(a) p19(a)
p18(a) p18(a)
p17(a) p17(a)
p16(a) p16(a)
@ -53,11 +53,9 @@ proc macrobust0(raw_input: string) =
p2(a) p2(a)
p1(a) p1(a)
result = output
echo output macro macrobust(input: static[string]): untyped =
macro macrobust(raw_input: untyped): untyped =
var output = "" var output = ""
proc p1(a:string) = proc p1(a:string) =
output.add(a) output.add(a)
@ -82,12 +80,9 @@ macro macrobust(raw_input: untyped): untyped =
proc p19(a:string) = p18(a) proc p19(a:string) = p18(a)
proc p20(a:string) = p19(a) proc p20(a:string) = p19(a)
let input = $raw_input
for a in input.split(): for a in input.split():
p20(a) p20(a)
p19(a) p19(a)
p18(a) p18(a)
p17(a) p17(a)
p16(a) p16(a)
@ -105,11 +100,11 @@ macro macrobust(raw_input: untyped): untyped =
p4(a) p4(a)
p3(a) p3(a)
p2(a) p2(a)
p1(a)
echo output result = newLit(output)
discard result
macrobust """ const input = """
fdsasadfsdfa sadfsdafsdaf fdsasadfsdfa sadfsdafsdaf
dsfsdafdsfadsfa fsdaasdfasdf dsfsdafdsfadsfa fsdaasdfasdf
fsdafsadfsad asdfasdfasdf fsdafsadfsad asdfasdfasdf
@ -122,16 +117,7 @@ macrobust """
sdfasdafsadf sdfasdafsdaf sdfasdafsdaf sdfasdafsadf sdfasdafsdaf sdfasdafsdaf
""" """
let str1 = macrobust(input)
let str2 = macrobust0(input)
macrobust0 """ doAssert str1 == str2
fdsasadfsdfa sadfsdafsdaf
dsfsdafdsfadsfa fsdaasdfasdf
fsdafsadfsad asdfasdfasdf
fdsasdfasdfa sadfsadfsadf
sadfasdfsdaf sadfsdafsdaf dsfasdaf
sadfsdafsadf fdsasdafsadf fdsasadfsdaf
sdfasadfsdafdfsa sadfsadfsdaf
sdafsdaffsda sdfasadfsadf
fsdasdafsdfa sdfasdfafsda
sdfasdafsadf sdfasdafsdaf sdfasdafsdaf
"""

View file

@ -1,3 +1,10 @@
discard """
output: '''
@[2000-01-01T00:00:00+00:00, 2001-01-01T00:00:00+00:00, 2002-01-01T00:00:00+00:00, 2003-01-01T00:00:00+00:00, 2004-01-01T00:00:00+00:00, 2005-01-01T00:00:00+00:00, 2006-01-01T00:00:00+00:00, 2007-01-01T00:00:00+00:00, 2008-01-01T00:00:00+00:00, 2009-01-01T00:00:00+00:00, 2010-01-01T00:00:00+00:00, 2011-01-01T00:00:00+00:00, 2012-01-01T00:00:00+00:00, 2013-01-01T00:00:00+00:00, 2014-01-01T00:00:00+00:00, 2015-01-01T00:00:00+00:00]
@[2000-01-01T00:00:00+00:00, 2001-01-01T00:00:00+00:00, 2002-01-01T00:00:00+00:00, 2003-01-01T00:00:00+00:00, 2004-01-01T00:00:00+00:00, 2005-01-01T00:00:00+00:00, 2006-01-01T00:00:00+00:00, 2007-01-01T00:00:00+00:00, 2008-01-01T00:00:00+00:00, 2009-01-01T00:00:00+00:00, 2010-01-01T00:00:00+00:00, 2011-01-01T00:00:00+00:00, 2012-01-01T00:00:00+00:00, 2013-01-01T00:00:00+00:00, 2014-01-01T00:00:00+00:00, 2015-01-01T00:00:00+00:00]
'''
"""
# bug #2073 # bug #2073
import sequtils import sequtils

View file

@ -14,6 +14,7 @@ proc testExceptions(id: int, sleep: float) =
numbers.add(id) numbers.add(id)
raise (ref ValueError)() raise (ref ValueError)()
except: except:
suspend(sleep)
numbers.add(id) numbers.add(id)
suspend(sleep) suspend(sleep)
numbers.add(id) numbers.add(id)
@ -22,6 +23,6 @@ proc testExceptions(id: int, sleep: float) =
start(proc() = testExceptions(1, 0.01)) start(proc() = testExceptions(1, 0.01))
start(proc() = testExceptions(2, 0.011)) start(proc() = testExceptions(2, 0.011))
run() coro.run()
doAssert(stackCheckValue == 1100220033, "Thread stack got corrupted") doAssert(stackCheckValue == 1100220033, "Thread stack got corrupted")
doAssert(numbers == @[1, 2, 1, 2, 1, 2, 1, 2, 1, 2], "Coroutines executed in incorrect order") doAssert(numbers == @[1, 2, 1, 2, 1, 2, 1, 2, 1, 2], "Coroutines executed in incorrect order")

View file

@ -1,5 +1,6 @@
discard """ discard """
targets: "cpp" targets: "cpp"
action: compile
""" """
import tables, lists import tables, lists

View file

@ -1,4 +1,8 @@
discard """
output: '''
hi
'''
"""
import mdefaultprocparam import mdefaultprocparam
p() p()

View file

@ -1,3 +1,6 @@
# Test for the compiler to be able to compile a Nim file with spaces in it. discard """
output: "Successful"
"""
# Test for the compiler to be able to compile a Nim file with spaces in the directory name.
echo("Successful") echo("Successful")

View file

@ -1,3 +1,10 @@
discard """
output: '''
1
1
'''
"""
# Test the discardable pragma # Test the discardable pragma
proc p(x, y: int): int {.discardable.} = proc p(x, y: int): int {.discardable.} =

View file

@ -1,3 +1,8 @@
discard """
action: compile
"""
# XXX: it is not actually tested if the effects are inferred
type type
PMenu = ref object PMenu = ref object

View file

@ -1,3 +1,7 @@
discard """
action: compile
"""
#bug #712 #bug #712
import tables import tables

View file

@ -1,3 +1,13 @@
discard """
output: '''
Test
abcxyz123
'''
"""
proc fakeReadLine(): string =
"abcxyz123"
type type
TMaybe[T] = object TMaybe[T] = object
case empty: bool case empty: bool
@ -12,7 +22,7 @@ proc Nothing[T](): TMaybe[T] =
result.empty = true result.empty = true
proc safeReadLine(): TMaybe[string] = proc safeReadLine(): TMaybe[string] =
var r = stdin.readLine() var r = fakeReadLine()
if r == "": return Nothing[string]() if r == "": return Nothing[string]()
else: return Just(r) else: return Just(r)
@ -21,3 +31,4 @@ when isMainModule:
echo(Test.value) echo(Test.value)
var mSomething = safeReadLine() var mSomething = safeReadLine()
echo(mSomething.value) echo(mSomething.value)
mSomething = safeReadLine()

View file

@ -1,5 +1,6 @@
discard """ discard """
cmd: "nim $target --hints:on --threads:on $options $file" cmd: "nim $target --hints:on --threads:on $options $file"
action: compile
""" """
type type
@ -36,4 +37,3 @@ when isMainModule:
echo("test") echo("test")
joinThread(thr) joinThread(thr)
os.sleep(3000) os.sleep(3000)

View file

@ -1,3 +1,16 @@
discard """
output: '''
Length correct
Correct
Correct
Correct
Correct
Correct
Correct
Correct
Correct
'''
"""
type type
TIdObj* = object of RootObj TIdObj* = object of RootObj
@ -19,4 +32,3 @@ proc myNewString(L: int): string {.inline.} =
echo("Wrong") echo("Wrong")
var s = myNewString(8) var s = myNewString(8)

View file

@ -1,3 +1,10 @@
discard """
output: '''
[Suite] memoization
'''
"""
# This file needs to be called 'test' nim to provoke a clash # This file needs to be called 'test' nim to provoke a clash
# with the unittest.test name. Issue # # with the unittest.test name. Issue #
@ -14,4 +21,3 @@ proc fib(n: int): int = 40
suite "memoization": suite "memoization":
test "recursive function memoization": test "recursive function memoization":
check fastFib(40) == fib(40) check fastFib(40) == fib(40)

View file

@ -1,3 +1,10 @@
discard """
output: '''
This exe: /home/arne/proj/nim/Nim/tests/misc/tcmdline
Number of parameters: 0
tests/misc/tcmdline
'''
"""
# Test the command line # Test the command line
import import

View file

@ -1,3 +1,9 @@
discard """
output: '''
1
2
'''
"""
proc p(a, b: int, c: proc ()) = proc p(a, b: int, c: proc ()) =
c() c()

View file

@ -1,3 +1,7 @@
discard """
disabled: true
"""
import os import os
proc getDllName: string = proc getDllName: string =
@ -12,5 +16,3 @@ proc myImport2(s: int) {.cdecl, importc, dynlib: getDllName().}
myImport("test2") myImport("test2")
myImport2(12) myImport2(12)

View file

@ -1,3 +1,7 @@
discard """
action: compile
"""
type type
Bar = object Bar = object
x: int x: int

View file

@ -1,18 +1,25 @@
discard """
outputsub: "is newer than"
"""
# test the new LastModificationTime() proc # test the new LastModificationTime() proc
let
file1 = "tests/testdata/data.csv"
file2 = "tests/testdata/doc1.xml"
import import
os, times, strutils os, times, strutils
proc main() = proc main() =
var var
a, b: Time a, b: Time
a = getLastModificationTime(paramStr(1)) a = getLastModificationTime(file1)
b = getLastModificationTime(paramStr(2)) b = getLastModificationTime(file2)
writeLine(stdout, $a) writeLine(stdout, $a)
writeLine(stdout, $b) writeLine(stdout, $b)
if a < b: if a < b:
write(stdout, "$2 is newer than $1\n" % [paramStr(1), paramStr(2)]) write(stdout, "$2 is newer than $1\n" % [file1, file2])
else: else:
write(stdout, "$1 is newer than $2\n" % [paramStr(1), paramStr(2)]) write(stdout, "$1 is newer than $2\n" % [file1, file2])
main() main()

View file

@ -1,3 +1,10 @@
discard """
output: '''
Hello!(x: 1, y: 2, z: 3)
(x: 1.0, y: 2.0)
'''
"""
# Test nested loops and some other things # Test nested loops and some other things
proc andTest() = proc andTest() =
@ -84,4 +91,3 @@ proc main[T]() =
echo myType2 echo myType2
main[int]() main[int]()

View file

@ -1,3 +1,10 @@
discard """
outputsub: '''
Simple tree node allocation worked!
Simple cycle allocation worked!
'''
"""
# Test the implementation of the new operator # Test the implementation of the new operator
# and the code generation for gc walkers # and the code generation for gc walkers
# (and the garbage collector): # (and the garbage collector):

View file

@ -1,3 +1,11 @@
discard """
nimout: '''
tprep.nim(25, 9) Hint: Case 2 [User]
tprep.nim(27, 11) Hint: Case 2.3 [User]
'''
outputsub: ""
"""
# Test the features that used to belong to the preprocessor # Test the features that used to belong to the preprocessor
import import

View file

@ -17,10 +17,7 @@ proc echoSeq(a: seq[int]) =
for i in low(a)..high(a): for i in low(a)..high(a):
echo(a[i]) echo(a[i])
var let list = QuickSort(@[89,23,15,23,56,123,356,12,7,1,6,2,9,4,3])
list: seq[int] let expected = @[1, 2, 3, 4, 6, 7, 9, 12, 15, 23, 56, 89, 123, 356]
list = QuickSort(@[89,23,15,23,56,123,356,12,7,1,6,2,9,4,3])
echoSeq(list)
doAssert list == expected

View file

@ -1,3 +1,28 @@
discard """
output: '''
false
false
false
false
false
false
false
false
false
false
128
1
2
3
4
255
17
45
19000
4294967288
'''
"""
# implements and tests an efficient radix tree # implements and tests an efficient radix tree
## another method to store an efficient array of pointers: ## another method to store an efficient array of pointers:

View file

@ -1,3 +1,11 @@
discard """
output: '''
test the improved readline handling that does not care whether its
Macintosh, Unix or Windows text format.
'''
"""
# test the improved readline handling that does not care whether its # test the improved readline handling that does not care whether its
# Macintosh, Unix or Windows text format. # Macintosh, Unix or Windows text format.
@ -8,5 +16,6 @@ var
if open(inp, "tests/misc/treadln.nim"): if open(inp, "tests/misc/treadln.nim"):
while not endOfFile(inp): while not endOfFile(inp):
line = readLine(inp) line = readLine(inp)
echo("#" & line & "#") if line.len >= 2 and line[0] == '#' and line[1] == ' ':
echo line[2..^1]
close(inp) close(inp)

View file

@ -1,3 +1,10 @@
discard """
output: '''
mylist
'''
"""
type type
TListItemType* = enum TListItemType* = enum
RedisNil, RedisString RedisNil, RedisString
@ -15,7 +22,8 @@ proc seq*() =
proc lrange*(key: string): TRedisList = proc lrange*(key: string): TRedisList =
var foo: TListItem var foo: TListItem
foo.kind = RedisNil foo.kind = RedisString
foo.str = key
result = @[foo] result = @[foo]
when isMainModule: when isMainModule:

View file

@ -1,3 +1,23 @@
discard """
exitcode: 1
output: '''
Traceback (most recent call last)
tstrace.nim(36) tstrace
tstrace.nim(28) recTest
tstrace.nim(28) recTest
tstrace.nim(28) recTest
tstrace.nim(28) recTest
tstrace.nim(28) recTest
tstrace.nim(28) recTest
tstrace.nim(28) recTest
tstrace.nim(28) recTest
tstrace.nim(28) recTest
tstrace.nim(28) recTest
tstrace.nim(31) recTest
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
'''
"""
# Test the new stacktraces (great for debugging!) # Test the new stacktraces (great for debugging!)
{.push stack_trace: on.} {.push stack_trace: on.}

View file

@ -23,4 +23,4 @@ proc editDistance(a, b: string): int =
c[(i-1)*n + (j-1)] = min(x,min(y,z)) c[(i-1)*n + (j-1)] = min(x,min(y,z))
return c[n*m] return c[n*m]
write(stdout, editDistance("abc", "abd")) doAssert editDistance("abc", "abd") == 3

View file

@ -12,13 +12,13 @@ let t4 = (v2 mod 2'u64).uint64 # works
# bug #2550 # bug #2550
var x: uint # doesn't work var x: uint # doesn't work
echo x mod 2 == 0 doAssert x mod 2 == 0
var y: uint64 # doesn't work var y: uint64 # doesn't work
echo y mod 2 == 0 doAssert y mod 2 == 0
var z: uint32 # works var z: uint32 # works
echo z mod 2 == 0 doAssert z mod 2 == 0
var a: int # works var a: int # works
echo a mod 2 == 0 doAssert a mod 2 == 0

View file

@ -1,3 +1,7 @@
discard """
action: compile
"""
# Test various aspects # Test various aspects
# bug #572 # bug #572

View file

@ -1,6 +1,8 @@
discard """ discard """
msg: "Warning: cannot prove that field 'x.s' is accessible [ProveField]" msg: "Warning: cannot prove that field 'x.s' is accessible [ProveField]"
line:51 line:51
action: run
output: "abc abc"
""" """
import strutils import strutils

View file

@ -1,7 +1,10 @@
discard """
action: compile
"""
# bug #4671 # bug #4671
{.experimental.} {.experimental.}
{.this: self.} {.this: self.}
type type
SomeObj = object SomeObj = object
f: int f: int

View file

@ -1,5 +1,5 @@
discard """ discard """
ccodeCheck: "\\i @'deepCopy(' .*" ccodeCheck: "@'genericDeepCopy(' .*"
action: compile action: compile
""" """

View file

@ -1,11 +1,6 @@
discard """ discard """
sortoutput: true
output: ''' output: '''
Hello 1
Hello 2
Hello 3
Hello 4
Hello 5
Hello 6
0 0
1 1
2 2
@ -16,6 +11,12 @@ Hello 6
7 7
8 8
9 9
Hello 1
Hello 2
Hello 3
Hello 4
Hello 5
Hello 6
''' '''
""" """

View file

@ -1,5 +1,14 @@
import unittest
import hashes discard """
output: '''
[Suite] hashes
[Suite] hashing
'''
"""
import unittest, hashes
suite "hashes": suite "hashes":
suite "hashing": suite "hashing":

View file

@ -1,3 +1,6 @@
discard """
output: "[Suite] httpcore"
"""
import unittest import unittest

View file

@ -1,5 +1,11 @@
discard """
output: '''
{"data":[1]}
'''
"""
# Test case for https://github.com/nim-lang/Nim/issues/6385 # Test case for https://github.com/nim-lang/Nim/issues/6385
import mjsonexternproc import mjsonexternproc
# import json # import json
foo(1) foo(1)

View file

@ -1,3 +1,7 @@
discard """
disabled: true
"""
## JSON tests based on https://github.com/nst/JSONTestSuite ## JSON tests based on https://github.com/nst/JSONTestSuite
import unittest, import unittest,

View file

@ -1,14 +1,18 @@
discard """ discard """
outputsub: ""
""" """
import import
unittest, osproc, streams, os, strformat unittest, osproc, streams, os, strformat, strutils
const STRING_DATA = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." const STRING_DATA = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
const TEST_FILE = "tests/testdata/string.txt" const TEST_FILE = "tests/testdata/string.txt"
proc echoLoop(str: string): string = proc echoLoop(str: string): string =
result = "" result = ""
var process = startProcess(findExe("tests/system/helpers/readall_echo")) let exe = findExe("tests/system/helpers/readall_echo")
echo "exe: ", exe
var process = startProcess(exe)
var input = process.inputStream var input = process.inputStream
input.write(str) input.write(str)
input.close() input.close()
@ -22,10 +26,9 @@ suite "io":
test "stdin": test "stdin":
check: check:
echoLoop(STRING_DATA) == STRING_DATA echoLoop(STRING_DATA) == STRING_DATA
echoLoop(STRING_DATA[0..3999]) == STRING_DATA[0..3999]
test "file": test "file":
check: check:
readFile(TEST_FILE) == STRING_DATA readFile(TEST_FILE).strip == STRING_DATA
proc verifyFileSize(sz: int64) = proc verifyFileSize(sz: int64) =

View file

@ -1,3 +1,7 @@
discard """
output: "0"
"""
# bug #5135 # bug #5135
proc fail*[E](e: E): void = proc fail*[E](e: E): void =

View file

@ -1,13 +1,17 @@
# bug #1940 # bug #1940
discard """ discard """
nimout: '''=== nimout: '''
===
merge (A) with (B) merge (A) with (B)
merge (A B) with (C) merge (A B) with (C)
merge (A B C) with (D) merge (A B C) with (D)
merge (A B C D) with (E) merge (A B C D) with (E)
merge (A B C D E) with (F) merge (A B C D E) with (F)
===''' ===
'''
output: "A B C D E F"
""" """
type SqlStmt = tuple type SqlStmt = tuple

View file

@ -1,3 +1,7 @@
discard """
action: compile
"""
var var
e = "abc" e = "abc"

View file

@ -1,4 +1,15 @@
discard """
output: '''
0
1
2
3
0
1
2
3
'''
"""
# bug #1915 # bug #1915
import macros import macros

View file

@ -1,5 +1,8 @@
discard """
exitcode: 1
outputsub: "0"
"""
import tconfusinglocal import tconfusinglocal
fail "foo" fail "foo"

View file

@ -1,3 +1,11 @@
discard """
output: '''
1
yay
12
'''
"""
template withOpenFile(f: untyped, filename: string, mode: FileMode, template withOpenFile(f: untyped, filename: string, mode: FileMode,
actions: untyped): untyped = actions: untyped): untyped =

View file

@ -1,7 +1,8 @@
discard """
action: compile
"""
import db_sqlite import db_sqlite
var db: DbConn var db: DbConn
exec(db, sql"create table blabla()") exec(db, sql"create table blabla()")

View file

@ -1,3 +1,7 @@
discard """
output: "4"
"""
type type
TFoo = object TFoo = object
@ -25,4 +29,3 @@ echo f.second[1]
#echo `second[]`(f,1) #echo `second[]`(f,1)
# this is the only way I could use it, but not what I expected # this is the only way I could use it, but not what I expected

View file

@ -1,3 +1,9 @@
discard """
output: '''
M=1000, D=500, C=100, L=50, X=10, V=5, I=1
'''
"""
const romanNumbers = [ const romanNumbers = [
("M", 1000), ("D", 500), ("C", 100), ("M", 1000), ("D", 500), ("C", 100),
("L", 50), ("X", 10), ("V", 5), ("I", 1) ] ("L", 50), ("X", 10), ("V", 5), ("I", 1) ]
@ -12,5 +18,3 @@ for key, val in items(romanNumbers):
proc PrintBiTuple(t: tuple[k: string, v: int]): int = proc PrintBiTuple(t: tuple[k: string, v: int]): int =
stdout.write(t.k & "=" & $t.v & ", ") stdout.write(t.k & "=" & $t.v & ", ")
return 0 return 0

View file

@ -1,4 +1,5 @@
discard """ discard """
action: compile
""" """
import strutils import strutils
@ -28,4 +29,3 @@ Possible Commands:
CompileDate, CompileTime] CompileDate, CompileTime]
echo HelpText echo HelpText

View file

@ -1,3 +1,8 @@
discard """
nimout: "##"
"""
import macros import macros
proc testProc: string {.compileTime.} = proc testProc: string {.compileTime.} =
@ -14,9 +19,9 @@ when true:
const const
x = testProc() x = testProc()
echo "##", x, "##" doAssert x == ""
# bug #1310 # bug #1310
static: static:
var i, j: set[int8] = {} var i, j: set[int8] = {}
var k = i + j var k = i + j

View file

@ -7,6 +7,6 @@ const
relRes = slurp"./tslurp.nim" relRes = slurp"./tslurp.nim"
absRes = slurp(getScriptDir() / "tslurp.nim") absRes = slurp(getScriptDir() / "tslurp.nim")
echo relRes doAssert relRes.len > 200
echo absRes doAssert absRes.len > 200
doAssert relRes == absRes