faster CIs (#13803)
* ttables: smaller table, 5x speedup * thavlak: less iterations, less loops; 30% speedup * tasyncclosestall: shorter timeout; 35% speedup * gcleak4: less iterations, 2x speedup * ttimes: remove deprecated stuff * tdangerisrelease: remove cpp backend, 3x speedup * tfrexp1: smaller range, 2x speedup * trtree: fix warnings, less iterations, 6x speedup * tasyncawait_cyclebreaker: smaller swarm size; 2x speedup * trealloc: smaller number of iterations; 10x speedup * towned_binary_tree: less iterations, 4x speedup * tclosure: remove unused code, less iterations; 2x speedup * twaitany: less durations; 1.4x speedup * tasync_misc: less iterations, 2x speedup * t8535: smaller sleep, 1.5x speedup * tmanyjoin: smaller sleep, 2x speedup * t12221: shorter sleeps, removed two slower tests; 1.6x speedup * tfuturestream: smaller sleep; 1.5x speedup * growobjcrash: less iterations; 2x speedup * ttryrecv: smaller sleep; 1.5x speedup * treusetvar: less threads; 2x speedup * delete tthreadanalysis2, basically a duplicate of tthreadanalysis * t7758: less iterations, 1.5x speedup * tasyncawait: smaller swarm, less messages; 1.5x speedup * tjsandnativeasync: smaller sleep, 1.5x speedup * tpendingcheck: smaller sleep, 1.5x speedup * remove rodfiles test category * move tseq from its own category to 'collections' category * remove unneeded tests and helpers from 'assert' category * stdlib: merge tbitops2 into tbitops * remove 'trepr2' from 'stdlib' cat * merge 'tstreams' into one file * remove 'tinefficient_const_table' from 'ccbugs' cat * merge 'tcollections_to_string' into 'tcollections' * tblocking_channel: smaller sleep, small speedup * tconvexhull: less iterartions; 1.2x speedup * merge 'tdeepcopy2' into 'tdeepcopy' * merge 'tdisjoint_slice2' into 'tdisjoint_slice1' * tmissing_deepcopy: smaller sequence * tsendtwice: smaller arrays; 5x speedup * remove 'tindexerrorformatbounds' * disable multimethod tests * remove 'gc:none' and 'refc' without 'd:useRealtimeGC' from gc tests * koch.nim: bootstrap just with '-d:release', no need for 'csource' * add github workflow for documentation * testament: no need for 8 sub-second decimals
This commit is contained in:
parent
2a278f6eba
commit
8088633250
72 changed files with 532 additions and 1082 deletions
|
|
@ -1,10 +1,13 @@
|
|||
discard """
|
||||
nimout: "OK"
|
||||
output: "OK"
|
||||
output: '''
|
||||
OK
|
||||
OK
|
||||
'''
|
||||
"""
|
||||
import bitops
|
||||
|
||||
proc main() =
|
||||
proc main1() =
|
||||
const U8 = 0b0011_0010'u8
|
||||
const I8 = 0b0011_0010'i8
|
||||
const U16 = 0b00100111_00101000'u16
|
||||
|
|
@ -261,7 +264,172 @@ block: # not ready for vm because exception is compile error
|
|||
doAssert false
|
||||
|
||||
|
||||
main()
|
||||
main1()
|
||||
static:
|
||||
# test everything on vm as well
|
||||
main()
|
||||
main1()
|
||||
|
||||
|
||||
|
||||
proc main2() =
|
||||
const U8 = 0b0011_0010'u8
|
||||
const I8 = 0b0011_0010'i8
|
||||
const U16 = 0b00100111_00101000'u16
|
||||
const I16 = 0b00100111_00101000'i16
|
||||
const U32 = 0b11010101_10011100_11011010_01010000'u32
|
||||
const I32 = 0b11010101_10011100_11011010_01010000'i32
|
||||
const U64A = 0b01000100_00111111_01111100_10001010_10011001_01001000_01111010_00010001'u64
|
||||
const I64A = 0b01000100_00111111_01111100_10001010_10011001_01001000_01111010_00010001'i64
|
||||
const U64B = 0b00110010_11011101_10001111_00101000_00000000_00000000_00000000_00000000'u64
|
||||
const I64B = 0b00110010_11011101_10001111_00101000_00000000_00000000_00000000_00000000'i64
|
||||
|
||||
doAssert( U64A.fastLog2 == 62)
|
||||
doAssert( I64A.fastLog2 == 62)
|
||||
doAssert( U64A.countLeadingZeroBits == 1)
|
||||
doAssert( I64A.countLeadingZeroBits == 1)
|
||||
doAssert( U64A.countTrailingZeroBits == 0)
|
||||
doAssert( I64A.countTrailingZeroBits == 0)
|
||||
doAssert( U64A.firstSetBit == 1)
|
||||
doAssert( I64A.firstSetBit == 1)
|
||||
doAssert( U64A.parityBits == 1)
|
||||
doAssert( I64A.parityBits == 1)
|
||||
doAssert( U64A.countSetBits == 29)
|
||||
doAssert( I64A.countSetBits == 29)
|
||||
doAssert( U64A.rotateLeftBits(37) == 0b00101001_00001111_01000010_00101000_10000111_11101111_10010001_01010011'u64)
|
||||
doAssert( U64A.rotateRightBits(37) == 0b01010100_11001010_01000011_11010000_10001010_00100001_11111011_11100100'u64)
|
||||
|
||||
doAssert( U64B.firstSetBit == 36)
|
||||
doAssert( I64B.firstSetBit == 36)
|
||||
|
||||
doAssert( U32.fastLog2 == 31)
|
||||
doAssert( I32.fastLog2 == 31)
|
||||
doAssert( U32.countLeadingZeroBits == 0)
|
||||
doAssert( I32.countLeadingZeroBits == 0)
|
||||
doAssert( U32.countTrailingZeroBits == 4)
|
||||
doAssert( I32.countTrailingZeroBits == 4)
|
||||
doAssert( U32.firstSetBit == 5)
|
||||
doAssert( I32.firstSetBit == 5)
|
||||
doAssert( U32.parityBits == 0)
|
||||
doAssert( I32.parityBits == 0)
|
||||
doAssert( U32.countSetBits == 16)
|
||||
doAssert( I32.countSetBits == 16)
|
||||
doAssert( U32.rotateLeftBits(21) == 0b01001010_00011010_10110011_10011011'u32)
|
||||
doAssert( U32.rotateRightBits(21) == 0b11100110_11010010_10000110_10101100'u32)
|
||||
|
||||
doAssert( U16.fastLog2 == 13)
|
||||
doAssert( I16.fastLog2 == 13)
|
||||
doAssert( U16.countLeadingZeroBits == 2)
|
||||
doAssert( I16.countLeadingZeroBits == 2)
|
||||
doAssert( U16.countTrailingZeroBits == 3)
|
||||
doAssert( I16.countTrailingZeroBits == 3)
|
||||
doAssert( U16.firstSetBit == 4)
|
||||
doAssert( I16.firstSetBit == 4)
|
||||
doAssert( U16.parityBits == 0)
|
||||
doAssert( I16.parityBits == 0)
|
||||
doAssert( U16.countSetBits == 6)
|
||||
doAssert( I16.countSetBits == 6)
|
||||
doAssert( U16.rotateLeftBits(12) == 0b10000010_01110010'u16)
|
||||
doAssert( U16.rotateRightBits(12) == 0b01110010_10000010'u16)
|
||||
|
||||
doAssert( U8.fastLog2 == 5)
|
||||
doAssert( I8.fastLog2 == 5)
|
||||
doAssert( U8.countLeadingZeroBits == 2)
|
||||
doAssert( I8.countLeadingZeroBits == 2)
|
||||
doAssert( U8.countTrailingZeroBits == 1)
|
||||
doAssert( I8.countTrailingZeroBits == 1)
|
||||
doAssert( U8.firstSetBit == 2)
|
||||
doAssert( I8.firstSetBit == 2)
|
||||
doAssert( U8.parityBits == 1)
|
||||
doAssert( I8.parityBits == 1)
|
||||
doAssert( U8.countSetBits == 3)
|
||||
doAssert( I8.countSetBits == 3)
|
||||
doAssert( U8.rotateLeftBits(3) == 0b10010001'u8)
|
||||
doAssert( U8.rotateRightBits(3) == 0b0100_0110'u8)
|
||||
|
||||
static :
|
||||
# test bitopts at compile time with vm
|
||||
doAssert( U8.fastLog2 == 5)
|
||||
doAssert( I8.fastLog2 == 5)
|
||||
doAssert( U8.countLeadingZeroBits == 2)
|
||||
doAssert( I8.countLeadingZeroBits == 2)
|
||||
doAssert( U8.countTrailingZeroBits == 1)
|
||||
doAssert( I8.countTrailingZeroBits == 1)
|
||||
doAssert( U8.firstSetBit == 2)
|
||||
doAssert( I8.firstSetBit == 2)
|
||||
doAssert( U8.parityBits == 1)
|
||||
doAssert( I8.parityBits == 1)
|
||||
doAssert( U8.countSetBits == 3)
|
||||
doAssert( I8.countSetBits == 3)
|
||||
doAssert( U8.rotateLeftBits(3) == 0b10010001'u8)
|
||||
doAssert( U8.rotateRightBits(3) == 0b0100_0110'u8)
|
||||
|
||||
|
||||
|
||||
template test_undefined_impl(ffunc: untyped; expected: int; is_static: bool) =
|
||||
doAssert( ffunc(0'u8) == expected)
|
||||
doAssert( ffunc(0'i8) == expected)
|
||||
doAssert( ffunc(0'u16) == expected)
|
||||
doAssert( ffunc(0'i16) == expected)
|
||||
doAssert( ffunc(0'u32) == expected)
|
||||
doAssert( ffunc(0'i32) == expected)
|
||||
doAssert( ffunc(0'u64) == expected)
|
||||
doAssert( ffunc(0'i64) == expected)
|
||||
|
||||
template test_undefined(ffunc: untyped; expected: int) =
|
||||
test_undefined_impl(ffunc, expected, false)
|
||||
static:
|
||||
test_undefined_impl(ffunc, expected, true)
|
||||
|
||||
when defined(noUndefinedBitOpts):
|
||||
# check for undefined behavior with zero.
|
||||
test_undefined(countSetBits, 0)
|
||||
test_undefined(parityBits, 0)
|
||||
test_undefined(firstSetBit, 0)
|
||||
test_undefined(countLeadingZeroBits, 0)
|
||||
test_undefined(countTrailingZeroBits, 0)
|
||||
test_undefined(fastLog2, -1)
|
||||
|
||||
# check for undefined behavior with rotate by zero.
|
||||
doAssert( U8.rotateLeftBits(0) == U8)
|
||||
doAssert( U8.rotateRightBits(0) == U8)
|
||||
doAssert( U16.rotateLeftBits(0) == U16)
|
||||
doAssert( U16.rotateRightBits(0) == U16)
|
||||
doAssert( U32.rotateLeftBits(0) == U32)
|
||||
doAssert( U32.rotateRightBits(0) == U32)
|
||||
doAssert( U64A.rotateLeftBits(0) == U64A)
|
||||
doAssert( U64A.rotateRightBits(0) == U64A)
|
||||
|
||||
# check for undefined behavior with rotate by integer width.
|
||||
doAssert( U8.rotateLeftBits(8) == U8)
|
||||
doAssert( U8.rotateRightBits(8) == U8)
|
||||
doAssert( U16.rotateLeftBits(16) == U16)
|
||||
doAssert( U16.rotateRightBits(16) == U16)
|
||||
doAssert( U32.rotateLeftBits(32) == U32)
|
||||
doAssert( U32.rotateRightBits(32) == U32)
|
||||
doAssert( U64A.rotateLeftBits(64) == U64A)
|
||||
doAssert( U64A.rotateRightBits(64) == U64A)
|
||||
|
||||
static: # check for undefined behavior with rotate by zero.
|
||||
doAssert( U8.rotateLeftBits(0) == U8)
|
||||
doAssert( U8.rotateRightBits(0) == U8)
|
||||
doAssert( U16.rotateLeftBits(0) == U16)
|
||||
doAssert( U16.rotateRightBits(0) == U16)
|
||||
doAssert( U32.rotateLeftBits(0) == U32)
|
||||
doAssert( U32.rotateRightBits(0) == U32)
|
||||
doAssert( U64A.rotateLeftBits(0) == U64A)
|
||||
doAssert( U64A.rotateRightBits(0) == U64A)
|
||||
|
||||
# check for undefined behavior with rotate by integer width.
|
||||
doAssert( U8.rotateLeftBits(8) == U8)
|
||||
doAssert( U8.rotateRightBits(8) == U8)
|
||||
doAssert( U16.rotateLeftBits(16) == U16)
|
||||
doAssert( U16.rotateRightBits(16) == U16)
|
||||
doAssert( U32.rotateLeftBits(32) == U32)
|
||||
doAssert( U32.rotateRightBits(32) == U32)
|
||||
doAssert( U64A.rotateLeftBits(64) == U64A)
|
||||
doAssert( U64A.rotateRightBits(64) == U64A)
|
||||
|
||||
echo "OK"
|
||||
|
||||
main2()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,167 +0,0 @@
|
|||
discard """
|
||||
output: "OK"
|
||||
"""
|
||||
import bitops
|
||||
|
||||
|
||||
proc main() =
|
||||
const U8 = 0b0011_0010'u8
|
||||
const I8 = 0b0011_0010'i8
|
||||
const U16 = 0b00100111_00101000'u16
|
||||
const I16 = 0b00100111_00101000'i16
|
||||
const U32 = 0b11010101_10011100_11011010_01010000'u32
|
||||
const I32 = 0b11010101_10011100_11011010_01010000'i32
|
||||
const U64A = 0b01000100_00111111_01111100_10001010_10011001_01001000_01111010_00010001'u64
|
||||
const I64A = 0b01000100_00111111_01111100_10001010_10011001_01001000_01111010_00010001'i64
|
||||
const U64B = 0b00110010_11011101_10001111_00101000_00000000_00000000_00000000_00000000'u64
|
||||
const I64B = 0b00110010_11011101_10001111_00101000_00000000_00000000_00000000_00000000'i64
|
||||
|
||||
doAssert( U64A.fastLog2 == 62)
|
||||
doAssert( I64A.fastLog2 == 62)
|
||||
doAssert( U64A.countLeadingZeroBits == 1)
|
||||
doAssert( I64A.countLeadingZeroBits == 1)
|
||||
doAssert( U64A.countTrailingZeroBits == 0)
|
||||
doAssert( I64A.countTrailingZeroBits == 0)
|
||||
doAssert( U64A.firstSetBit == 1)
|
||||
doAssert( I64A.firstSetBit == 1)
|
||||
doAssert( U64A.parityBits == 1)
|
||||
doAssert( I64A.parityBits == 1)
|
||||
doAssert( U64A.countSetBits == 29)
|
||||
doAssert( I64A.countSetBits == 29)
|
||||
doAssert( U64A.rotateLeftBits(37) == 0b00101001_00001111_01000010_00101000_10000111_11101111_10010001_01010011'u64)
|
||||
doAssert( U64A.rotateRightBits(37) == 0b01010100_11001010_01000011_11010000_10001010_00100001_11111011_11100100'u64)
|
||||
|
||||
doAssert( U64B.firstSetBit == 36)
|
||||
doAssert( I64B.firstSetBit == 36)
|
||||
|
||||
doAssert( U32.fastLog2 == 31)
|
||||
doAssert( I32.fastLog2 == 31)
|
||||
doAssert( U32.countLeadingZeroBits == 0)
|
||||
doAssert( I32.countLeadingZeroBits == 0)
|
||||
doAssert( U32.countTrailingZeroBits == 4)
|
||||
doAssert( I32.countTrailingZeroBits == 4)
|
||||
doAssert( U32.firstSetBit == 5)
|
||||
doAssert( I32.firstSetBit == 5)
|
||||
doAssert( U32.parityBits == 0)
|
||||
doAssert( I32.parityBits == 0)
|
||||
doAssert( U32.countSetBits == 16)
|
||||
doAssert( I32.countSetBits == 16)
|
||||
doAssert( U32.rotateLeftBits(21) == 0b01001010_00011010_10110011_10011011'u32)
|
||||
doAssert( U32.rotateRightBits(21) == 0b11100110_11010010_10000110_10101100'u32)
|
||||
|
||||
doAssert( U16.fastLog2 == 13)
|
||||
doAssert( I16.fastLog2 == 13)
|
||||
doAssert( U16.countLeadingZeroBits == 2)
|
||||
doAssert( I16.countLeadingZeroBits == 2)
|
||||
doAssert( U16.countTrailingZeroBits == 3)
|
||||
doAssert( I16.countTrailingZeroBits == 3)
|
||||
doAssert( U16.firstSetBit == 4)
|
||||
doAssert( I16.firstSetBit == 4)
|
||||
doAssert( U16.parityBits == 0)
|
||||
doAssert( I16.parityBits == 0)
|
||||
doAssert( U16.countSetBits == 6)
|
||||
doAssert( I16.countSetBits == 6)
|
||||
doAssert( U16.rotateLeftBits(12) == 0b10000010_01110010'u16)
|
||||
doAssert( U16.rotateRightBits(12) == 0b01110010_10000010'u16)
|
||||
|
||||
doAssert( U8.fastLog2 == 5)
|
||||
doAssert( I8.fastLog2 == 5)
|
||||
doAssert( U8.countLeadingZeroBits == 2)
|
||||
doAssert( I8.countLeadingZeroBits == 2)
|
||||
doAssert( U8.countTrailingZeroBits == 1)
|
||||
doAssert( I8.countTrailingZeroBits == 1)
|
||||
doAssert( U8.firstSetBit == 2)
|
||||
doAssert( I8.firstSetBit == 2)
|
||||
doAssert( U8.parityBits == 1)
|
||||
doAssert( I8.parityBits == 1)
|
||||
doAssert( U8.countSetBits == 3)
|
||||
doAssert( I8.countSetBits == 3)
|
||||
doAssert( U8.rotateLeftBits(3) == 0b10010001'u8)
|
||||
doAssert( U8.rotateRightBits(3) == 0b0100_0110'u8)
|
||||
|
||||
static :
|
||||
# test bitopts at compile time with vm
|
||||
doAssert( U8.fastLog2 == 5)
|
||||
doAssert( I8.fastLog2 == 5)
|
||||
doAssert( U8.countLeadingZeroBits == 2)
|
||||
doAssert( I8.countLeadingZeroBits == 2)
|
||||
doAssert( U8.countTrailingZeroBits == 1)
|
||||
doAssert( I8.countTrailingZeroBits == 1)
|
||||
doAssert( U8.firstSetBit == 2)
|
||||
doAssert( I8.firstSetBit == 2)
|
||||
doAssert( U8.parityBits == 1)
|
||||
doAssert( I8.parityBits == 1)
|
||||
doAssert( U8.countSetBits == 3)
|
||||
doAssert( I8.countSetBits == 3)
|
||||
doAssert( U8.rotateLeftBits(3) == 0b10010001'u8)
|
||||
doAssert( U8.rotateRightBits(3) == 0b0100_0110'u8)
|
||||
|
||||
|
||||
|
||||
template test_undefined_impl(ffunc: untyped; expected: int; is_static: bool) =
|
||||
doAssert( ffunc(0'u8) == expected)
|
||||
doAssert( ffunc(0'i8) == expected)
|
||||
doAssert( ffunc(0'u16) == expected)
|
||||
doAssert( ffunc(0'i16) == expected)
|
||||
doAssert( ffunc(0'u32) == expected)
|
||||
doAssert( ffunc(0'i32) == expected)
|
||||
doAssert( ffunc(0'u64) == expected)
|
||||
doAssert( ffunc(0'i64) == expected)
|
||||
|
||||
template test_undefined(ffunc: untyped; expected: int) =
|
||||
test_undefined_impl(ffunc, expected, false)
|
||||
static:
|
||||
test_undefined_impl(ffunc, expected, true)
|
||||
|
||||
when defined(noUndefinedBitOpts):
|
||||
# check for undefined behavior with zero.
|
||||
test_undefined(countSetBits, 0)
|
||||
test_undefined(parityBits, 0)
|
||||
test_undefined(firstSetBit, 0)
|
||||
test_undefined(countLeadingZeroBits, 0)
|
||||
test_undefined(countTrailingZeroBits, 0)
|
||||
test_undefined(fastLog2, -1)
|
||||
|
||||
# check for undefined behavior with rotate by zero.
|
||||
doAssert( U8.rotateLeftBits(0) == U8)
|
||||
doAssert( U8.rotateRightBits(0) == U8)
|
||||
doAssert( U16.rotateLeftBits(0) == U16)
|
||||
doAssert( U16.rotateRightBits(0) == U16)
|
||||
doAssert( U32.rotateLeftBits(0) == U32)
|
||||
doAssert( U32.rotateRightBits(0) == U32)
|
||||
doAssert( U64A.rotateLeftBits(0) == U64A)
|
||||
doAssert( U64A.rotateRightBits(0) == U64A)
|
||||
|
||||
# check for undefined behavior with rotate by integer width.
|
||||
doAssert( U8.rotateLeftBits(8) == U8)
|
||||
doAssert( U8.rotateRightBits(8) == U8)
|
||||
doAssert( U16.rotateLeftBits(16) == U16)
|
||||
doAssert( U16.rotateRightBits(16) == U16)
|
||||
doAssert( U32.rotateLeftBits(32) == U32)
|
||||
doAssert( U32.rotateRightBits(32) == U32)
|
||||
doAssert( U64A.rotateLeftBits(64) == U64A)
|
||||
doAssert( U64A.rotateRightBits(64) == U64A)
|
||||
|
||||
static: # check for undefined behavior with rotate by zero.
|
||||
doAssert( U8.rotateLeftBits(0) == U8)
|
||||
doAssert( U8.rotateRightBits(0) == U8)
|
||||
doAssert( U16.rotateLeftBits(0) == U16)
|
||||
doAssert( U16.rotateRightBits(0) == U16)
|
||||
doAssert( U32.rotateLeftBits(0) == U32)
|
||||
doAssert( U32.rotateRightBits(0) == U32)
|
||||
doAssert( U64A.rotateLeftBits(0) == U64A)
|
||||
doAssert( U64A.rotateRightBits(0) == U64A)
|
||||
|
||||
# check for undefined behavior with rotate by integer width.
|
||||
doAssert( U8.rotateLeftBits(8) == U8)
|
||||
doAssert( U8.rotateRightBits(8) == U8)
|
||||
doAssert( U16.rotateLeftBits(16) == U16)
|
||||
doAssert( U16.rotateRightBits(16) == U16)
|
||||
doAssert( U32.rotateLeftBits(32) == U32)
|
||||
doAssert( U32.rotateRightBits(32) == U32)
|
||||
doAssert( U64A.rotateLeftBits(64) == U64A)
|
||||
doAssert( U64A.rotateRightBits(64) == U64A)
|
||||
|
||||
echo "OK"
|
||||
|
||||
main()
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
-d:noIntrinsicsBitOpts
|
||||
-d:noUndefinedBitOps
|
||||
|
|
@ -41,6 +41,6 @@ when manualTest:
|
|||
|
||||
frexp_test(-1000.0, 1000.0, 0.0125)
|
||||
else:
|
||||
frexp_test(-1000000.0, 1000000.0, 0.125)
|
||||
frexp_test(-200000.0, 200000.0, 0.125)
|
||||
|
||||
echo "ok"
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
discard """
|
||||
outputsub: ""
|
||||
"""
|
||||
|
||||
# output not testable because repr prints pointer addresses
|
||||
# test the new "repr" built-in proc
|
||||
|
||||
type
|
||||
TEnum = enum
|
||||
en1, en2, en3, en4, en5, en6
|
||||
|
||||
TPoint {.final.} = object
|
||||
x, y, z: int
|
||||
s: array[0..1, string]
|
||||
e: TEnum
|
||||
|
||||
var
|
||||
p: TPoint
|
||||
q: ref TPoint
|
||||
s: seq[ref TPoint]
|
||||
|
||||
p.x = 0
|
||||
p.y = 13
|
||||
p.z = 45
|
||||
p.s[0] = "abc"
|
||||
p.s[1] = "xyz"
|
||||
p.e = en6
|
||||
|
||||
new(q)
|
||||
q[] = p
|
||||
|
||||
s = @[q, q, q, q]
|
||||
|
||||
writeLine(stdout, repr(p))
|
||||
writeLine(stdout, repr(q))
|
||||
writeLine(stdout, repr(s))
|
||||
writeLine(stdout, repr(en4))
|
||||
|
|
@ -1,11 +1,16 @@
|
|||
discard """
|
||||
input: "Arne"
|
||||
output: '''
|
||||
input: "Arne"
|
||||
output: '''
|
||||
Hello! What is your name?
|
||||
Nice name: Arne
|
||||
fs is: nil
|
||||
|
||||
threw exception
|
||||
'''
|
||||
nimout: '''
|
||||
I
|
||||
AM
|
||||
GROOT
|
||||
'''
|
||||
disabled: "windows"
|
||||
"""
|
||||
|
|
@ -38,3 +43,9 @@ block tstreams3:
|
|||
var fs = openFileStream("shouldneverexist.txt")
|
||||
except IoError:
|
||||
echo "threw exception"
|
||||
|
||||
static:
|
||||
var s = newStringStream("I\nAM\nGROOT")
|
||||
for line in s.lines:
|
||||
echo line
|
||||
s.close
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
discard """
|
||||
output: '''fs is: nil'''
|
||||
"""
|
||||
import streams
|
||||
var
|
||||
fs = newFileStream("amissingfile.txt")
|
||||
line = ""
|
||||
echo "fs is: ",repr(fs)
|
||||
if not isNil(fs):
|
||||
while fs.readLine(line):
|
||||
echo line
|
||||
fs.close()
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
discard """
|
||||
output: "threw exception"
|
||||
nimout: '''
|
||||
I
|
||||
AM
|
||||
GROOT
|
||||
'''
|
||||
"""
|
||||
import streams
|
||||
|
||||
try:
|
||||
var fs = openFileStream("shouldneverexist.txt")
|
||||
except IoError:
|
||||
echo "threw exception"
|
||||
|
||||
static:
|
||||
var s = newStringStream("I\nAM\nGROOT")
|
||||
for line in s.lines:
|
||||
echo line
|
||||
s.close
|
||||
|
|
@ -309,7 +309,7 @@ suite "ttimes":
|
|||
check dt.nanosecond == convert(Milliseconds, Nanoseconds, 1)
|
||||
check d(seconds = 1, milliseconds = 500) * 2 == d(seconds = 3)
|
||||
check d(seconds = 3) div 2 == d(seconds = 1, milliseconds = 500)
|
||||
check d(milliseconds = 1001).seconds == 1
|
||||
check d(milliseconds = 1001).inSeconds == 1
|
||||
check d(seconds = 1, milliseconds = 500) - d(milliseconds = 1250) ==
|
||||
d(milliseconds = 250)
|
||||
check d(seconds = 1, milliseconds = 1) < d(seconds = 1, milliseconds = 2)
|
||||
|
|
@ -504,12 +504,6 @@ suite "ttimes":
|
|||
check $parse("02 Fir 2019", "dd MMM yyyy", utc(), loc) == "2019-01-02T00:00:00Z"
|
||||
check $parse("Fourthy 6, 2017", "MMMM d, yyyy", utc(), loc) == "2017-04-06T00:00:00Z"
|
||||
|
||||
test "countLeapYears":
|
||||
# 1920, 2004 and 2020 are leap years, and should be counted starting at the following year
|
||||
check countLeapYears(1920) + 1 == countLeapYears(1921)
|
||||
check countLeapYears(2004) + 1 == countLeapYears(2005)
|
||||
check countLeapYears(2020) + 1 == countLeapYears(2021)
|
||||
|
||||
test "timezoneConversion":
|
||||
var l = now()
|
||||
let u = l.utc
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue