Commit 83cc1b88 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Associate comment with code when no space in between.

An off-by-one bug which prevented one from placing a comment right
before some other code construct without leaving a space in between.
parent 53aa12cd
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -138,17 +138,17 @@ module JsDuck

    # True if range A is less than range B
    def less(a, b)
      return a[1] < b[0]
      return a[1] <= b[0]
    end

    # True if range A is greater than range B
    def greater(a, b)
      return a[0] > b[1]
      return a[0] >= b[1]
    end

    # True if range A is within range B
    def within(a, b)
      return b[0] < a[0] && a[1] < b[1]
      return b[0] <= a[0] && a[1] <= b[1]
    end


+13 −1
Original line number Diff line number Diff line
@@ -256,5 +256,17 @@ describe JsDuck::JsParser do
    end
  end

  describe "parsing comment immediately before object literal" do
    before do
      @docs = parse(<<-EOS)
          x = /* Blah */{};
      EOS
    end

    it "associates comment with the code" do
      @docs[0][:comment].should == " Blah "
      @docs[0][:code]["type"].should == "ObjectExpression"
    end
  end

end