MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / binary_arithmetic

Function binary_arithmetic

tests/test_class.rs:866–889  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

864
865#[test]
866fn binary_arithmetic() {
867 let gil = Python::acquire_gil();
868 let py = gil.python();
869
870 let c = BinaryArithmetic::create_instance(py).unwrap();
871 py_run!(py, c, "assert c + c == 'BA + BA'");
872 py_run!(py, c, "assert c + 1 == 'BA + 1'");
873 py_run!(py, c, "assert 1 + c == '1 + BA'");
874 py_run!(py, c, "assert c - 1 == 'BA - 1'");
875 py_run!(py, c, "assert 1 - c == '1 - BA'");
876 py_run!(py, c, "assert c * 1 == 'BA * 1'");
877 py_run!(py, c, "assert 1 * c == '1 * BA'");
878
879 py_run!(py, c, "assert c << 1 == 'BA << 1'");
880 py_run!(py, c, "assert 1 << c == '1 << BA'");
881 py_run!(py, c, "assert c >> 1 == 'BA >> 1'");
882 py_run!(py, c, "assert 1 >> c == '1 >> BA'");
883 py_run!(py, c, "assert c & 1 == 'BA & 1'");
884 py_run!(py, c, "assert 1 & c == '1 & BA'");
885 py_run!(py, c, "assert c ^ 1 == 'BA ^ 1'");
886 py_run!(py, c, "assert 1 ^ c == '1 ^ BA'");
887 py_run!(py, c, "assert c | 1 == 'BA | 1'");
888 py_run!(py, c, "assert 1 | c == '1 | BA'");
889}
890
891py_class!(class RichComparisons |py| {
892 def __repr__(&self) -> PyResult<&'static str> {

Callers

nothing calls this directly

Calls 1

pythonMethod · 0.80

Tested by

no test coverage detected