Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

71 lines (61 sloc) 2.032 kb
require 'spec_helper'
describe Parslet::Atoms do
include Parslet
let(:visitor) { flexmock(:visitor) }
describe Parslet::Atoms::Str do
let(:parslet) { str('foo') }
it "should call back visitor" do
visitor.should_receive(:visit_str).with('foo').once
parslet.accept(visitor)
end
end
describe Parslet::Atoms::Re do
let(:parslet) { match['abc'] }
it "should call back visitor" do
visitor.should_receive(:visit_re).with('[abc]').once
parslet.accept(visitor)
end
end
describe Parslet::Atoms::Sequence do
let(:parslet) { str('a') >> str('b') }
it "should call back visitor" do
visitor.should_receive(:visit_sequence).with(Array).once
parslet.accept(visitor)
end
end
describe Parslet::Atoms::Repetition do
let(:parslet) { str('a').repeat(1,2) }
it "should call back visitor" do
visitor.should_receive(:visit_repetition).with(1, 2, Parslet::Atoms::Base).once
parslet.accept(visitor)
end
end
describe Parslet::Atoms::Alternative do
let(:parslet) { str('a') | str('b') }
it "should call back visitor" do
visitor.should_receive(:visit_alternative).with(Array).once
parslet.accept(visitor)
end
end
describe Parslet::Atoms::Named do
let(:parslet) { str('a').as(:a) }
it "should call back visitor" do
visitor.should_receive(:visit_named).with(:a, Parslet::Atoms::Base).once
parslet.accept(visitor)
end
end
describe Parslet::Atoms::Entity do
let(:parslet) { Parslet::Atoms::Entity.new('foo', &lambda {}) }
it "should call back visitor" do
visitor.should_receive(:visit_entity).with('foo', Proc).once
parslet.accept(visitor)
end
end
describe Parslet::Atoms::Lookahead do
let(:parslet) { str('a').absent? }
it "should call back visitor" do
visitor.should_receive(:visit_lookahead).with(false, Parslet::Atoms::Base).once
parslet.accept(visitor)
end
end
end
Jump to Line
Something went wrong with that request. Please try again.