2017-04-10 15:12:15 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module Mom
|
2017-09-10 18:48:46 +02:00
|
|
|
class TestConstToIvarAssignemnt < MiniTest::Test
|
2017-09-10 11:36:16 +02:00
|
|
|
include MomCompile
|
2017-04-10 15:12:15 +02:00
|
|
|
|
2017-04-12 10:53:02 +02:00
|
|
|
def setup
|
|
|
|
Risc.machine.boot
|
2017-09-10 11:36:16 +02:00
|
|
|
@stats = compile_first_method_flat( "@a = 5")
|
2017-04-10 15:12:15 +02:00
|
|
|
end
|
2017-04-12 10:53:02 +02:00
|
|
|
|
2017-09-10 11:36:16 +02:00
|
|
|
def test_if_compiles
|
|
|
|
assert_equal SlotConstant , @stats.class , @stats
|
|
|
|
end
|
|
|
|
def test_length
|
|
|
|
assert_equal 1 , @stats.length
|
|
|
|
end
|
|
|
|
def test_assigns_class
|
2018-03-13 08:00:51 +01:00
|
|
|
assert_equal Mom::IntegerConstant , @stats.right.class , @stats.inspect
|
2017-09-10 11:36:16 +02:00
|
|
|
end
|
|
|
|
def test_assigns_value
|
|
|
|
assert_equal 5 , @stats.right.value , @stats.inspect
|
2017-04-12 10:53:02 +02:00
|
|
|
end
|
|
|
|
|
2017-04-10 15:12:15 +02:00
|
|
|
end
|
2017-09-10 18:48:46 +02:00
|
|
|
class TestConstToLocalAssignemnt < MiniTest::Test
|
|
|
|
include MomCompile
|
|
|
|
def setup
|
|
|
|
Risc.machine.boot
|
|
|
|
@stats = compile_first_method_flat( "a = 5")
|
|
|
|
end
|
|
|
|
def test_if_compiles
|
|
|
|
assert_equal SlotConstant , @stats.class , @stats
|
|
|
|
end
|
|
|
|
def test_length
|
|
|
|
assert_equal 1 , @stats.length
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class TestIvarToLocalAssignemnt < MiniTest::Test
|
|
|
|
include MomCompile
|
|
|
|
def setup
|
|
|
|
Risc.machine.boot
|
|
|
|
@stats = compile_first_method_flat( "a = @a")
|
|
|
|
end
|
|
|
|
def test_if_compiles
|
|
|
|
assert_equal SlotMove , @stats.class , @stats
|
|
|
|
end
|
|
|
|
def test_length
|
|
|
|
assert_equal 1 , @stats.length
|
|
|
|
end
|
|
|
|
def test_assigns_class
|
2018-03-13 08:00:51 +01:00
|
|
|
assert_equal Mom::SlotDefinition , @stats.right.class , @stats.inspect
|
2017-09-10 18:48:46 +02:00
|
|
|
end
|
|
|
|
end
|
2017-04-10 15:12:15 +02:00
|
|
|
end
|