Torsten Rüger
1ee01622c3
All preloading where it needs to be (some)tests for the preload split compiler test remembered binary tests (usually just run on travis)
43 lines
966 B
Ruby
43 lines
966 B
Ruby
require_relative "helper"
|
|
module Mom
|
|
class PlusEquals < Instruction
|
|
attr_reader :a , :b
|
|
def initialize(source , arg , b)
|
|
super(source)
|
|
@a = arg
|
|
@b = b
|
|
end
|
|
def to_risc(compiler)
|
|
Risc.label("some" , "thing")
|
|
end
|
|
end
|
|
end
|
|
|
|
module Vool
|
|
class TestMacroMom < MiniTest::Test
|
|
include VoolCompile
|
|
|
|
def setup
|
|
@compiler = compile_main( "X.plus_equals(arg,1)")
|
|
@ins = @compiler.mom_instructions.next
|
|
end
|
|
|
|
def test_class_compiles
|
|
assert_equal Mom::PlusEquals , @ins.class , @ins
|
|
end
|
|
def test_arg1
|
|
assert_equal Vool::LocalVariable , @ins.a.class
|
|
assert_equal :arg , @ins.a.name
|
|
end
|
|
def test_arg2
|
|
assert_equal Vool::IntegerConstant , @ins.b.class
|
|
assert_equal 1 , @ins.b.value
|
|
end
|
|
def test_to_risc
|
|
comp = @compiler.to_risc
|
|
assert_equal Risc::MethodCompiler , comp.class
|
|
assert_equal :main , comp.callable.name
|
|
end
|
|
end
|
|
end
|