2019-08-25 13:40:59 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module Ruby
|
|
|
|
class TestPlusEqualsRuby < Minitest::Test
|
|
|
|
include RubyTests
|
|
|
|
def setup
|
|
|
|
@lst = compile_main( "X.plus_equals(1)")
|
|
|
|
end
|
|
|
|
def method_body
|
|
|
|
@lst.body.first.body
|
|
|
|
end
|
|
|
|
def test_class
|
|
|
|
assert_equal Ruby::ClassStatement , @lst.class
|
|
|
|
assert_equal Ruby::Statements , @lst.body.class
|
|
|
|
end
|
|
|
|
def test_method
|
|
|
|
assert_equal Ruby::MethodStatement , @lst.body.first.class
|
|
|
|
assert_equal Ruby::SendStatement , method_body.class
|
|
|
|
end
|
|
|
|
def test_send
|
|
|
|
assert_equal :X , method_body.receiver.name
|
|
|
|
assert_equal :plus_equals , method_body.name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class TestPlusEquals < Minitest::Test
|
|
|
|
include RubyTests
|
|
|
|
def setup
|
2019-10-03 23:36:49 +02:00
|
|
|
@lst = compile( "X.plus_equals(1)").to_sol
|
2019-08-25 13:40:59 +02:00
|
|
|
end
|
|
|
|
def test_class
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::MacroExpression , @lst.class
|
2019-08-25 13:40:59 +02:00
|
|
|
end
|
|
|
|
def test_arg1
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::IntegerConstant , @lst.arguments.first.class
|
2019-08-25 13:40:59 +02:00
|
|
|
end
|
|
|
|
def test_name
|
|
|
|
assert_equal :plus_equals , @lst.name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class TestPlusEqualsX < Minitest::Test
|
|
|
|
include RubyTests
|
|
|
|
def setup
|
2019-10-03 23:36:49 +02:00
|
|
|
@lst = compile_main( "X.plus_equals(arg,1)").to_sol
|
2019-08-25 13:40:59 +02:00
|
|
|
end
|
|
|
|
def method_body
|
|
|
|
@lst.body.first.body
|
|
|
|
end
|
|
|
|
def test_class
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::ClassExpression , @lst.class
|
|
|
|
assert_equal Sol::MethodExpression , @lst.body.first.class
|
2019-08-25 13:40:59 +02:00
|
|
|
end
|
|
|
|
def test_macro_class
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::ReturnStatement , method_body.class
|
|
|
|
assert_equal Sol::MacroExpression , method_body.return_value.class
|
2019-08-25 13:40:59 +02:00
|
|
|
end
|
|
|
|
def test_args
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::LocalVariable , method_body.return_value.arguments.first.class
|
|
|
|
assert_equal Sol::IntegerConstant , method_body.return_value.arguments.last.class
|
2019-08-25 13:40:59 +02:00
|
|
|
end
|
|
|
|
def test_name
|
|
|
|
assert_equal :plus_equals , method_body.return_value.name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|