namarara/spec/mm2ep_depend/priority_parser_spec.rb

43 lines
1 KiB
Ruby
Raw Normal View History

2017-09-14 10:08:33 +00:00
require 'spec_helper'
require 'mm2ep_depend'
describe Mm2ep::Depend::Parser do
let(:parser) do
2019-12-21 15:55:15 +00:00
Mm2ep::Depend::Parser.new(Mm2ep::Depend::Lexer.new)
end
2017-09-14 10:08:33 +00:00
it 'has to do not before or' do
2019-12-21 15:55:15 +00:00
line = 'NOT true OR NOT true'
token = parser.parse(line)
assert_equal('( NOT ( bool:true ) ) OR ( NOT ( bool:true ) )', token.to_s)
2017-09-14 10:08:33 +00:00
end
it 'has to do not before and' do
2019-12-21 15:55:15 +00:00
line = 'NOT false AND NOT false'
token = parser.parse(line)
assert_equal(
'( NOT ( bool:false ) ) AND ( NOT ( bool:false ) )',
token.to_s
)
2017-09-14 10:08:33 +00:00
end
it 'has to do and before or' do
2019-12-21 15:55:15 +00:00
line = 'false OR true AND false'
token = parser.parse(line)
assert_equal(
'( bool:false ) OR ( ( bool:true ) AND ( bool:false ) )',
token.to_s
)
2017-09-14 10:08:33 +00:00
end
it 'has to do and before or operators' do
2019-12-21 15:55:15 +00:00
line = 'false OR false AND true OR true'
token = parser.parse(line)
assert_equal(
'( ( bool:false ) OR ( ( bool:false ) '\
'AND ( bool:true ) ) ) OR ( bool:true )',
token.to_s
)
2017-09-14 10:08:33 +00:00
end
end