2019-09-28 08:38:34 +02:00
|
|
|
require_relative "../helper"
|
|
|
|
|
|
|
|
module Util
|
|
|
|
class MethodCompiler
|
|
|
|
include Util::CompilerList
|
|
|
|
attr_reader :name
|
|
|
|
def initialize(name)
|
|
|
|
@name = name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-09-28 14:07:20 +02:00
|
|
|
class TestCompilerListOne < Minitest::Test
|
2019-09-28 08:38:34 +02:00
|
|
|
|
|
|
|
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
|
2019-09-28 11:41:38 +02:00
|
|
|
assert_equal :one , @compiler.find_compiler{|c| c.name == :one}.name
|
2019-09-28 08:38:34 +02:00
|
|
|
end
|
|
|
|
end
|
2019-09-28 14:07:20 +02:00
|
|
|
class TestCompilerListTwo < Minitest::Test
|
2019-09-28 08:38:34 +02:00
|
|
|
|
|
|
|
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
|
2019-09-28 11:41:38 +02:00
|
|
|
def test_each
|
|
|
|
all = []
|
|
|
|
@compiler.each_compiler{|c| all << c.name}
|
|
|
|
assert_equal [:one, :two] , all
|
|
|
|
end
|
2019-09-28 08:38:34 +02:00
|
|
|
end
|
|
|
|
end
|