mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-29 03:37:55 +00:00
updated tests to be executed
This commit is contained in:
@@ -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
|
||||
|
||||
import
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
discard """
|
||||
output: '''
|
||||
1
|
||||
2
|
||||
'''
|
||||
"""
|
||||
|
||||
proc p(a, b: int, c: proc ()) =
|
||||
c()
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
disabled: true
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
proc getDllName: string =
|
||||
@@ -12,5 +16,3 @@ proc myImport2(s: int) {.cdecl, importc, dynlib: getDllName().}
|
||||
|
||||
myImport("test2")
|
||||
myImport2(12)
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
action: compile
|
||||
"""
|
||||
|
||||
type
|
||||
Bar = object
|
||||
x: int
|
||||
|
||||
@@ -1,18 +1,25 @@
|
||||
discard """
|
||||
outputsub: "is newer than"
|
||||
"""
|
||||
# test the new LastModificationTime() proc
|
||||
|
||||
let
|
||||
file1 = "tests/testdata/data.csv"
|
||||
file2 = "tests/testdata/doc1.xml"
|
||||
|
||||
import
|
||||
os, times, strutils
|
||||
|
||||
proc main() =
|
||||
var
|
||||
a, b: Time
|
||||
a = getLastModificationTime(paramStr(1))
|
||||
b = getLastModificationTime(paramStr(2))
|
||||
a = getLastModificationTime(file1)
|
||||
b = getLastModificationTime(file2)
|
||||
writeLine(stdout, $a)
|
||||
writeLine(stdout, $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:
|
||||
write(stdout, "$1 is newer than $2\n" % [paramStr(1), paramStr(2)])
|
||||
write(stdout, "$1 is newer than $2\n" % [file1, file2])
|
||||
|
||||
main()
|
||||
|
||||
@@ -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
|
||||
|
||||
proc andTest() =
|
||||
@@ -84,4 +91,3 @@ proc main[T]() =
|
||||
echo myType2
|
||||
|
||||
main[int]()
|
||||
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
discard """
|
||||
outputsub: '''
|
||||
Simple tree node allocation worked!
|
||||
Simple cycle allocation worked!
|
||||
'''
|
||||
"""
|
||||
|
||||
# Test the implementation of the new operator
|
||||
# and the code generation for gc walkers
|
||||
# (and the garbage collector):
|
||||
|
||||
@@ -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
|
||||
|
||||
import
|
||||
|
||||
@@ -17,10 +17,7 @@ proc echoSeq(a: seq[int]) =
|
||||
for i in low(a)..high(a):
|
||||
echo(a[i])
|
||||
|
||||
var
|
||||
list: seq[int]
|
||||
|
||||
list = QuickSort(@[89,23,15,23,56,123,356,12,7,1,6,2,9,4,3])
|
||||
echoSeq(list)
|
||||
|
||||
let list = QuickSort(@[89,23,15,23,56,123,356,12,7,1,6,2,9,4,3])
|
||||
let expected = @[1, 2, 3, 4, 6, 7, 9, 12, 15, 23, 56, 89, 123, 356]
|
||||
|
||||
doAssert list == expected
|
||||
|
||||
@@ -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
|
||||
|
||||
## another method to store an efficient array of pointers:
|
||||
|
||||
@@ -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
|
||||
# Macintosh, Unix or Windows text format.
|
||||
|
||||
@@ -8,5 +16,6 @@ var
|
||||
if open(inp, "tests/misc/treadln.nim"):
|
||||
while not endOfFile(inp):
|
||||
line = readLine(inp)
|
||||
echo("#" & line & "#")
|
||||
if line.len >= 2 and line[0] == '#' and line[1] == ' ':
|
||||
echo line[2..^1]
|
||||
close(inp)
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
discard """
|
||||
output: '''
|
||||
mylist
|
||||
'''
|
||||
"""
|
||||
|
||||
|
||||
type
|
||||
TListItemType* = enum
|
||||
RedisNil, RedisString
|
||||
@@ -15,7 +22,8 @@ proc seq*() =
|
||||
|
||||
proc lrange*(key: string): TRedisList =
|
||||
var foo: TListItem
|
||||
foo.kind = RedisNil
|
||||
foo.kind = RedisString
|
||||
foo.str = key
|
||||
result = @[foo]
|
||||
|
||||
when isMainModule:
|
||||
|
||||
@@ -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!)
|
||||
|
||||
{.push stack_trace: on.}
|
||||
|
||||
@@ -23,4 +23,4 @@ proc editDistance(a, b: string): int =
|
||||
c[(i-1)*n + (j-1)] = min(x,min(y,z))
|
||||
return c[n*m]
|
||||
|
||||
write(stdout, editDistance("abc", "abd"))
|
||||
doAssert editDistance("abc", "abd") == 3
|
||||
|
||||
@@ -12,13 +12,13 @@ let t4 = (v2 mod 2'u64).uint64 # works
|
||||
# bug #2550
|
||||
|
||||
var x: uint # doesn't work
|
||||
echo x mod 2 == 0
|
||||
doAssert x mod 2 == 0
|
||||
|
||||
var y: uint64 # doesn't work
|
||||
echo y mod 2 == 0
|
||||
doAssert y mod 2 == 0
|
||||
|
||||
var z: uint32 # works
|
||||
echo z mod 2 == 0
|
||||
doAssert z mod 2 == 0
|
||||
|
||||
var a: int # works
|
||||
echo a mod 2 == 0
|
||||
doAssert a mod 2 == 0
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
action: compile
|
||||
"""
|
||||
|
||||
# Test various aspects
|
||||
|
||||
# bug #572
|
||||
|
||||
Reference in New Issue
Block a user