Sha256: ef98899b5d9556c7c1d8302956c1087f89f2c2d3d1b97248c840ae5b6824290e

Contents?: true

Size: 724 Bytes

Versions: 39

Compression:

Stored size: 724 Bytes

Contents

require 'opal/parser'

module ParserHelpers
  def parsed(source, file='(ParserHelpers:string)')
    Opal::Parser.new.parse(source, file)
  end

  def expect_parsed(source)
    expect(parsed(source))
  end

  def expect_parsed_string(source)
    expect(parsed(source)[1])
  end

  def expect_lines(source)
    expect(parsed_nodes(source).map { |sexp| sexp.line })
  end

  def expect_columns(source)
    expect(parsed_nodes(source).map { |sexp| sexp.column })
  end

  def parsed_nodes(source)
    parsed = Opal::Parser.new.parse(source)
    parsed.type == :block ? parsed.children : [parsed]
  end
end

if defined? RSpec
  RSpec.configure do |config|
    config.include ParserHelpers
  end
else
  include ParserHelpers
end

Version data entries

39 entries across 39 versions & 3 rubygems

Version Path
opal-0.10.6 spec/support/parser_helpers.rb
opal-0.10.6.beta spec/support/parser_helpers.rb
opal-0.10.5 spec/support/parser_helpers.rb
opal-0.10.4 spec/support/parser_helpers.rb
opal-0.10.3 spec/support/parser_helpers.rb
opal-0.10.2 spec/support/parser_helpers.rb
opal-0.10.1 spec/support/parser_helpers.rb
opal-0.10.0 spec/support/parser_helpers.rb
opal-0.10.0.rc2 spec/support/parser_helpers.rb
opal-0.9.4 spec/support/parser_helpers.rb
opal-0.9.3 spec/support/parser_helpers.rb
opal-0.10.0.rc1 spec/support/parser_helpers.rb
opal-0.10.0.beta5 spec/support/parser_helpers.rb
opal-0.10.0.beta4 spec/support/parser_helpers.rb
opal-0.10.0.beta3 spec/support/parser_helpers.rb
opal-0.10.0.beta2 spec/support/parser_helpers.rb
opal-0.10.0.beta1 spec/support/parser_helpers.rb
opal-0.9.2 spec/support/parser_helpers.rb
opal-0.9.0 spec/support/parser_helpers.rb
opal-0.9.0.rc1 spec/support/parser_helpers.rb