Skip to content

Commit

Permalink
Add a few more tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
BonsaiDen committed Feb 28, 2011
1 parent 252bb56 commit 20a33fd
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion test/test.js
Expand Up @@ -127,22 +127,40 @@ exports.testArrayIndex = function(test) {
};

exports.testArrayLikes = function(test) {
test.expect(3);
test.expect(4);

// Arguments should be supported
function foo() {
test.equals(format('Good {-2} Sir {1}.', arguments),
'Good evening Sir Lancelot.');
}
foo('evening', 'Lancelot');

// Support array like object
var arrayThing = {0: 'evening', 1: 'Lancelot', length: 2};
test.equals(format('Good {-2} Sir {1}.', arrayThing),
'Good evening Sir Lancelot.');

// only have numeric lengths work
arrayThing.length = '4';
test.notEqual(format('Good {-2} Sir {1}.', arrayThing),
'Good evening Sir Lancelot.');

// make sure to now fall for prototype stuff
function Foo() {
this[0] = 'evening';
this[1] = 'Lancelot';
}
Foo.prototype.length = 4;

// make sure it's bulletproof
Foo.prototype.hasOwnProperty = function() {
return false;
};

test.notEqual(format('Good {-2} Sir {1}.', new Foo()),
'Good evening Sir Lancelot.');

test.done();
};

Expand Down

0 comments on commit 20a33fd

Please sign in to comment.