bit of renaming and a string test
This commit is contained in:
5
test/risc/builtin/README.md
Normal file
5
test/risc/builtin/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# Builtin Testing
|
||||
|
||||
Basically test builtin methods by their output.
|
||||
|
||||
Currently through Interpreter only
|
@ -5,52 +5,52 @@ module Risc
|
||||
class IntCmp < BuiltinTest
|
||||
|
||||
def test_smaller_true
|
||||
run_input "4 < 5"
|
||||
run_main "4 < 5"
|
||||
assert_equal Parfait::TrueClass , get_return.class
|
||||
end
|
||||
def test_smaller_false
|
||||
run_input "6 < 5"
|
||||
run_main "6 < 5"
|
||||
assert_equal Parfait::FalseClass , get_return.class
|
||||
end
|
||||
def test_smaller_false_same
|
||||
run_input "5 < 5"
|
||||
run_main "5 < 5"
|
||||
assert_equal Parfait::FalseClass , get_return.class
|
||||
end
|
||||
def test_larger_true
|
||||
run_input "5 > 4"
|
||||
run_main "5 > 4"
|
||||
assert_equal Parfait::TrueClass , get_return.class
|
||||
end
|
||||
def test_larger_false
|
||||
run_input "5 > 6"
|
||||
run_main "5 > 6"
|
||||
assert_equal Parfait::FalseClass , get_return.class
|
||||
end
|
||||
def test_larger_false_same
|
||||
run_input "5 > 5"
|
||||
run_main "5 > 5"
|
||||
assert_equal Parfait::FalseClass , get_return.class
|
||||
end
|
||||
|
||||
def test_smaller_or_true
|
||||
run_input "4 <= 5"
|
||||
run_main "4 <= 5"
|
||||
assert_equal Parfait::TrueClass , get_return.class
|
||||
end
|
||||
def test_smaller_or_false
|
||||
run_input "6 <= 5"
|
||||
run_main "6 <= 5"
|
||||
assert_equal Parfait::FalseClass , get_return.class
|
||||
end
|
||||
def test_smaller_or_same
|
||||
run_input "5 <= 5"
|
||||
run_main "5 <= 5"
|
||||
assert_equal Parfait::TrueClass , get_return.class
|
||||
end
|
||||
def test_larger_or_true
|
||||
run_input "5 >= 4"
|
||||
run_main "5 >= 4"
|
||||
assert_equal Parfait::TrueClass , get_return.class
|
||||
end
|
||||
def test_larger_or_false
|
||||
run_input "5 >= 6"
|
||||
run_main "5 >= 6"
|
||||
assert_equal Parfait::FalseClass , get_return.class
|
||||
end
|
||||
def test_larger_or_same
|
||||
run_input "5 >= 5"
|
||||
run_main "5 >= 5"
|
||||
assert_equal Parfait::TrueClass , get_return.class
|
||||
end
|
||||
end
|
||||
|
@ -5,36 +5,36 @@ module Risc
|
||||
class IntMath < BuiltinTest
|
||||
|
||||
def test_add
|
||||
run_input "5 + 5"
|
||||
run_main "5 + 5"
|
||||
assert_equal Parfait::Integer , get_return.class
|
||||
assert_equal 10 , get_return.value
|
||||
end
|
||||
def test_minus
|
||||
run_input "5 - 5"
|
||||
run_main "5 - 5"
|
||||
assert_equal 0 , get_return.value
|
||||
end
|
||||
def test_minus_neg
|
||||
run_input "5 - 15"
|
||||
run_main "5 - 15"
|
||||
assert_equal -10 , get_return.value
|
||||
end
|
||||
def test_rshift
|
||||
run_input "#{2**8} >> 3"
|
||||
run_main "#{2**8} >> 3"
|
||||
assert_equal 2**5 , get_return.value
|
||||
end
|
||||
def test_lshift
|
||||
run_input "#{2**8} << 3"
|
||||
run_main "#{2**8} << 3"
|
||||
assert_equal 2**11 , get_return.value
|
||||
end
|
||||
def test_div10
|
||||
run_input "45.div10"
|
||||
run_main "45.div10"
|
||||
assert_equal 4 , get_return.value
|
||||
end
|
||||
def test_div4
|
||||
run_input "45.div4"
|
||||
run_main "45.div4"
|
||||
assert_equal 11 , get_return.value
|
||||
end
|
||||
def test_mult
|
||||
run_input "4 * 4"
|
||||
run_main "4 * 4"
|
||||
assert_equal 16 , get_return.value
|
||||
end
|
||||
end
|
||||
|
5
test/risc/interpreter/README.md
Normal file
5
test/risc/interpreter/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# Small Tests using Interpreter
|
||||
|
||||
Mini fragments that test the output of single statements.
|
||||
|
||||
Using the Interpreter.
|
5
test/risc/mains/README.md
Normal file
5
test/risc/mains/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# Method testing
|
||||
|
||||
Test Whole methods by their output. Using the main method (implicitly)
|
||||
|
||||
Through Interpreter
|
@ -1,12 +1,12 @@
|
||||
require_relative '../helper'
|
||||
|
||||
module Mains
|
||||
class TestLargerWhile < MiniTest::Test
|
||||
class TestAdds < MiniTest::Test
|
||||
include Risc::Ticker
|
||||
def setup;end
|
||||
|
||||
def test_ruby_adds
|
||||
run_input <<HERE
|
||||
run_main <<HERE
|
||||
a = 0
|
||||
b = 20
|
||||
while( a < b )
|
||||
@ -19,7 +19,7 @@ HERE
|
||||
assert_equal 10 , get_return.value
|
||||
end
|
||||
def test_ruby_subs
|
||||
run_input <<HERE
|
||||
run_main <<HERE
|
||||
b = 10
|
||||
while( b >= 1 )
|
||||
b = b - 1
|
||||
@ -30,7 +30,7 @@ HERE
|
||||
assert_equal 0 , get_return.value
|
||||
end
|
||||
def test_ruby_adds_fibo
|
||||
run_input <<HERE
|
||||
run_main <<HERE
|
||||
n = 6
|
||||
a = 0
|
||||
b = 1
|
||||
|
16
test/risc/mains/test_puts.rb
Normal file
16
test/risc/mains/test_puts.rb
Normal file
@ -0,0 +1,16 @@
|
||||
require_relative '../helper'
|
||||
|
||||
module Mains
|
||||
class TestPuts < MiniTest::Test
|
||||
include Risc::Ticker
|
||||
def setup;end
|
||||
|
||||
def test_say_hi
|
||||
hi = "Hello there"
|
||||
run_main "'#{hi}'.putstring"
|
||||
assert_equal Parfait::Integer , get_return.class
|
||||
assert_equal hi.length , get_return.value
|
||||
assert_equal hi , @interpreter.stdout
|
||||
end
|
||||
end
|
||||
end
|
5
test/risc/methods/README.md
Normal file
5
test/risc/methods/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# Method Testing
|
||||
|
||||
Test the calling of several methods (including Builtin)
|
||||
|
||||
All in one class though. Using the Interpreter.
|
@ -80,7 +80,7 @@ module Risc
|
||||
end
|
||||
|
||||
# do the setup, compile and run the input to the end
|
||||
def run_input(input)
|
||||
def run_main(input)
|
||||
@string_input = as_main(input)
|
||||
do_setup
|
||||
run_all
|
||||
|
Reference in New Issue
Block a user