Skip to content

Commit a510aed

Browse files
Tests and fix objobject ne impl
1 parent dab4f73 commit a510aed

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

tests/snippets/builtin_complex.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@
88

99
assert complex(1, -1) == complex(1, -1)
1010
assert complex(1, 0) == 1
11-
assert not complex(1, 1) == 1
11+
assert 1 == complex(1, 0)
12+
assert complex(1, 1) != 1
13+
assert 1 != complex(1, 1)
1214
assert complex(1, 0) == 1.0
13-
assert not complex(1, 1) == 1.0
14-
assert not complex(1, 0) == 1.5
15+
assert 1.0 == complex(1, 0)
16+
assert complex(1, 1) != 1.0
17+
assert 1.0 != complex(1, 1)
18+
assert complex(1, 0) != 1.5
19+
assert not 1.0 != complex(1, 0)
1520
assert bool(complex(1, 0))
16-
assert not complex(1, 2) == complex(1, 1)
17-
# Currently broken - see issue #419
18-
# assert complex(1, 2) != 'foo'
21+
assert complex(1, 2) != complex(1, 1)
22+
assert complex(1, 2) != 'foo'
1923
assert complex(1, 2).__eq__('foo') == NotImplemented
2024

2125
# __neg__

vm/src/obj/objobject.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ fn object_ne(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
4040
args,
4141
required = [(zelf, Some(vm.ctx.object())), (other, None)]
4242
);
43-
let eq = vm.call_method(zelf, "__eq__", vec![other.clone()])?;
43+
44+
let eq = vm._eq(zelf.clone(), other.clone())?;
4445
objbool::not(vm, &eq)
4546
}
4647

0 commit comments

Comments
 (0)