Sha256: 9c6896b650a30821e5687d8feab480224d7344b0bc4d938eb4b678551f6cd7a6

Contents?: true

Size: 693 Bytes

Versions: 6

Compression:

Stored size: 693 Bytes

Contents

require File.join(File.dirname(__FILE__), '..', 'lib', 'ludy/test/helper')
require 'ludy/variable'

class TestVariable < Test::Unit::TestCase
  include Ludy
  def swap a, b
    a.__obj__, b.__obj__ = b.__obj__, a.__obj__
  end

  def test_swap
    a, b = var(1), var(2)
    swap a, b
    assert_equal 2, a
    assert_equal 1, b
  end

  class Qoo
    def cool
      'cool ~~~~'
    end
  end
  def test_variable
    x = var Qoo.new
    y = x

    assert_equal x.__obj__, y.__obj__
    assert_equal Qoo, x.__obj__.class
    assert_equal Qoo, x.class

    assert_equal 'cool ~~~~', x.cool
    assert_equal 'cool ~~~~', y.cool

    x.__obj__ = nil

    assert x.nil?
    assert y.nil?
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ludy-0.1.3 test/test_variable.rb
ludy-0.1.4 test/test_variable.rb
ludy-0.1.5 test/test_variable.rb
ludy-0.1.6 test/test_variable.rb
ludy-0.1.7 test/test_variable.rb
ludy-0.1.8 test/test_variable.rb