2014-06-25 14:20:46 +02:00
|
|
|
require_relative '../helper'
|
|
|
|
require 'parslet/convenience'
|
2014-08-21 21:57:20 +02:00
|
|
|
require "yaml"
|
2014-06-25 14:20:46 +02:00
|
|
|
|
2015-07-02 09:44:44 +02:00
|
|
|
Parfait::Object.class_eval do
|
|
|
|
def secret_layout_hammer
|
|
|
|
internal_object_set(Parfait::Object::LAYOUT_INDEX , nil)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-06-26 10:34:48 +02:00
|
|
|
module VirtualHelper
|
2015-05-05 13:04:37 +02:00
|
|
|
# need a code generator, for arm
|
2014-06-25 14:20:46 +02:00
|
|
|
def setup
|
2015-05-12 14:36:44 +02:00
|
|
|
# @object_space = Boot::Space.new "Arm"
|
2014-06-25 14:20:46 +02:00
|
|
|
end
|
|
|
|
|
2014-07-30 20:07:48 +02:00
|
|
|
def check
|
2015-06-01 07:33:23 +02:00
|
|
|
machine = Virtual::Machine.boot
|
2014-07-30 20:43:12 +02:00
|
|
|
expressions = machine.compile_main @string_input
|
2015-05-24 15:55:03 +02:00
|
|
|
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
|
2015-07-02 09:44:44 +02:00
|
|
|
expressions.first.secret_layout_hammer
|
|
|
|
expressions.first.code.secret_layout_hammer
|
2015-05-24 15:55:03 +02:00
|
|
|
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
|
2015-06-19 11:29:41 +02:00
|
|
|
is = Sof.write(expressions)
|
2015-07-02 09:44:44 +02:00
|
|
|
puts is
|
2015-05-05 14:11:09 +02:00
|
|
|
is.gsub!("\n" , "*^*")
|
2015-07-02 09:26:48 +02:00
|
|
|
assert_equal @output , is
|
2014-06-25 14:20:46 +02:00
|
|
|
end
|
2015-05-05 13:04:37 +02:00
|
|
|
|
2014-06-25 14:20:46 +02:00
|
|
|
end
|
2015-06-01 16:31:35 +02:00
|
|
|
|
2015-05-24 17:05:20 +02:00
|
|
|
class UnusedSofEquality
|
|
|
|
# simple thought: don't recurse for Blocks, just check their names
|
|
|
|
def == other
|
|
|
|
return false unless other.class == self.class
|
|
|
|
Sof::Util.attributes(self).each do |a|
|
|
|
|
begin
|
|
|
|
left = send(a)
|
|
|
|
rescue NoMethodError
|
|
|
|
next # not using instance variables that are not defined as attr_readers for equality
|
|
|
|
end
|
|
|
|
begin
|
|
|
|
right = other.send(a)
|
|
|
|
rescue NoMethodError
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
return false unless left.class == right.class
|
|
|
|
if( left.is_a? Block)
|
|
|
|
return false unless left.name == right.name
|
|
|
|
else
|
|
|
|
return false unless left == right
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|