renamed writeln to writeLine in tests

This commit is contained in:
patrick dw 2015-06-19 01:34:34 -05:00
commit 69e15ac32f
39 changed files with 456 additions and 456 deletions

View file

@ -7,8 +7,8 @@ var
i: int
params = paramCount()
i = 0
writeln(stdout, "This exe: " & getAppFilename())
writeln(stdout, "Number of parameters: " & $params)
writeLine(stdout, "This exe: " & getAppFilename())
writeLine(stdout, "Number of parameters: " & $params)
while i <= params:
writeln(stdout, paramStr(i))
writeLine(stdout, paramStr(i))
i = i + 1

View file

@ -1,3 +1,3 @@
# test the new endian magic
writeln(stdout, repr(system.cpuEndian))
writeLine(stdout, repr(system.cpuEndian))

View file

@ -22,7 +22,7 @@ macro macrotest(n: expr): stmt {.immediate.} =
result = newNimNode(nnkStmtList, n)
for i in 2..n.len-1:
result.add(newCall("write", n[1], n[i]))
result.add(newCall("writeln", n[1], newStrLitNode("")))
result.add(newCall("writeLine", n[1], newStrLitNode("")))
macro debug(n: expr): stmt {.immediate.} =
let n = callsite()
@ -30,7 +30,7 @@ macro debug(n: expr): stmt {.immediate.} =
for i in 1..n.len-1:
result.add(newCall("write", newIdentNode("stdout"), toStrLit(n[i])))
result.add(newCall("write", newIdentNode("stdout"), newStrLitNode(": ")))
result.add(newCall("writeln", newIdentNode("stdout"), n[i]))
result.add(newCall("writeLine", newIdentNode("stdout"), n[i]))
macrotest(stdout, "finally", 4, 5, "variable", "argument lists")
macrotest(stdout)
@ -38,7 +38,7 @@ macrotest(stdout)
#GC_disable()
echo("This was compiled by Nim version " & system.NimVersion)
writeln(stdout, "Hello", " World", "!")
writeLine(stdout, "Hello", " World", "!")
echo(["a", "b", "c", "d"].len)
for x in items(["What's", "your", "name", "?", ]):

View file

@ -8,8 +8,8 @@ proc main() =
a, b: TTime
a = getLastModificationTime(paramStr(1))
b = getLastModificationTime(paramStr(2))
writeln(stdout, $a)
writeln(stdout, $b)
writeLine(stdout, $a)
writeLine(stdout, $b)
if a < b:
write(stdout, "$2 is newer than $1\n" % [paramStr(1), paramStr(2)])
else:

View file

@ -24,10 +24,10 @@ var size = parseInt (paramStr (1))
var bit = 128
var byteAcc = 0
stdout.writeln ("P4")
stdout.writeLine ("P4")
stdout.write ($size)
stdout.write (" ")
stdout.writeln ($size)
stdout.writeLine ($size)
var fsize = float (size)
for y in 0 .. size-1:

View file

@ -9,4 +9,4 @@ var
x = 1
y = high(int)
writeln(stdout, $ ( x +% y ) )
writeLine(stdout, $ ( x +% y ) )

View file

