forked from madrobby/zepto
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor new methods to use array awesomeness
- Loading branch information
Showing
8 changed files
with
75 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Zepto Compatibility unit tests</title> | ||
<script src="../src/polyfill.js"></script> | ||
<script src="../src/zepto.js"></script> | ||
<script src="../vendor/evidence.js"></script> | ||
</head> | ||
<body> | ||
<h1>Zepto Compatibility unit tests</h1> | ||
<p> | ||
See the browser console for results. | ||
</p> | ||
<script> | ||
Evidence.TestCase.extend('ZeptoTest', { | ||
|
||
// test to see if we augment String.prototype.trim if not supported natively | ||
testTrim: function(t){ | ||
t.assertEqual("blah", " blah ".trim()); | ||
}, | ||
|
||
// test to see if we augment Array.prototype.reduceif not supported natively | ||
testReduce: function(t){ | ||
t.assertEqual( | ||
10, | ||
[0,1,2,3,4].reduce(function(p,c){ return p+c }) | ||
); | ||
|
||
t.assertEqual( | ||
20, | ||
[0,1,2,3,4].reduce(function(p,c){ return p+c }, 10) | ||
); | ||
|
||
var flattened = [[0,1], [2,3], [4,5]].reduce(function(a,b){ | ||
return a.concat(b); | ||
}); | ||
|
||
t.assertEqual(6, flattened.length); | ||
|
||
for(var i=0;i<6;i++) t.assertEqual(i, flattened[i]); | ||
} | ||
|
||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters