Add some spec for simple expr (var, bool expr ) and change priority check

This commit is contained in:
Brendon 2017-09-20 15:44:55 +02:00
parent b6f535abc0
commit 40be4077fe
6 changed files with 47 additions and 4 deletions

View file

@ -0,0 +1 @@
false

View file

@ -0,0 +1 @@
( true )

View file

@ -0,0 +1 @@
true

View file

@ -0,0 +1 @@
a_girl_has_no_name

View file

@ -12,27 +12,37 @@ describe Mm2ep::Depend::Parser do
line = File
.read(testfile('success_priority_not_or.txt')).delete("\n")
token = parser.parse(line.chomp)
assert_equal(false, token.compute)
assert_equal('( NOT ( bool:true ) ) OR ( NOT ( bool:true ) )', token.to_s)
end
it 'has to do not before and' do
line = File
.read(testfile('success_priority_not_and.txt')).delete("\n")
token = parser.parse(line.chomp)
assert_equal(true, token.compute)
assert_equal(
'( NOT ( bool:false ) ) AND ( NOT ( bool:false ) )',
token.to_s
)
end
it 'has to do and before or' do
line = File
.read(testfile('success_priority_or_and.txt')).delete("\n")
token = parser.parse(line.chomp)
assert_equal(false, token.compute)
assert_equal(
'( bool:false ) OR ( ( bool:true ) AND ( bool:false ) )',
token.to_s
)
end
it 'has to do and before or operators' do
line = File
.read(testfile('success_priority_or_and_or.txt')).delete("\n")
token = parser.parse(line.chomp)
assert_equal(true, token.compute)
assert_equal(
'( ( bool:false ) OR ( ( bool:false ) '\
'AND ( bool:true ) ) ) OR ( bool:true )',
token.to_s
)
end
end

View file

@ -8,6 +8,35 @@ describe Mm2ep::Depend::Parser do
)
end
it 'has to find var and compute it to expr' do
line = File
.read(testfile('success_simple_var_expr.txt')).delete("\n")
parser.names = { 'a_girl_has_no_name' => 'true' }
token = parser.parse(line.chomp)
assert_equal(true, token.compute)
end
it 'has to find true boolean and compute it to expr' do
line = File
.read(testfile('success_simple_t_bool_expr.txt')).delete("\n")
token = parser.parse(line.chomp)
assert_equal(true, token.compute)
end
it 'has to find false boolean and compute it to expr' do
line = File
.read(testfile('success_simple_f_bool_expr.txt')).delete("\n")
token = parser.parse(line.chomp)
assert_equal(false, token.compute)
end
it 'has to find parenthesis expr and compute it to expr' do
line = File
.read(testfile('success_simple_parenthesis_expr.txt')).delete("\n")
token = parser.parse(line.chomp)
assert_equal(true, token.compute)
end
it 'has to apply not on expr' do
line = File
.read(testfile('success_simple_not_expr.txt')).delete("\n")