2020-02-13 07:02:23 +01:00
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module SlotLanguage
|
|
|
|
class TestAssignment < MiniTest::Test
|
|
|
|
include SlotHelper
|
|
|
|
|
|
|
|
def test_slot_load_rinst
|
|
|
|
assert_equal Assignment , compile_class("a = @b")
|
|
|
|
end
|
|
|
|
def test_slot_load_linst
|
|
|
|
assert_equal Assignment , compile_class("@a = b")
|
|
|
|
end
|
|
|
|
def test_slot_load_lrinst
|
|
|
|
assert_equal Assignment , compile_class("@a = @b")
|
|
|
|
end
|
|
|
|
def test_slot_load_linst_trav
|
|
|
|
assert_equal Assignment , compile_class("@a = b.c")
|
|
|
|
end
|
|
|
|
def test_slot_load_linst_trav2
|
|
|
|
assert_equal Assignment , compile_class("@a.c = b.c")
|
|
|
|
end
|
|
|
|
def test_assign
|
|
|
|
assign = compile("c = d")
|
|
|
|
assert_equal Assignment , assign.class
|
|
|
|
end
|
|
|
|
def test_assign1
|
|
|
|
assign = compile("c = c.next")
|
|
|
|
assert_equal Assignment , assign.class
|
|
|
|
end
|
|
|
|
def test_assign2
|
|
|
|
assign = compile("c.next = d")
|
|
|
|
assert_equal Assignment , assign.class
|
|
|
|
end
|
|
|
|
def test_shift
|
|
|
|
load = compile("word = name.member")
|
|
|
|
assert_equal Assignment , load.class
|
|
|
|
assert_equal :word , load.left.names.first
|
2020-02-13 07:10:04 +01:00
|
|
|
assert_equal Variable , load.right.class
|
2020-02-13 07:02:23 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|