Torsten Rüger
9f81d78767
also via util::compiler_ist leave collection as much in place as possible (though collections and seperate block_compilers are about to go)
52 lines
1.2 KiB
Ruby
52 lines
1.2 KiB
Ruby
require_relative "../helper"
|
|
|
|
module Util
|
|
class MethodCompiler
|
|
include Util::CompilerList
|
|
attr_reader :name
|
|
def initialize(name)
|
|
@name = name
|
|
end
|
|
end
|
|
|
|
class TestCompilerListOne < Minitest::Test
|
|
|
|
def setup
|
|
@compiler = MethodCompiler.new(:one)
|
|
end
|
|
def add_two
|
|
@compiler.add_method_compiler MethodCompiler.new(:two)
|
|
end
|
|
def test_basic_length
|
|
assert_equal 1 , @compiler.num_compilers
|
|
end
|
|
def test_last_empty
|
|
assert_equal :one , @compiler.last_compiler.name
|
|
end
|
|
def test_find_one
|
|
assert_equal :one , @compiler.find_compiler{|c| c.name == :one}.name
|
|
end
|
|
end
|
|
class TestCompilerListTwo < Minitest::Test
|
|
|
|
def setup
|
|
@compiler = MethodCompiler.new(:one)
|
|
@compiler.add_method_compiler MethodCompiler.new(:two)
|
|
end
|
|
def test_can_add
|
|
assert_equal 2 , @compiler.num_compilers
|
|
end
|
|
def test_last_two
|
|
assert_equal :two , @compiler.last_compiler.name
|
|
end
|
|
def test_find_two
|
|
assert_equal :two , @compiler.find_compiler{|c| c.name == :two}.name
|
|
end
|
|
def test_each
|
|
all = []
|
|
@compiler.each_compiler{|c| all << c.name}
|
|
assert_equal [:one, :two] , all
|
|
end
|
|
end
|
|
end
|