rubyx/test/fragments/test_string_class.rb

75 lines
1.3 KiB
Ruby
Raw Normal View History

require_relative 'helper'
2014-06-24 11:25:03 +02:00
class TestStringClass < MiniTest::Test
include Fragments
2014-06-24 11:25:03 +02:00
def test_string_class
@string_input = <<HERE
class Object
2014-06-13 22:41:45 +02:00
def raise()
putstring()
exit()
end
def method_missing(name,args)
name.raise()
end
def class()
l = @layout
return l.class()
end
def resolve_method(name)
clazz = class()
function = clazz._get_instance_variable(name)
index = clazz.index_of(name)
if( function == 0 )
name.raise()
else
return function
end
end
def index_of( name )
l = @layout
return l.index_of(name)
end
def old_layout()
return @layout
end
end
class Class
def Class.new_object( length )
return 4
end
end
class String
def String.new_string( len )
return Class.new_object( len << 2 )
end
def length()
return @length
end
def plus(str)
my_length = @length
str_len = str.length()
2014-06-02 12:45:08 +02:00
new_string = String.new_string(my_length + str_len)
i = 0
while( i < my_length) do
char = get(i)
new_string.set(i , char)
i = i + 1
end
i = 0
while( i < str_len) do
char = str.get(i)
new_string.set( i + my_length , char)
i = i + 1
end
return new_string
end
end
HERE
2015-07-19 12:31:13 +02:00
@expect = [Virtual::Return ]
check
2014-06-02 12:45:08 +02:00
end
end