/vendor/gems/facets-2.4.5/test/more/test_prototype.rb
Ruby | 35 lines | 25 code | 9 blank | 1 comment | 0 complexity | 10842930928d458c553bde20032248cc MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, IPL-1.0, AGPL-1.0, LGPL-3.0
- # Test facets/prototype.rb
- require 'facets/prototype.rb'
- require 'test/unit'
- class TestPrototypeKernel < Test::Unit::TestCase
- def test_new
- q = nil
- s = "Testing"
- assert_nothing_raised { q = s.new }
- assert_equal( s, q )
- assert_not_equal( s.object_id, q.object_id )
- end
- end
- class TestPrototype < Test::Unit::TestCase
- def setup
- @person = prototype do
- @name = ''
- @age = 0
- @announce = fn { |x| "#{x}, #{name} is #{age}" }
- end
- @person.name = 'Tom'
- @person.age = 35
- end
- def test_simple_case
- assert_equal( "Peter, Tom is 35", @person.announce['Peter'])
- end
- end