Created
November 27, 2011 06:20
-
-
Save austinbv/1397084 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def == (list) | |
(0..size).each do |position| | |
if set[position] != list.set[position] | |
return false | |
end | |
end | |
true | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
context "with a populated list" do | |
before(:each) do | |
@list = List.new | |
@list.add 1 | |
@list.add 4 | |
@list.add 5 | |
@list.add 3 | |
end | |
describe "when campairing to another list" do | |
it "retuns true when the lists are equal" do | |
list2 = List.new | |
list2.add 1 | |
list2.add 4 | |
list2.add 5 | |
list2.add 3 | |
@list.equals(list2).should be_true | |
(@list == list2).should be_true | |
(@list != list2).should be_false | |
end | |
it "returns false when the lists aren't equal" do | |
list2 = List.new | |
list2.add 2 | |
list2.add 4 | |
list2.add 6 | |
list2.add 3 | |
@list.equals(list2).should be_false | |
(@list == list2).should be_false | |
(@list != list2).should be_true | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment