Skip to content

Instantly share code, notes, and snippets.

@tundal45
Created June 29, 2010 19:54
Show Gist options
  • Save tundal45/457723 to your computer and use it in GitHub Desktop.
Save tundal45/457723 to your computer and use it in GitHub Desktop.
require 'test/unit'
class StringTest < 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