2019-03-07 09:47:48 +01:00
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module Ruby
|
|
|
|
class TestClassStatementTransform < MiniTest::Test
|
|
|
|
include AttributeTests
|
|
|
|
|
|
|
|
def attr_def
|
|
|
|
"attr :page"
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_method_len
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal 2 , @sol.body.length , "setter, getter"
|
2019-03-07 09:47:48 +01:00
|
|
|
end
|
|
|
|
def test_setter
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::MethodExpression , setter.class
|
2019-03-07 09:47:48 +01:00
|
|
|
end
|
|
|
|
def test_setter_assign
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::Statements , setter.body.class
|
|
|
|
assert_equal Sol::IvarAssignment , setter.body.first.class
|
2019-03-07 09:47:48 +01:00
|
|
|
end
|
|
|
|
def test_setter_return
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::Statements , setter.body.class
|
|
|
|
assert_equal Sol::ReturnStatement , setter.body.last.class
|
2019-03-07 09:47:48 +01:00
|
|
|
end
|
|
|
|
def test_setter_name
|
|
|
|
assert_equal :page= , setter.name
|
|
|
|
end
|
|
|
|
def test_setter_args
|
|
|
|
assert_equal [:val] , setter.args
|
|
|
|
end
|
|
|
|
end
|
2019-03-07 10:00:18 +01:00
|
|
|
class TestClassStatementTransformReader < MiniTest::Test
|
|
|
|
include AttributeTests
|
2019-03-07 09:47:48 +01:00
|
|
|
|
2019-03-07 10:00:18 +01:00
|
|
|
def attr_def
|
|
|
|
"attr_reader :page"
|
|
|
|
end
|
|
|
|
def test_method_len
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal 1 , @sol.body.length , "setter, getter"
|
2019-03-07 10:00:18 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2019-03-07 09:47:48 +01:00
|
|
|
end
|