2017-04-12 19:29:45 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
2019-10-03 23:36:49 +02:00
|
|
|
module Sol
|
2019-10-03 19:55:41 +02:00
|
|
|
class TestIvarSlotMachine < MiniTest::Test
|
2019-10-03 23:36:49 +02:00
|
|
|
include SolCompile
|
2017-04-12 19:29:45 +02:00
|
|
|
|
|
|
|
def setup
|
2019-09-12 12:10:31 +02:00
|
|
|
@compiler = compile_main( "@a = 5")
|
2019-10-03 19:55:41 +02:00
|
|
|
@ins = @compiler.slot_instructions.next
|
2017-04-12 19:29:45 +02:00
|
|
|
end
|
|
|
|
|
2019-09-18 21:07:58 +02:00
|
|
|
def test_array
|
|
|
|
check_array [SlotLoad, SlotLoad, ReturnJump, Label, ReturnSequence ,
|
|
|
|
Label] , @ins
|
2017-09-07 07:17:13 +02:00
|
|
|
end
|
2017-04-12 19:29:45 +02:00
|
|
|
def test_class_compiles
|
2019-09-18 21:07:58 +02:00
|
|
|
assert_equal SlotLoad , @ins.class , @ins
|
2018-03-15 16:25:23 +01:00
|
|
|
assert @ins.left
|
|
|
|
assert_equal :message , @ins.left.known_object
|
2017-04-12 19:29:45 +02:00
|
|
|
end
|
|
|
|
def test_slot_gets_self
|
2018-03-15 16:25:23 +01:00
|
|
|
assert_equal :receiver , @ins.left.slots[0]
|
2017-04-12 19:29:45 +02:00
|
|
|
end
|
|
|
|
def test_slot_assigns_to_local
|
2018-03-15 16:25:23 +01:00
|
|
|
assert_equal :a , @ins.left.slots[-1]
|
2017-04-12 19:29:45 +02:00
|
|
|
end
|
|
|
|
def test_slot_assigns_something
|
2018-03-15 16:25:23 +01:00
|
|
|
assert @ins.right
|
2019-10-03 19:55:41 +02:00
|
|
|
assert_equal SlotMachine::IntegerConstant , @ins.right.known_object.class
|
2017-04-12 19:29:45 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|