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:
@ -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
|
Reference in New Issue
Block a user