Sha256: d9c1522119c6b3c65a3a569788352bb020726eb5e6857f17d2b8ec541d152462

Contents?: true

Size: 779 Bytes

Versions: 21

Compression:

Stored size: 779 Bytes

Contents

class Nanoc::Int::MemoizationTest < Nanoc::TestCase
  class Sample1
    extend Nanoc::Int::Memoization

    def initialize(value)
      @value = value
    end

    def run(n)
      @value * 10 + n
    end
    memoize :run
  end

  class Sample2
    extend Nanoc::Int::Memoization

    def initialize(value)
      @value = value
    end

    def run(n)
      @value * 100 + n
    end
    memoize :run
  end

  def test_normal
    sample1a = Sample1.new(10)
    sample1b = Sample1.new(15)
    sample2a = Sample2.new(20)
    sample2b = Sample2.new(25)

    3.times do
      assert_equal 10 * 10 + 5,  sample1a.run(5)
      assert_equal 10 * 15 + 7,  sample1b.run(7)
      assert_equal 100 * 20 + 5, sample2a.run(5)
      assert_equal 100 * 25 + 7, sample2b.run(7)
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
nanoc-4.2.2 test/base/test_memoization.rb
nanoc-4.2.1 test/base/test_memoization.rb
nanoc-4.2.0 test/base/test_memoization.rb
nanoc-4.1.6 test/base/test_memoization.rb
nanoc-4.2.0b1 test/base/test_memoization.rb
nanoc-4.1.5 test/base/test_memoization.rb
nanoc-4.1.4 test/base/test_memoization.rb
nanoc-4.1.3 test/base/test_memoization.rb
nanoc-4.1.2 test/base/test_memoization.rb
nanoc-4.1.1 test/base/test_memoization.rb
nanoc-4.1.0 test/base/test_memoization.rb
nanoc-4.1.0rc2 test/base/test_memoization.rb
nanoc-4.1.0rc1 test/base/test_memoization.rb
nanoc-4.1.0b1 test/base/test_memoization.rb
nanoc-4.1.0a1 test/base/test_memoization.rb
nanoc-4.0.2 test/base/test_memoization.rb
nanoc-4.0.1 test/base/test_memoization.rb
nanoc-4.0.0 test/base/test_memoization.rb
nanoc-4.0.0rc3 test/base/test_memoization.rb
nanoc-4.0.0rc2 test/base/test_memoization.rb