diff options
| author | Carson McDonald <[email protected]> | 2013-07-06 08:53:40 -0400 |
|---|---|---|
| committer | Carson McDonald <[email protected]> | 2013-07-06 08:53:40 -0400 |
| commit | 1d27d4e03f1957e78c10a088ccf0f16268baaa91 (patch) | |
| tree | ec1bc50654222f6068b055ce96b3055c068bfe7b /test/t/integer.rb | |
| parent | bccf1259f528e1605308b9cf005ad4f10897e592 (diff) | |
| download | mruby-1d27d4e03f1957e78c10a088ccf0f16268baaa91.tar.gz mruby-1d27d4e03f1957e78c10a088ccf0f16268baaa91.zip | |
Add a few more shift tests
Diffstat (limited to 'test/t/integer.rb')
| -rw-r--r-- | test/t/integer.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/t/integer.rb b/test/t/integer.rb index 46011f94a..9b19216d9 100644 --- a/test/t/integer.rb +++ b/test/t/integer.rb @@ -104,6 +104,14 @@ assert('Integer#<<', '15.2.8.3.12') do # 00010111 (23) # = 00101110 (46) assert_equal 23 << 1, 46 + + # Left Shift by a negative is Right Shift + assert_equal 46 << -1, 23 + + # Raise when shift is too large + assert_raise(RangeError) do + 2 << 128 + end end assert('Integer#>>', '15.2.8.3.13') do @@ -111,6 +119,17 @@ assert('Integer#>>', '15.2.8.3.13') do # 00101110 (46) # = 00010111 (23) assert_equal 46 >> 1, 23 + + # Right Shift by a negative is Left Shift + assert_equal 23 >> -1, 46 + + # Don't raise on large Right Shift + assert_equal 23 >> 128, 0 + + # Raise when shift is too large + assert_raise(RangeError) do + 2 >> -128 + end end assert('Integer#ceil', '15.2.8.3.14') do |
