* fixes #13744

* improve style

Co-authored-by: cooldome <ariabushenko@gmail.ru>
This commit is contained in:
cooldome 2020-03-25 13:44:52 +00:00 • committed by GitHub
commit 182d3c16e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 1 deletions

View file

@ -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()