mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-05 04:27:44 +00:00
tests themselves contain the expected result
This commit is contained in:
@@ -74,15 +74,18 @@ const
|
||||
|
||||
proc rawGetTok(c: var TCfgParser, tok: var TToken)
|
||||
|
||||
proc open*(c: var TCfgParser, input: PStream, filename: string) {.
|
||||
proc open*(c: var TCfgParser, input: PStream, filename: string,
|
||||
lineOffset = 0) {.
|
||||
rtl, extern: "npc$1".} =
|
||||
## initializes the parser with an input stream. `Filename` is only used
|
||||
## for nice error messages.
|
||||
## for nice error messages. `lineOffset` can be used to influence the line
|
||||
## number information in the generated error messages.
|
||||
lexbase.open(c, input)
|
||||
c.filename = filename
|
||||
c.state = startState
|
||||
c.tok.kind = tkInvalid
|
||||
c.tok.literal = ""
|
||||
inc(c.linenumber, lineOffset)
|
||||
rawGetTok(c, c.tok)
|
||||
|
||||
proc close*(c: var TCfgParser) {.rtl, extern: "npc$1".} =
|
||||
@@ -291,6 +294,23 @@ proc errorStr*(c: TCfgParser, msg: string): string {.rtl, extern: "npc$1".} =
|
||||
## column information.
|
||||
result = `%`("$1($2, $3) Error: $4",
|
||||
[c.filename, $getLine(c), $getColumn(c), msg])
|
||||
|
||||
proc warningStr*(c: TCfgParser, msg: string): string {.rtl, extern: "npc$1".} =
|
||||
## returns a properly formated warning message containing current line and
|
||||
## column information.
|
||||
result = `%`("$1($2, $3) Warning: $4",
|
||||
[c.filename, $getLine(c), $getColumn(c), msg])
|
||||
|
||||
proc ignoreMsg*(c: TCfgParser, e: TCfgEvent): string {.rtl, extern: "npc$1".} =
|
||||
## returns a properly formated warning message containing that
|
||||
## an entry is ignored.
|
||||
case e.kind
|
||||
of cfgSectionStart: result = c.warningStr("section ignored: " & e.section)
|
||||
of cfgKeyValuePair: result = c.warningStr("key ignored: " & e.key)
|
||||
of cfgOption:
|
||||
result = c.warningStr("command ignored: " & e.key & ": " & e.value)
|
||||
of cfgError: result = e.msg
|
||||
of cfgEof: result = ""
|
||||
|
||||
proc getKeyValPair(c: var TCfgParser, kind: TCfgEventKind): TCfgEvent =
|
||||
if c.tok.kind == tkSymbol:
|
||||
|
||||
@@ -271,7 +271,6 @@ when false:
|
||||
j = j * 10 + ord(frmt[i]) - ord('0')
|
||||
inc(i)
|
||||
if frmt[i] notin {'0'..'9'}: break
|
||||
num = j
|
||||
add(s, compiledArg(j))
|
||||
of '{':
|
||||
inc(i)
|
||||
@@ -281,7 +280,6 @@ when false:
|
||||
inc(i)
|
||||
if frmt[i] == '}': inc(i)
|
||||
else: raise newException(EInvalidValue, "invalid format string")
|
||||
num = j
|
||||
add(s, compiledArg(j))
|
||||
else: raise newException(EInvalidValue, "invalid format string")
|
||||
var start = i
|
||||
@@ -316,7 +314,6 @@ proc `%`*(frmt: string, args: openarray[PRope]): PRope {.
|
||||
j = j * 10 + ord(frmt[i]) - ord('0')
|
||||
inc(i)
|
||||
if frmt[i] notin {'0'..'9'}: break
|
||||
num = j
|
||||
add(result, args[j-1])
|
||||
of '{':
|
||||
inc(i)
|
||||
@@ -326,7 +323,6 @@ proc `%`*(frmt: string, args: openarray[PRope]): PRope {.
|
||||
inc(i)
|
||||
if frmt[i] == '}': inc(i)
|
||||
else: raise newException(EInvalidValue, "invalid format string")
|
||||
num = j
|
||||
add(result, args[j-1])
|
||||
else: raise newException(EInvalidValue, "invalid format string")
|
||||
var start = i
|
||||
|
||||
@@ -139,7 +139,7 @@ proc findNormalized(x: string, inArray: openarray[string]): int =
|
||||
var i = 0
|
||||
while i < high(inArray):
|
||||
if cmpIgnoreStyle(x, inArray[i]) == 0: return i
|
||||
inc(i, 2) # incrementing by 1 would probably result in a
|
||||
inc(i, 2) # incrementing by 1 would probably lead to a
|
||||
# security hole...
|
||||
return -1
|
||||
|
||||
@@ -166,7 +166,6 @@ proc addf*(s: var string, formatstr: string, a: openarray[string]) {.
|
||||
while formatstr[i] in Digits:
|
||||
j = j * 10 + ord(formatstr[i]) - ord('0')
|
||||
inc(i)
|
||||
num = j
|
||||
add s, a[j - 1]
|
||||
of '{':
|
||||
var j = i+1
|
||||
@@ -1003,5 +1002,6 @@ when isMainModule:
|
||||
it goes""", 10, false)
|
||||
assert formatBiggestFloat(0.00000000001, ffDecimal, 11) == "0.00000000001"
|
||||
assert formatBiggestFloat(0.00000000001, ffScientific, 1) == "1.0e-11"
|
||||
|
||||
|
||||
assert "$# $3 $# $#" % ["a", "b", "c"] == "a c b c"
|
||||
|
||||
|
||||
@@ -364,8 +364,8 @@ type
|
||||
TLineInfo*{.final.} = object # This is designed to be as small as possible,
|
||||
# because it is used
|
||||
# in syntax nodes. We safe space here by using
|
||||
# two int16 and an int32
|
||||
# on 64 bit and on 32 bit systems this is
|
||||
# two int16 and an int32.
|
||||
# On 64 bit and on 32 bit systems this is
|
||||
# only 8 bytes.
|
||||
line*, col*: int16
|
||||
fileIndex*: int32
|
||||
@@ -454,10 +454,8 @@ proc getMessageStr(msg: TMsgKind, arg: string): string =
|
||||
result = `%`(msgKindToString(msg), [arg])
|
||||
|
||||
proc inCheckpoint*(current: TLineInfo): bool =
|
||||
## prints the line information if in checkpoint
|
||||
result = false
|
||||
for i in countup(0, high(checkPoints)):
|
||||
if (current.line == checkPoints[i].line) and
|
||||
if (current.line >= checkPoints[i].line) and
|
||||
(current.fileIndex == (checkPoints[i].fileIndex)):
|
||||
return true
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ Name: "Nimrod"
|
||||
Version: "$version"
|
||||
; Windows and i386 must be first!
|
||||
OS: "windows;linux;macosx;freebsd;netbsd;openbsd;solaris"
|
||||
CPU: "i386;amd64;powerpc" # ;sparc
|
||||
CPU: "i386;amd64;powerpc64" # ;sparc
|
||||
Authors: "Andreas Rumpf"
|
||||
Description: """This is the Nimrod Compiler. Nimrod is a new statically typed,
|
||||
imperative programming language, that supports procedural, functional, object
|
||||
|
||||
@@ -143,8 +143,9 @@ const
|
||||
type
|
||||
TSystemCPU* = enum # Also add CPU for in initialization section and
|
||||
# alias conditionals to condsyms (end of module).
|
||||
cpuNone, cpuI386, cpuM68k, cpuAlpha, cpuPowerpc, cpuSparc, cpuVm, cpuIa64,
|
||||
cpuAmd64, cpuMips, cpuArm, cpuEcmaScript, cpuNimrodVM
|
||||
cpuNone, cpuI386, cpuM68k, cpuAlpha, cpuPowerpc, cpuPowerpc64,
|
||||
cpuSparc, cpuVm, cpuIa64, cpuAmd64, cpuMips, cpuArm,
|
||||
cpuEcmaScript, cpuNimrodVM
|
||||
|
||||
type
|
||||
TEndian* = enum
|
||||
@@ -158,7 +159,8 @@ const
|
||||
(name: "i386", intSize: 32, endian: littleEndian, floatSize: 64, bit: 32),
|
||||
(name: "m68k", intSize: 32, endian: bigEndian, floatSize: 64, bit: 32),
|
||||
(name: "alpha", intSize: 64, endian: littleEndian, floatSize: 64, bit: 64),
|
||||
(name: "powerpc", intSize: 32, endian: bigEndian, floatSize: 64, bit: 32),
|
||||
(name: "powerpc", intSize: 32, endian: bigEndian, floatSize: 64, bit: 32),
|
||||
(name: "powerpc64", intSize: 64, endian: bigEndian, floatSize: 64, bit: 64),
|
||||
(name: "sparc", intSize: 32, endian: bigEndian, floatSize: 64, bit: 32),
|
||||
(name: "vm", intSize: 32, endian: littleEndian, floatSize: 64, bit: 32),
|
||||
(name: "ia64", intSize: 64, endian: littleEndian, floatSize: 64, bit: 64),
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
## This file implements features required for IDE support.
|
||||
|
||||
import ast, astalgo, semdata, msgs, types
|
||||
import scanner, ast, astalgo, semdata, msgs, types
|
||||
|
||||
const
|
||||
sep = '\t'
|
||||
@@ -33,12 +33,16 @@ proc SymToStr(s: PSym, isLocal: bool): string =
|
||||
result.add(sep)
|
||||
result.add($ToColumn(s.info))
|
||||
|
||||
proc suggestSym(s: PSym): bool {.inline.} =
|
||||
result = s.name.s[0] in scanner.SymChars
|
||||
|
||||
proc suggestExpr*(c: PContext, n: PNode) =
|
||||
if not msgs.inCheckpoint(n.info): return
|
||||
|
||||
for i in countdown(c.tab.tos-1, 0):
|
||||
for it in items(c.tab.stack[i]):
|
||||
MessageOut(SymToStr(it, i > ModuleTablePos))
|
||||
if suggestSym(it):
|
||||
MessageOut(SymToStr(it, i > ModuleTablePos))
|
||||
quit(0)
|
||||
|
||||
proc suggestStmt*(c: PContext, n: PNode) =
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
tack.nim;125
|
||||
tambsym2.nim;7
|
||||
tambsys.nim;
|
||||
tarray.nim;10012
|
||||
tarraycons.nim;6
|
||||
tarray2.nim;[16, 25, 36]
|
||||
tarray3.nim;3
|
||||
tassert.nim;assertion failure!this shall be always written
|
||||
tbind1.nim;3
|
||||
tbind3.nim;1
|
||||
tbintre2.nim;helloworld99110223
|
||||
tbintree.nim;helloworld99110223
|
||||
tbug499771.nim;TSubRange: 5 from 1 to 10
|
||||
tbug511622.nim;3
|
||||
tcasestm.nim;ayyy
|
||||
tcgbug.nim;
|
||||
tclosure.nim;2 4 6 8 10
|
||||
tcnstseq.nim;AngelikaAnneAnnaAnkaAnja
|
||||
tconstr2.nim;69
|
||||
tcontinuexc.nim;ECcaught
|
||||
tcopy.nim;TEMP=C:\Programs\xyz\bin
|
||||
tcountup.nim;0123456789
|
||||
tcurrncy.nim;25
|
||||
temit.nim;509
|
||||
tenumhole.nim;my value A1my value Bconc2valueCabc4abc
|
||||
texcsub.nim;caught!
|
||||
texplicitgeneric1.nim;Key: 12 value: 12Key: 13 value: 13 Key: A value: 12 Key: B value: 13
|
||||
tfinally.nim;came here 3
|
||||
tfinally2.nim;ABCD
|
||||
tfinally3.nim;false
|
||||
tfloat1.nim;Error: unhandled exception: FPU operation caused an overflow [EFloatOverflow]
|
||||
tfloat2.nim;Error: unhandled exception: FPU operation caused a NaN result [EFloatInvalidOp]
|
||||
tfloat3.nim;Nimrod 3.4368930843, 0.3299290698 C double: 3.4368930843, 0.3299290698
|
||||
tformat.nim;Hi Andreas! How do you feel, Rumpf?
|
||||
thintoff.nim;0
|
||||
tinit.nim;Hello from module! Hello from main module!
|
||||
tints.nim;Success
|
||||
tisopr.nim;falsetrue
|
||||
titer2.nim;123
|
||||
titer3.nim;1231
|
||||
titer5.nim;abcxyz
|
||||
titer6.nim;000
|
||||
tlenopenarray.nim;1
|
||||
tlowhigh.nim;10
|
||||
tmatrix.nim;111
|
||||
tmultim1.nim;7
|
||||
tmultim2.nim;collide: unit, thing collide: unit, thing collide: thing, unit
|
||||
tmultim3.nim;Hi derived!
|
||||
tmultim4.nim;hello
|
||||
tnamedenumfields.nim;my value A0my value Bconc1valueCabc3abc
|
||||
tnestif.nim;i == 2
|
||||
tnestprc.nim;10
|
||||
toop1.nim;34[]o 5
|
||||
topenarrayrepr.nim;5 - [1]
|
||||
topenlen.nim;7
|
||||
toprprec.nim;done
|
||||
toverflw.nim;the computation overflowed
|
||||
toverflw2.nim;Error: unhandled exception: over- or underflow [EOverflow]
|
||||
toverl2.nim;true012
|
||||
toverlop.nim;3
|
||||
toverwr.nim;hello
|
||||
tovfint.nim;works!
|
||||
tpos.nim;6
|
||||
tprintf.nim;Andreas Rumpf
|
||||
tprocvar.nim;papbpcpdpe7
|
||||
tquotewords.nim;thisanexample
|
||||
tregex.nim;key: keyAYes!
|
||||
treguse.nim;055this should be the casehugh
|
||||
treraise.nim;Error: unhandled exception: bla [ESomeOtherErr]
|
||||
tromans.nim;success
|
||||
tseqcon.nim;Hithere, what's your name?Hathere, what's your name?
|
||||
tseqtuple.nim;fA13msg1falsefB14msg2truefC15msg3false
|
||||
tsets.nim;Ha ein F ist in s!
|
||||
tsidee2.nim;5
|
||||
tsidee3.nim;5
|
||||
tsimmeth.nim;HELLO WORLD!
|
||||
tsplit.nim;true
|
||||
tstrange.nim;hallo4
|
||||
tstrlits.nim;a""long string"""""abc"def
|
||||
tstrutil.nim;ha/home/a1xyz/usr/bin
|
||||
tvardecl.nim;44
|
||||
tvariantasgn.nim;came here
|
||||
tvariantstack.nim;came here
|
||||
tvarnums.nim;Success!
|
||||
tvartup.nim;2 3
|
||||
tunhandledexc.nim;Error: unhandled exception: bla [ESomeOtherErr]
|
||||
twrongexc.nim;Error: unhandled exception [EInvalidValue]
|
||||
txmlgen.nim;<h1><a href="http://force7.de/nimrod">Nimrod</a></h1>
|
||||
txmltree.nim;true
|
||||
|
Can't render this file because it contains an unexpected character in line 79 and column 15.
|
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tack.nim"
|
||||
output: "125"
|
||||
"""
|
||||
# the Ackermann function
|
||||
|
||||
proc ack(x, y: int): int =
|
||||
@@ -13,3 +17,5 @@ proc ack(x, y: int): int =
|
||||
|
||||
# echo(ack(0, 0))
|
||||
write(stdout, ack(3, 4)) #OUT 125
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tambsym2.nim"
|
||||
output: "7"
|
||||
"""
|
||||
# Test overloading of procs with locals
|
||||
|
||||
type
|
||||
@@ -16,3 +20,5 @@ m.len = 7
|
||||
m.data = "1234"
|
||||
|
||||
x(m, 5) #OUT 7
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tambsys.nim"
|
||||
output: ""
|
||||
"""
|
||||
# Test ambiguous symbols
|
||||
|
||||
import mambsys1, mambsys2
|
||||
@@ -5,3 +9,5 @@ import mambsys1, mambsys2
|
||||
var
|
||||
v: mambsys1.TExport
|
||||
mambsys2.foo(3) #OUT
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tarray.nim"
|
||||
output: "10012"
|
||||
"""
|
||||
# simple check for one dimensional arrays
|
||||
|
||||
type
|
||||
@@ -25,3 +29,5 @@ write(stdout, sum([1, 2, 3, 4]))
|
||||
write(stdout, sum([]))
|
||||
write(stdout, getPos( (x: 5, y: 7) ))
|
||||
#OUT 10012
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tarray2.nim"
|
||||
output: "[16, 25, 36]"
|
||||
"""
|
||||
# simple check for one dimensional arrays
|
||||
|
||||
type
|
||||
@@ -16,3 +20,5 @@ y = x
|
||||
echo repr(mul(x, y))
|
||||
|
||||
#OUT [16, 25, 36]
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tarray3.nim"
|
||||
output: "3"
|
||||
"""
|
||||
# simple check for two dimensional arrays
|
||||
|
||||
const
|
||||
@@ -5,3 +9,5 @@ const
|
||||
|
||||
echo myData[0][2] #OUT 3
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tarraycons.nim"
|
||||
output: "6"
|
||||
"""
|
||||
|
||||
type
|
||||
TEnum = enum
|
||||
@@ -15,3 +19,5 @@ const
|
||||
|
||||
echo myMapping[eC][1]
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tassert.nim"
|
||||
output: "assertion failure!this shall be always written"
|
||||
"""
|
||||
# test assert and exception handling
|
||||
|
||||
proc callB() = assert(False)
|
||||
@@ -14,3 +18,5 @@ finally:
|
||||
system.write(stdout, "this shall be always written")
|
||||
|
||||
assert(false) #OUT assertion failure!this shall be always written
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tbind1.nim"
|
||||
output: "3"
|
||||
"""
|
||||
# Test the new ``bind`` keyword for templates
|
||||
|
||||
proc p1(x: int8, y: int): int = return x + y
|
||||
@@ -12,3 +16,5 @@ proc p1(x: int, y: int8): int = return x - y
|
||||
|
||||
echo tempBind(1'i8, 2'i8) #OUT 3
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
discard """
|
||||
file: "tbind3.nim"
|
||||
output: "1"
|
||||
"""
|
||||
# Module B
|
||||
import mbind3
|
||||
|
||||
echo genId() #OUT 1
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tbintre2.nim"
|
||||
output: "helloworld99110223"
|
||||
"""
|
||||
# Same test, but check module boundaries
|
||||
|
||||
import tbintree
|
||||
@@ -23,3 +27,5 @@ for y in items(r2):
|
||||
|
||||
#OUT helloworld99110223
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tbintree.nim"
|
||||
output: "helloworld99110223"
|
||||
"""
|
||||
type
|
||||
TBinaryTree[T] = object # TBinaryTree is a generic type with
|
||||
# with generic param ``T``
|
||||
@@ -99,3 +103,5 @@ when isMainModule:
|
||||
stdout.write(y)
|
||||
|
||||
#OUT helloworld99110223
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
discard """
|
||||
file: "tbug499771.nim"
|
||||
output: "TSubRange: 5 from 1 to 10"
|
||||
"""
|
||||
type TSubRange = range[1 .. 10]
|
||||
var sr: TSubRange = 5
|
||||
echo("TSubRange: " & $sr & " from " & $low(TSubRange) & " to " &
|
||||
$high(TSubRange))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tbug511622.nim"
|
||||
output: "3"
|
||||
"""
|
||||
import StrUtils, Math
|
||||
|
||||
proc FibonacciA(n: int): int64 =
|
||||
@@ -8,3 +12,5 @@ proc FibonacciA(n: int): int64 =
|
||||
|
||||
echo FibonacciA(4) #OUT 3
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tcasestm.nim"
|
||||
output: "ayyy"
|
||||
"""
|
||||
# Test the case statement
|
||||
|
||||
type
|
||||
@@ -30,3 +34,5 @@ else:
|
||||
|
||||
#OUT ayyy
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tcgbug.nim"
|
||||
output: ""
|
||||
"""
|
||||
|
||||
type
|
||||
TObj = object
|
||||
@@ -15,3 +19,5 @@ var
|
||||
new(a)
|
||||
q(a)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tclosure.nim"
|
||||
output: "2 4 6 8 10"
|
||||
"""
|
||||
# Test the closure implementation
|
||||
|
||||
proc map(n: var openarray[int], fn: proc (x: int): int {.closure}) =
|
||||
@@ -24,3 +28,5 @@ for x in items(myData):
|
||||
#OUT 2 4 6 8 10
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tcnstseq.nim"
|
||||
output: "AngelikaAnneAnnaAnkaAnja"
|
||||
"""
|
||||
# Test the new implicit conversion from sequences to arrays in a constant
|
||||
# context.
|
||||
|
||||
@@ -9,3 +13,5 @@ const
|
||||
for x in items(myWords):
|
||||
write(stdout, x) #OUT AngelikaAnneAnnaAnkaAnja
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tconstr2.nim"
|
||||
output: "69"
|
||||
"""
|
||||
# Test array, record constructors
|
||||
|
||||
type
|
||||
@@ -18,3 +22,5 @@ const
|
||||
write(stdout, things[0].x)
|
||||
#OUT 69
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tcontinuexc.nim"
|
||||
output: "ECcaught"
|
||||
"""
|
||||
type
|
||||
ESomething = object of E_Base
|
||||
ESomeOtherErr = object of E_Base
|
||||
@@ -21,3 +25,5 @@ finally:
|
||||
|
||||
#OUT ECcaught
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tcopy.nim"
|
||||
output: "TEMP=C:\\Programs\\xyz\\bin"
|
||||
"""
|
||||
# tests the copy proc
|
||||
|
||||
import
|
||||
@@ -17,3 +21,5 @@ proc main() =
|
||||
|
||||
main()
|
||||
#OUT TEMP=C:\Programs\xyz\bin
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tcountup.nim"
|
||||
output: "0123456789"
|
||||
"""
|
||||
|
||||
# Test new countup and unary <
|
||||
|
||||
@@ -6,3 +10,5 @@ for i in 0 .. < 10'i64:
|
||||
|
||||
#OUT 0123456789
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tcurrncy.nim"
|
||||
output: "25"
|
||||
"""
|
||||
template Additive(typ: typeDesc): stmt =
|
||||
proc `+` *(x, y: typ): typ {.borrow.}
|
||||
proc `-` *(x, y: typ): typ {.borrow.}
|
||||
@@ -30,3 +34,5 @@ DefineCurrency(TDollar, int)
|
||||
DefineCurrency(TEuro, int)
|
||||
echo($( 12.TDollar + 13.TDollar )) #OUT 25
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "temit.nim"
|
||||
output: "509"
|
||||
"""
|
||||
# Test the new ``emit`` pragma:
|
||||
|
||||
{.emit: """
|
||||
@@ -12,3 +16,5 @@ proc embedsC() {.pure.} =
|
||||
embedsC()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tenumhole.nim"
|
||||
output: "my value A1my value Bconc2valueCabc4abc"
|
||||
"""
|
||||
|
||||
const
|
||||
strValB = "my value B"
|
||||
@@ -14,3 +18,5 @@ var x = valueD
|
||||
echo valueA, ord(valueA), valueB, ord(valueB), valueC, valueD, ord(valueD), x
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "texcsub.nim"
|
||||
output: "caught!"
|
||||
"""
|
||||
# Test inheritance for exception matching:
|
||||
|
||||
try:
|
||||
@@ -9,3 +13,5 @@ except:
|
||||
|
||||
#OUT caught!
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "texplicitgeneric1.nim"
|
||||
output: "Key: 12 value: 12Key: 13 value: 13 Key: A value: 12 Key: B value: 13"
|
||||
"""
|
||||
# test explicit type instantiation
|
||||
|
||||
type
|
||||
@@ -30,3 +34,5 @@ c.add('B', "13")
|
||||
for k, v in items(c):
|
||||
stdout.write(" Key: ", $k, " value: ", v)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
output: "Key: 12 value: 12Key: 13 value: 13 Key: A value: 12 Key: B value: 13"
|
||||
"""
|
||||
|
||||
# test explicit type instantiation
|
||||
|
||||
type
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tfinally.nim"
|
||||
output: "came here 3"
|
||||
"""
|
||||
# Test return in try statement:
|
||||
|
||||
proc main: int =
|
||||
@@ -13,3 +17,5 @@ proc main: int =
|
||||
|
||||
echo main() #OUT came here 3
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tfinally2.nim"
|
||||
output: "ABCD"
|
||||
"""
|
||||
# Test break in try statement:
|
||||
|
||||
proc main: int =
|
||||
@@ -19,3 +23,5 @@ proc main: int =
|
||||
|
||||
discard main() #OUT ABCD
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tfinally3.nim"
|
||||
output: "false"
|
||||
"""
|
||||
# Test break in try statement:
|
||||
|
||||
proc main: bool =
|
||||
@@ -10,3 +14,5 @@ proc main: bool =
|
||||
|
||||
echo main() #OUT false
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tfloat1.nim"
|
||||
output: "Error: unhandled exception: FPU operation caused an overflow [EFloatOverflow]"
|
||||
"""
|
||||
# Test new floating point exceptions
|
||||
|
||||
{.floatChecks: on.}
|
||||
@@ -6,3 +10,5 @@ var x = 0.8
|
||||
var y = 0.0
|
||||
|
||||
echo x / y #OUT Error: unhandled exception: FPU operation caused an overflow [EFloatOverflow]
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tfloat2.nim"
|
||||
output: "Error: unhandled exception: FPU operation caused a NaN result [EFloatInvalidOp]"
|
||||
"""
|
||||
# Test new floating point exceptions
|
||||
|
||||
{.floatChecks: on.}
|
||||
@@ -6,3 +10,5 @@ var x = 0.0
|
||||
var y = 0.0
|
||||
|
||||
echo x / y #OUT Error: unhandled exception: FPU operation caused a NaN result [EFloatInvalidOp]
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tfloat3.nim"
|
||||
output: "Nimrod 3.4368930843, 0.3299290698 C double: 3.4368930843, 0.3299290698"
|
||||
"""
|
||||
|
||||
import math, strutils
|
||||
|
||||
@@ -16,3 +20,5 @@ var x: float = 1.234567890123456789
|
||||
c_printf("Nimrod %.10f, %.10f ", exp(x), cos(x))
|
||||
printFloats()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
discard """
|
||||
file: "tformat.nim"
|
||||
output: "Hi Andreas! How do you feel, Rumpf?"
|
||||
"""
|
||||
# Tests the new format proc (including the & and &= operators)
|
||||
|
||||
import strutils
|
||||
|
||||
echo("Hi $1! How do you feel, $2?\n" % ["Andreas", "Rumpf"])
|
||||
#OUT Hi Andreas! How do you feel, Rumpf?
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
discard """
|
||||
file: "thintoff.nim"
|
||||
output: "0"
|
||||
"""
|
||||
|
||||
{.hint[XDeclaredButNotUsed]: off.}
|
||||
var
|
||||
x: int
|
||||
|
||||
echo x #OUT 0
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
discard """
|
||||
file: "tinit.nim"
|
||||
output: "Hello from module! Hello from main module!"
|
||||
"""
|
||||
# Test the new init section in modules
|
||||
|
||||
import minit
|
||||
|
||||
write(stdout, "Hello from main module!\n")
|
||||
#OUT Hello from module! Hello from main module!
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tints.nim"
|
||||
output: "Success"
|
||||
"""
|
||||
# Test the different integer operations
|
||||
|
||||
var testNumber = 0
|
||||
@@ -39,3 +43,5 @@ test(`shl`, 0xffffffff'i32, 0x4'i32, 0xfffffff0'i32)
|
||||
|
||||
Echo("Success") #OUT Success
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tisopr.nim"
|
||||
output: "falsetrue"
|
||||
"""
|
||||
# Test is operator
|
||||
|
||||
type
|
||||
@@ -18,3 +22,5 @@ write(stdout, p(m))
|
||||
write(stdout, p(n))
|
||||
|
||||
#OUT falsetrue
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "titer2.nim"
|
||||
output: "123"
|
||||
"""
|
||||
# Try to break the transformation pass:
|
||||
iterator iterAndZero(a: var openArray[int]): int =
|
||||
for i in 0..len(a)-1:
|
||||
@@ -8,3 +12,5 @@ var x = [[1, 2, 3], [4, 5, 6]]
|
||||
for y in iterAndZero(x[0]): write(stdout, $y)
|
||||
#OUT 123
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "titer3.nim"
|
||||
output: "1231"
|
||||
"""
|
||||
|
||||
iterator count1_3: int =
|
||||
yield 1
|
||||
@@ -14,4 +18,5 @@ iterator iter1(a: openArray[int]): int =
|
||||
var x = [[1, 2, 3], [4, 5, 6]]
|
||||
for y in iter1(x[0]): write(stdout, $y)
|
||||
|
||||
#OUT 1231
|
||||
#OUT 1231
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "titer5.nim"
|
||||
output: "abcxyz"
|
||||
"""
|
||||
# Test method call syntax for iterators:
|
||||
import strutils
|
||||
|
||||
@@ -8,3 +12,5 @@ for x in lines.split():
|
||||
|
||||
#OUT abcxyz
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "titer6.nim"
|
||||
output: "000"
|
||||
"""
|
||||
# Test iterator with more than 1 yield statement
|
||||
|
||||
import strutils
|
||||
@@ -29,3 +33,5 @@ proc wordWrap2(s: string, maxLineWidth = 80,
|
||||
for word, isSep in tokenize2(s, seps):
|
||||
var w = 0
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
discard """
|
||||
file: "tlenopenarray.nim"
|
||||
output: "1"
|
||||
"""
|
||||
|
||||
# len(x) --> len([x]) --> match!
|
||||
echo len(1_000_000) #OUT 1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tlowhigh.nim"
|
||||
output: "10"
|
||||
"""
|
||||
# Test the magic low() and high() procs
|
||||
|
||||
type
|
||||
@@ -16,3 +20,5 @@ proc sum(a: openarray[int]): int =
|
||||
|
||||
write(stdout, sum([1, 2, 3, 4]))
|
||||
#OUT 10
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tmatrix.nim"
|
||||
output: "111"
|
||||
"""
|
||||
# Test overloading of [] with multiple indices
|
||||
|
||||
type
|
||||
@@ -58,3 +62,5 @@ for i in 0..w-1:
|
||||
|
||||
for i in 0..w-1:
|
||||
stdout.write(m[i,i]) #OUT 111
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tmultim1.nim"
|
||||
output: "7"
|
||||
"""
|
||||
# Test multi methods
|
||||
|
||||
type
|
||||
@@ -21,3 +25,5 @@ proc newPlus(a, b: ref TExpr): ref TPlusExpr =
|
||||
result.b = b
|
||||
|
||||
echo eval(newPlus(newPlus(newLit(1), newLit(2)), newLit(4))) #OUT 7
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tmultim2.nim"
|
||||
output: "collide: unit, thing collide: unit, thing collide: thing, unit"
|
||||
"""
|
||||
# Test multi methods
|
||||
|
||||
type
|
||||
@@ -28,3 +32,5 @@ collide(a, b)
|
||||
#OUT collide: unit, thing collide: unit, thing collide: thing, unit
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tmultim3.nim"
|
||||
output: "Hi derived!"
|
||||
"""
|
||||
import mmultim3
|
||||
|
||||
type
|
||||
@@ -12,3 +16,5 @@ new(a)
|
||||
myObj = a
|
||||
testMyObj()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tmultim4.nim"
|
||||
output: "hello"
|
||||
"""
|
||||
type
|
||||
Test = object of TObject
|
||||
|
||||
@@ -37,3 +41,5 @@ for z in 1..4:
|
||||
# break
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tnamedenumfields.nim"
|
||||
output: "my value A0my value Bconc1valueCabc3abc"
|
||||
"""
|
||||
|
||||
const
|
||||
strValB = "my value B"
|
||||
@@ -15,3 +19,5 @@ var x = valueD
|
||||
echo valueA, ord(valueA), valueB, ord(valueB), valueC, valueD, ord(valueD), x
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tnestif.nim"
|
||||
output: "i == 2"
|
||||
"""
|
||||
# test nested ifs
|
||||
|
||||
var
|
||||
@@ -16,3 +20,5 @@ elif x == 2:
|
||||
else:
|
||||
write(stdout, "looks like Python")
|
||||
#OUT i == 2
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tnestprc.nim"
|
||||
output: "10"
|
||||
"""
|
||||
# Test nested procs without closures
|
||||
|
||||
proc Add3(x: int): int =
|
||||
@@ -8,3 +12,5 @@ proc Add3(x: int): int =
|
||||
|
||||
echo Add3(7) #OUT 10
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "toop1.nim"
|
||||
output: "34[]o 5"
|
||||
"""
|
||||
# Test the stuff in the tutorial
|
||||
import macros
|
||||
|
||||
@@ -80,3 +84,5 @@ c!draw()
|
||||
|
||||
#OUT 34[]o 5
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "topenarrayrepr.nim"
|
||||
output: "5 - [1]"
|
||||
"""
|
||||
type
|
||||
TProc = proc (n: int, m: openarray[int64])
|
||||
|
||||
@@ -9,3 +13,5 @@ proc Bar(n: int, m: openarray[int64]) =
|
||||
|
||||
Foo(5, Bar) #OUT 5 - [1]
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "topenlen.nim"
|
||||
output: "7"
|
||||
"""
|
||||
# Tests a special bug
|
||||
|
||||
proc choose(b: openArray[string]): string = return b[0]
|
||||
@@ -10,3 +14,5 @@ proc p(a, b: openarray[string]): int =
|
||||
|
||||
discard choose(["sh", "-c", $p([""], ["a"])])
|
||||
echo($p(["", "ha", "abc"], ["xyz"])) #OUT 7
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "toprprec.nim"
|
||||
output: "done"
|
||||
"""
|
||||
# Test operator precedence:
|
||||
|
||||
assert 3+5*5-2 == 28- -26-28
|
||||
@@ -10,3 +14,5 @@ assert 34 ^- 6 ^- 2 == 30
|
||||
assert 34 - 6 - 2 == 26
|
||||
echo "done"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "toverflw.nim"
|
||||
output: "the computation overflowed"
|
||||
"""
|
||||
# Tests nimrod's ability to detect overflows
|
||||
|
||||
{.push overflowChecks: on.}
|
||||
@@ -13,3 +17,5 @@ except EOverflow:
|
||||
|
||||
{.pop.} # overflow check
|
||||
#OUT the computation overflowed
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
discard """
|
||||
file: "toverflw2.nim"
|
||||
output: "Error: unhandled exception: over- or underflow [EOverflow]"
|
||||
"""
|
||||
var a : int32 = 2147483647
|
||||
var b : int32 = 2147483647
|
||||
var c = a + b
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "toverl2.nim"
|
||||
output: "true012"
|
||||
"""
|
||||
# Test new overloading resolution rules
|
||||
|
||||
import strutils
|
||||
@@ -19,3 +23,5 @@ for x in toverl2(3):
|
||||
stdout.write("\n")
|
||||
#OUT true012
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "toverlop.nim"
|
||||
output: "3"
|
||||
"""
|
||||
# Test operator overloading
|
||||
|
||||
proc `%` (a, b: int): int =
|
||||
@@ -8,3 +12,5 @@ x = 15
|
||||
y = 6
|
||||
write(stdout, x % y)
|
||||
#OUT 3
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "toverwr.nim"
|
||||
output: "hello"
|
||||
"""
|
||||
# Test the overloading resolution in connection with a qualifier
|
||||
|
||||
proc write(t: TFile, s: string) =
|
||||
@@ -5,3 +9,5 @@ proc write(t: TFile, s: string) =
|
||||
|
||||
system.write(stdout, "hello")
|
||||
#OUT hello
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tovfint.nim"
|
||||
output: "works!"
|
||||
"""
|
||||
# this tests the new overflow literals
|
||||
|
||||
var
|
||||
@@ -15,3 +19,5 @@ else:
|
||||
write(stdout, "broken!\n")
|
||||
|
||||
#OUT works!
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tpos.nim"
|
||||
output: "6"
|
||||
"""
|
||||
# test this particular function
|
||||
|
||||
proc mypos(sub, s: string, start: int = 0): int =
|
||||
@@ -27,3 +31,5 @@ var sub = "hello"
|
||||
var s = "world hello"
|
||||
write(stdout, mypos(sub, s))
|
||||
#OUT 6
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tprintf.nim"
|
||||
output: "Andreas Rumpf"
|
||||
"""
|
||||
# Test a printf proc
|
||||
|
||||
proc printf(file: TFile, args: openarray[string]) =
|
||||
@@ -8,3 +12,5 @@ proc printf(file: TFile, args: openarray[string]) =
|
||||
|
||||
printf(stdout, ["Andreas ", "Rumpf\n"])
|
||||
#OUT Andreas Rumpf
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tprocvar.nim"
|
||||
output: "papbpcpdpe7"
|
||||
"""
|
||||
# test variables of type proc
|
||||
|
||||
proc pa() {.cdecl.} = write(stdout, "pa")
|
||||
@@ -24,3 +28,5 @@ discard x(3, 4)
|
||||
|
||||
#OUT papbpcpdpe7
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tquotewords.nim"
|
||||
output: "thisanexample"
|
||||
"""
|
||||
# Test an idea I recently had:
|
||||
|
||||
import macros
|
||||
@@ -17,3 +21,5 @@ for w in items(myWordList):
|
||||
|
||||
echo s #OUT thisanexample
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tregex.nim"
|
||||
output: "key: keyAYes!"
|
||||
"""
|
||||
# Test the new regular expression module
|
||||
# which is based on the PCRE library
|
||||
|
||||
@@ -18,3 +22,5 @@ else:
|
||||
echo("Bug!")
|
||||
|
||||
#OUT key: keyAYes!
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "treguse.nim"
|
||||
output: "055this should be the casehugh"
|
||||
"""
|
||||
# Test the register usage of the virtual machine and
|
||||
# the blocks in var statements
|
||||
|
||||
@@ -19,3 +23,5 @@ proc main(a, b: int) =
|
||||
|
||||
main(45, 1000)
|
||||
#OUT 055this should be the casehugh
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "treraise.nim"
|
||||
output: "Error: unhandled exception: bla [ESomeOtherErr]"
|
||||
"""
|
||||
type
|
||||
ESomething = object of E_Base
|
||||
ESomeOtherErr = object of E_Base
|
||||
@@ -15,3 +19,5 @@ except ESomething:
|
||||
except:
|
||||
raise
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tromans.nim"
|
||||
output: "success"
|
||||
"""
|
||||
import
|
||||
strutils
|
||||
|
||||
@@ -63,3 +67,5 @@ for i in items([1238, 1777, 3830, 2401, 379, 33, 940, 3973]):
|
||||
|
||||
echo "success" #OUT success
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tseqcon.nim"
|
||||
output: "Hithere, what\'s your name?Hathere, what\'s your name?"
|
||||
"""
|
||||
# Test the add proc for sequences and strings
|
||||
|
||||
const
|
||||
@@ -43,3 +47,5 @@ when nestedFixed:
|
||||
nested()
|
||||
|
||||
#OUT Hithere, what's your name?Hathere, what's your name?
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tseqtuple.nim"
|
||||
output: "fA13msg1falsefB14msg2truefC15msg3false"
|
||||
"""
|
||||
|
||||
type
|
||||
TMsg = tuple[
|
||||
@@ -20,3 +24,5 @@ for file, line, msg, err in items(s):
|
||||
|
||||
#OUT fA13msg1falsefB14msg2truefC15msg3false
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tsets.nim"
|
||||
output: "Ha ein F ist in s!"
|
||||
"""
|
||||
# Test the handling of sets
|
||||
|
||||
import
|
||||
@@ -56,3 +60,5 @@ for x in low(TTokTypeRange) .. high(TTokTypeRange):
|
||||
#writeln(stdout, "the token '$1' is in the set" % repr(x))
|
||||
|
||||
#OUT Ha ein F ist in s!
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tsidee2.nim"
|
||||
output: "5"
|
||||
"""
|
||||
|
||||
var
|
||||
global: int
|
||||
@@ -9,3 +13,5 @@ proc SideEffectLyer(x, y: int): int {.noSideEffect.} =
|
||||
|
||||
echo SideEffectLyer(1, 3) #OUT 5
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tsidee3.nim"
|
||||
output: "5"
|
||||
"""
|
||||
|
||||
var
|
||||
global: int
|
||||
@@ -9,3 +13,5 @@ proc noSideEffect(x, y: int, p: proc (a: int): int {.noSideEffect.}): int {.noSi
|
||||
|
||||
echo noSideEffect(1, 3, dontcare) #OUT 5
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tsimmeth.nim"
|
||||
output: "HELLO WORLD!"
|
||||
"""
|
||||
# Test method simulation
|
||||
|
||||
import strutils
|
||||
@@ -6,3 +10,5 @@ var x = "hello world!".toLower.toUpper
|
||||
x.echo()
|
||||
#OUT HELLO WORLD!
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tsplit.nim"
|
||||
output: "true"
|
||||
"""
|
||||
import strutils
|
||||
|
||||
var s = ""
|
||||
@@ -12,3 +16,5 @@ else:
|
||||
|
||||
#OUT true
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tstrange.nim"
|
||||
output: "hallo4"
|
||||
"""
|
||||
# test for extremely strange bug
|
||||
|
||||
proc ack(x: int, y: int): int =
|
||||
@@ -15,3 +19,5 @@ gen("hallo")
|
||||
write(stdout, ack(5, 4))
|
||||
#OUT hallo4
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tstrlits.nim"
|
||||
output: "a\"\"long string\"\"\"\"\"abc\"def"
|
||||
"""
|
||||
# Test the new different string literals
|
||||
|
||||
const
|
||||
@@ -12,3 +16,5 @@ stdout.write(tripleEmpty)
|
||||
stdout.write(raw)
|
||||
#OUT a""long string"""""abc"def
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tstrutil.nim"
|
||||
output: "ha/home/a1xyz/usr/bin"
|
||||
"""
|
||||
# test the new strutils module
|
||||
|
||||
import
|
||||
@@ -37,3 +41,5 @@ assert(editDistance("prefix__hallo_suffix", "prefix__hao_suffix") == 2)
|
||||
|
||||
main()
|
||||
#OUT ha/home/a1xyz/usr/bin
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tunhandledexc.nim"
|
||||
output: "Error: unhandled exception: bla [ESomeOtherErr]"
|
||||
"""
|
||||
type
|
||||
ESomething = object of E_Base
|
||||
ESomeOtherErr = object of E_Base
|
||||
@@ -14,3 +18,5 @@ when True:
|
||||
except ESomething:
|
||||
echo("Error happened")
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tvardecl.nim"
|
||||
output: "44"
|
||||
"""
|
||||
# Test the new variable declaration syntax
|
||||
|
||||
var
|
||||
@@ -7,3 +11,5 @@ var
|
||||
|
||||
write(stdout, a)
|
||||
write(stdout, b) #OUT 44
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tvariantasgn.nim"
|
||||
output: "came here"
|
||||
"""
|
||||
#BUG
|
||||
type
|
||||
TAnyKind = enum
|
||||
@@ -22,3 +26,5 @@ nr.intVal = 78
|
||||
# s = nr # works
|
||||
nr = s # fails!
|
||||
echo "came here"
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tvariantstack.nim"
|
||||
output: "came here"
|
||||
"""
|
||||
#BUG
|
||||
type
|
||||
TAnyKind = enum
|
||||
@@ -44,3 +48,5 @@ stack.push(nr)
|
||||
var t = stack.pop()
|
||||
echo "came here"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tvarnums.nim"
|
||||
output: "Success!"
|
||||
"""
|
||||
# Test variable length binary integers
|
||||
|
||||
import
|
||||
@@ -134,3 +138,5 @@ tm(low(int32))
|
||||
tm(high(int32))
|
||||
|
||||
writeln(stdout, "Success!") #OUT Success!
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "tvartup.nim"
|
||||
output: "2 3"
|
||||
"""
|
||||
# Test the new tuple unpacking
|
||||
|
||||
proc divmod(a, b: int): tuple[di, mo: int] =
|
||||
@@ -9,3 +13,5 @@ stdout.write(" ")
|
||||
stdout.write(y)
|
||||
|
||||
#OUT 2 3
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
discard """
|
||||
file: "twrongexc.nim"
|
||||
output: "Error: unhandled exception [EInvalidValue]"
|
||||
"""
|
||||
try:
|
||||
raise newException(EInvalidValue, "")
|
||||
except EOverflow:
|
||||
echo("Error caught")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
discard """
|
||||
file: "txmlgen.nim"
|
||||
output: "<h1><a href=\"http://force7.de/nimrod\">Nimrod</a></h1>"
|
||||
"""
|
||||
import xmlgen
|
||||
|
||||
var nim = "Nimrod"
|
||||
echo h1(a(href="http://force7.de/nimrod", nim))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
file: "txmltree.nim"
|
||||
output: "true"
|
||||
"""
|
||||
|
||||
import xmltree, strtabs
|
||||
|
||||
@@ -5,3 +9,5 @@ var x = <>a(href="nimrod.de", newText("www.nimrod-test.de"))
|
||||
|
||||
echo($x == "<a href=\"nimrod.de\">www.nimrod-test.de</a>")
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
t99bott.nim;20;constant expression expected
|
||||
tadrdisc.nim;15;for a 'var' type a variable needs to be passed
|
||||
tambsym.nim;6;ambiguous identifier
|
||||
tambsym2.nim;4;undeclared identifier: 'CreateRGBSurface'
|
||||
tambsym3.nim;6;ambiguous identifier
|
||||
tarraycons.nim;9;invalid order in array constructor
|
||||
tatomic.nim;2;identifier expected, but found 'atomic'
|
||||
tbind2.nim;7;ambiguous call
|
||||
tbind4.nim;4;undeclared identifier: 'lastId'
|
||||
tblock1.nim;9;undeclared identifier: 'ha'
|
||||
tconstr1.nim;20;type mismatch
|
||||
tillrec.nim;8;illegal recursion in type 'TIllegal'
|
||||
tinc.nim;3;for a 'var' type a variable needs to be passed
|
||||
tinout.nim;7;for a 'var' type a variable needs to be passed
|
||||
tinvalidnewseq.nim;10;type mismatch: got (array[0..6, string], int)
|
||||
tinvwhen.nim;6;invalid indentation
|
||||
titer4.nim;2;iterator within for loop context expected
|
||||
tmethod.nim;2;'method' needs a parameter that has an object type
|
||||
tnamedparams.nim;3; Error: type mismatch: got (input: string, filename: string, line: int, col: int)
|
||||
tnamspc.nim;5;undeclared identifier: 'global'
|
||||
tnoop.nim;6;expression 'a()' cannot be called
|
||||
tnot.nim;9;type mismatch
|
||||
topaque.nim;11;undeclared field: 'buffer'
|
||||
topena1.nim;4;invalid type
|
||||
toverl.nim;6;attempt to redefine 'TNone'
|
||||
trawstr.nim;5;closing " expected
|
||||
trecinca.nim;3;recursive dependency: 'tests/reject/trecincb.nim'
|
||||
trecincb.nim;4;recursive dependency: 'tests/reject/trecincb.nim'
|
||||
treciter.nim;4;recursive dependency: 'myrec'
|
||||
trectype.nim;20;internal error: cannot generate C type for: PA
|
||||
trefs.nim;15;type mismatch
|
||||
tsidee1.nim;7;'SideEffectLyer' can have side effects
|
||||
tsidee4.nim;10;type mismatch
|
||||
tsimtych.nim;5;type mismatch: got (bool) but expected 'string'
|
||||
tstatret.nim;4;statement not allowed after
|
||||
tstmtexp.nim;3;value returned by statement has to be discarded
|
||||
ttempl2.nim;13;undeclared identifier: 'b'
|
||||
ttypelessemptyset.nim;0;Error: internal error: invalid kind for last(tyEmpty)
|
||||
tunderscores.nim;3;invalid token: _
|
||||
twrongtupleaccess.nim;4;undeclared field: 'setBLAH'
|
||||
typredef.nim;2;illegal recursion in type 'Uint8'
|
||||
|
Can't render this file because it contains an unexpected character in line 26 and column 23.
|
@@ -1,3 +1,8 @@
|
||||
discard """
|
||||
file: "t99bott.nim"
|
||||
line: 25
|
||||
errormsg: "constant expression expected"
|
||||
"""
|
||||
## 99 Bottles of Beer
|
||||
## http://www.99-bottles-of-beer.net/
|
||||
## Nimrod version
|
||||
@@ -26,3 +31,5 @@ echo "No more bottles of beer on the wall, no more bottles of beer."
|
||||
echo "Go to the store and buy some more, 99 bottles of beer on the wall."
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user