clean up more tests
This commit is contained in:
parent
c1d31a541d
commit
88fc4c0e47
@ -54,12 +54,6 @@ HERE
|
||||
check
|
||||
end
|
||||
|
||||
def pest_module_name
|
||||
@string_input = 'FooBar '
|
||||
@output = ""
|
||||
check
|
||||
end
|
||||
|
||||
def test_string
|
||||
@string_input = "\"hello\""
|
||||
@output = "- Virtual::Return(:type => Virtual::Reference, :value => :hello)"
|
||||
|
@ -7,4 +7,3 @@ require_relative "test_putint"
|
||||
require_relative "test_functions"
|
||||
require_relative "test_recursive_fibo"
|
||||
require_relative "test_while_fibo"
|
||||
#require_relative "test_string_class"
|
||||
|
@ -1,63 +0,0 @@
|
||||
require_relative 'helper'
|
||||
|
||||
class TestList < MiniTest::Test
|
||||
include Fragments
|
||||
|
||||
def ttest_list_clas
|
||||
@string_input = <<HERE
|
||||
class Object
|
||||
end
|
||||
class List
|
||||
def Node.new()
|
||||
return 4
|
||||
end
|
||||
def get(key)
|
||||
if( @next )
|
||||
return @next.get(key)
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end
|
||||
def set(key , value)
|
||||
if(@next)
|
||||
@next.set(key,value)
|
||||
else
|
||||
@next = Node.new()
|
||||
@next.initialize(key,value)
|
||||
end
|
||||
end
|
||||
end
|
||||
class Node < List
|
||||
def initialize(key,value)
|
||||
@key = key
|
||||
@value = value
|
||||
end
|
||||
def get(key)
|
||||
if(@key == key)
|
||||
return @value
|
||||
else
|
||||
return super(key)
|
||||
end
|
||||
end
|
||||
def set(key,value)
|
||||
if(@key == key)
|
||||
@value = value
|
||||
else
|
||||
super(key,value)
|
||||
end
|
||||
end
|
||||
end
|
||||
list = List.new()
|
||||
list.set(1,1)
|
||||
list.set(2,2)
|
||||
i = list.get(1)
|
||||
i.putint()
|
||||
HERE
|
||||
@should = [0x0,0xb0,0xa0,0xe3,0x2a,0x10,0xa0,0xe3,0x13,0x0,0x0,0xeb,0x1,0x70,0xa0,0xe3,0x0,0x0,0x0,0xef,0x0,0x70,0xa0,0xe1,0x0,0x40,0x2d,0xe9,0xa,0x30,0x42,0xe2,0x22,0x21,0x42,0xe0,0x22,0x22,0x82,0xe0,0x22,0x24,0x82,0xe0,0x22,0x28,0x82,0xe0,0xa2,0x21,0xa0,0xe1,0x2,0x41,0x82,0xe0,0x84,0x30,0x53,0xe0,0x1,0x20,0x82,0x52,0xa,0x30,0x83,0x42,0x30,0x30,0x83,0xe2,0x0,0x30,0xc1,0xe5,0x1,0x10,0x41,0xe2,0x0,0x0,0x52,0xe3,0xef,0xff,0xff,0x1b,0x0,0x80,0xbd,0xe8,0x0,0x40,0x2d,0xe9,0x1,0x20,0xa0,0xe1,0x20,0x10,0x8f,0xe2,0x9,0x10,0x81,0xe2,0xe9,0xff,0xff,0xeb,0x14,0x10,0x8f,0xe2,0xc,0x20,0xa0,0xe3,0x1,0x0,0xa0,0xe3,0x4,0x70,0xa0,0xe3,0x0,0x0,0x0,0xef,0x0,0x70,0xa0,0xe1,0x0,0x80,0xbd,0xe8,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20]
|
||||
@output = " 42 "
|
||||
parse
|
||||
@target = [:Word , :plus]
|
||||
write "class"
|
||||
end
|
||||
|
||||
end
|
@ -1,82 +0,0 @@
|
||||
require_relative 'helper'
|
||||
|
||||
class TestStringClass < MiniTest::Test
|
||||
include Fragments
|
||||
|
||||
def test_string_class
|
||||
@string_input = <<HERE
|
||||
class Object
|
||||
int raise()
|
||||
self.putstring()
|
||||
self.exit()
|
||||
end
|
||||
int method_missing(ref name,ref args)
|
||||
name.raise()
|
||||
end
|
||||
ref class()
|
||||
ref l = self.layout
|
||||
l = l.object_class()
|
||||
return l
|
||||
end
|
||||
ref resolve_method(ref name)
|
||||
ref clazz = self.class()
|
||||
ref function = clazz._get_instance_variable(name)
|
||||
int index = clazz.index_of(name)
|
||||
if( function == nil )
|
||||
name.raise()
|
||||
else
|
||||
return function
|
||||
end
|
||||
end
|
||||
int index_of( ref name )
|
||||
ref l = self.layout
|
||||
return l.index_of(name)
|
||||
end
|
||||
ref old_layout()
|
||||
return self.layout
|
||||
end
|
||||
end
|
||||
class Class
|
||||
int Class.new_object( int length )
|
||||
return 4
|
||||
end
|
||||
end
|
||||
class String
|
||||
|
||||
ref self.new_string(int len )
|
||||
len = len << 2
|
||||
return super.new_object( len)
|
||||
end
|
||||
|
||||
int length()
|
||||
return self.length
|
||||
end
|
||||
|
||||
int plus(ref str)
|
||||
my_length = self.length
|
||||
str_len = str.length()
|
||||
my_length = str_len + my_length
|
||||
new_string = self.new_string(my_length )
|
||||
i = 0
|
||||
while( i < my_length)
|
||||
char = get(i)
|
||||
new_string.set(i , char)
|
||||
i = i + 1
|
||||
end
|
||||
i = 0
|
||||
while( i < str_len)
|
||||
char = str.get(i)
|
||||
len = i + my_length
|
||||
new_string.set( len , char)
|
||||
i = i + 1
|
||||
end
|
||||
return new_string
|
||||
end
|
||||
|
||||
end
|
||||
HERE
|
||||
@expect = [Virtual::Return ]
|
||||
check
|
||||
end
|
||||
|
||||
end
|
@ -3,10 +3,9 @@ require_relative "../helper"
|
||||
|
||||
class TestCompat < MiniTest::Test
|
||||
|
||||
def ttest_list_create_from_array
|
||||
def test_list_create_from_array
|
||||
array = [1,2,3]
|
||||
list = Virtual.new_list(array)
|
||||
assert_equal list , Virtual.new_list(array)
|
||||
assert_equal array , list.to_a
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user