rebooting tests for small compiles
This commit is contained in:
@ -1,7 +1,16 @@
|
||||
require_relative "virtual_helper"
|
||||
|
||||
|
||||
class TestBasic < MiniTest::Test
|
||||
include VirtualHelper
|
||||
def check
|
||||
expressions = Virtual.machine.boot.compile_main @string_input
|
||||
if( expressions.first.is_a? Virtual::Self )
|
||||
expressions.first.type.instance_variable_set :@of_class , nil
|
||||
end
|
||||
is = Sof.write(expressions)
|
||||
#puts is
|
||||
assert_equal @output , is
|
||||
end
|
||||
|
||||
def test_number
|
||||
@string_input = '42 '
|
||||
|
@ -1,16 +1,38 @@
|
||||
require_relative "virtual_helper"
|
||||
|
||||
class TestMethods < MiniTest::Test
|
||||
include VirtualHelper
|
||||
#TODO need to rethink this approach
|
||||
# Sof working as well as it is will serialize the whole space as everythink is reachable from a
|
||||
# method. Even ignoring the size and readability issues, it make sthe test to fragile:
|
||||
# any small object change anywhere in parfait will cause a different output
|
||||
def ttest_simplest_function
|
||||
@string_input = <<HERE
|
||||
module Virtual
|
||||
class TestMethods < MiniTest::Test
|
||||
|
||||
def check
|
||||
Virtual.machine.boot.compile_main @string_input
|
||||
produced = Virtual.machine.space.get_main.source
|
||||
assert @output , "No output given"
|
||||
assert_equal @output.length , produced.blocks.length , "Block length"
|
||||
produced.blocks.each_with_index do |b,i|
|
||||
codes = @output[i]
|
||||
assert codes , "No codes for block #{i}"
|
||||
assert_equal b.codes.length , codes.length , "Code length for block #{i}"
|
||||
b.codes.each_with_index do |c , ii |
|
||||
assert_equal codes[ii] , c.class , "Block #{i} , code #{ii}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_simplest_function
|
||||
@string_input = <<HERE
|
||||
def foo(x)
|
||||
5
|
||||
end
|
||||
HERE
|
||||
@output = [[MethodEnter] ,[MethodReturn]]
|
||||
check
|
||||
end
|
||||
|
||||
def ttest_second_simplest_function
|
||||
@string_input = <<HERE
|
||||
def foo(x)
|
||||
x
|
||||
end
|
||||
HERE
|
||||
@output = nil
|
||||
check
|
||||
@ -142,3 +164,4 @@ HERE
|
||||
check
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,37 +1,13 @@
|
||||
require_relative '../helper'
|
||||
require 'parslet/convenience'
|
||||
require "yaml"
|
||||
|
||||
Parfait::Object.class_eval do
|
||||
def secret_layout_hammer
|
||||
internal_object_set(Parfait::Object::LAYOUT_INDEX , nil)
|
||||
end
|
||||
end
|
||||
|
||||
module VirtualHelper
|
||||
# need a code generator, for arm
|
||||
def setup
|
||||
@machine = Virtual.machine.boot
|
||||
end
|
||||
|
||||
def check
|
||||
expressions = @machine.compile_main @string_input
|
||||
if( expressions.first.is_a? Parfait::Method )
|
||||
# stops the whole objectspace beeing tested
|
||||
# with the class comes superclass and all methods
|
||||
expressions.first.instance_variable_set :@for_class , nil
|
||||
expressions.first.secret_layout_hammer
|
||||
expressions.first.code.secret_layout_hammer
|
||||
end
|
||||
if( expressions.first.is_a? Virtual::Self )
|
||||
# stops the whole objectspace beeing tested
|
||||
# with the class comes superclass and all methods
|
||||
expressions.first.type.instance_variable_set :@of_class , nil
|
||||
end
|
||||
is = Sof.write(expressions)
|
||||
#puts is
|
||||
is.gsub!("\n" , "*^*")
|
||||
assert_equal @output , is
|
||||
Virtual.machine.boot.compile_main @string_input
|
||||
produced = Virtual.machine.space.get_main.source
|
||||
assert_equal @output , produced
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user