minor fixes

This commit is contained in:
Torsten Ruger 2015-11-16 18:02:13 +02:00
parent f50d7b57a4
commit f92ea36fe5
6 changed files with 14 additions and 12 deletions

1
.gitignore vendored
View File

@ -39,3 +39,4 @@ pkg
# Object files # Object files
*.o *.o
log log
tmp

View File

@ -11,7 +11,7 @@ class Object
end end
end end
HERE HERE
@length = 36 @length = 37
@stdout = "Hello Raisa, I am salama" @stdout = "Hello Raisa, I am salama"
check check
end end

View File

@ -31,7 +31,7 @@ class Object
end end
end end
HERE HERE
@length = 46 @length = 47
@stdout = "10" @stdout = "10"
check check
end end
@ -53,7 +53,7 @@ class Object
end end
end end
HERE HERE
@length = 61 @length = 62
@stdout = "else" @stdout = "else"
check check
end end

View File

@ -3,7 +3,7 @@ require_relative 'helper'
class TestWord < MiniTest::Test class TestWord < MiniTest::Test
include Fragments include Fragments
def test_hello def test_word_new
@string_input = <<HERE @string_input = <<HERE
class Object class Object
Word self.new() Word self.new()

View File

@ -20,10 +20,10 @@ HERE
"LoadConstant","SetSlot","FunctionCall","Label","GetSlot", "LoadConstant","SetSlot","FunctionCall","Label","GetSlot",
"LoadConstant","SetSlot","LoadConstant","SetSlot","LoadConstant", "LoadConstant","SetSlot","LoadConstant","SetSlot","LoadConstant",
"SetSlot","LoadConstant","SetSlot","RegisterTransfer","FunctionCall", "SetSlot","LoadConstant","SetSlot","RegisterTransfer","FunctionCall",
"Label","GetSlot","RegisterTransfer","Syscall","RegisterTransfer", "Label","GetSlot","GetSlot","RegisterTransfer","Syscall",
"RegisterTransfer","SetSlot","Label","FunctionReturn","RegisterTransfer", "RegisterTransfer","RegisterTransfer","SetSlot","Label","FunctionReturn",
"GetSlot","GetSlot","Label","FunctionReturn","RegisterTransfer", "RegisterTransfer","GetSlot","GetSlot","Label","FunctionReturn",
"Syscall","NilClass"] "RegisterTransfer","Syscall","NilClass"]
end end
def test_branch def test_branch
@ -47,13 +47,13 @@ HERE
end end
def test_putstring def test_putstring
done = ticks(24) done = ticks(25)
assert_equal Register::Syscall , done.class assert_equal Register::Syscall , done.class
assert_equal "Hello again" , @interpreter.stdout assert_equal "Hello again" , @interpreter.stdout
end end
def test_return def test_return
done = ticks(29) done = ticks(30)
assert_equal Register::FunctionReturn , done.class assert_equal Register::FunctionReturn , done.class
assert Register::Label , @interpreter.instruction.class assert Register::Label , @interpreter.instruction.class
assert @interpreter.instruction.is_a?(Register::Instruction) , "not instruction #{@interpreter.instruction}" assert @interpreter.instruction.is_a?(Register::Instruction) , "not instruction #{@interpreter.instruction}"

View File

@ -33,8 +33,9 @@ HERE
end end
def write_file def write_file
file_name = caller(3).first.split("in ").last.chop.reverse.chop.reverse file_name = caller(3).first.split("in ").last.chop.sub("`","")
file_name = File.dirname(__FILE__) + "/" + file_name + ".o" return if file_name.include?("run")
file_name = "./tmp/" + file_name + ".o"
Register.machine.translate_arm Register.machine.translate_arm
writer = Elf::ObjectWriter.new writer = Elf::ObjectWriter.new
writer.save file_name writer.save file_name