Add some spec for simple expr (var, bool expr ) and change priority check
This commit is contained in:
parent
b6f535abc0
commit
40be4077fe
6 changed files with 47 additions and 4 deletions
1
spec/files/success_simple_f_bool_expr.txt
Normal file
1
spec/files/success_simple_f_bool_expr.txt
Normal file
|
@ -0,0 +1 @@
|
|||
false
|
1
spec/files/success_simple_parenthesis_expr.txt
Normal file
1
spec/files/success_simple_parenthesis_expr.txt
Normal file
|
@ -0,0 +1 @@
|
|||
( true )
|
1
spec/files/success_simple_t_bool_expr.txt
Normal file
1
spec/files/success_simple_t_bool_expr.txt
Normal file
|
@ -0,0 +1 @@
|
|||
true
|
1
spec/files/success_simple_var_expr.txt
Normal file
1
spec/files/success_simple_var_expr.txt
Normal file
|
@ -0,0 +1 @@
|
|||
a_girl_has_no_name
|
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue