Sha256: b3ce68fa2eaf98d34c7cee53ab21592cc7df51644a9de2f06929bbd9f367005e

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

%w( . ./lib ../lib ).each{|lib| $:.unshift lib}
require 'pervasives'
require 'test/unit'

class Pervasives::Test < Test::Unit::TestCase

  def test_a_0
    klass = Class.new
    pklass = nil 
    obj = nil

    assert_nothing_raised{ pklass = Pervasives klass }
    assert_nothing_raised{ obj = pklass.new }

    assert_equal klass, obj.class 
  end


  def test_b_0
    klass = Class.new
    obj = nil
    value = nil

    klass.module_eval{ def self.new() raise end }
    assert_nothing_raised{ obj = Pervasives(klass).new }

    klass.module_eval{ def class() raise end}
    assert_nothing_raised{ value = Pervasives(obj).class }
    assert_equal klass, value 

    klass.module_eval{ def to_s() raise end}
    assert_nothing_raised{ Pervasives(obj).to_s }
  end

  def test_c_0
    klass = Class.new
    obj = nil
    proxy = nil


    assert_nothing_raised{ obj = Pervasives(klass).new }
    object_id = obj.object_id
    to_s = obj.to_s

    instance_method_list = nil
    klass.module_eval{
      instance_method_list = instance_methods
      instance_methods.each{|m| define_method(m){ raise }}
    }

    assert_nothing_raised{ proxy = Pervasives obj }

    assert_nothing_raised{ proxy.to_s }
    assert_equal to_s, proxy.to_s
    assert_equal to_s, Pervasives(obj).to_s
    assert_equal object_id, proxy.object_id
    assert_equal object_id, Pervasives(obj).object_id
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pervasives-1.1.0 test/pervasives.rb