switch to 0 based indexing

the world rocked for a moment (and more fixes to follow)
also the crumbling of idealism was heard
This commit is contained in:
Torsten Ruger 2018-05-14 11:55:01 +03:00
parent 4856b9891d
commit ab01fa3862
19 changed files with 205 additions and 235 deletions

View File

@ -27,7 +27,7 @@ module Parfait
set_instance_type( instance_type )
end
def sof_reference_name
def rxf_reference_name
name
end

View File

@ -32,15 +32,15 @@ module Parfait
return get_type.get_length
end
# 1 -based index
# 0 -based index
def get_internal_word(index)
return super if index <= data_start
return super if index < data_start
@memory[index]
end
# 1 -based index
def set_internal_word(index , value)
return super if index <= data_start
return super if index < data_start
raise "Word[#{index}] = nil" if( value.nil? )
@memory[index] = value
value
@ -49,7 +49,7 @@ module Parfait
class Data4 < DataObject
def data_length
3
4
end
def padded_length
2 * 4
@ -58,7 +58,7 @@ module Parfait
class Data8 < DataObject
def data_length
7
8
end
def padded_length
8 * 4
@ -66,7 +66,7 @@ module Parfait
end
class Data16 < DataObject
def data_length
15
16
end
def padded_length
16 * 4

View File

@ -75,8 +75,8 @@ module Parfait
# yield to each key value pair
def each
index = 1
while index <= @keys.get_length
index = 0
while index < @keys.get_length
key = @keys.get(index)
value = @values.get(index)
yield key , value
@ -93,8 +93,8 @@ module Parfait
string + "}"
end
def to_sof_node(writer , level , ref)
Sof.hash_to_sof_node( self , writer , level , ref)
def to_rxf_node(writer , level , ref)
Sof.hash_to_rxf_node( self , writer , level , ref)
end
end
end

View File

