Add str.__rmod__() method. #190 (#1262)

* Add str.__rmod__ method.

* Add tests for str.__rmod__ method.

* Improve test for str.__rmod__ method.

* Change str.__rmod__ method return value type.

* Format with rustfmt.

* Remove not required code of str.__rmod__ method.

* Improve with clippy.
This commit is contained in:
ChJR
2019-08-16 15:40:32 +09:00
committed by Windel Bouwman
parent 2b02371ba1
commit 1dceae9205
2 changed files with 8 additions and 0 deletions

View File

@@ -293,3 +293,6 @@ assert next(str_iter_reversed) == "2"
assert next(str_iter_reversed) == "1"
assert next(str_iter_reversed, None) == None
assert_raises(StopIteration, lambda: next(str_iter_reversed))
assert str.__rmod__('%i', 30) == NotImplemented
assert_raises(TypeError, lambda: str.__rmod__(30, '%i'))

View File

@@ -518,6 +518,11 @@ impl PyString {
do_cformat(vm, format_string, values.clone())
}
#[pymethod(name = "__rmod__")]
fn rmod(&self, _values: PyObjectRef, vm: &VirtualMachine) -> PyResult {
Ok(vm.ctx.not_implemented())
}
#[pymethod]
fn format(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
if args.args.is_empty() {