PageRenderTime 908ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/mediashelf/fedora-migrator
Ruby | 36 lines | 25 code | 10 blank | 1 comment | 0 complexity | f210ed919dbb65fc2f3ce03cc8668c64 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, IPL-1.0, AGPL-1.0, LGPL-3.0
  1. # Test facets/memoize.rb
  2. require 'facets/memoize.rb'
  3. require 'test/unit'
  4. class TC_Memoize < Test::Unit::TestCase
  5. class T
  6. def initialize(a)
  7. @a = a
  8. end
  9. def a
  10. "#{@a ^ 3 + 4}"
  11. end
  12. memoize :a
  13. end
  14. def setup
  15. @t = T.new(2)
  16. end
  17. def test_memoize_01
  18. assert_equal( @t.a, @t.a )
  19. end
  20. def test_memoize_02
  21. assert_equal( @t.a.__id__, @t.a.__id__ )
  22. end
  23. def test_memoize_03
  24. assert_equal( @t.a.__id__, @t.a.__id__ )
  25. end
  26. end