@ -14,58 +14,60 @@
module Parfait
class List < Object
def self.get_length_index
2
return 2
end
def self.get_indexed(index)
index + 2
return index + 2
end
def length_index
1
end
def get_offset
2
return 2
end
def get_length
r = get_internal_word( 2 ) #one for type
r = get_internal_word( length_index ) #one for type
r.nil? ? 0 : r
end
# set the value at index.
# Lists start from index 1
# Lists start from index 0
def set( index , value)
raise "Only positive indexes #{index}" if index <= 0
if index > get_length
grow_to(index)
raise "Only positive indexes #{index}" if index < 0
if index >= get_length
grow_to(index + 1)
end
# start one higher than offset, which is where the length is
set_internal_word( index + 2, value)
set_internal_word( index + get_offset, value)
end
# set the value at index.
# Lists start from index 1
# Lists start from index 0
def get( index )
raise "Only positive indexes, #{index}" if index <= 0
raise "Only positive indexes, #{index}" if index < 0
ret = nil
if(index <= get_length)
if(index < get_length)
# start one higher than offset, which is where the length is
ret = get_internal_word(index + 2 )
ret = get_internal_word(index + get_offset )
end
ret
end
def grow_to( len)
def grow_to( len )
raise "Only positive lenths, #{len}" if len < 0
old_length = get_length
return if old_length >= len
# raise "bounds error at #{len}" if( len + offset > 16 )
# be nice to use the indexed_length , but that relies on booted space
set_internal_word( 2 , len) #one for type
set_internal_word( length_index , len) #one for type
end
def shrink_to( len )
raise "Only positive lenths, #{len}" if len < 0
old_length = get_length
return if old_length <= len
set_internal_word( 2 , len)
set_internal_word( length_index , len)
end
def indexed_length
@ -82,13 +84,13 @@ module Parfait
return index_of(item) != nil
end
# index of item, remeber first item has index 1
# index of item
# return nil if no such item
def index_of( item )
max = self.get_length
#puts "length #{max} #{max.class}"
counter = 1
while( counter <= max )
counter = 0
while( counter < max )
if( get(counter) == item)
return counter
end
@ -101,14 +103,14 @@ module Parfait
def next_value(val)
index = index_of(val)
return nil unless index
return nil if index == get_length
return nil if index == (get_length - 1)
return get(index + 1)
end
# push means add to the end
# this automatically grows the List
def push( value )
to = self.get_length + 1
to = self.get_length
set( to , value)
to
end
@ -131,12 +133,12 @@ module Parfait
def first
return nil if empty?
get(1)
get(0)
end
def last
return nil if empty?
get(get_length())
get(get_length() - 1)
end
def empty?
@ -148,7 +150,7 @@ module Parfait
return false if other.class != self.class
return false if other.get_length != self.get_length
index = self.get_length
while(index > 0)
while(index >= 0)
return false if other.get(index) != self.get(index)
index = index - 1
end
@ -158,7 +160,7 @@ module Parfait
# above, correct, implementation causes problems in the machine object space
# because when a second empty (newly created) list is added, it is not actually
# added as it exists already. TODO, but hack with below identity function
def == other
def ==( other )
self.object_id == other.object_id
end
@ -172,8 +174,8 @@ module Parfait
end
def each
index = 1
while index <= self.get_length
index = 0
while index < self.get_length
item = get(index)
yield item
index = index + 1
@ -182,8 +184,8 @@ module Parfait
end
def each_with_index
index = 1
while index <= self.get_length
index = 0
while index < self.get_length
item = get(index)
yield item , index
index = index + 1
@ -192,8 +194,8 @@ module Parfait
end
def each_pair
index = 1
while index <= self.get_length
index = 0
while index < self.get_length
key = get( index )
value = get(index + 1)
yield key , value
@ -203,8 +205,8 @@ module Parfait
end
def find
index = 1
while index <= self.get_length
index = 0
while index < self.get_length
item = get(index)
return item if yield item
index = index + 1
@ -212,34 +214,34 @@ module Parfait
return nil
end
def set_length len
def set_length( len )
was = self.get_length
return if was == len
if(was < len)
grow_to len
grow_to( len )
else
shrink_to len
shrink_to( len )
end
end
def inspect
index = 1
index = 0
ret = ""
while index <= self.get_length
while index < self.get_length
item = get(index)
ret += item.inspect
ret += "," unless index == self.get_length
ret += "," unless index == (self.get_length - 1)
index = index + 1
end
ret
end
# 1 -based index
# 0 -based index
def get_internal_word(index)
@memory[index]
end
# 1 -based index
# 0 -based index
def set_internal_word(index , value)
raise "Word[#{index}] = " if((self.class == Parfait::Word) and value.nil? )
@memory[index] = value
@ -248,8 +250,8 @@ module Parfait
alias :[] :get
def to_sof_node(writer , level , ref )
Sof.array_to_sof_node(self , writer , level , ref )
def to_rxf_node(writer , level , ref )
Sof.array_to_rxf_node(self , writer , level , ref )
end
def dup
@ -262,8 +264,8 @@ module Parfait
def to_a
array = []
index = 1
while( index <= self.get_length)
index = 0
while( index < self.get_length)
array[index - 1] = get(index)
index = index + 1
end
@ -275,9 +277,9 @@ module Parfait
def self.new_list array
list = Parfait::List.new
list.set_length array.length
index = 1
while index <= array.length do
list.set(index , array[index - 1])
index = 0
while index < array.length do
list.set(index , array[index])
index = index + 1
end
list

View File

@ -7,13 +7,13 @@
# Objects are arranged or layed out (in memory) according to their Type
# every object has a Type. Type objects are immutalbe and may be reused for a group/class
# off objects.
# of objects.
# The Type of an object may change, but then a new Type is created
# The Type also defines the class of the object
# The Type is **always** the first entry (index 1) in an object
# The Type is **always** the first entry (index 0) in an object
module Parfait
TYPE_INDEX = 1
TYPE_INDEX = 0
class Object
@ -30,16 +30,16 @@ module Parfait
object
end
# 1 -based index
# 0 -based index
def get_internal_word(index)
name = get_type().name_at(index)
return nil unless name
instance_variable_get("@#{name}".to_sym)
end
# 1 -based index
# 0 -based index
def set_internal_word(index , value)
return set_type(value) if( index == 1)
return set_type(value) if( index == 0)
raise "not type #{@type.class}" unless @type.is_a?(Type)
name = @type.name_at(index)
#return value unless name
@ -111,7 +111,7 @@ module Parfait
end
# parfait versions are deliberately called different, so we "relay"
# have to put the "@" on the names for sof to take them off again
# have to put the "@" on the names for rfx to take them off again
def instance_variables
get_instance_variables.to_a.collect{ |n| "@#{n}".to_sym }
end

View File

@ -121,7 +121,7 @@ module Parfait
@classes[name] = c
end
def sof_reference_name
def rxf_reference_name
"space"
end

View File

