Commit 6ebb294a authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Fix crash when documenting anonymous function.

Let the parsed function literal name default to empty string, not nil.
parent 99263102
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ module JsDuck
      match("function")
      return {
        :type => :function,
        :name => look(:ident) ? match(:ident)[:value] : nil,
        :name => look(:ident) ? match(:ident)[:value] : "",
        :params => function_parameters,
        :body => function_body,
      }
+14 −0
Original line number Diff line number Diff line
@@ -137,6 +137,20 @@ describe JsDuck::Aggregator do
    it_should_behave_like "method documentation"
  end

  describe "anonymous function" do
    before do
      @doc = parse("/** Some function */ function() {}")[0]
    end

    it "detects method" do
      @doc[:tagname].should == :method
    end

    it "detects empty method name" do
      @doc[:name].should == ""
    end
  end

  describe "explicit @method without @param-s" do
    before do
      @doc = parse(<<-EOS)[0]