Project

General

Profile

Bug #11485 ยป ripper-ignored-nl-nil.patch

jeremyevans0 (Jeremy Evans), 07/03/2019 08:31 PM

View differences:

parse.y
8671 8671
	      case '|':
8672 8672
	      case '&':
8673 8673
	      case '.': {
8674
#ifndef RIPPER
8674 8675
		dispatch_delayed_token(p, tIGNORED_NL);
8676
#else
8677
                if (p->delayed != Qnil) {
8678
		    dispatch_delayed_token(p, tIGNORED_NL);
8679
                }
8680
#endif
8675 8681
		if (c == '|' ? peek(p, '>') : (peek(p, '.') == (c == '&'))) {
8676 8682
		    pushback(p, c);
8677 8683
		    dispatch_scan_event(p, tSP);
test/ripper/test_parser_events.rb
751 751
    assert_equal true, thru_ifop
752 752
  end
753 753

  
754
  def test_ignored_nl
755
    ignored_nl = []
756
    parse("foo # comment\n...\n", :on_ignored_nl) {|_, a| ignored_nl << a}
757
    assert_equal ["\n"], ignored_nl
758
  end
759

  
754 760
  def test_lambda
755 761
    thru_lambda = false
756 762
    parse('->{}', :on_lambda) {thru_lambda = true}