Sha256: bc9f881ce9fc4baf81a704ef8ef2e1b446a32d5659577ed92d392871ede41ea7

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'

describe Melbourne::Parser do

  it 'should correctly parse "str.split(//i)"' do
    ruby = 'str.split(//i)'
    ast  = {:sendwitharguments=>
      {:@block=>nil,
       :@name=>:split,
       :@line=>1,
       :@privately=>false,
       :@receiver=>
        {:send=>
          {:@block=>nil,
           :@name=>:str,
           :@line=>1,
           :@privately=>true,
           :@receiver=>{:self=>{:@line=>1}},
           :@check_for_local=>false}},
       :@check_for_local=>false,
       :@arguments=>
        {:actualarguments=>
          {:@array=>
            [{:regexliteral=>{:@source=>:"<blank>", :@options=>1, :@line=>1}}],
           :@splat=>nil,
           :@line=>1}}}}

    ruby.should parse_as(ast)
  end

  it 'should correctly parse "/x/n"' do
    ruby = '/x/n'
    ast  = {:regexliteral=>{:@source=>:x, :@options=>16, :@line=>1}}

    ruby.should parse_as(ast)
  end

  it 'should correctly parse "/x/o"' do
    ruby = '/x/o'
    ast  = {:regexliteral=>{:@source=>:x, :@options=>0, :@line=>1}}

    ruby.should parse_as(ast)
  end

  it 'should correctly parse "/x/"' do
    ruby = '/x/'
    ast  = {:regexliteral=>{:@source=>:x, :@options=>0, :@line=>1}}

    ruby.should parse_as(ast)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
melbourne-1.0.1 spec/lib/parser/regex_spec.rb
melbourne-1.0.0 spec/lib/parser/regex_spec.rb