Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opEquals() is not honoured with 0.14 alpha 8 #98

Open
skruppy opened this issue Sep 12, 2021 · 4 comments
Open

opEquals() is not honoured with 0.14 alpha 8 #98

skruppy opened this issue Sep 12, 2021 · 4 comments

Comments

@skruppy
Copy link

skruppy commented Sep 12, 2021

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
}
@gedaiu
Copy link
Owner

gedaiu commented Sep 16, 2021

It's interesting that you have all of these edge cases... I guess you have some complex tests. Those asserts are fixed now on 0.14.0.alpha9

Please let me know how it works for you.

@skruppy
Copy link
Author

skruppy commented Sep 18, 2021

Thanks for your quick response. I still have to test the new release in the "big" project, but for now, it seems I still have some edge cases up my sleeve https://gitlab.com/Skruppy/csg-fitter/-/jobs/1601647959 , sorry 😄. Some of the assertion fails are from my project not fully ported to the newest dmd release, but some unfortunately are probably still fluent assers problems.

@skruppy
Copy link
Author

skruppy commented Sep 19, 2021

I'm super sorry, but I found an other edge case. With alpha.9, the upper examples works, but by changing the variables to arrays it will fail again:

	assert([a1] == [b1]); // works
	assert([a1] != [a2]); // works
	
	[a1].should.equal([b1]); // [a1] should equal [Thing(132599446648072)]
	[a1].should.not.equal([a2]); // works

@gedaiu
Copy link
Owner

gedaiu commented Sep 19, 2021

No worries! Unfortunately, I don't have much time for developing this library, so thanks for finding those use cases. Comparing object using opEqual is enabled just for the equal operation. I will reserve some time to do it for the others as well... maybe next weekend. I hope you don't need those right away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants