Commit a554b529 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Correct RegExp detection.

parent 9a176397
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -233,6 +233,8 @@ module JsDuck
          "Array"
        elsif v.is_a?(Hash)
          "Object"
        elsif v == nil && ast["type"] == "Literal" && ast["raw"] =~ /\A\//
          "RegExp"
        else
          nil
        end
+4 −0
Original line number Diff line number Diff line
@@ -72,6 +72,10 @@ describe "JsDuck::Ast detects property with" do
      detect("/** */ var foo = false;")[:type].should == "Boolean"
    end

    it "regex" do
      detect("/** */ var foo = /abc/g;")[:type].should == "RegExp"
    end

    it "array" do
      detect("/** */ var foo = [];")[:type].should == "Array"
    end