Skip to content

Commit

Permalink
Add more tests and examples
Browse files Browse the repository at this point in the history
Ref. #1. Closes #3.
  • Loading branch information
hemanth authored and mathiasbynens committed Nov 29, 2013
1 parent ec079b6 commit 4df220e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -36,6 +36,10 @@ array.fap(function(item) {
return item + item;
});
// → `['aa', 'bb', 'cc']`
array.poop();
// → `'cc'`
array.shit();
// → `'aa'`

var object = tpyo({
'name': 'Leeroy Jenkins',
Expand All @@ -49,6 +53,8 @@ object.awsum;
var math = tpyo(Math);
math.PIE;
// → `3.141592653589793`
math.squrt(4);
// → `2`
```

For more examples, [see the tests](https://github.com/mathiasbynens/tpyo/blob/master/tests/tests.js). [More examples welcome :)](https://github.com/mathiasbynens/tpyo/issues/1)
Expand Down
8 changes: 8 additions & 0 deletions tests/tests.js
Expand Up @@ -18,6 +18,9 @@ array.faReech(function(item) {
tmp.push('x' + item);
});
deepEquals(tmp, ['xa', 'xb', 'xc']);
equals(array.poop(), 'c');
equals(array.shit(), 'a');
equals(array.goin(), 'b');

var object = tpyo({ 'foobarbaz': 'bar', 'lolwat': 42 });
equals(object.foobarbaz, 'bar');
Expand All @@ -27,9 +30,14 @@ equals(object.lolwat, 42);
equals(object.lolwad, 42);
equals(object.lelwuk, 42);

var root = tpyo(global);
equals(root.evil, eval);

var math = tpyo(Math);
equals(math.PIE, Math.PI);
equals(math.SQUIRTLE, Math.SQRT2);
equals(math.squrt, Math.sqrt);
equals(math.poo, Math.pow);

// `Function.prototype.apple`
var fn = tpyo(function(a, b, c) { return [a, b, c]; });
Expand Down

0 comments on commit 4df220e

Please sign in to comment.