Forum: IronRuby should equal in RubySpecs

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.
Shri B. (Guest)
on 2009-01-07 11:09
(Received via mailing list)
I noticed this in core\thread\current_spec.rb.

  it "returns the current thread" do
    t = Thread.new { Thread.current }
    t.value.should equal(t)
    Thread.current.should_not equal(t.value)
  end

Is this any different than writing "t.value.should == t"? Is either of
them the recommended way? Seems odd to support two ways of writing the
exact same thing.

Thanks,
Shri
Michael L. (Guest)
on 2009-01-07 21:26
(Received via mailing list)
require 'mspec'
describe "equals" do
  it "compares objects not values" do

    a = "a"
    b = "a"
    c = a

    a.should equal(c)
    a.should_not equal(b)
    a.should == b

  end
end
Shri B. (Guest)
on 2009-01-07 21:43
(Received via mailing list)
I see. should== is value equality, and should+equal is reference
equality.

From: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] On Behalf Of Michael
Letterle
Sent: Wednesday, January 07, 2009 11:26 AM
To: removed_email_address@domain.invalid
Subject: Re: [Ironruby-core] should equal in RubySpecs

require 'mspec'
describe "equals" do
  it "compares objects not values" do

    a = "a"
    b = "a"
    c = a

    a.should equal(c)
    a.should_not equal(b)
    a.should == b

  end
end

On Wed, Jan 7, 2009 at 3:48 AM, Shri B.
<removed_email_address@domain.invalid<mailto:removed_email_address@domain.invalid>> 
wrote:

I noticed this in core\thread\current_spec.rb.



  it "returns the current thread" do

    t = Thread.new { Thread.current }

    t.value.should equal(t)

    Thread.current.should_not equal(t.value)

  end



Is this any different than writing "t.value.should == t"? Is either of
them the recommended way? Seems odd to support two ways of writing the
exact same thing.



Thanks,

Shri
Jim D. (Guest)
on 2009-01-07 21:58
(Received via mailing list)
Along those lines, you have to remember that Ruby has 4 distinct ways to
define equality. #eql?, #equal?, #== and #===.  This post covers it:
http://probablycorey.wordpress.com/2008/02/26/ruby...

JD

From: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] On Behalf Of Michael
Letterle
Sent: Wednesday, January 07, 2009 11:26 AM
To: removed_email_address@domain.invalid
Subject: Re: [Ironruby-core] should equal in RubySpecs

require 'mspec'
describe "equals" do
  it "compares objects not values" do

    a = "a"
    b = "a"
    c = a

    a.should equal(c)
    a.should_not equal(b)
    a.should == b

  end
end

On Wed, Jan 7, 2009 at 3:48 AM, Shri B.
<removed_email_address@domain.invalid<mailto:removed_email_address@domain.invalid>> 
wrote:

I noticed this in core\thread\current_spec.rb.



  it "returns the current thread" do

    t = Thread.new { Thread.current }

    t.value.should equal(t)

    Thread.current.should_not equal(t.value)

  end



Is this any different than writing "t.value.should == t"? Is either of
them the recommended way? Seems odd to support two ways of writing the
exact same thing.



Thanks,

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