diff options
author | konsumlamm <44230978+konsumlamm@users.noreply.github.com> | 2023-07-25 17:56:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-25 17:56:14 +0200 |
commit | c0994c2dbdaaa6276b91c206d3377d68789f49ec (patch) | |
tree | d7d7ac8078a6bb5271097287e44aef35a349de54 /tests | |
parent | 1c2ccfad08191e936fadd52450b53dfea105a34d (diff) | |
download | Nim-c0994c2dbdaaa6276b91c206d3377d68789f49ec.tar.gz |
[JS] Fix casting to ints (#22327)
* [JS] Fix casting to ints * Simplify `genCast` by using `asUintN`/`asIntN`
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cast/tcast.nim | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/cast/tcast.nim b/tests/cast/tcast.nim new file mode 100644 index 000000000..205444ea3 --- /dev/null +++ b/tests/cast/tcast.nim @@ -0,0 +1,21 @@ +discard """ + targets: "c cpp js" +""" + +proc main() = + block: # bug #16806 + let + a = 42u16 + b = cast[int16](a) + doAssert a.int16 == 42 + doAssert b in int16.low..int16.high + + block: # bug #16808 + doAssert cast[int8](cast[uint8](int8(-12))) == int8(-12) + doAssert cast[int16](cast[uint16](int16(-12))) == int16(-12) + doAssert cast[int32](cast[uint32](int32(-12))) == int32(-12) + + doAssert cast[int8](int16.high) == -1 + +static: main() +main() |