putting melon tests into module and splitting to one per file

This commit is contained in:
Torsten Ruger 2017-01-11 19:18:04 +02:00
parent 83d943afa5
commit 89f5badc16
10 changed files with 181 additions and 138 deletions

View File

@ -2,7 +2,8 @@ require_relative '../helper'
require "register/interpreter" require "register/interpreter"
require "parser/ruby22" require "parser/ruby22"
module MelonTests module Melon
module MelonTests
def setup def setup
@parser = Parser::Ruby22 @parser = Parser::Ruby22
@ -12,4 +13,5 @@ module MelonTests
assert true assert true
#puts @parser.parse @string_input #puts @parser.parse @string_input
end end
end
end end

View File

@ -1,9 +1,10 @@
require_relative 'helper' require_relative 'helper'
class TestRubyAdds < MiniTest::Test module Melon
class TestRubyAdds < MiniTest::Test
include MelonTests include MelonTests
def test_ruby_adds def pest_ruby_adds
@string_input = <<HERE @string_input = <<HERE
def fibo( n) def fibo( n)
a = 0 a = 0
@ -21,31 +22,5 @@ HERE
@stdout = "Hello there" @stdout = "Hello there"
check check
end end
def pest_ruby_adds_looping
@string_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
counter = 100000
while(counter > 0) do
fibo(40)
counter -= 1
end
HERE
@length = 37
@stdout = "Hello Raisa, I am salama"
check
end end
end end

View File

@ -1,9 +1,10 @@
require_relative 'helper' require_relative 'helper'
class TestRubyCalls < MiniTest::Test module Melon
class TestRubyCalls < MiniTest::Test
include MelonTests include MelonTests
def test_ruby_calls def pest_ruby_calls
@string_input = <<HERE @string_input = <<HERE
def fibo_r( n ) def fibo_r( n )
@ -19,27 +20,5 @@ HERE
@stdout = "Hello there" @stdout = "Hello there"
check check
end end
def pest_ruby_calls_looping
@string_input = <<HERE
def fibo_r( n )
if( n < 2 )
return n
else
return fibo_r(n - 1) + fibo_r(n - 2)
end
end
counter = 1000
while(counter > 0) do
fibo_r(20)
counter -= 1
end
HERE
@length = 37
@stdout = ""
check
end end
end end

View File

@ -1,8 +1,10 @@
require_relative 'helper' require_relative 'helper'
class TestRubyHello < MiniTest::Test module Melon
class TestRubyHello < MiniTest::Test
include MelonTests include MelonTests
def test_ruby_hello def test_ruby_hello
@string_input = <<HERE @string_input = <<HERE
puts "Hello there" puts "Hello there"
@ -11,17 +13,5 @@ HERE
check check
end end
def pest_ruby_hello_looping
@string_input = <<HERE
counter = 100000;
while(counter > 0) do
puts "Hello there"
STDOUT.flush
counter = counter - 1
end
HERE
@length = 37
@stdout = "Hello Raisa, I am salama"
check
end end
end end

View File

@ -1,28 +1,16 @@
require_relative 'helper' require_relative 'helper'
class TestRubyItos < MiniTest::Test module Melon
class TestRubyItos < MiniTest::Test
include MelonTests include MelonTests
def test_ruby_itos def pest_ruby_itos
@string_input = <<HERE @string_input = <<HERE
100000.to_s 100000.to_s
HERE HERE
@stdout = "Hello there" @stdout = "Hello there"
check check
end end
def pest_ruby_itos_looping
@string_input = <<HERE
counter = 100000
while(counter > 0) do
str = counter.to_s
counter = counter - 1
end
str
HERE
@length = 37
@stdout = "Hello Raisa, I am salama"
check
end end
end end

View File

@ -1,17 +1,19 @@
require_relative 'helper' require_relative 'helper'
class TestRubyLoop < MiniTest::Test module Melon
class TestRubyLoop < MiniTest::Test
include MelonTests include MelonTests
def test_ruby_loop def pest_ruby_loop
@string_input = <<HERE @string_input = <<HERE
counter = 100000 counter = 100000
while(counter > 0) do while(counter > 0) do
counter -= 1 counter -= 1
end end
HERE HERE
@stdout = "Hello there" @stdout = "Hello there"
check check
end end
end
end end

View File

@ -0,0 +1,34 @@
require_relative 'helper'
module Melon
class TestManyAdds < MiniTest::Test
include MelonTests
def pest_ruby_adds_looping
@string_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
counter = 100000
while(counter > 0) do
fibo(40)
counter -= 1
end
HERE
@length = 37
@stdout = "Hello there"
check
end
end
end

View File

@ -0,0 +1,30 @@
require_relative 'helper'
module Melon
class TestManyCalls < MiniTest::Test
include MelonTests
def pest_ruby_calls_looping
@string_input = <<HERE
def fibo_r( n )
if( n < 2 )
return n
else
return fibo_r(n - 1) + fibo_r(n - 2)
end
end
counter = 1000
while(counter > 0) do
fibo_r(20)
counter -= 1
end
HERE
@length = 37
@stdout = ""
check
end
end
end

View File

@ -0,0 +1,21 @@
require_relative 'helper'
module Melon
class TestManyHello < MiniTest::Test
include MelonTests
def pest_ruby_hello_looping
@string_input = <<HERE
counter = 100000;
while(counter > 0) do
puts "Hello there"
STDOUT.flush
counter = counter - 1
end
HERE
@length = 37
@stdout = "Hello there"
check
end
end
end

View File

@ -0,0 +1,22 @@
require_relative 'helper'
module Melon
class TestManyItos < MiniTest::Test
include MelonTests
def pest_ruby_itos_looping
@string_input = <<HERE
counter = 100000
while(counter > 0) do
str = counter.to_s
counter = counter - 1
end
str
HERE
@length = 37
@stdout = "Hello Raisa, I am salama"
check
end
end
end