tashr.nim 1016 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. discard """
  2. output: ''''''
  3. targets: '''c js'''
  4. """
  5. # issue #6255, feature request
  6. # arithmetic right shift
  7. var x1 = -123'i8
  8. var x2 = -123'i16
  9. var x3 = -123'i32
  10. var x4 = -123'i64
  11. var x5 = -123
  12. block codegen_test:
  13. doAssert ashr(x1, 1) == -62
  14. doAssert ashr(x2, 1) == -62
  15. doAssert ashr(x3, 1) == -62
  16. doAssert ashr(x4, 1) == -62
  17. doAssert ashr(x5, 1) == -62
  18. block semfold_test:
  19. doAssert ashr(-123'i8 , 1) == -62
  20. doAssert ashr(-123'i16, 1) == -62
  21. doAssert ashr(-123'i32, 1) == -62
  22. doAssert ashr(-123'i64, 1) == -62
  23. doAssert ashr(-123 , 1) == -62
  24. static: # VM test
  25. doAssert ashr(-123'i8 , 1) == -62
  26. doAssert ashr(-123'i16, 1) == -62
  27. doAssert ashr(-123'i32, 1) == -62
  28. doAssert ashr(-123'i64, 1) == -62
  29. doAssert ashr(-123 , 1) == -62
  30. var y1 = -123'i8
  31. var y2 = -123'i16
  32. var y3 = -123'i32
  33. var y4 = -123'i64
  34. var y5 = -123
  35. doAssert ashr(y1, 1) == -62
  36. doAssert ashr(y2, 1) == -62
  37. doAssert ashr(y3, 1) == -62
  38. doAssert ashr(y4, 1) == -62
  39. doAssert ashr(y5, 1) == -62