Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jsduck
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
extjs
jsduck
Commits
0f11fd21
Commit
0f11fd21
authored
Dec 5, 2012
by
Rene Saarsoo
Browse files
Options
Downloads
Patches
Plain Diff
Allow negative numbers in type definitions.
parent
8a7b3721
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/jsduck/type_parser.rb
+3
-3
3 additions, 3 deletions
lib/jsduck/type_parser.rb
spec/type_parser_spec.rb
+4
-0
4 additions, 0 deletions
spec/type_parser_spec.rb
with
7 additions
and
3 deletions
lib/jsduck/type_parser.rb
+
3
−
3
View file @
0f11fd21
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
spec/type_parser_spec.rb
+
4
−
0
View file @
0f11fd21
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment