refactoring on tests

This commit is contained in:
Torsten Ruger
2015-05-15 21:03:11 +03:00
parent b5d44bf2f3
commit 217eda2436
4 changed files with 25 additions and 24 deletions

View File

@ -4,45 +4,45 @@ class BasicSof < MiniTest::Test
include Checker
def test_true
@out = Sof::Writer.write(true)
@out = true
check "true"
end
def test_string
@out = Sof::Writer.write("true")
@out = "true"
check "'true'"
end
def test_num
@out = Sof::Writer.write(124)
@out = 124
check "124"
end
def test_simple_array
@out = Sof::Writer.write([true, 1234])
@out = [true, 1234]
check "[true, 1234]"
end
def test_array_array
@out = Sof::Writer.write([true, 1 , [true , 12 ]])
@out = [true, 1 , [true , 12 ]]
check "-true\n-1\n-[true, 12]"
end
def test_array_array_reverse
@out = Sof::Writer.write([ [true , 12 ], true, 1])
@out = [ [true , 12 ], true, 1]
check "-[true, 12]\n-true\n-1"
end
def test_array_array_array
@out = Sof::Writer.write([true, 1 , [true , 12 , [true , 123 ]]])
@out = [true, 1 , [true , 12 , [true , 123 ]]]
check "-true\n-1\n--true\n -12\n -[true, 123]"
end
def test_simple_hash
@out = Sof::Writer.write({ one: 1 , tru: true })
@out = { one: 1 , tru: true }
check "{:one => 1, :tru => true}"
end
def test_array_hash
@out = Sof::Writer.write([true, 1 , { one: 1 , tru: true }])
@out = [true, 1 , { one: 1 , tru: true }]
check "-true\n-1\n-{:one => 1, :tru => true}"
end
def test_array_recursive
ar = [true, 1 ]
ar << ar
@out = Sof::Writer.write(ar)
@out = ar
check "&1 [true, 1, *1]"
end
end