2017-09-14 10:08:33 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
require 'mm2ep_depend'
|
|
|
|
|
|
|
|
describe Mm2ep::Depend::Parser do
|
2017-09-20 10:08:32 +00:00
|
|
|
let(:parser) do
|
|
|
|
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
|
2017-09-20 10:08:32 +00:00
|
|
|
line = File
|
|
|
|
.read(testfile('success_priority_not_or.txt')).delete("\n")
|
2017-09-14 10:08:33 +00:00
|
|
|
token = parser.parse(line.chomp)
|
2017-09-20 13:44:55 +00:00
|
|
|
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
|
2017-09-20 10:08:32 +00:00
|
|
|
line = File
|
|
|
|
.read(testfile('success_priority_not_and.txt')).delete("\n")
|
2017-09-14 10:08:33 +00:00
|
|
|
token = parser.parse(line.chomp)
|
2017-09-20 13:44:55 +00:00
|
|
|
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
|
2017-09-20 10:08:32 +00:00
|
|
|
line = File
|
|
|
|
.read(testfile('success_priority_or_and.txt')).delete("\n")
|
2017-09-14 10:08:33 +00:00
|
|
|
token = parser.parse(line.chomp)
|
2017-09-20 13:44:55 +00:00
|
|
|
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
|
2017-09-20 10:08:32 +00:00
|
|
|
line = File
|
|
|
|
.read(testfile('success_priority_or_and_or.txt')).delete("\n")
|
2017-09-14 10:08:33 +00:00
|
|
|
token = parser.parse(line.chomp)
|
2017-09-20 13:44:55 +00:00
|
|
|
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
|