rubyx/test/util/test_compiler_list.rb
Torsten Rüger 9f81d78767 Also make risc compilers a linked lists
also via util::compiler_ist
leave collection as much in place as possible
(though collections and seperate block_compilers are about to go)
2019-09-28 15:08:08 +03:00

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