Loading lib/jsduck/function_ast.rb +6 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,8 @@ module JsDuck "Boolean" elsif string?(ast) "String" elsif regexp?(ast) "RegExp" else :other end Loading Loading @@ -130,6 +132,10 @@ module JsDuck ast["type"] == "Literal" && ast["value"].is_a?(String) end def regexp?(ast) ast["type"] == "Literal" && ast["raw"] =~ /^\// end def control_flow?(ast) CONTROL_FLOW[ast["type"]] end Loading spec/function_ast_spec.rb +6 −0 Original line number Diff line number Diff line Loading @@ -307,4 +307,10 @@ describe "JsDuck::FunctionAst#return_types" do end end describe "returns ['RegExp'] when function body" do it "returns a regex literal" do returns("/** */ function foo() { return /.*/; }").should == ["RegExp"] end end end Loading
lib/jsduck/function_ast.rb +6 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,8 @@ module JsDuck "Boolean" elsif string?(ast) "String" elsif regexp?(ast) "RegExp" else :other end Loading Loading @@ -130,6 +132,10 @@ module JsDuck ast["type"] == "Literal" && ast["value"].is_a?(String) end def regexp?(ast) ast["type"] == "Literal" && ast["raw"] =~ /^\// end def control_flow?(ast) CONTROL_FLOW[ast["type"]] end Loading
spec/function_ast_spec.rb +6 −0 Original line number Diff line number Diff line Loading @@ -307,4 +307,10 @@ describe "JsDuck::FunctionAst#return_types" do end end describe "returns ['RegExp'] when function body" do it "returns a regex literal" do returns("/** */ function foo() { return /.*/; }").should == ["RegExp"] end end end