1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
require 'spec_helper'
RSpec.describe('Expression::Base#to_h') do
include_examples 'parse', /abc/, [] => [Root, to_h: {
token: :root,
type: :expression,
text: 'abc',
starts_at: 0,
length: 3,
quantifier: nil,
options: {},
level: 0,
set_level: 0,
conditional_level: 0,
expressions: [
{
token: :literal,
type: :literal,
text: 'abc',
starts_at: 0,
length: 3,
quantifier: nil,
options: {},
level: 0,
set_level: 0,
conditional_level: 0
}
]
}]
include_examples 'parse', /a{2,4}/, [0, :q] => [Quantifier, to_h: {
max: 4,
min: 2,
mode: :greedy,
text: '{2,4}',
token: :interval,
}]
specify('Conditional#to_h') do
root = RP.parse('(?<A>a)(?(<A>)b|c)')
expect { root.to_h }.not_to(raise_error)
end
end
|