This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Assert.sol - Bug in Assert.notEqual
for list types
#770
Comments
Also, here is the output from
|
This actually will also fail when the very first element of the arrays match. The code goes like this:
So if |
PR#769 contains the fix for this as well. |
Closing this in favor of trufflesuite/truffle-core#101 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When working on #769, I was reviewing your pattern for error reporting and noticed that you have a bug in the case where two equal length arrays with different values will fail the
Assert.notEqual
check.Lets say
a
contains[1,2]
andb
contains[3, 4]
, you would expectAssert.notEqual(a, b, "a not equal to b");
to return true since they are not equal to each other. However, due to the way that this case is handled, the function incorrectly treats them as equal.Here is a short test case to illustrate the point. Below, the
testEqual_GOOD()
does the right thing and asserts, while thetestNotEqual_BAD()
throws an assert even though the two arrays are clearly not equal (but have the same length). Notice that if the arrays are of different lengths - everything is a-ok (testNotEqual_GOOD()
).This error occurs due to the fact that you guys employ a negation trick on the call to
_report
for these cases since the variabler
captures the equality of the lengths of the arrays being compared. If the lengths do not match, this works great. The bug lives in the code where on a match (not equal is true) - the code setsr
to true which is later negated.I will send you a patch shortly :)
The text was updated successfully, but these errors were encountered: