small test fixes
This commit is contained in:
parent
67a6ef9f67
commit
4103da7490
@ -11,8 +11,14 @@ module Elf
|
||||
Risc.machine.boot
|
||||
end
|
||||
|
||||
def check(file)
|
||||
Vool::VoolCompiler.ruby_to_binary( "class Space;def main(arg);#{@input};end;end" )
|
||||
def in_space(input)
|
||||
"class Space; #{input} ; end"
|
||||
end
|
||||
def as_main(input)
|
||||
in_space("def main(arg);#{input};end")
|
||||
end
|
||||
def check(input, file)
|
||||
Vool::VoolCompiler.ruby_to_binary( input )
|
||||
writer = Elf::ObjectWriter.new(Risc.machine)
|
||||
writer.save "test/#{file}.o"
|
||||
end
|
||||
|
@ -1,12 +0,0 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Elf
|
||||
class AddTest < FullTest
|
||||
|
||||
def test_add
|
||||
@input = "return 2 + 2"
|
||||
@exit_code = 4
|
||||
check "add"
|
||||
end
|
||||
end
|
||||
end
|
28
test/elf/test_something.rb
Normal file
28
test/elf/test_something.rb
Normal file
@ -0,0 +1,28 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Elf
|
||||
class SomethingTest < FullTest
|
||||
|
||||
def test_add
|
||||
input = <<HERE
|
||||
def fibo( n)
|
||||
a = 0
|
||||
b = 1
|
||||
i = 1
|
||||
while( i < n ) do
|
||||
result = a + b
|
||||
a = b
|
||||
b = result
|
||||
i += 1
|
||||
end
|
||||
return result
|
||||
end
|
||||
def main(arg)
|
||||
return fibo(20)
|
||||
end
|
||||
HERE
|
||||
@exit_code = 4
|
||||
check in_space(input) , "fibo"
|
||||
end
|
||||
end
|
||||
end
|
@ -1,14 +1,14 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Elf
|
||||
class HelloTest < FullTest
|
||||
class SomeOtherTest < FullTest
|
||||
|
||||
def test_string_put
|
||||
hello = "Hello World!\n"
|
||||
@input = "return '#{hello}'.putstring"
|
||||
input = "return '#{hello}'.putstring"
|
||||
@stdout = hello
|
||||
@exit_code = hello.length
|
||||
check "hello"
|
||||
check as_main(input), "hello"
|
||||
end
|
||||
end
|
||||
end
|
@ -16,10 +16,12 @@ class TestZeroCode < MiniTest::Test
|
||||
name == :main or name == :__init__
|
||||
end
|
||||
|
||||
def pest_empty_translate
|
||||
def test_empty_translate
|
||||
assert_equal 2 , @space.get_all_methods.length
|
||||
@machine.translate(:arm)
|
||||
writer = Elf::ObjectWriter.new(@machine , @objects )
|
||||
@machine.position_all
|
||||
@machine.create_binary
|
||||
writer = Elf::ObjectWriter.new(@machine )
|
||||
writer.save "test/zero.o"
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user