Skip to content

Instantly share code, notes, and snippets.

@tundal45
Created June 29, 2010 20:01
Show Gist options
  • Save tundal45/457730 to your computer and use it in GitHub Desktop.
Save tundal45/457730 to your computer and use it in GitHub Desktop.
require 'test/unit'
class ArrayTest < Test::Unit::TestCase
def test_plus_equals_creates_new_object
original_string = ["Hello"]
hi = original_string
assert_equal original_string.object_id, hi.object_id
there = ["World"]
hi += there
assert_not_equal original_string.object_id, hi.object_id
end
def test_shovel_does_not_create_new_object
original_string = ["Hello"]
hi = original_string
assert_equal original_string.object_id, hi.object_id
there = ["World"]
hi << there
assert_equal original_string.object_id, hi.object_id
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment