Forum: Ruby test/unit : params order in assert_equal

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2c7c807a1df0c76a8fc823c709b501a9?d=identicon&s=25 Victor Shepelev (Guest)
on 2006-05-05 07:19
(Received via mailing list)
Hi all.

I've found myself to always writing:

assert_equal variable_to_test, 'value expected'

And Test::Unit says to me:
'some wrong value' expected but was 'value expected'

when I'd want to see

'value expected' expected but was 'some wrong value'

Is it because English is not my native? I mean, all others think that
order

assert equal <what I test>, <what I expect>

is natural?

BTW, "my" order seems more natural to mee also because long expressions:
assert_equal some/very*long.calculations(Of::My.value), 'blah'
vs.
assert_equal 'blah', some/very*long.calculations(Of::My.value)

Thanks,
Victor.
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 Eric Hodel (Guest)
on 2006-05-05 10:04
(Received via mailing list)
On May 4, 2006, at 10:19 PM, Victor Shepelev wrote:

>
> 'value expected' expected but was 'some wrong value'
>
> Is it because English is not my native? I mean, all others think
> that order
>
> assert equal <what I test>, <what I expect>
>
> is natural?

expected always comes first for all the assertions.

--
Eric Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
2c7c807a1df0c76a8fc823c709b501a9?d=identicon&s=25 Victor Shepelev (Guest)
on 2006-05-05 12:36
(Received via mailing list)
> BTW, "my" order seems more natural to mee also because long expressions:
> assert_equal some/very*long.calculations(Of::My.value), 'blah'
> vs.
> assert_equal 'blah', some/very*long.calculations(Of::My.value)

Wrong example :) I meant the opposite:

[Some very long calculation of x]
assert_equal x, %w(one two three four five) #my way
vs.
[Some very long calculation of x]
assert_equal %w(one two three four five), x #common way

sorry :)

victor.
68db3bafb0a990bf605c4cf62bf85db0?d=identicon&s=25 bpettichord@gmail.com (Guest)
on 2006-05-17 08:03
(Received via mailing list)
assert_equal seems backwards to native english speakers, too. use rspec
instead.

  require 'spec' # gem install rspec
  # calculate x
  x.should.equal %w(one two three four five)

it actually works!

bret
This topic is locked and can not be replied to.