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,14 +2,16 @@ require_relative '../helper'
require "register/interpreter"
require "parser/ruby22"
module MelonTests
module Melon
module MelonTests
def setup
@parser = Parser::Ruby22
end
def setup
@parser = Parser::Ruby22
end
def check
assert true
#puts @parser.parse @string_input
def check
assert true
#puts @parser.parse @string_input
end
end
end

View File

@ -1,51 +1,26 @@
require_relative 'helper'
class TestRubyAdds < MiniTest::Test
include MelonTests
module Melon
class TestRubyAdds < MiniTest::Test
include MelonTests
def test_ruby_adds
@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
def pest_ruby_adds
@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
return result
end
HERE
@stdout = "Hello there"
check
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
@stdout = "Hello there"
check
end
counter = 100000
while(counter > 0) do
fibo(40)
counter -= 1
end
HERE
@length = 37
@stdout = "Hello Raisa, I am salama"
check
end
end

View File

@ -1,45 +1,24 @@
require_relative 'helper'
class TestRubyCalls < MiniTest::Test
include MelonTests
module Melon
class TestRubyCalls < MiniTest::Test
include MelonTests
def test_ruby_calls
@string_input = <<HERE
def pest_ruby_calls
@string_input = <<HERE
def fibo_r( n )
if( n < 2 )
return n
else
return fibo_r(n - 1) + fibo_r(n - 2)
end
end
def fibo_r( n )
if( n < 2 )
return n
else
return fibo_r(n - 1) + fibo_r(n - 2)
end
end
fibo 40
fibo 40
HERE
@stdout = "Hello there"
check
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
@stdout = "Hello there"
check
end
counter = 1000
while(counter > 0) do
fibo_r(20)
counter -= 1
end
HERE
@length = 37
@stdout = ""
check
end
end

View File

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

View File

@ -1,28 +1,16 @@
require_relative 'helper'
class TestRubyItos < MiniTest::Test
include MelonTests
module Melon
class TestRubyItos < MiniTest::Test
include MelonTests
def test_ruby_itos
@string_input = <<HERE
100000.to_s
def pest_ruby_itos
@string_input = <<HERE
100000.to_s
HERE
@stdout = "Hello there"
check
end
@stdout = "Hello there"
check
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

View File

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