fluent-asserts
fluent-asserts copied to clipboard
opEquals() is not honoured with 0.14 alpha 8
with Version 0.14.0.alpha8 opEquals()
is not honoured anymore when asserting equality. It worked prior version 0.14. See the following MWE:
import std.stdio;
import fluent.asserts;
void main() {}
class Thing {
int x;
this(int x) { this.x = x; }
override bool opEquals(Object o) {
if(typeid(this) != typeid(o)) return false;
alias a = this;
auto b = cast(typeof(this)) o;
return a.x == b.x;
}
}
unittest {
auto a1 = new Thing(1);
auto b1 = new Thing(1);
auto a2 = new Thing(2);
assert(a1 == b1); // works
assert(a1 != a2); // works
a1.should.equal(b1); // a1 should equal Thing(132421593017436). Thing(132421593017402) is not equal to Thing(132421593017436)
a1.should.not.equal(a2); // works
}