Sha256: 7f552d56cb9d354614397bd0b312abdab82874e0a736d9bee33be0f4728e6470
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
# TODO refactor this and test_jvm_compiler to use mirah.rb $:.unshift File.join(File.dirname(__FILE__),'..','lib') require 'test/unit' require 'mirah' class TestMacros < Test::Unit::TestCase java_import 'java.lang.System' def parse(code) Mirah::AST.type_factory = Mirah::JVM::Types::TypeFactory.new name = "script" + System.nano_time.to_s state = Mirah::CompilationState.new state.save_extensions = false transformer = Mirah::Transform::Transformer.new(state) Java::MirahImpl::Builtin.initialize_builtins(transformer) ast = Mirah::AST.parse(code, name, true, transformer) typer = Mirah::Typer::JVM.new(transformer) ast.infer(typer, true) typer.resolve(true) ast end def test_macro_helper script = parse(<<-EOF) import duby.lang.compiler.Compiler def helper(mirah:Compiler) name = "foobar" mirah.quote { `name` } end EOF end def test_self_call_in_unquote script = parse(<<-EOF) import duby.lang.compiler.Compiler def foobar(name:String) name end def helper(mirah:Compiler) name = "foobar" mirah.quote { `foobar(name)` } end EOF end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mirah-0.0.7-java | test/test_macros.rb |
mirah-0.0.6-java | test/test_macros.rb |