Torsten Rüger
8df2e4bf08
Just added the compiler, that can parse Slot directly into SlotMachine code (no language layer in between) Still unclear wheather the Maker is a thing, but since it was in the Language layer i did not remove it (yet) Otherwise just the compiler and all the tests, moved from the slot_language.
39 lines
1.1 KiB
Ruby
39 lines
1.1 KiB
Ruby
require_relative "../helper"
|
|
|
|
module SlotMachine
|
|
class TestVariable < MiniTest::Test
|
|
include SlotHelper
|
|
def compile_var(str)
|
|
var = compile(str)
|
|
assert var.is_a?(Slotted) , "Was #{var.class}"
|
|
var
|
|
end
|
|
def test_local
|
|
assert_equal SlottedMessage , compile_var("a").class
|
|
end
|
|
def test_inst
|
|
var = compile_var("@a")
|
|
assert_equal SlottedMessage , var.class
|
|
end
|
|
def test_local_chain
|
|
chain = compile_var("a.b")
|
|
assert_equal Slot , chain.slots.class
|
|
assert_equal :b , chain.slots.next_slot.name
|
|
end
|
|
def test_local_chain2
|
|
chain = compile_var("a.b.c")
|
|
assert_equal Slot , chain.slots.next_slot.next_slot.class
|
|
assert_equal :c , chain.slots.next_slot.next_slot.name
|
|
end
|
|
def test_inst_chain
|
|
chain = compile_var("@a.b")
|
|
assert_equal SlottedMessage , chain.class
|
|
assert_equal Slot , chain.slots.class
|
|
assert_equal :receiver , chain.slots.name
|
|
assert_equal Slot , chain.slots.class
|
|
assert_equal :a , chain.slots.next_slot.name
|
|
assert_equal :b , chain.slots.next_slot.next_slot.name
|
|
end
|
|
end
|
|
end
|