Removing preloads from mains tests
Instead of loading all preload for all tests, adding just those functions that are needed for each. Should reduce test times. Also renaming tests to give some indication of difficulty. Alas they are not run in that order.
This commit is contained in:
parent
1022390e0f
commit
41eccb9382
@ -2,14 +2,19 @@
|
||||
|
||||
Test methods by their output and exit codes (return, since it is the main).
|
||||
|
||||
There are only two tests here (lus one, see below), one for interpreter, one for arm.
|
||||
There are only two tests here (plus one, see below), one for interpreter, one for arm.
|
||||
Both run the same tests. The actual ruby code that is run is in the source dir.
|
||||
Test methods are generated, one for each source file.
|
||||
|
||||
## Files
|
||||
|
||||
File names follow [name,stdout,exitcode] joined by _ pattern. Stdout may be left blank,
|
||||
but exit code must be supplied.
|
||||
File names follow [order,name,stdout,exitcode] joined by _ pattern.
|
||||
Stdout may be left blank, but exit code must be supplied.
|
||||
|
||||
The order number is some number giving the difficulty of the test, higher is more.
|
||||
The first digit represents how many external methods the code relies on, the second
|
||||
is some general indicator, ie recursive is more difficult than not, syscalls more than
|
||||
normal calls, if or while more than nothing etc.
|
||||
|
||||
## Arm
|
||||
|
||||
|
10
test/mains/source/10_add__4.rb
Normal file
10
test/mains/source/10_add__4.rb
Normal file
@ -0,0 +1,10 @@
|
||||
class Integer < Data4
|
||||
def +(right)
|
||||
X.int_operator(:+)
|
||||
end
|
||||
end
|
||||
class Space
|
||||
def main(arg)
|
||||
return 2 + 2
|
||||
end
|
||||
end
|
@ -1,3 +1,8 @@
|
||||
class Integer < Data4
|
||||
def -(right)
|
||||
X.int_operator(:-)
|
||||
end
|
||||
end
|
||||
class Space
|
||||
def same( n )
|
||||
return n
|
@ -1,3 +1,8 @@
|
||||
class Integer < Data4
|
||||
def +(right)
|
||||
X.int_operator(:+)
|
||||
end
|
||||
end
|
||||
class Space
|
||||
def self.simple
|
||||
return 2 + 2
|
@ -1,3 +1,8 @@
|
||||
class Word < Data8
|
||||
def putstring
|
||||
X.putstring
|
||||
end
|
||||
end
|
||||
class Class < Behaviour
|
||||
def name
|
||||
@name
|
@ -1,3 +1,8 @@
|
||||
class Word < Data8
|
||||
def putstring
|
||||
X.putstring
|
||||
end
|
||||
end
|
||||
class Space
|
||||
def main(arg)
|
||||
return "Hello-there".putstring
|
@ -1,3 +1,13 @@
|
||||
class Integer < Data4
|
||||
def <(right)
|
||||
X.comparison(:<)
|
||||
end
|
||||
end
|
||||
class Word < Data8
|
||||
def putstring
|
||||
X.putstring
|
||||
end
|
||||
end
|
||||
class Space
|
||||
def if_small( n )
|
||||
if( n < 10)
|
@ -1,3 +1,13 @@
|
||||
class Integer < Data4
|
||||
def <(right)
|
||||
X.comparison(:<)
|
||||
end
|
||||
end
|
||||
class Word < Data8
|
||||
def putstring
|
||||
X.putstring
|
||||
end
|
||||
end
|
||||
class Space
|
||||
def if_small( n )
|
||||
if( n < 10)
|
@ -1,3 +1,11 @@
|
||||
class Integer < Data4
|
||||
def <(right)
|
||||
X.comparison(:<)
|
||||
end
|
||||
def -(right)
|
||||
X.int_operator(:-)
|
||||
end
|
||||
end
|
||||
class Space
|
||||
|
||||
def down( n )
|
@ -1,3 +1,11 @@
|
||||
class Integer < Data4
|
||||
def <(right)
|
||||
X.comparison(:<)
|
||||
end
|
||||
def +(right)
|
||||
X.int_operator(:+)
|
||||
end
|
||||
end
|
||||
class Space
|
||||
def main(arg)
|
||||
n = 6
|
18
test/mains/source/31_while__0.rb
Normal file
18
test/mains/source/31_while__0.rb
Normal file
@ -0,0 +1,18 @@
|
||||
class Integer < Data4
|
||||
def >=(right)
|
||||
X.comparison(:>=)
|
||||
end
|
||||
def -(right)
|
||||
X.int_operator(:-)
|
||||
end
|
||||
end
|
||||
|
||||
class Space
|
||||
def main(arg)
|
||||
b = 10
|
||||
while( b >= 1 )
|
||||
b = b - 1
|
||||
end
|
||||
return b
|
||||
end
|
||||
end
|
22
test/mains/source/32_adds__10.rb
Normal file
22
test/mains/source/32_adds__10.rb
Normal file
@ -0,0 +1,22 @@
|
||||
class Integer < Data4
|
||||
def <(right)
|
||||
X.comparison(:<)
|
||||
end
|
||||
def +(right)
|
||||
X.int_operator(:+)
|
||||
end
|
||||
def -(right)
|
||||
X.int_operator(:-)
|
||||
end
|
||||
end
|
||||
class Space
|
||||
def main(arg)
|
||||
a = 0
|
||||
b = 20
|
||||
while( a < b )
|
||||
a = a + 1
|
||||
b = b - 1
|
||||
end
|
||||
return a
|
||||
end
|
||||
end
|
@ -1,3 +1,15 @@
|
||||
class Integer < Data4
|
||||
def <(right)
|
||||
X.comparison(:<)
|
||||
end
|
||||
def +(right)
|
||||
X.int_operator(:+)
|
||||
end
|
||||
def -(right)
|
||||
X.int_operator(:-)
|
||||
end
|
||||
end
|
||||
|
||||
class Space
|
||||
|
||||
def fibo_r( n )
|
@ -1,3 +1,16 @@
|
||||
class Integer < Data4
|
||||
def <(right)
|
||||
X.comparison(:<)
|
||||
end
|
||||
def +(right)
|
||||
X.int_operator(:+)
|
||||
end
|
||||
end
|
||||
class Word < Data8
|
||||
def putstring
|
||||
X.putstring
|
||||
end
|
||||
end
|
||||
class Space
|
||||
def times(n)
|
||||
i = 0
|
@ -1,5 +0,0 @@
|
||||
class Space
|
||||
def main(arg)
|
||||
return 2 + 2
|
||||
end
|
||||
end
|
@ -1,11 +0,0 @@
|
||||
class Space
|
||||
def main(arg)
|
||||
a = 0
|
||||
b = 20
|
||||
while( a < b )
|
||||
a = a + 1
|
||||
b = b - 1
|
||||
end
|
||||
return a
|
||||
end
|
||||
end
|
@ -1,9 +0,0 @@
|
||||
class Space
|
||||
def main(arg)
|
||||
b = 10
|
||||
while( b >= 1 )
|
||||
b = b - 1
|
||||
end
|
||||
return b
|
||||
end
|
||||
end
|
@ -19,12 +19,12 @@ module Mains
|
||||
return tests unless has_qemu
|
||||
all.each do |file_name|
|
||||
fullname = file_name.split("/").last.split(".").first
|
||||
name , stdout , exit_code = fullname.split("_")
|
||||
method_name = "test_#{name}"
|
||||
order , name , stdout , exit_code = fullname.split("_")
|
||||
method_name = "test_#{order}_#{name}"
|
||||
input = File.read(file_name)
|
||||
tests << method_name
|
||||
self.send(:define_method, method_name ) do
|
||||
out , code = run_code(input , name)
|
||||
out , code = run_code(input , "#{order}_#{name}")
|
||||
assert_equal stdout , out , "Wrong stdout #{name}"
|
||||
assert_equal exit_code , code.to_s , "Wrong exit code #{name}"
|
||||
end
|
||||
@ -49,9 +49,8 @@ module Mains
|
||||
|
||||
def run_code(input , name )
|
||||
puts "Compiling #{name}.o" if DEBUG
|
||||
code = Vool::Builtin.builtin_code + input
|
||||
|
||||
linker = ::RubyX::RubyXCompiler.new({}).ruby_to_binary( code , :arm )
|
||||
linker = ::RubyX::RubyXCompiler.new({}).ruby_to_binary( input , :arm )
|
||||
writer = Elf::ObjectWriter.new(linker)
|
||||
|
||||
writer.save "mains.o"
|
||||
|
@ -11,12 +11,11 @@ module Mains
|
||||
tests =[]
|
||||
all.each do |file_name|
|
||||
fullname = file_name.split("/").last.split(".").first
|
||||
name , stdout , exit_code = fullname.split("_")
|
||||
method_name = "test_#{name}"
|
||||
order , name , stdout , exit_code = fullname.split("_")
|
||||
method_name = "test_#{order}_#{name}"
|
||||
tests << method_name
|
||||
input = File.read(file_name)
|
||||
self.send(:define_method, method_name ) do
|
||||
@preload = "all"
|
||||
ticks = run_input(input)
|
||||
#puts "Ticks for #{method_name}=#{ticks}"
|
||||
assert_equal stdout , @interpreter.stdout , "Wrong stdout #{name}"
|
||||
|
@ -5,8 +5,8 @@ module RubyX
|
||||
class TestRubyXCliCompile < MiniTest::Test
|
||||
|
||||
def test_compile
|
||||
assert_output(/compiling/) {RubyXC.start(["compile" , "--preload",
|
||||
"--integers=50","--messages=50","test/mains/source/add__4.rb"])}
|
||||
assert_output(/compiling/) {RubyXC.start(["compile" ,
|
||||
"--integers=50","--messages=50","test/mains/source/00_one-call__8.rb"])}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -5,8 +5,8 @@ module RubyX
|
||||
class TestRubyXCliExecute < MiniTest::Test
|
||||
|
||||
def test_execute
|
||||
assert_output(/Running/) {RubyXC.start(["execute" ,"--preload",
|
||||
"--integers=50","--messages=50" , "test/mains/source/add__4.rb"])}
|
||||
assert_output(/Running/) {RubyXC.start(["execute" ,
|
||||
"--integers=50","--messages=50" , "test/mains/source/00_one-call__8.rb"])}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -5,8 +5,8 @@ module RubyX
|
||||
class TestRubyXCliInterpret < MiniTest::Test
|
||||
|
||||
def test_interpret
|
||||
assert_output(/interpreting/) {RubyXC.start(["interpret" ,"--preload",
|
||||
"--integers=50","--messages=50" , "test/mains/source/add__4.rb"])}
|
||||
assert_output(/interpreting/) {RubyXC.start(["interpret" ,
|
||||
"--integers=50","--messages=50" , "test/mains/source/00_one-call__8.rb"])}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -5,8 +5,8 @@ module RubyX
|
||||
class TestRubyXCliStats < MiniTest::Test
|
||||
|
||||
def test_stats
|
||||
out, err = capture_io {RubyXC.start(["stats" ,"--preload",
|
||||
"--integers=50","--messages=50", "test/mains/source/add__4.rb"])}
|
||||
out, err = capture_io {RubyXC.start(["stats" ,
|
||||
"--integers=50","--messages=50", "test/mains/source/00_one-call__8.rb"])}
|
||||
assert out.include?("Space") , out
|
||||
assert out.include?("Total") , out
|
||||
assert out.include?("Objects=") , out
|
||||
|
Loading…
x
Reference in New Issue
Block a user