2018-06-26 20:28:27 +03:00
|
|
|
require_relative "helper"
|
|
|
|
|
2018-07-19 14:46:51 +03:00
|
|
|
module Ruby
|
2018-07-19 16:22:44 +03:00
|
|
|
class TestBlockStatement < MiniTest::Test
|
2018-06-29 22:46:39 +03:00
|
|
|
include RubyTests
|
2018-07-07 17:57:46 +03:00
|
|
|
|
2018-06-26 20:28:27 +03:00
|
|
|
def setup()
|
|
|
|
input = "plus_one{|arg1| arg1 + 1 } "
|
2018-06-29 22:46:39 +03:00
|
|
|
@lst = compile( input )
|
2018-06-26 20:28:27 +03:00
|
|
|
end
|
|
|
|
def test_block
|
2019-08-19 10:31:11 +03:00
|
|
|
assert_equal RubyBlockStatement , @lst.class
|
2018-07-19 16:22:44 +03:00
|
|
|
end
|
|
|
|
def test_send
|
|
|
|
assert_equal SendStatement , @lst.send.class
|
2018-06-26 20:28:27 +03:00
|
|
|
end
|
|
|
|
def test_method_name
|
2018-07-19 16:22:44 +03:00
|
|
|
assert_equal :plus_one , @lst.send.name
|
2018-06-26 20:28:27 +03:00
|
|
|
end
|
|
|
|
def test_block_args
|
2018-07-19 16:22:44 +03:00
|
|
|
assert_equal [:arg1] , @lst.args
|
2018-06-26 20:28:27 +03:00
|
|
|
end
|
|
|
|
def test_block_body
|
2018-07-19 16:22:44 +03:00
|
|
|
assert_equal SendStatement , @lst.body.class
|
|
|
|
assert_equal 1 , @lst.body.arguments.length
|
2018-06-26 20:28:27 +03:00
|
|
|
end
|
|
|
|
end
|
2019-10-04 00:36:49 +03:00
|
|
|
class TestBlockStatementSol < MiniTest::Test
|
2018-07-20 20:07:15 +03:00
|
|
|
include RubyTests
|
|
|
|
|
|
|
|
def setup()
|
|
|
|
input = "plus_one{|arg1| arg1 + 1 } "
|
2019-10-04 00:36:49 +03:00
|
|
|
@lst = compile( input ).to_sol
|
2018-07-20 20:07:15 +03:00
|
|
|
end
|
|
|
|
def test_block
|
2019-10-04 00:36:49 +03:00
|
|
|
assert_equal Sol::SendStatement , @lst.class
|
2018-07-20 20:07:15 +03:00
|
|
|
end
|
2019-08-19 14:23:55 +03:00
|
|
|
def test_send_name
|
|
|
|
assert_equal :plus_one , @lst.name
|
2018-07-20 20:07:15 +03:00
|
|
|
end
|
|
|
|
def test_send_block_arg
|
2019-08-19 14:23:55 +03:00
|
|
|
assert_equal 1 , @lst.arguments.length
|
2019-10-04 00:36:49 +03:00
|
|
|
assert_equal Sol::LambdaExpression , @lst.arguments.first.class
|
2018-07-20 20:07:15 +03:00
|
|
|
end
|
|
|
|
def test_block_args
|
2019-08-19 14:23:55 +03:00
|
|
|
assert_equal [:arg1] , @lst.arguments.first.args
|
2018-07-20 20:07:15 +03:00
|
|
|
end
|
|
|
|
end
|
2018-06-26 20:28:27 +03:00
|
|
|
end
|