diff --git a/test/bench/rubyx/loop.rb b/test/bench/rubyx/loop.rb index b01cf61a..3dca22ab 100644 --- a/test/bench/rubyx/loop.rb +++ b/test/bench/rubyx/loop.rb @@ -9,3 +9,5 @@ class Space return b end end +# 9.5 local +# 45 on pi diff --git a/test/bench/rubyx/noop.rb b/test/bench/rubyx/noop.rb index b54859f1..2157caf7 100644 --- a/test/bench/rubyx/noop.rb +++ b/test/bench/rubyx/noop.rb @@ -3,3 +3,6 @@ class Space return 0 end end + +# 5.5 local +# 42 on pi diff --git a/test/bench/rubyx/times.rb b/test/bench/rubyx/times.rb new file mode 100644 index 00000000..f6e27069 --- /dev/null +++ b/test/bench/rubyx/times.rb @@ -0,0 +1,17 @@ +class Space + def times(n) + i = 0 + while( i < n ) + yield + i = i + 1 + end + return n + end + def main(arg) + return times(100000) { + return 1 + } + end +end +# 13 local +# 51 on pi diff --git a/test/mains/source/times_11111_5.rb b/test/mains/source/times_11111_5.rb new file mode 100644 index 00000000..4bf51877 --- /dev/null +++ b/test/mains/source/times_11111_5.rb @@ -0,0 +1,15 @@ +class Space + def times(n) + i = 0 + while( i < n ) + yield + i = i + 1 + end + return n + end + def main(arg) + return times(5) { + "1".putstring + } + end +end diff --git a/test/mains/test_new.rb b/test/mains/test_new.rb index 63e48bca..3ead3eaa 100644 --- a/test/mains/test_new.rb +++ b/test/mains/test_new.rb @@ -1,10 +1,10 @@ require_relative 'helper' -# The "New" in this TestNew means that this is the place to develop a new test for the mains dir. -# If you just pop a file in the source directory, all tests will run. (Well, actually guard does -# not pick up changes on that source dir yet, but when you run it manually, all tests run) +# The "New" in this TestNew means that this is the place to develop a new test for the +# mains dir. +# If you just pop a file in the source directory, all tests will run. # This is fine if all is fine. But if all is fine, you are not developing, just playing. -# So when you really need to itereate this editing this gives guard auto-run and just of that +# So when you really need to itereate editing this gives guard auto-run and just of that # one test that you work on. # After getting the test to run, copy paste the whole code into a file in source and revert @@ -17,11 +17,20 @@ module Mains def whole_input <<-eos class Space - def self.simple - return 2 + 2 + def times + n = 5 + i = 0 + while( i < 5 ) + yield + i = i + 1 + end + return 1 end def main(arg) - return Space.simple + times{ + "1".putstring + } + return 4 end end eos @@ -35,6 +44,7 @@ module Mains run_all assert_equal ::Integer , get_return.class , " " assert_equal 4 , get_return , " " + assert_equal "hi" , @interpreter.stdout end end