Sha256: e5dbbd7fb652ad7bf7d68d1e37bc5a63d6cc496cb605d3843c3d59b9effa2d03

Contents?: true

Size: 880 Bytes

Versions: 1

Compression:

Stored size: 880 Bytes

Contents

require 'spec_helper'

module Rubocop
  module Cop
    describe Grammar do
      EXAMPLE = '3.times { |i| x = i }'
      let (:grammar) { Grammar.new(Ripper.lex(EXAMPLE)) }

      it "correlates token indices to grammar paths" do
        method_block = [:program, :method_add_block]
        grammar.correlate(Ripper.sexp(EXAMPLE)).should == {
          0  => method_block + [:call, :@int],
          2  => method_block + [:call, :@ident],
          6  => method_block + [:brace_block, :block_var],
          7  => method_block + [:brace_block, :block_var, :params, :@ident],
          8  => method_block + [:brace_block, :block_var],
          10 => method_block + [:brace_block, :assign, :var_field, :@ident],
          12 => method_block + [:brace_block, :assign],
          14 => method_block + [:brace_block, :assign, :var_ref, :@ident],
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-0.1.0 spec/rubocop/cops/grammar_spec.rb