forked from Rust-related/RustPython
bool.real
This commit is contained in:
@@ -80,6 +80,11 @@ assert False.__xor__(False) is False
|
||||
assert False.__rxor__(0) is not False
|
||||
assert False.__rxor__(False) is False
|
||||
|
||||
assert True.real == 1
|
||||
assert True.imag == 0
|
||||
assert type(True.real) is int
|
||||
assert type(True.imag) is int
|
||||
|
||||
# Check work for sequence and map
|
||||
assert bool({}) is False
|
||||
assert bool([]) is False
|
||||
|
||||
@@ -77,7 +77,7 @@ The class bool is a subclass of the class int, and cannot be subclassed.";
|
||||
"__rand__" => context.new_rustfunc(bool_rand),
|
||||
"__xor__" => context.new_rustfunc(bool_xor),
|
||||
"__rxor__" => context.new_rustfunc(bool_rxor),
|
||||
"__doc__" => context.new_str(bool_doc.to_string())
|
||||
"__doc__" => context.new_str(bool_doc.to_string()),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -681,8 +681,8 @@ impl PyInt {
|
||||
Ok(PyBytes::new(bytes))
|
||||
}
|
||||
#[pyproperty]
|
||||
fn real(zelf: PyRef<Self>, _vm: &VirtualMachine) -> PyIntRef {
|
||||
zelf
|
||||
fn real(&self, vm: &VirtualMachine) -> PyObjectRef {
|
||||
vm.ctx.new_int(self.value.clone())
|
||||
}
|
||||
|
||||
#[pyproperty]
|
||||
|
||||
Reference in New Issue
Block a user