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.
Victor S. (Guest)
on 2006-05-05 09: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.
Eric H. (Guest)
on 2006-05-05 12:04
(Received via mailing list)
On May 4, 2006, at 10:19 PM, Victor S. 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 H. - removed_email_address@domain.invalid - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
Victor S. (Guest)
on 2006-05-05 14: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.
(Guest)
on 2006-05-17 10: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.