Commit 1d2f096b authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Allow n-dimensional arrays in type definitions.

parent 16b541d9
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ module JsDuck

    # The basic type
    #
    #     <ident> [ "." <ident> ]* [ "[]" ] [ "..." ]
    #     <ident> [ "." <ident> ]* [ "[]" ]* [ "..." ]
    #
    # dot-separated identifiers followed by optional "[]"
    def base_type
@@ -72,7 +72,9 @@ module JsDuck
        return false
      end

      @out << "[]" if @input.scan(/\[\]/)
      while @input.scan(/\[\]/)
        @out << "[]"
      end

      @out << "..." if @input.scan(/\.\.\./)

+8 −0
Original line number Diff line number Diff line
@@ -30,6 +30,14 @@ describe JsDuck::TypeParser do
    parse("Ext.form.Panel[]").should == true
  end

  it "matches 2D array" do
    parse("String[][]").should == true
  end

  it "matches 3D array" do
    parse("String[][][]").should == true
  end

  describe "matches alteration of" do
    it "simple types" do
      parse("Number/String").should == true