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

View File

@ -1,51 +1,26 @@
require_relative 'helper' require_relative 'helper'
class TestRubyAdds < MiniTest::Test module Melon
include MelonTests class TestRubyAdds < MiniTest::Test
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
b = 1 b = 1
i = 1 i = 1
while( i < n ) do while( i < n ) do
result = a + b result = a + b
a = b a = b
b = result b = result
i+= 1 i+= 1
end
return result
end end
return result
end
HERE HERE
@stdout = "Hello there" @stdout = "Hello there"
check 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
end 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,45 +1,24 @@
require_relative 'helper' require_relative 'helper'
class TestRubyCalls < MiniTest::Test module Melon
include MelonTests class TestRubyCalls < MiniTest::Test
include MelonTests
def test_ruby_calls def pest_ruby_calls
@string_input = <<HERE @string_input = <<HERE
def fibo_r( n ) def fibo_r( n )
if( n < 2 ) if( n < 2 )
return n return n
else else
return fibo_r(n - 1) + fibo_r(n - 2) return fibo_r(n - 1) + fibo_r(n - 2)
end end
end end
fibo 40 fibo 40
HERE HERE
@stdout = "Hello there" @stdout = "Hello there"
check 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
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,27 +1,17 @@
require_relative 'helper' require_relative 'helper'
class TestRubyHello < MiniTest::Test module Melon
include MelonTests 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 def test_ruby_hello
@string_input = <<HERE @string_input = <<HERE
counter = 100000; puts "Hello there"
while(counter > 0) do
puts "Hello there"
STDOUT.flush
counter = counter - 1
end
HERE HERE
@length = 37 @stdout = "Hello there"
@stdout = "Hello Raisa, I am salama" check
check end
end end
end end

View File

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