Loading lib/jsduck/type_parser.rb +3 −3 Original line number Diff line number Diff line Loading @@ -158,7 +158,7 @@ module JsDuck return false unless function_type elsif @input.check(/['"]/) return false unless string_literal elsif @input.check(/\d/) elsif @input.check(/[\d-]/) return false unless number_literal else return false unless type_name Loading Loading @@ -305,10 +305,10 @@ module JsDuck end # # <number-literal> ::= <digit>+ [ "." <digit>+ ] # <number-literal> ::= [ "-" ] <digit>+ [ "." <digit>+ ] # def number_literal @out << @input.scan(/\d+(\.\d+)?/) @out << @input.scan(/-?\d+(\.\d+)?/) true end Loading spec/type_parser_spec.rb +4 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,10 @@ describe JsDuck::TypeParser do parse('42').should == true end it "matches negative number literal" do parse('-6').should == true end it "matches float number literal" do parse('3.14').should == true end Loading Loading
lib/jsduck/type_parser.rb +3 −3 Original line number Diff line number Diff line Loading @@ -158,7 +158,7 @@ module JsDuck return false unless function_type elsif @input.check(/['"]/) return false unless string_literal elsif @input.check(/\d/) elsif @input.check(/[\d-]/) return false unless number_literal else return false unless type_name Loading Loading @@ -305,10 +305,10 @@ module JsDuck end # # <number-literal> ::= <digit>+ [ "." <digit>+ ] # <number-literal> ::= [ "-" ] <digit>+ [ "." <digit>+ ] # def number_literal @out << @input.scan(/\d+(\.\d+)?/) @out << @input.scan(/-?\d+(\.\d+)?/) true end Loading
spec/type_parser_spec.rb +4 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,10 @@ describe JsDuck::TypeParser do parse('42').should == true end it "matches negative number literal" do parse('-6').should == true end it "matches float number literal" do parse('3.14').should == true end Loading