fold last of the virtual into register
This commit is contained in:
4
test/register/test_all.rb
Normal file
4
test/register/test_all.rb
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
require_relative "test_compat"
|
||||
require_relative "test_padding"
|
||||
require_relative "test_positioning"
|
22
test/register/test_compat.rb
Normal file
22
test/register/test_compat.rb
Normal file
@ -0,0 +1,22 @@
|
||||
require_relative "../helper"
|
||||
|
||||
|
||||
class TestCompat < MiniTest::Test
|
||||
|
||||
def setup
|
||||
Register.machine.boot unless Register.machine.booted
|
||||
end
|
||||
|
||||
def test_list_create_from_array
|
||||
array = [1,2,3]
|
||||
list = Register.new_list(array)
|
||||
assert_equal array , list.to_a
|
||||
end
|
||||
|
||||
def test_word_create_from_string
|
||||
string = "something"
|
||||
word = Register.new_word(string)
|
||||
assert_equal word , Register.new_word(string)
|
||||
assert_equal string , word.to_string
|
||||
end
|
||||
end
|
31
test/register/test_machine.rb
Normal file
31
test/register/test_machine.rb
Normal file
@ -0,0 +1,31 @@
|
||||
#require_relative "compiler_helper"
|
||||
|
||||
class TestMachine #< MiniTest::Test
|
||||
#include CompilerHelper
|
||||
|
||||
def test_object
|
||||
@string_input = <<HERE
|
||||
class Object
|
||||
def get_class()
|
||||
@layout.get_class()
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@output = nil
|
||||
check
|
||||
end
|
||||
|
||||
def test_message_tpye
|
||||
@string_input = <<HERE
|
||||
class Message
|
||||
def get_type_for(name)
|
||||
index = @layout.get_index(name)
|
||||
get_at(index)
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@output = ""
|
||||
check
|
||||
end
|
||||
|
||||
end
|
27
test/register/test_padding.rb
Normal file
27
test/register/test_padding.rb
Normal file
@ -0,0 +1,27 @@
|
||||
require_relative "../helper"
|
||||
|
||||
class Padded
|
||||
include Padding
|
||||
end
|
||||
|
||||
class TestPadding < MiniTest::Test
|
||||
|
||||
def setup
|
||||
@pad = Padded.new
|
||||
end
|
||||
def test_small
|
||||
[6,20,23,24].each do |p|
|
||||
assert_equal 32 , @pad.padded(p) , "Expecting 32 for #{p}"
|
||||
end
|
||||
end
|
||||
def test_medium
|
||||
[26,40,53,56].each do |p|
|
||||
assert_equal 64 , @pad.padded(p) , "Expecting 64 for #{p}"
|
||||
end
|
||||
end
|
||||
def test_large
|
||||
[58,88].each do |p|
|
||||
assert_equal 96 , @pad.padded(p) , "Expecting 96 for #{p}"
|
||||
end
|
||||
end
|
||||
end
|
24
test/register/test_positioning.rb
Normal file
24
test/register/test_positioning.rb
Normal file
@ -0,0 +1,24 @@
|
||||
require_relative "../helper"
|
||||
|
||||
class TestPositioning < MiniTest::Test
|
||||
def setup
|
||||
Register.machine.boot unless Register.machine.booted
|
||||
end
|
||||
def test_list1
|
||||
list = Register.new_list([1])
|
||||
list.set_layout( Parfait::Layout.new Object)
|
||||
assert_equal 32 , list.word_length
|
||||
end
|
||||
def test_list5
|
||||
list = Register.new_list([1,2,3,4,5])
|
||||
list.set_layout( Parfait::Layout.new Object)
|
||||
# TODO check why this is 64 and not 32
|
||||
assert_equal 32 , list.word_length
|
||||
end
|
||||
def test_layout
|
||||
layout = Parfait::Layout.new Object
|
||||
layout.set_layout( Parfait::Layout.new Object)
|
||||
layout.push 5
|
||||
assert_equal 32 , layout.word_length
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user