some test change because of renaming
next is a keyword, can't be used as instance writer fake_memory gets the pobject for debug
This commit is contained in:
parent
b0aefe31fe
commit
84de400529
@ -22,9 +22,9 @@ end
|
||||
require_relative "risc/padding"
|
||||
require_relative "risc/position/position"
|
||||
require_relative "risc/platform"
|
||||
require "parfait"
|
||||
require_relative "risc/parfait_adapter"
|
||||
require_relative "risc/parfait_boot"
|
||||
require_relative "risc/parfait_adapter"
|
||||
require "parfait"
|
||||
require_relative "risc/linker"
|
||||
require_relative "risc/callable_compiler"
|
||||
require_relative "risc/method_compiler"
|
||||
|
@ -58,7 +58,6 @@ module Parfait
|
||||
|
||||
space = Space.new( classes )
|
||||
Parfait.set_object_space( space )
|
||||
|
||||
end
|
||||
|
||||
# types is where the snake bites its tail. Every chain ends at a type and then it
|
||||
@ -94,6 +93,7 @@ module Parfait
|
||||
# and off cource we can't use space.create_class , but still they need to go there
|
||||
def self.boot_classes(types)
|
||||
classes = Dictionary.new
|
||||
classes.type = types[:Dictionary]
|
||||
type_names.each do |name , vars|
|
||||
super_c = super_class_names[name] || :Object
|
||||
clazz = Class.new(name , super_c , types[name] )
|
||||
@ -132,16 +132,16 @@ module Parfait
|
||||
# unfortuantely that constant condenses every detail about the system, class names
|
||||
# and all instance variable names. Really have to find a better way
|
||||
def self.type_names
|
||||
{BinaryCode: {next: :BinaryCode} ,
|
||||
Block: {binary: :BinaryCode, next: :Block,
|
||||
{BinaryCode: {next_code: :BinaryCode} ,
|
||||
Block: {binary: :BinaryCode, next_callable: :Block,
|
||||
arguments_type: :Type , self_type: :Type, frame_type: :Type,
|
||||
name: :Word } ,
|
||||
|
||||
|
||||
CacheEntry: {cached_type: :Type , cached_method: :CallableMethod } ,
|
||||
Callable: {binary: :BinaryCode,next: :Callable ,
|
||||
Callable: {binary: :BinaryCode,next_callable: :Callable ,
|
||||
arguments_type: :Type , self_type: :Type, frame_type: :Type,
|
||||
name: :Word } ,
|
||||
CallableMethod: {binary: :BinaryCode, next: :CallableMethod ,
|
||||
CallableMethod: {binary: :BinaryCode, next_callable: :CallableMethod ,
|
||||
arguments_type: :Type , self_type: :Type, frame_type: :Type ,
|
||||
name: :Word , blocks: :Block} ,
|
||||
Class: {instance_methods: :List, instance_type: :Type,
|
||||
@ -150,7 +150,7 @@ module Parfait
|
||||
Data4: {},
|
||||
Data8: {},
|
||||
Data16: {},
|
||||
Dictionary: {keys: :List , values: :List } ,
|
||||
Dictionary: {i_keys: :List , i_values: :List } ,
|
||||
Integer: {next_integer: :Integer},
|
||||
FalseClass: {},
|
||||
List: {indexed_length: :Integer , next_list: :List} ,
|
||||
|
@ -18,14 +18,14 @@ module Parfait
|
||||
assert_equal 2 , @code.get_instance_variables.get_length
|
||||
end
|
||||
def test_var_next
|
||||
assert_equal :next , @code.get_instance_variables[1]
|
||||
assert_equal :next_code , @code.get_instance_variables[1]
|
||||
end
|
||||
def test_next_nil
|
||||
assert_nil @code.next
|
||||
assert_nil @code.next_code
|
||||
end
|
||||
def test_ensure_next
|
||||
assert BinaryCode , @code.ensure_next.class
|
||||
assert @code.next
|
||||
assert @code.next_code
|
||||
end
|
||||
def test_data_length
|
||||
assert_equal 13 , @code.data_length
|
||||
@ -42,8 +42,8 @@ module Parfait
|
||||
end
|
||||
def test_next_not_nil
|
||||
@code = BinaryCode.new(16)
|
||||
assert @code.next
|
||||
assert_nil @code.next.next
|
||||
assert @code.next_code
|
||||
assert_nil @code.next_code.next_code
|
||||
end
|
||||
def test_set_char1
|
||||
assert @code.set_char(1 , 1)
|
||||
@ -74,19 +74,19 @@ module Parfait
|
||||
end
|
||||
def test_extend
|
||||
@code.extend_to(20)
|
||||
assert @code.next
|
||||
assert_nil @code.next.next
|
||||
assert @code.next_code
|
||||
assert_nil @code.next_code.next_code
|
||||
end
|
||||
def test_auto_extend #extend by seting word
|
||||
assert_nil @code.next
|
||||
assert_nil @code.next_code
|
||||
@code.set_word(20 , 1)
|
||||
assert @code.next
|
||||
assert @code.next_code
|
||||
end
|
||||
def test_extend_extended
|
||||
@code.extend_to(20)
|
||||
@code.extend_to(30)
|
||||
assert @code.next.next
|
||||
assert_nil @code.next.next.next
|
||||
assert @code.next_code.next_code
|
||||
assert_nil @code.next_code.next_code.next_code
|
||||
end
|
||||
def test_each_word
|
||||
len = 0
|
||||
@ -104,7 +104,7 @@ module Parfait
|
||||
@code.each_word(false){ |w| all << w}
|
||||
assert_equal 0 , all.first
|
||||
assert_equal 12 , all.last
|
||||
assert_nil @code.next
|
||||
assert_nil @code.next_code
|
||||
end
|
||||
def test_set_word
|
||||
assert_equal 1 , @code.set_word(1 , 1)
|
||||
@ -120,12 +120,12 @@ module Parfait
|
||||
def test_set_12
|
||||
@code.set_word(12 , 12)
|
||||
assert_equal 0 , @code.get_last
|
||||
assert_nil @code.next
|
||||
assert_nil @code.next_code
|
||||
assert_equal 12 , @code.get_word(12)
|
||||
end
|
||||
def test_set_last_no_extend
|
||||
@code.set_last(1)
|
||||
assert_nil @code.next
|
||||
assert_nil @code.next_code
|
||||
end
|
||||
def test_set_last_and_get
|
||||
@code.set_last(1)
|
||||
@ -138,9 +138,9 @@ module Parfait
|
||||
end
|
||||
def test_step_13
|
||||
@code.set_word(13,13)
|
||||
assert @code.next
|
||||
assert @code.next_code
|
||||
assert_equal 13, @code.get_word(13)
|
||||
assert_equal 13, @code.next.get_word(0)
|
||||
assert_equal 13, @code.next_code.get_word(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -68,7 +68,7 @@ module Parfait
|
||||
end
|
||||
def test_one_set1
|
||||
assert_equal 2 , @list.set(0,2)
|
||||
assert_equal 1 , @list.get_internal_word(List.get_length_index)
|
||||
assert_equal 1 , @list.get_internal_word(1)
|
||||
assert_equal 2 , @list.get_internal_word(List.type_length)
|
||||
end
|
||||
def test_set1_len
|
||||
|
@ -12,7 +12,7 @@ module Parfait
|
||||
@list.push((@list.data_length + 1).to_s)
|
||||
end
|
||||
def test_next
|
||||
assert_nil @list.next
|
||||
assert_nil @list.next_list
|
||||
end
|
||||
def test_setup_len
|
||||
assert_equal List.data_length , @list.get_length
|
||||
|
@ -11,7 +11,7 @@ module Parfait
|
||||
assert_equal 9 , @mess.get_type.instance_length , @mess.get_type.inspect
|
||||
end
|
||||
def test_attribute_set
|
||||
@mess.set_receiver( 55)
|
||||
@mess.set_receiver( 55 ) # 55 is not parfait, hance not actually allowed
|
||||
assert_equal 55 , @mess.receiver
|
||||
end
|
||||
def test_indexed
|
||||
|
@ -178,20 +178,4 @@ module Parfait
|
||||
end
|
||||
end
|
||||
end
|
||||
class TestMethods < ParfaitTest
|
||||
def setup
|
||||
super
|
||||
Risc::Builtin.boot_functions
|
||||
end
|
||||
def test_integer
|
||||
int = Parfait.object_space.get_class_by_name :Integer
|
||||
assert_equal 14, int.instance_type.method_names.get_length
|
||||
end
|
||||
def test_methods_booted
|
||||
word = @space.get_type_by_class_name(:Word)
|
||||
assert_equal 3 , word.method_names.get_length
|
||||
assert word.get_method(:putstring) , "no putstring"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
20
test/parfait/test_space2.rb
Normal file
20
test/parfait/test_space2.rb
Normal file
@ -0,0 +1,20 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Parfait
|
||||
class TestMethods < ParfaitTest
|
||||
def setup
|
||||
super
|
||||
Risc::Builtin.boot_functions
|
||||
end
|
||||
def test_integer
|
||||
int = Parfait.object_space.get_class_by_name :Integer
|
||||
assert_equal 14, int.instance_type.method_names.get_length
|
||||
end
|
||||
def test_methods_booted
|
||||
word = @space.get_type_by_class_name(:Word)
|
||||
assert_equal 3 , word.method_names.get_length
|
||||
assert word.get_method(:putstring) , "no putstring"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -27,102 +27,4 @@ module Parfait
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class TestWord < ParfaitTest
|
||||
def setup
|
||||
super
|
||||
@word = Parfait::Word.new(5)
|
||||
end
|
||||
def test_len
|
||||
assert_equal 5 , @word.length
|
||||
end
|
||||
def test_len_internal
|
||||
assert_equal 5 , @word.char_length
|
||||
end
|
||||
def test_first_char
|
||||
assert_equal 32 , @word.get_char(1)
|
||||
end
|
||||
def test_equals_copy
|
||||
assert_equal @word.copy , @word
|
||||
end
|
||||
def test_equals_copy2
|
||||
@word.set_char(0 , 2)
|
||||
@word.set_char(4 , 6)
|
||||
assert_equal @word.copy , @word
|
||||
end
|
||||
def test_equals_same
|
||||
assert_equal ::Parfait::Word.new(5) , @word
|
||||
end
|
||||
def test_index_check_get
|
||||
assert_raises RuntimeError do
|
||||
@word.get_char(-6)
|
||||
end
|
||||
end
|
||||
def test_index_check_set
|
||||
assert_raises RuntimeError do
|
||||
@word.set_char(6 , 32)
|
||||
end
|
||||
end
|
||||
def test_index_check_get
|
||||
assert_raises RuntimeError do
|
||||
@word.get_char(6)
|
||||
end
|
||||
end
|
||||
def test_index_check_set
|
||||
assert_raises RuntimeError do
|
||||
@word.set_char(-6 , 32)
|
||||
end
|
||||
end
|
||||
def test_one_char
|
||||
assert_equal 32 , @word.set_char(1 , 32)
|
||||
end
|
||||
def test_one_char_doesnt_cause_problems
|
||||
@word.set_char(1 , 32)
|
||||
assert_equal 32 , @word.get_char(1)
|
||||
end
|
||||
def test_one_set1
|
||||
assert_equal 44 , @word.set_char(1, 44 )
|
||||
end
|
||||
def test_two_sets
|
||||
assert_equal 1 , @word.set_char(1,1)
|
||||
assert_equal 44 , @word.set_char(1,44)
|
||||
end
|
||||
def test_one_get1
|
||||
test_one_set1
|
||||
assert_equal 44 , @word.get_char(1)
|
||||
end
|
||||
def test_many_get
|
||||
shouldda = { 1 => 11 , 2 => 22 , 3 => 33}
|
||||
shouldda.each do |k,v|
|
||||
@word.set_char(k,v)
|
||||
end
|
||||
shouldda.each do |k,v|
|
||||
assert_equal v , @word.get_char(k)
|
||||
end
|
||||
end
|
||||
def test_not_same
|
||||
one = Parfait.new_word("one")
|
||||
two = Parfait.new_word("two")
|
||||
assert !one.compare(two)
|
||||
end
|
||||
def test_is_same
|
||||
one = Parfait.new_word("one")
|
||||
two = Parfait.new_word("one")
|
||||
assert one.compare(two)
|
||||
end
|
||||
def test_first_char
|
||||
one = Parfait.new_word("one")
|
||||
one.set_char(0 , "T".ord)
|
||||
assert_equal "Tne" , one.to_string
|
||||
end
|
||||
def test_sec_char
|
||||
one = Parfait.new_word("one")
|
||||
one.set_char(1 , "m".ord)
|
||||
assert_equal "ome" , one.to_string
|
||||
end
|
||||
def test_more_char
|
||||
one = Parfait.new_word("one")
|
||||
assert_raises {one.set_char(3 , "s".ord)}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
101
test/parfait/test_word2.rb
Normal file
101
test/parfait/test_word2.rb
Normal file
@ -0,0 +1,101 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Parfait
|
||||
class TestWord < ParfaitTest
|
||||
def setup
|
||||
super
|
||||
@word = Parfait::Word.new(5)
|
||||
end
|
||||
def test_len
|
||||
assert_equal 5 , @word.length
|
||||
end
|
||||
def test_len_internal
|
||||
assert_equal 5 , @word.char_length
|
||||
end
|
||||
def test_first_char
|
||||
assert_equal 32 , @word.get_char(1)
|
||||
end
|
||||
def test_equals_copy
|
||||
assert_equal @word.copy , @word
|
||||
end
|
||||
def test_equals_copy2
|
||||
@word.set_char(0 , 2)
|
||||
@word.set_char(4 , 6)
|
||||
assert_equal @word.copy , @word
|
||||
end
|
||||
def test_equals_same
|
||||
assert_equal ::Parfait::Word.new(5) , @word
|
||||
end
|
||||
def test_index_check_get
|
||||
assert_raises RuntimeError do
|
||||
@word.get_char(-6)
|
||||
end
|
||||
end
|
||||
def test_index_check_set
|
||||
assert_raises RuntimeError do
|
||||
@word.set_char(6 , 32)
|
||||
end
|
||||
end
|
||||
def test_index_check_get
|
||||
assert_raises RuntimeError do
|
||||
@word.get_char(6)
|
||||
end
|
||||
end
|
||||
def test_index_check_set
|
||||
assert_raises RuntimeError do
|
||||
@word.set_char(-6 , 32)
|
||||
end
|
||||
end
|
||||
def test_one_char
|
||||
assert_equal 32 , @word.set_char(1 , 32)
|
||||
end
|
||||
def test_one_char_doesnt_cause_problems
|
||||
@word.set_char(1 , 32)
|
||||
assert_equal 32 , @word.get_char(1)
|
||||
end
|
||||
def test_one_set1
|
||||
assert_equal 44 , @word.set_char(1, 44 )
|
||||
end
|
||||
def test_two_sets
|
||||
assert_equal 1 , @word.set_char(1,1)
|
||||
assert_equal 44 , @word.set_char(1,44)
|
||||
end
|
||||
def test_one_get1
|
||||
test_one_set1
|
||||
assert_equal 44 , @word.get_char(1)
|
||||
end
|
||||
def test_many_get
|
||||
shouldda = { 1 => 11 , 2 => 22 , 3 => 33}
|
||||
shouldda.each do |k,v|
|
||||
@word.set_char(k,v)
|
||||
end
|
||||
shouldda.each do |k,v|
|
||||
assert_equal v , @word.get_char(k)
|
||||
end
|
||||
end
|
||||
def test_not_same
|
||||
one = Parfait.new_word("one")
|
||||
two = Parfait.new_word("two")
|
||||
assert !one.compare(two)
|
||||
end
|
||||
def test_is_same
|
||||
one = Parfait.new_word("one")
|
||||
two = Parfait.new_word("one")
|
||||
assert one.compare(two)
|
||||
end
|
||||
def test_first_char
|
||||
one = Parfait.new_word("one")
|
||||
one.set_char(0 , "T".ord)
|
||||
assert_equal "Tne" , one.to_string
|
||||
end
|
||||
def test_sec_char
|
||||
one = Parfait.new_word("one")
|
||||
one.set_char(1 , "m".ord)
|
||||
assert_equal "ome" , one.to_string
|
||||
end
|
||||
def test_more_char
|
||||
one = Parfait.new_word("one")
|
||||
assert_raises {one.set_char(3 , "s".ord)}
|
||||
end
|
||||
end
|
||||
end
|
@ -3,7 +3,7 @@ require_relative "../helper"
|
||||
module Risc
|
||||
class TestFakeMemory < MiniTest::Test
|
||||
def setup
|
||||
@fake = FakeMemory.new(2,16)
|
||||
@fake = FakeMemory.new(1 , 2,16)
|
||||
end
|
||||
def test_init
|
||||
assert @fake
|
||||
@ -17,9 +17,6 @@ module Risc
|
||||
def test_access_fail_big
|
||||
assert_raises {@fake.set(20 , 12)}
|
||||
end
|
||||
def test_access_fail_small
|
||||
assert_raises {@fake.set(1 , 12)}
|
||||
end
|
||||
def test_access_fail_minus
|
||||
assert_raises {@fake.set(-1 , 12)}
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user