Skip to content

Commit

Permalink
test for boolean coercion from auto-numeric patch
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Dec 21, 2010
1 parent 85f8007 commit 964baa7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/optimist.js
Expand Up @@ -44,6 +44,7 @@ function Argv (args, cwd) {

function set (key, val) {
var num = Number(val);
// var value = typeof val === 'string' && isNaN(num) ? val : num;
var value = isNaN(num) ? val : num;

if (key in self.argv) {
Expand Down
7 changes: 3 additions & 4 deletions test/parse.js
@@ -1,10 +1,9 @@
var optimist = require('optimist');

exports['short boolean'] = function (assert) {
assert.eql(
optimist.parse([ '-b' ]),
{ b : true, _ : [], $0 : 'expresso' }
);
var parse = optimist.parse([ '-b' ]);
assert.eql(parse, { b : true, _ : [], $0 : 'expresso' });
assert.eql(typeof parse.b, 'boolean');
};

exports['long boolean'] = function (assert) {
Expand Down

0 comments on commit 964baa7

Please sign in to comment.