Change order of arguments in `match` object of `equal-to-matcher`
Closed this issue · 5 comments
I try to do:
[] > test
* 1 2 3 > arr
assert-that > @
list arr
$.equal-to arr
Writing the tests I have in mind: assert that list
is equal to arr
. I expect test works fine.
The result:
EOtest_worksTest.testWorks:169->PhDefault.attr:253->PhDefault.attr:253 » Ex EOorg.EOeolang.EOstringν107="The object is at the line #34, position #6; caused by Error at "match.σ" attribute; caused by Error at "equal-to-matcher.x" attribute; caused by The object is at the line #73, position #21; caused by Error at "equal-to.x" attribute; caused by The object is at the line #50, position #17; caused by Error at "test-works.res" attribute; caused by The object is at the line #42, position #2; caused by ExUnset: Error at "EOorg.EOeolang.EOarray#eq" attribute; caused by ExUnset: Can't get(), attribute "eq" is absent among other 7 attrs (ρ, with, σ, at, Δ, length, empty) and φ is absent"SF
The reasons of such behaviour are:
- array does not have object
eq
- order of comparison in
match
object ofequal-to-matcher
:
[x] > equal-to-matcher
[a] > match
eq. > @
x
a
Here a
is an actual value, x
is what we expect. So when we say "assert that a
is equal to x
" I believe it would be more correct to do a.eq x
not x.eq a
.
@Graur WDYT?
@maxonfjvipon I don't see the difference. This order was managed according to original Hamcrest documentation: https://hamcrest.org/JavaHamcrest/javadoc/1.3/org/hamcrest/Matchers.html#equalTo(T)
And this reordering won't help to avoid such errors
@Graur in this case with list-equal-to-array comparison it will help because list
has method eq
but array
does not.
And when we say list equal to array we mean that we call eq
method of list
not array
@maxonfjvipon I believe we shouldn't compare list and array. We can compare only lists
@Graur I got you, thanks