Sha256: ab862f49419172b6b5b8046e9c280c037c2df98ff68329f07a6a4ef1e790f4f7

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

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.new
  end

  describe "for a simple well known program" do
    let :program do
      "puts 'Hello World'"
    end

    it "gives the same result" do
      original = oldparser.parse program
      imitation = newparser.parse program

      imitation.must_equal original
    end
  end

  describe "for a more complex program" do
    let :program do
      <<-END
      module Quux
        class Foo
          def bar
            baz = 3
            qux baz
          end
          def qux it
            if it == 3
              [1,2,3].map {|i| 2*i}
            end
          end
        end
      end

      Quux::Foo.new.bar
      END
    end

    it "gives the same result" do
      original = oldparser.parse program
      imitation = newparser.parse program

      imitation.must_equal original
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ripper_ruby_parser-0.0.1 test/end_to_end/comparison_test.rb