manage to create ruby methods

This commit is contained in:
Torsten Ruger
2017-01-12 20:38:04 +02:00
parent 89f5badc16
commit 3f6c1bc3a3
12 changed files with 76 additions and 24 deletions

View File

@ -1 +1,13 @@
require_relative '../helper'
module Melon
module CompilerHelper
def in_Space(statements)
"class Space ; #{statements} ; end"
end
def as_main(statements)
in_Space("def main ; #{statements}; end")
end
end
end

View File

@ -1,3 +1,4 @@
require_relative "test_type_collector"
require_relative "test_method_collector"
require_relative "test_locals_collector"
require_relative "test_class_creation"

View File

@ -0,0 +1,19 @@
require_relative "helper"
module Melon
class TestMethod < MiniTest::Test
include CompilerHelper
def setup
Register.machine.boot
end
def test_creates_method_in_class
Compiler.compile in_Space("def meth; @ivar;end")
space = Parfait.object_space.get_class
method = space.get_method(:meth)
assert method , "No method created"
end
end
end

View File

@ -6,12 +6,15 @@ module Melon
module MelonTests
def setup
@parser = Parser::Ruby22
Register.machine.boot
end
def check
assert true
#puts @parser.parse @string_input
Compiler.compile @string_input
Register::Collector.collect_space
@interpreter = Register::Interpreter.new
@interpreter.start Register.machine.init
nil
end
end
end

View File

@ -3,3 +3,8 @@ require_relative "test_calls"
require_relative "test_hello"
require_relative "test_itos"
require_relative "test_loop"
require_relative "test_many_adds"
require_relative "test_many_hello"
require_relative "test_many_calls"
require_relative "test_many_itos"

View File

@ -6,11 +6,9 @@ module Melon
def test_ruby_hello
@string_input = <<HERE
puts "Hello there"
HERE
@stdout = "Hello there"
check
@string_input = 'puts "Hello there"'
assert !check
# assert_equal "Hello there" , @interpreter.stdout
end
end

View File

@ -1,3 +1,2 @@
require_relative "compiler/test_all"
require_relative "fragments/test_all"
require_relative "test_compiler"