Sha256: c69345d65b49f8c47d7f78684c651ad926d7a549ef9735d68dbdd0345b873066

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

require 'helper'
describe Pry do

  [
    ["p = '", "'"],
    ["def", "a", "(); end"],
    ["p = <<FOO", "lots", "and", "lots of", "foo", "FOO"],
    ["[", ":lets,", "'list',", "[/nested/", "], things ]"],
    ["abc =~ /hello", "/"],
    ["issue = %W/", "343/"],
    ["pouts(<<HI, 'foo", "bar", "HI", "baz')"],
  ].each do |foo|
    it "should not raise an error on broken lines: #{foo.join("\\n")}" do
      output = StringIO.new
      redirect_pry_io(InputTester.new(*foo), output) do
        Pry.start
      end

      output.string.should.not =~ /SyntaxError/
    end
  end

  [
    ["end"],
    ["puts )("],
    ["1 1"],
    ["puts :"],
    # in this case the syntax error is "expecting ')'".
    (Pry::Helpers::BaseHelpers.rbx? ? nil : ["def", "method(1"])
  ].compact.each do |foo|
    it "should raise an error on invalid syntax like #{foo.inspect}" do
      output = StringIO.new
      redirect_pry_io(InputTester.new(*foo), output) do
        Pry.start
      end
      output.string.should =~ /SyntaxError/
    end
  end

  it "should not intefere with syntax errors explicitly raised" do
    output = StringIO.new
    redirect_pry_io(InputTester.new(%q{raise SyntaxError, "unexpected $end"}), output) do
      Pry.start
    end
    output.string.should =~ /SyntaxError/
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pry-0.9.8pre3 test/test_syntax_checking.rb
pry-0.9.8pre3-i386-mswin32 test/test_syntax_checking.rb
pry-0.9.8pre3-i386-mingw32 test/test_syntax_checking.rb
pry-0.9.8pre3-java test/test_syntax_checking.rb