Skip to content
Snippets Groups Projects
Commit 0f11fd21 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Allow negative numbers in type definitions.

parent 8a7b3721
Branches
Tags
No related merge requests found
......@@ -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
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment