Sha256: 16537016f9b548e9a64565299872ecc6fe7538123950777b1991d35645359e43

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require File.expand_path("../test_helper.rb", File.dirname(__FILE__))
require "ruby_parser"

describe "Using RipperRubyParser and RubyParser" do
  let :newparser do
    RipperRubyParser::Parser.new
  end

  let :oldparser do
    RubyParser.for_current_ruby
  end

  describe "for a program with quite some comments" do
    let :program do
      <<-RUBY
      # Foo
      class Foo
        # The foo
        # method
        def foo
          bar # bar
          # internal comment
        end

        def bar
          baz
        end
      end
      # Quux
      module Qux
        class Quux
          def bar
          end
          def baz
          end
        end
      end
      RUBY
    end

    let :original do
      oldparser.parse program
    end

    let :imitation do
      newparser.parse program
    end

    it "gives the same result" do
      _(imitation).must_equal original
    end

    it "gives the same result with comments" do
      _(to_comments(imitation)).must_equal to_comments(original)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ripper_ruby_parser-1.7.2 test/end_to_end/comments_test.rb
ripper_ruby_parser-1.7.1 test/end_to_end/comments_test.rb
ripper_ruby_parser-1.7.0 test/end_to_end/comments_test.rb