Skip to content

Commit 3077d7b

Browse files
committed
Merge branch 'master' into bojan/objfloat-__lt__
2 parents 4bb412a + 068489b commit 3077d7b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

vm/src/obj/objfloat.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,21 @@ fn float_lt(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
7777
}
7878

7979

80+
fn float_le(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
81+
arg_check!(
82+
vm,
83+
args,
84+
required = [
85+
(zelf, Some(vm.ctx.float_type())),
86+
(other, Some(vm.ctx.float_type()))
87+
]
88+
);
89+
let zelf = get_value(zelf);
90+
let other = get_value(other);
91+
let result = zelf <= other;
92+
Ok(vm.ctx.new_bool(result))
93+
}
94+
8095
fn float_abs(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
8196
arg_check!(vm, args, required = [(i, Some(vm.ctx.float_type()))]);
8297
Ok(vm.ctx.new_float(get_value(i).abs()))
@@ -188,6 +203,7 @@ pub fn init(context: &PyContext) {
188203
let ref float_type = context.float_type;
189204
float_type.set_attr("__eq__", context.new_rustfunc(float_eq));
190205
float_type.set_attr("__lt__", context.new_rustfunc(float_lt));
206+
float_type.set_attr("__le__", context.new_rustfunc(float_le));
191207
float_type.set_attr("__abs__", context.new_rustfunc(float_abs));
192208
float_type.set_attr("__add__", context.new_rustfunc(float_add));
193209
float_type.set_attr("__divmod__", context.new_rustfunc(float_divmod));

0 commit comments

Comments
 (0)