t21564.nim 480 B

1234567891011121314151617181920212223242526272829
  1. discard """
  2. targets: "c js"
  3. """
  4. import bitops
  5. import std/assertions
  6. proc main() =
  7. block: # bug #21564
  8. # tesk `bitops.bitsliced` patch
  9. doAssert(0x17.bitsliced(4..7) == 0x01)
  10. doAssert(0x17.bitsliced(0..3) == 0x07)
  11. block:
  12. # test in-place `bitops.bitslice`
  13. var t = 0x12F4
  14. t.bitslice(4..7)
  15. doAssert(t == 0xF)
  16. block:
  17. # test `bitops.toMask` patch via bitops.masked
  18. doAssert(0x12FFFF34.masked(8..23) == 0x00FFFF00)
  19. main()
  20. static:
  21. main()