@ -1,3 +1,5 @@
module Parfait
# An Object is really a hash like structure. It is dynamic and
# you want to store values by name (instance variable names).
#
@ -32,7 +34,6 @@
# there is only one instance of every type. Hash and equality are defined on type
# for this to work.
module Parfait
class Type < Object
attr_reader :object_class , :names , :types , :methods
@ -178,11 +179,11 @@ module Parfait
end
# index of the variable when using get_internal_word
# (get_internal_word is 1 based and 1 is always the type)
# (get_internal_word is 0 based and 0 is always the type)
def variable_index( name )
has = @names.index_of(name)
return nil unless has
raise "internal error #{name}:#{has}" if has < 1
raise "internal error #{name}:#{has}" if has < 0
has
end
@ -202,14 +203,14 @@ module Parfait
"Type[#{names.inspect}]"
end
def sof_reference_name
def rxf_reference_name
"#{@object_class.name}_Type"
end
alias :name :sof_reference_name
alias :name :rxf_reference_name
def each
index = 1
while( index <= get_length() )
index = 0
while( index < get_length() )
yield( name_at(index) , type_at(index) )
index += 1
end
@ -222,6 +223,8 @@ module Parfait
def to_hash
hash = {}
each do |name , type|
raise "Name nil #{type}" unless name
raise "Type nil #{name}" unless type
hash[name] = type
end
hash

View File

@ -109,7 +109,7 @@ module Parfait
frame_type.types.get(index + 1)
end
def sof_reference_name
def rxf_reference_name
"Method: " + @name.to_s
end

View File

@ -25,12 +25,12 @@ module Parfait
# initialize with length. For now we try to keep all non-parfait (including String) out
# String will contain spaces for non-zero length
# Risc provides methods to create Parfait objects from ruby
def initialize len
def initialize( len )
super()
@char_length = 0
raise "Must init with int, not #{len.class}" unless len.kind_of? Fixnum
raise "Must init with positive, not #{len}" if len < 0
set_length( len , 32 ) unless len == 0 #32 beeing ascii space
set_length( len , 32 ) unless len == 0 #32 being ascii space
#puts "type #{self.get_type} #{self.object_id.to_s(16)}"
end
@ -38,8 +38,8 @@ module Parfait
# return a copy of self
def copy
cop = Word.new( self.length )
index = 1
while( index <= self.length )
index = 0
while( index < self.length )
cop.set_char(index , self.get_char(index))
index = index + 1
end
@ -53,14 +53,14 @@ module Parfait
end
# make every char equal the given one
def fill_with char
def fill_with( char )
fill_from_with(0 , char)
end
def fill_from_with from , char
def fill_from_with( from , char )
len = self.length()
return if from <= 0
while( from <= len)
return if from < 0
while( from < len)
set_char( from , char)
from = from + 1
end
@ -134,12 +134,12 @@ module Parfait
return ret
end
# private method to calculate negative indexes into positives
def range_correct_index at
# private method to account for
def range_correct_index( at )
index = at
# index = self.length + at if at < 0
raise "index must be positive , not #{at}" if (index <= 0)
raise "index too large #{at} > #{self.length}" if (index > self.length )
raise "index must be positive , not #{at}" if (index < 0)
raise "index too large #{at} > #{self.length}" if (index >= self.length )
return index + 11
end
@ -149,8 +149,8 @@ module Parfait
def compare( other )
return false if other.class != self.class
return false if other.length != self.length
len = self.length
while(len > 0)
len = self.length - 1
while(len >= 0)
return false if self.get_char(len) != other.get_char(len)
len = len - 1
end
@ -168,8 +168,8 @@ module Parfait
def to_string
string = ""
index = 1
while( index <= @char_length)
index = 0
while( index < @char_length)
char = get_char(index)
string += char ? char.chr : "*"
index = index + 1
@ -177,8 +177,8 @@ module Parfait
string
end
# as we answered is_value? with true, sof will create a basic node with this string
def to_sof
# as we answered is_value? with true, rfx will create a basic node with this string
def to_rfx
"'" + to_s + "'"
end
@ -197,7 +197,7 @@ module Parfait
string = string.to_s if string.is_a? Symbol
word = Word.new( string.length )
string.codepoints.each_with_index do |code , index |
word.set_char(index + 1 , code)
word.set_char(index , code)
end
word
end

View File