@ -2,141 +2,141 @@ discard """
file: "tvarnums.nim"
output: "Success!"
"""
# Test variable length binary integers
import
strutils
type
TBuffer = array [0..10, int8]
proc toVarNum(x: int32, b: var TBuffer) =
# encoding: first bit indicates end of number (0 if at end)
# second bit of the first byte denotes the sign (1 --> negative)
var a = x
if x != low(x):
# low(int) is a special case,
# because abs() does not work here!
# we leave x as it is and use the check >% instead of >
# for low(int) this is needed and positive numbers are not affected
# anyway
a = abs(x)
# first 6 bits:
b[0] = toU8(ord(a >% 63'i32) shl 7 or (ord(x < 0'i32) shl 6) or (int(a) and 63))
a = a shr 6'i32 # skip first 6 bits
var i = 1
while a != 0'i32:
b[i] = toU8(ord(a >% 127'i32) shl 7 or (int(a) and 127))
inc(i)
a = a shr 7'i32
proc toVarNum64(x: int64, b: var TBuffer) =
# encoding: first bit indicates end of number (0 if at end)
# second bit of the first byte denotes the sign (1 --> negative)
var a = x
if x != low(x):
# low(int) is a special case,
# because abs() does not work here!
# we leave x as it is and use the check >% instead of >
# for low(int) this is needed and positive numbers are not affected
# anyway
a = abs(x)
# first 6 bits:
b[0] = toU8(ord(a >% 63'i64) shl 7 or (ord(x < 0'i64) shl 6) or int(a and 63))
a = a shr 6 # skip first 6 bits
var i = 1
while a != 0'i64:
b[i] = toU8(ord(a >% 127'i64) shl 7 or int(a and 127))
inc(i)
a = a shr 7
proc toNum64(b: TBuffer): int64 =
# treat first byte different:
result = ze64(b[0]) and 63
var
i = 0
Shift = 6'i64
while (ze(b[i]) and 128) != 0:
inc(i)
result = result or ((ze64(b[i]) and 127) shl Shift)
inc(Shift, 7)
if (ze(b[0]) and 64) != 0: # sign bit set?
result = not result +% 1
# this is the same as ``- result``
# but gives no overflow error for low(int)
proc toNum(b: TBuffer): int32 =
# treat first byte different:
result = ze(b[0]) and 63
var
i = 0
Shift = 6'i32
while (ze(b[i]) and 128) != 0:
inc(i)
result = result or ((int32(ze(b[i])) and 127'i32) shl Shift)
Shift = Shift + 7'i32
if (ze(b[0]) and (1 shl 6)) != 0: # sign bit set?
result = (not result) +% 1'i32
# this is the same as ``- result``
# but gives no overflow error for low(int)
proc toBinary(x: int64): string =
result = newString(64)
for i in 0..63:
result[63-i] = chr((int(x shr i) and 1) + ord('0'))
proc t64(i: int64) =
var
b: TBuffer
toVarNum64(i, b)
var x = toNum64(b)
if x != i:
writeln(stdout, $i)
writeln(stdout, toBinary(i))
writeln(stdout, toBinary(x))
proc t32(i: int32) =
var
b: TBuffer
toVarNum(i, b)
var x = toNum(b)
if x != i:
writeln(stdout, toBinary(i))
writeln(stdout, toBinary(x))
proc tm(i: int32) =
var
b: TBuffer
toVarNum64(i, b)
var x = toNum(b)
if x != i:
writeln(stdout, toBinary(i))
writeln(stdout, toBinary(x))
t32(0)
t32(1)
t32(-1)
t32(-100_000)
t32(100_000)
t32(low(int32))
t32(high(int32))
t64(low(int64))
t64(high(int64))
t64(0)
t64(-1)
t64(1)
t64(1000_000)
t64(-1000_000)
tm(0)
tm(1)
tm(-1)
tm(-100_000)
tm(100_000)
tm(low(int32))
tm(high(int32))
writeln(stdout, "Success!") #OUT Success!
# Test variable length binary integers
import
strutils
type
TBuffer = array [0..10, int8]
proc toVarNum(x: int32, b: var TBuffer) =
# encoding: first bit indicates end of number (0 if at end)
# second bit of the first byte denotes the sign (1 --> negative)
var a = x
if x != low(x):
# low(int) is a special case,
# because abs() does not work here!
# we leave x as it is and use the check >% instead of >
# for low(int) this is needed and positive numbers are not affected
# anyway
a = abs(x)
# first 6 bits:
b[0] = toU8(ord(a >% 63'i32) shl 7 or (ord(x < 0'i32) shl 6) or (int(a) and 63))
a = a shr 6'i32 # skip first 6 bits
var i = 1
while a != 0'i32:
b[i] = toU8(ord(a >% 127'i32) shl 7 or (int(a) and 127))
inc(i)
a = a shr 7'i32
proc toVarNum64(x: int64, b: var TBuffer) =
# encoding: first bit indicates end of number (0 if at end)
# second bit of the first byte denotes the sign (1 --> negative)
var a = x
if x != low(x):
# low(int) is a special case,
# because abs() does not work here!
# we leave x as it is and use the check >% instead of >
# for low(int) this is needed and positive numbers are not affected
# anyway
a = abs(x)
# first 6 bits:
b[0] = toU8(ord(a >% 63'i64) shl 7 or (ord(x < 0'i64) shl 6) or int(a and 63))
a = a shr 6 # skip first 6 bits
var i = 1
while a != 0'i64:
b[i] = toU8(ord(a >% 127'i64) shl 7 or int(a and 127))
inc(i)
a = a shr 7
proc toNum64(b: TBuffer): int64 =
# treat first byte different:
result = ze64(b[0]) and 63
var
i = 0
Shift = 6'i64
while (ze(b[i]) and 128) != 0:
inc(i)
result = result or ((ze64(b[i]) and 127) shl Shift)
inc(Shift, 7)
if (ze(b[0]) and 64) != 0: # sign bit set?
result = not result +% 1
# this is the same as ``- result``
# but gives no overflow error for low(int)
proc toNum(b: TBuffer): int32 =
# treat first byte different:
result = ze(b[0]) and 63
var
i = 0
Shift = 6'i32
while (ze(b[i]) and 128) != 0:
inc(i)
result = result or ((int32(ze(b[i])) and 127'i32) shl Shift)
Shift = Shift + 7'i32
if (ze(b[0]) and (1 shl 6)) != 0: # sign bit set?
result = (not result) +% 1'i32
# this is the same as ``- result``
# but gives no overflow error for low(int)
proc toBinary(x: int64): string =
result = newString(64)
for i in 0..63:
result[63-i] = chr((int(x shr i) and 1) + ord('0'))
proc t64(i: int64) =
var
b: TBuffer
toVarNum64(i, b)
var x = toNum64(b)
if x != i:
writeLine(stdout, $i)
writeLine(stdout, toBinary(i))
writeLine(stdout, toBinary(x))
proc t32(i: int32) =
var
b: TBuffer
toVarNum(i, b)
var x = toNum(b)
if x != i:
writeLine(stdout, toBinary(i))
writeLine(stdout, toBinary(x))
proc tm(i: int32) =
var
b: TBuffer
toVarNum64(i, b)
var x = toNum(b)
if x != i:
writeLine(stdout, toBinary(i))
writeLine(stdout, toBinary(x))
t32(0)
t32(1)
t32(-1)
t32(-100_000)
t32(100_000)
t32(low(int32))
t32(high(int32))
t64(low(int64))
t64(high(int64))
t64(0)
t64(-1)
t64(1)
t64(1000_000)
t64(-1000_000)
tm(0)
tm(1)
tm(-1)
tm(-100_000)
tm(100_000)
tm(low(int32))
tm(high(int32))
writeLine(stdout, "Success!") #OUT Success!