PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/gems/facets-2.4.5/test/more/test_prototype.rb

https://bitbucket.org/mediashelf/fedora-migrator
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
  1. # Test facets/prototype.rb
  2. require 'facets/prototype.rb'
  3. require 'test/unit'
  4. class TestPrototypeKernel < Test::Unit::TestCase
  5. def test_new
  6. q = nil
  7. s = "Testing"
  8. assert_nothing_raised { q = s.new }
  9. assert_equal( s, q )
  10. assert_not_equal( s.object_id, q.object_id )
  11. end
  12. end
  13. class TestPrototype < Test::Unit::TestCase
  14. def setup
  15. @person = prototype do
  16. @name = ''
  17. @age = 0
  18. @announce = fn { |x| "#{x}, #{name} is #{age}" }
  19. end
  20. @person.name = 'Tom'
  21. @person.age = 35
  22. end
  23. def test_simple_case
  24. assert_equal( "Peter, Tom is 35", @person.announce['Peter'])
  25. end
  26. end