daily pastebin goal
37%
SHARE
TWEET

Untitled

a guest May 26th, 2018 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require 'test/unit'
  2.  
  3. class ShallowTest < Test::Unit::TestCase
  4.   def test_standard_copy_should_be_by_reference_and_changes_should_back_propagate
  5.     simple_array = [1,"hello", 3.000]
  6.     copied_array = simple_array
  7.     copied_array[0] = nil
  8.     copied_array[1] = nil
  9.     copied_array[2] = nil
  10.    
  11.     assert_equal copied_array, simple_array
  12.   end
  13.  
  14.   def test_clone_should_be_by_value_and_changes_should_not_back_propogate
  15.     simple_array = [1,"hello", 3.000]
  16.     copied_array = simple_array.clone
  17.     copied_array[0] = nil
  18.     copied_array[1] = nil
  19.     copied_array[2] = nil
  20.    
  21.     assert_not_equal copied_array, simple_array
  22.   end
  23. end
  24.  
  25. #  2 tests, 2 assertions, 0 failures, 0 errors
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top