Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
34316572
...
343165726a87c656f188e3bb9f68341ae2f76e8c
authored
2011-12-25 16:50:06 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added type checks to cli test suite
1 parent
b1d4a2b0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletions
modules/cli.js
tests/suites/cli.js
modules/cli.js
View file @
3431657
...
...
@@ -70,6 +70,12 @@ exports.parse = function(phantomArgs) {
return
extract
;
};
/**
* Cast a string argument to its typed equivalent.
*
* @param String arg
* @return Mixed
*/
function
castArgument
(
arg
)
{
if
(
arg
.
match
(
/^-
?\d
+$/
))
{
return
parseInt
(
arg
,
10
);
...
...
tests/suites/cli.js
View file @
3431657
...
...
@@ -35,8 +35,10 @@
t
.
assertEquals
(
parsed
.
options
,
{
universe
:
42
,
lap
:
13.37
,
chucknorris
:
true
,
oops
:
false
},
'parse() returns expected options object'
);
t
.
assertEquals
(
parsed
.
get
(
'universe'
),
42
,
'parse() can cast a numeric option value'
);
t
.
assertEquals
(
parsed
.
get
(
'lap'
),
13.37
,
'parse() can cast a float option value'
);
t
.
assertType
(
parsed
.
get
(
'lap'
),
"number"
,
'parse() can cast a boolean value'
);
t
.
assert
(
parsed
.
get
(
'chucknorris'
),
'parse() can get a flag value by its option name'
);
t
.
assert
(
!
parsed
.
get
(
'oops'
),
'parse() can cast a boolean value'
);
t
.
assertType
(
parsed
.
get
(
'oops'
),
"boolean"
,
'parse() can cast a boolean value'
);
t
.
assertEquals
(
parsed
.
get
(
'oops'
),
false
,
'parse() can cast a boolean value'
);
})(
cli
.
parse
([
'foo & bar'
,
'baz & boz'
,
'--universe=42'
,
'--lap=13.37'
,
'--chucknorris'
,
'--oops=false'
]));
t
.
done
();
...
...
Please
register
or
sign in
to post a comment