@ -18,7 +18,7 @@ module Parfait
assert_equal 2 , @code.get_instance_variables.get_length
end
def test_var_next
assert_equal :next , @code.get_instance_variables[2]
assert_equal :next , @code.get_instance_variables[1]
end
def test_next_nil
assert_nil @code.next

View File

@ -39,7 +39,7 @@ module Parfait
20.times do
assert int
assert_equal Parfait::Integer , int.class
assert int.get_internal_word(2)
assert int.get_internal_word(1)
int = int.next_integer
end
end

View File

@ -24,15 +24,6 @@ module Parfait
@list.push(1)
assert_equal Parfait::Type , @list.get_type.class
end
def notest_type_is_first
type = @list.get_type
assert_equal 1 , type.variable_index(:type)
end
def notest_type_is_first_old
type = Parfait.object_space.classes.keys.get_type
assert_equal 1 , type.variable_index(:type)
end
def test_length0
assert_equal 0 , @list.get_length
assert_equal 0, @list.indexed_length
@ -41,17 +32,17 @@ module Parfait
assert_equal 2 , @list.get_offset
end
def test_indexed_index
# 1 type , 2 indexed_length
assert_equal 2 , @list.get_type.variable_index(:indexed_length)
# 0 type , 1 indexed_length
assert_equal 1 , @list.get_type.variable_index(:indexed_length)
end
def test_length1
@list.push :one
assert_equal 1 , @list.get_length
assert_equal 1 , @list.indexed_length
assert_equal 1 , @list.get_internal_word(Parfait::TYPE_INDEX + 1)
assert_equal :one , @list.get_internal_word(Parfait::TYPE_INDEX + 2)
end
def test_list_inspect
@list.set(1,1)
@list.set(0,1)
assert_equal "1" , @list.inspect
end
def test_list_equal
@ -70,74 +61,33 @@ module Parfait
assert_nil @list.get(3)
end
def test_one_set1
assert_equal 2 , @list.set(1,2)
assert_equal 1 , @list.get_internal_word(2)
assert_equal 2 , @list.set(0,2)
assert_equal 1 , @list.get_internal_word(1)
assert_equal 2 , @list.get_internal_word(2)
end
def test_set1_len
@list.set(1,1)
@list.set(0,1)
assert_equal 1 , @list.get_length
end
def test_one_get1
test_one_set1
assert_equal 2 , @list.get(0)
end
def test_one_set2
assert_equal :some , @list.set(2,:some)
end
def test_set2_len
@list.set(2,:some)
@list.set(1,:some)
assert_equal 2 , @list.get_length
end
def test_two_sets
assert_equal 1 , @list.set(1,1)
assert_equal :some , @list.set(1,:some)
end
def test_one_get1
test_one_set1
assert_equal 2 , @list.get(1)
end
def test_one_get2
test_one_set2
assert_equal :some , @list.get(2)
end
def set_shouldda
shouldda = { 1 => :one , 2 => :two , 3 => :three}
shouldda.each do |k,v|
@list.set(k,v)
end
shouldda
end
def test_many_get
shouldda = set_shouldda
shouldda.each do |k,v|
assert_equal v , @list.get(k)
end
end
def test_each
shouldda_values = set_shouldda.values
@list.each do |val|
shouldda_values.delete val
end
assert_equal 0 , shouldda_values.length
end
def test_each_index
set_shouldda
@list.each_with_index do |val , index|
assert_equal @list[index] , val
end
end
def test_each_pair_length
shouldda_values = set_shouldda.values
@list.each_pair do |key,val|
shouldda_values.delete key
shouldda_values.delete val
end
assert_equal 0 , shouldda_values.length
end
def test_each_pair_count
set_shouldda.values
counter = 0
@list.each_pair do |key,val|
counter += 1
end
assert_equal 2 , counter
end
def test_find
@list.set(1,1)
@list.set(2,2)
@ -147,35 +97,6 @@ module Parfait
@list.set(1,1)
assert_nil @list.find{|i| i == 3}
end
def test_delete_at
test_many_get
assert @list.delete_at 2
assert_equal 2 , @list.get_length
assert_equal 2 , @list.index_of( :three )
end
def test_delete
test_many_get
assert @list.delete :two
assert_equal 2 , @list.get_length
assert_equal 2 , @list.index_of( :three )
end
def test_index_of
test_many_get
assert_equal 2 , @list.index_of( :two )
assert_equal 3 , @list.index_of( :three )
assert_nil @list.index_of( :four )
end
def test_inspect
test_many_get
assert @list.inspect.include?("one") , @list.inspect
assert @list.inspect.include?("three") , @list.inspect
end
def test_inlcude
test_many_get
assert_equal true , @list.include?( :two )
assert_equal false , @list.include?( :four )
end
def test_empty_empty
assert_equal true , @list.empty?
end
@ -183,37 +104,81 @@ module Parfait
assert_equal 1 , @list.set(1,1)
assert_equal false , @list.empty?
end
def test_first
test_many_get
assert_equal :one , @list.first
end
def test_first_empty
assert_nil @list.first
end
def test_last
test_many_get
assert_equal :three , @list.last
end
def test_last_empty
assert_nil @list.last
end
end
class TestListContains < ParfaitTest
class TestListMany < ParfaitTest
def setup
super
@list = ::Parfait::List.new
@list.push :one
@list.push :two
@shouldda = { 0 => :one , 1 => :two , 2 => :three}
@shouldda.each{|k,v| @list.set(k,v)}
end
def test_next_value_ok
assert_equal :two , @list.next_value(:one)
end
def test_next_value_end
assert_nil @list.next_value(:two)
assert_nil @list.next_value(:three)
end
def test_delete_at
assert @list.delete_at 1
assert_equal 2 , @list.get_length
assert_equal 1 , @list.index_of( :three )
end
def test_last
assert_equal :three , @list.last
end
def test_many_get
assert @list.delete :two
assert_equal 2 , @list.get_length
assert_equal 1 , @list.index_of( :three )
end
def test_index_of
assert_equal 1 , @list.index_of( :two )
assert_equal 2 , @list.index_of( :three )
assert_nil @list.index_of( :four )
end
def test_inspect
assert @list.inspect.include?("one") , @list.inspect
assert @list.inspect.include?("three") , @list.inspect
end
def test_inlcude
assert_equal true , @list.include?( :two )
assert_equal false , @list.include?( :four )
end
def test_next_value_not_int
assert_nil @list.next_value(:three)
end
def test_each
shouldda_values = @shouldda.values
@list.each do |val|
shouldda_values.delete val
end
assert_equal 0 , shouldda_values.length
end
def test_each_index
@list.each_with_index do |val , index|
assert_equal @list[index] , val
end
end
def test_each_pair_length
shouldda_values = @shouldda.values
@list.each_pair do |key,val|
shouldda_values.delete key
shouldda_values.delete val
end
assert_equal 0 , shouldda_values.length
end
def test_each_pair_count
counter = 0
@list.each_pair do |key,val|
counter += 1
end
assert_equal 2 , counter
end
end
end

