Sha256: 3a18a4887da89c304ad2ee4e9b9276301ccd9d2cf6499acdcdcada033010d55d

Contents?: true

Size: 676 Bytes

Versions: 5

Compression:

Stored size: 676 Bytes

Contents

require File.join(File.dirname(__FILE__), '..', '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

5 entries across 5 versions & 2 rubygems

Version Path
godfat-ludy-0.1.13 test/ludy/test_variable.rb
ludy-0.1.10 test/ludy/test_variable.rb
ludy-0.1.11 test/ludy/test_variable.rb
ludy-0.1.13 test/ludy/test_variable.rb
ludy-0.1.9 test/ludy/test_variable.rb