Browse files

+ real rules in specs

  • Loading branch information...
1 parent f638a1a commit 3c007bd9521cad470932614fa69619689e4a7551 @kschiess kschiess committed Dec 29, 2011
Showing with 8 additions and 3 deletions.
  1. +8 −3 spec/acceptance/vm_spec.rb
View
11 spec/acceptance/vm_spec.rb
@@ -4,6 +4,11 @@
extend Parslet
include Parslet
+ def self.rule(name, &block)
+ let(name) { example = self; Parslet::Atoms::Entity.new(name) {
+ example.instance_eval(&block) } }
+ end
+
# Compiles the parser and runs it through the VM with the given input.
#
def vm_parse(parser, input)
@@ -176,9 +181,9 @@ def vm_fails(parser, input)
end
end
describe 'alternatives' do
- let(:radix) { digit >> str('r') >> digit }
- let(:digit) { match['\d'].repeat(1) }
- let(:atom) { radix | digit }
+ rule(:radix) { digit >> str('r') >> digit }
+ rule(:digit) { match['\d'].repeat(1) }
+ rule(:atom) { radix | digit }
it "should correctly reset source pos" do
vm_parses atom, '5'
end

0 comments on commit 3c007bd

Please sign in to comment.