forked from Rust-related/RustPython
- 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
22 lines
506 B
Python
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)
|