Sha256: 49cb211ea846159dd9dd7d16fee4ec06c01876e2e76e7b5b9d62505e2a04c080

Contents?: true

Size: 466 Bytes

Versions: 4

Compression:

Stored size: 466 Bytes

Contents

covers 'facets/module/memoize'

tests Module do

  unit :memoize  do
    tc = Class.new do
      def initialize(a)
        @a = a
      end
      def a
        "#{@a ^ 3 + 4}"
      end
      memoize :a
    end

    t1 = tc.new(1)
    t2 = tc.new(2)
    t3 = tc.new(3)

    t1.a.assert == "6"
    t2.a.assert == "5"
    t3.a.assert == "4"

    t1.a.__id__.assert == t1.a.__id__
    t2.a.__id__.assert == t2.a.__id__
    t3.a.__id__.assert == t3.a.__id__
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
facets-2.9.1 test/core-uncommon/module/test_memoize.rb
facets-2.9.0 test/tour/module/test_memoize.rb
facets-2.9.0.pre.2 test/tour/module/test_memoize.rb
facets-2.9.0.pre.1 test/tour/module/test_memoize.rb