View File

@ -15,7 +15,7 @@ module Parfait
assert_equal 55 , @mess.receiver
end
def test_indexed
assert_equal 9 , @mess.get_type.variable_index(:arguments)
assert_equal 8 , @mess.get_type.variable_index(:arguments)
end
def test_next_message
assert_equal Message , @mess.next_message.class

View File

@ -13,7 +13,7 @@ module Parfait
end
def test_one_set1
assert_equal @object.get_type , @object.set_internal_word(1, @object.get_type)
assert_equal @object.get_type , @object.set_internal_word(0, @object.get_type)
end
end

View File

@ -22,12 +22,12 @@ module Parfait
def test_arg1
assert_equal 2 , @method.arguments_length , @method.arguments_type.inspect
assert_equal Symbol , @method.arguments_type.names.first.class
assert_equal :bar , @method.argument_name(1)
assert_equal :bar , @method.argument_name(0)
end
def test_has_argument
assert_equal 1 , @method.has_argument(:bar)
assert_equal 2 , @method.has_argument(:foo)
assert_equal 0 , @method.has_argument(:bar)
assert_equal 1 , @method.has_argument(:foo)
end
def test_add_arg
@ -39,7 +39,7 @@ module Parfait
def test_get_arg_name1
index = @method.has_argument(:bar)
assert_equal 1 , index
assert_equal 0 , index
assert_equal :bar , @method.argument_name(index)
end
def test_get_arg_type1
@ -48,7 +48,7 @@ module Parfait
end
def test_get_arg_name2
index = @method.has_argument(:foo)
assert_equal 2 , index
assert_equal 1 , index
assert_equal :foo , @method.argument_name(index)
end
def test_get_arg_type2
@ -59,12 +59,12 @@ module Parfait
def test_local1
assert_equal 2 , @method.frame_length , @method.frame_type.inspect
assert_equal Symbol , @method.frame_type.names.first.class
assert_equal :local_bar , @method.locals_name(1)
assert_equal :local_bar , @method.locals_name(0)
end
def test_has_local
assert_equal 1 , @method.has_local(:local_bar)
assert_equal 2 , @method.has_local(:local_foo)
assert_equal 0 , @method.has_local(:local_bar)
assert_equal 1 , @method.has_local(:local_foo)
end
def test_add_local
@ -76,7 +76,7 @@ module Parfait
def test_get_locals_name1
index = @method.has_local(:local_bar)
assert_equal 1 , index
assert_equal 0 , index
assert_equal :local_bar , @method.locals_name(index)
end
def test_get_frame_type1
@ -85,7 +85,7 @@ module Parfait
end
def test_get_locals_name2
index = @method.has_local(:local_foo)
assert_equal 2 , index
assert_equal 1 , index
assert_equal :local_foo , @method.locals_name(index)
end
def test_get_frame_type2

