rubyx/test/ruby/helper.rb
Torsten Rüger b9bdc55059 A good start on the macro idea
I call it macro because it lets you insert basically arbitrary risc code into the ruby level. The way it works:
Reserve namespace X
map any X.some_call to a Mom instruction
by the name SomeCall
which must take the same args in constructor as given
And obviously produce whatever risc it wants
Hoping to rewrite builtin around this idea (with the existing Mom builtn instructions)
2019-08-25 14:40:59 +03:00

56 lines
1.3 KiB
Ruby

require_relative "../helper"
module Ruby
module RubyTests
include ScopeHelper
def setup
Parfait.boot!(Parfait.default_test_options)
end
def compile(input)
RubyCompiler.compile(input)
end
def compile_main(input)
RubyCompiler.compile(as_main(input))
end
def compile_main_vool(input)
xcompiler = RubyX::RubyXCompiler.new(RubyX.default_test_options)
xcompiler.ruby_to_vool(as_main(input))
end
def assert_raises_muted &block
orig_stdout = $stdout
$stdout = StringIO.new
assert_raises &block
$stdout = orig_stdout
end
end
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
def test_class
assert_equal Vool::ClassExpression , @vool.class
end
def test_body
assert_equal Vool::Statements , @vool.body.class
end
def test_getter
assert_equal Vool::MethodExpression , 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
end
end