2018-07-19 13:46:51 +02:00
|
|
|
require_relative "../helper"
|
|
|
|
|
|
|
|
module Ruby
|
|
|
|
module RubyTests
|
|
|
|
def setup
|
2019-02-08 22:03:23 +01:00
|
|
|
Parfait.boot!(Parfait.default_test_options)
|
2018-07-19 13:46:51 +02:00
|
|
|
end
|
|
|
|
def compile(input)
|
|
|
|
RubyCompiler.compile(input)
|
|
|
|
end
|
|
|
|
|
2019-03-05 19:36:40 +01:00
|
|
|
def assert_raises_muted &block
|
|
|
|
orig_stdout = $stdout
|
|
|
|
$stdout = StringIO.new
|
|
|
|
assert_raises &block
|
|
|
|
$stdout = orig_stdout
|
|
|
|
end
|
2018-07-19 13:46:51 +02:00
|
|
|
end
|
2019-03-07 09:47:48 +01:00
|
|
|
module AttributeTests
|
|
|
|
include RubyTests
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@vool = compile( "class Tryout < Base; #{attr_def};end" ).to_vool
|
|
|
|
end
|
|
|
|
def getter
|
|
|
|
@vool.body.statements.first
|
|
|
|
end
|
|
|
|
def setter
|
|
|
|
@vool.body.statements.last
|
|
|
|
end
|
2019-03-07 10:00:18 +01:00
|
|
|
def test_class
|
|
|
|
assert_equal Vool::ClassStatement , @vool.class
|
|
|
|
end
|
|
|
|
def test_body
|
|
|
|
assert_equal Vool::Statements , @vool.body.class
|
|
|
|
end
|
|
|
|
def test_getter
|
|
|
|
assert_equal Vool::MethodStatement , getter.class
|
|
|
|
end
|
|
|
|
def test_getter_return
|
|
|
|
assert_equal Vool::ReturnStatement , getter.body.class
|
|
|
|
end
|
|
|
|
def test_getter_name
|
|
|
|
assert_equal :page , getter.name
|
|
|
|
end
|
2019-03-07 09:47:48 +01:00
|
|
|
end
|
2018-07-19 13:46:51 +02:00
|
|
|
end
|