rubyx/test/slot_language/test_assignment.rb

56 lines
1.4 KiB
Ruby
Raw Normal View History

2020-02-13 07:02:23 +01:00
require_relative "helper"
module SlotLanguage
class TestAssignment < MiniTest::Test
include SlotHelper
2020-02-13 13:09:00 +01:00
def compile_assign(str)
assign = compile(str)
assert_equal Assignment , assign.class
assert_equal :a , assign.left.name
assert_equal :b , assign.right.name
assign
end
2020-02-13 07:02:23 +01:00
def test_slot_load_rinst
2020-02-13 13:09:00 +01:00
assign = compile_assign("a = @b")
2020-02-13 07:02:23 +01:00
end
def test_slot_load_linst
2020-02-13 13:09:00 +01:00
assign = compile_assign("@a = b")
2020-02-13 07:02:23 +01:00
end
def test_slot_load_lrinst
2020-02-13 13:09:00 +01:00
compile_assign("@a = @b")
2020-02-13 07:02:23 +01:00
end
def test_assign
2020-02-13 13:09:00 +01:00
assign = compile_assign("a = b")
2020-02-13 07:02:23 +01:00
assert_equal Assignment , assign.class
end
2020-02-13 13:09:00 +01:00
end
class TestAssignment2 < MiniTest::Test
include SlotHelper
def test_slot_load_linst_trav
assert_equal Assignment , compile_class("@a = b.c")
end
2020-02-13 07:02:23 +01:00
def test_assign1
assign = compile("c = c.next")
assert_equal Assignment , assign.class
end
def test_shift
2020-02-13 13:09:00 +01:00
load = compile("a = b.c")
2020-02-13 07:02:23 +01:00
assert_equal Assignment , load.class
2020-02-13 13:09:00 +01:00
assert_equal :a , load.left.name
assert_equal Variable , load.right.class
2020-02-13 07:02:23 +01:00
end
end
2020-02-13 13:09:00 +01:00
class TestAssignment3 < MiniTest::Test
include SlotHelper
def est_slot_load_linst_trav2
assert_equal Assignment , compile_class("@a.c = b.c")
end
def est_assign2
assign = compile("c.next = d")
assert_equal Assignment , assign.class
end
end
2020-02-13 07:02:23 +01:00
end