2019-08-15 20:30:36 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module Ruby
|
|
|
|
module LastBar
|
|
|
|
include RubyTests
|
|
|
|
def test_last_class
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::SendStatement , @lst.last.class
|
2019-08-15 20:30:36 +02:00
|
|
|
end
|
|
|
|
def test_last_name
|
|
|
|
assert_equal :last , @lst.last.name
|
|
|
|
end
|
|
|
|
def test_last_arg
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::LocalVariable , @lst.last.arguments.first.class
|
2019-08-15 20:30:36 +02:00
|
|
|
end
|
|
|
|
def test_lst_class
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::Statements , @lst.class
|
2019-08-15 20:30:36 +02:00
|
|
|
end
|
|
|
|
def test_lst_no_statements
|
2019-10-03 23:36:49 +02:00
|
|
|
@lst.statements.each{|st| assert( ! st.is_a?(Sol::Statements) , st.class)}
|
2019-08-15 20:30:36 +02:00
|
|
|
end
|
|
|
|
end
|
2019-10-03 23:36:49 +02:00
|
|
|
class TestSendSendArgSol < MiniTest::Test
|
2019-08-15 20:30:36 +02:00
|
|
|
include LastBar
|
|
|
|
def setup
|
2019-10-03 23:36:49 +02:00
|
|
|
@lst = compile( "last(foo(1))").to_sol
|
2019-08-15 20:30:36 +02:00
|
|
|
end
|
|
|
|
def test_classes
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::Statements , @lst.class
|
|
|
|
assert_equal Sol::LocalAssignment , @lst.first.class
|
|
|
|
assert_equal Sol::SendStatement , @lst.last.class
|
2019-08-15 20:30:36 +02:00
|
|
|
end
|
|
|
|
def test_foo1
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::SendStatement , @lst.first.value.class
|
2019-08-15 20:30:36 +02:00
|
|
|
assert_equal :foo , @lst.first.value.name
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::IntegerConstant , @lst.first.value.arguments.first.class
|
2019-08-15 20:30:36 +02:00
|
|
|
end
|
|
|
|
end
|
2019-10-03 23:36:49 +02:00
|
|
|
class Test3SendSol < MiniTest::Test
|
2019-08-15 20:30:36 +02:00
|
|
|
include LastBar
|
|
|
|
def setup
|
2019-10-03 23:36:49 +02:00
|
|
|
@lst = compile( "last(foo(more(1)))").to_sol
|
2019-08-15 20:30:36 +02:00
|
|
|
end
|
|
|
|
def test_classes
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::Statements , @lst.class
|
|
|
|
assert_equal Sol::LocalAssignment , @lst.first.class
|
|
|
|
assert_equal Sol::SendStatement , @lst.last.class
|
2019-08-15 20:30:36 +02:00
|
|
|
end
|
|
|
|
def test_foo
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::SendStatement , @lst.first.value.class
|
2019-08-15 20:30:36 +02:00
|
|
|
assert_equal :more , @lst.first.value.name
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::IntegerConstant , @lst.first.value.arguments.first.class
|
2019-08-15 20:30:36 +02:00
|
|
|
end
|
|
|
|
end
|
2019-10-03 23:36:49 +02:00
|
|
|
class Test5SendSol < MiniTest::Test
|
2019-08-15 20:30:36 +02:00
|
|
|
include LastBar
|
|
|
|
def setup
|
2019-10-03 23:36:49 +02:00
|
|
|
@lst = compile( "last(foo(more(even_more(1),and_more(with_more))))").to_sol
|
2019-08-15 20:30:36 +02:00
|
|
|
end
|
|
|
|
def test_classes
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::Statements , @lst.class
|
|
|
|
assert_equal Sol::LocalAssignment , @lst.first.class
|
|
|
|
assert_equal Sol::SendStatement , @lst.last.class
|
2019-08-15 20:30:36 +02:00
|
|
|
end
|
|
|
|
def test_foo
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::SendStatement , @lst.first.value.class
|
2019-08-15 20:30:36 +02:00
|
|
|
assert_equal :even_more , @lst.first.value.name
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::IntegerConstant , @lst.first.value.arguments.first.class
|
2019-08-15 20:30:36 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|