Files
RustPython/tests/snippets/test_bitwise.py
Joey Hain 47e95486f0 Reuse and improve ergonomics of assert_raises utility
- Move assert_raises to testutils
- Add optional message argument, with reasonable default
- Reverse order of expr and exception type for readability
- Lambda argument no longer takes parameter
- Convert applicable snippets to use assert_raises
2019-02-16 09:32:42 -08:00

22 lines
506 B
Python

from testutils import assert_raises
#
# Tests
#
assert 8 >> 3 == 1
assert 8 << 3 == 64
# Left shift raises type error
assert_raises(TypeError, lambda: 1 << 0.1)
assert_raises(TypeError, lambda: 1 << "abc")
# Right shift raises type error
assert_raises(TypeError, lambda: 1 >> 0.1)
assert_raises(TypeError, lambda: 1 >> "abc")
# Left shift raises value error on negative
assert_raises(ValueError, lambda: 1 << -1)
# Right shift raises value error on negative
assert_raises(ValueError, lambda: 1 >> -1)