/vendor/gems/facets-2.4.5/test/more/test_memoize.rb
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
- # Test facets/memoize.rb
- require 'facets/memoize.rb'
- require 'test/unit'
- class TC_Memoize < Test::Unit::TestCase
- class T
- def initialize(a)
- @a = a
- end
- def a
- "#{@a ^ 3 + 4}"
- end
- memoize :a
- end
- def setup
- @t = T.new(2)
- end
- def test_memoize_01
- assert_equal( @t.a, @t.a )
- end
- def test_memoize_02
- assert_equal( @t.a.__id__, @t.a.__id__ )
- end
- def test_memoize_03
- assert_equal( @t.a.__id__, @t.a.__id__ )
- end
- end