* fixes #13744 * improve style Co-authored-by: cooldome <ariabushenko@gmail.ru>
This commit is contained in:
parent
46c827be6a
commit
182d3c16e3
4 changed files with 44 additions and 1 deletions
|
|
@ -19,3 +19,38 @@ proc remap2[T](s: seq[int], typ: typedesc[T]): seq[T] =
|
|||
|
||||
echo remap1(@[1,2,3], float)
|
||||
echo remap2(@[1,2,3], float)
|
||||
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# conversion to bool, issue #13744
|
||||
proc test_conv_to_bool =
|
||||
var
|
||||
i0 = 0
|
||||
i1 = 1
|
||||
ih = high(uint)
|
||||
il = low(int)
|
||||
|
||||
f0 = 0.0
|
||||
f1 = 1.0
|
||||
fh = Inf
|
||||
fl = -Inf
|
||||
f_nan = NaN
|
||||
|
||||
doAssert(bool(i0) == false)
|
||||
doAssert(bool(i1) == true)
|
||||
doAssert(bool(-i1) == true)
|
||||
doAssert(bool(il) == true)
|
||||
doAssert(bool(ih) == true)
|
||||
|
||||
doAssert(bool(f0) == false)
|
||||
doAssert(bool(-f0) == false)
|
||||
doAssert(bool(f1) == true)
|
||||
doAssert(bool(-f1) == true)
|
||||
doAssert(bool(fh) == true)
|
||||
doAssert(bool(fl) == true)
|
||||
doAssert(bool(fnan) == true) # NaN to bool gives true according to standard
|
||||
|
||||
|
||||
static:
|
||||
test_conv_to_bool()
|
||||
test_conv_to_bool()
|
||||
Loading…
Add table
Add a link
Reference in a new issue