View File

@ -46,8 +46,8 @@ module Parfait
assert_equal @word.copy , @word
end
def test_equals_copy2
@word.set_char(1 , 2)
@word.set_char(5 , 6)
@word.set_char(0 , 2)
@word.set_char(4 , 6)
assert_equal @word.copy , @word
end
def test_equals_same

View File

@ -16,7 +16,7 @@ module Parfait
def test_type_is_first
type = @mess.get_type
assert_equal 1 , type.variable_index(:type)
assert_equal 0 , type.variable_index(:type)
end
def test_length
@ -38,16 +38,16 @@ module Parfait
def test_type_length_index
type = @mess.get_type.get_type
assert_equal 5 , type.variable_index(:methods)
assert_equal type.object_class , type.get_internal_word(4)
assert_equal 4 , type.variable_index(:methods)
assert_equal type.object_class , type.get_internal_word(3)
end
def test_no_index_below_1
def test_no_index_below_0
type = @mess.get_type
names = type.names
assert_equal 9 , names.get_length , names.inspect
names.each do |n|
assert type.variable_index(n) >= 1
assert type.variable_index(n) >= 0
end
end
@ -59,18 +59,18 @@ module Parfait
# not really parfait test, but related and no other place currently
def test_reg_index
message_ind = Risc.resolve_to_index( :message , :receiver )
assert_equal 3 , message_ind
assert_equal 2 , message_ind
@mess.set_receiver( 55)
assert_equal 55 , @mess.get_internal_word(message_ind)
end
def test_instance_type
assert_equal 2 , @mess.get_type.variable_index(:next_message)
assert_equal 1 , @mess.get_type.variable_index(:next_message)
end
def test_remove_me
type = @mess.get_type
assert_equal type , @mess.get_internal_word(1)
assert_equal type , @mess.get_internal_word(0)
end
end
end

View File

@ -18,12 +18,12 @@ module Parfait
def test_message_by_index
assert_equal @mess.next_message , @mess.get_instance_variable(:next_message)
index = @mess.get_type.variable_index :next_message
assert_equal 2 , index
assert_equal 1 , index
assert_equal @mess.next_message , @mess.get_internal_word(index)
end
def test_type_methods
assert_equal 5 , @mess.get_type.get_type.variable_index(:methods)
assert_equal 4 , @mess.get_type.get_type.variable_index(:methods)
end
end

View File

@ -41,21 +41,21 @@ module Parfait
def test_added_name_length
type = test_add_name
assert_equal 2 , type.names.get_length , type.inspect
assert_equal :type , type.names.get(1)
assert_equal :boo , type.names.get(2)
assert_equal :type , type.names.get(0)
assert_equal :boo , type.names.get(1)
end
def test_added_name_index
type = test_add_name
assert_equal 2 , type.variable_index(:boo)
assert_equal :Object , type.type_at(2)
assert_equal 1 , type.variable_index(:boo)
assert_equal :Object , type.type_at(1)
end
def test_basic_var_index
assert_equal 1 , @type.variable_index(:type)
assert_equal 0 , @type.variable_index(:type)
end
def test_basic_type_index
assert_equal :Type , @type.type_at(1)
assert_equal :Type , @type.type_at(0)
end
def test_inspect_added
@ -65,8 +65,8 @@ module Parfait
def test_added_names
type = test_add_name
assert_equal :type , type.names.get(1)
assert_equal :boo , type.names.get(2)
assert_equal :type , type.names.get(0)
assert_equal :boo , type.names.get(1)
assert_equal 2 , type.names.get_length
end