integer was wrong padded§ length

or rather right (2 as should be and will be)
but currently we use next AND value + type means 3, rounded 4
because we can’t swap types at compile time (as is planned at runtime,
we use next OR value)
This commit is contained in:
Torsten Ruger
2018-05-30 14:55:17 +03:00
parent 53107d3ef8
commit e86ca5ae9d
8 changed files with 72 additions and 30 deletions

View File

@ -3,7 +3,7 @@ require_relative "../helper"
class HelloTest < MiniTest::Test
def setup
Risc.machine
Risc.machine.boot
end
def check
Vool::VoolCompiler.ruby_to_binary( "class Space;def main(arg);#{@input};end;end" )

View File

@ -14,7 +14,7 @@ end
require "minitest/color"
require "minitest/autorun"
require "minitest/fail_fast"
#require "minitest/fail_fast"
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'test'))

View File

@ -0,0 +1,46 @@
require_relative "helper"
module Parfait
class TestClass < ParfaitTest
def test_data_class_api_base
assert_raises {DataObject.type_length}
end
def test_data_class_api4
assert_equal 4 , Data4.memory_size
end
def test_data_class_api8
assert_equal 8 , Data8.memory_size
end
def test_data_class_api16
assert_equal 16 , Data16.memory_size
end
def test_data_class_api32
assert_equal 32 , Data32.memory_size
end
def test_int_len
assert_equal 4 , Integer.new(1).data_length
end
def test_true_len
assert_equal 4 , TrueClass.new.data_length
end
def test_false_len
assert_equal 4 , FalseClass.new.data_length
end
def test_nil_len
assert_equal 4 , NilClass.new.data_length
end
def test_int_pad
assert_equal 16 , Integer.new(2).padded_length
end
def test_true_pad
assert_equal 16 , TrueClass.new.padded_length
end
def test_false_pad
assert_equal 16 , FalseClass.new.padded_length
end
def test_nil_pad
assert_equal 16 , NilClass.new.padded_length
end
end
end

View File

@ -46,7 +46,7 @@ module Risc
ret = main_ticks(63)
assert_equal FunctionReturn , ret.class
assert_equal :r1 , ret.register.symbol
assert_equal 18628 , @interpreter.get_register(ret.register)
assert_equal 19460 , @interpreter.get_register(ret.register)
end
def test_sys
sys = main_ticks(65)

View File

@ -52,7 +52,7 @@ module Risc
end
def test_pc1
@interpreter.tick
assert_equal 18392 , @interpreter.pc
assert_equal 19224 , @interpreter.pc
end
def test_tick2
@interpreter.tick
@ -66,7 +66,7 @@ module Risc
def test_pc2
@interpreter.tick
@interpreter.tick
assert_equal 18396 , @interpreter.pc
assert_equal 19228 , @interpreter.pc
end
def test_tick_14_jump
14.times {@interpreter.tick}

View File

@ -29,10 +29,10 @@ module Risc
assert_equal 0 , Position.get(@machine.cpu_init).at
end
def test_cpu_at
assert_equal "0x5714" , Position.get(@machine.cpu_init.first).to_s
assert_equal "0x5a54" , Position.get(@machine.cpu_init.first).to_s
end
def test_cpu_bin
assert_equal "0x570c" , Position.get(Position.get(@machine.cpu_init.first).binary).to_s
assert_equal "0x5a4c" , Position.get(Position.get(@machine.cpu_init.first).binary).to_s
end
def test_cpu_label
assert_equal Position::InstructionPosition , Position.get(@machine.cpu_init.first).class