Permalink
Browse files

publish tests for browsers with lowkick

  • Loading branch information...
1 parent ae75f6a commit 8217e025ea688cf0d33a1f9d8248d0168d6ca769 @azer committed Jun 9, 2012
Showing with 188 additions and 86 deletions.
  1. +3 −8 Makefile
  2. +71 −49 README.md
  3. +36 −0 test/browser.js
  4. +27 −0 test/config.json
  5. +16 −0 test/ext/es5-shim.min.js
  6. +17 −29 test/main.js
  7. +18 −0 test/results.json
View
@@ -1,11 +1,6 @@
-install:
- cp -rf ../functools ~/.node_modules/foo
+do=publish
-docs:
- cd man; \
- ronn functools.1.ron -r -5 --markdown
+test:
+ ./node_modules/lowkick/bin/lowkick $(do) test/config.json
.PHONY: test
-test:
- cd test; \
- node node.js
View
120 README.md
@@ -57,7 +57,7 @@ pickEvens([1,5,9,2,6,5]) // returns [2,6]
$ npm install functools
```
-or
+or
```bash
$ wget https://raw.github.com/azer/functools/master/lib/functools.js
@@ -135,56 +135,15 @@ args: 3,14,1,5,9
Call *function* once for element in *iterable*.
```javascript
-each(function(el,ind,list){ console.assert( el == list[ind] ); }, [3,1,4]);
-```
-
-## map(*function*,*iterable*)
-
-Invoke *function* once for each element of *iterable*. Creates a new iterable
-containing the values returned by the function.
-
-```javascript
-
-function square(n){
- return n*n;
-}
-
-map(square,[3,1,4,1,5,9]); // returns [9,1,16,1,25,81]
-```
-
-Objects can be passed as well;
-
-```javascript
-var dict = { 'en':'hello', 'tr': 'merhaba', 'fr':'bonjour' };
-
-function capitalize(){
- return string.charAt(0).toUpperCase() + string.slice(1);
-}
-
-map(capitalize, dict); // returns { 'en':'Hello', 'tr':'Merhaba', 'fr':'Bonjour' }
-```
-
-## map.async(*function*,*iterable*, *callback*)
-
-Apply async *function* to every item of *iterable*, receiving a callback
-function which takes error (if there is) and replacement parameters.
-
-```javascript
-function readFile(id, callback){ ... callback(undefined, data); }
-
-map.async(readFile, ['./foo/bar', './foo/qux', './corge'], function(error, files){
- if(error) throw error;
-
- console.log(files[0]); // will put the content of ./foo/bar
-});
+each([3,1,4], function(el,ind,list){ console.assert( el == list[ind] ); });
```
## filter(*function*,*iterable*)
Construct a new array from those elements of *iterable* for which *function* returns true.
```javascript
-filter(function(el,ind,list){ return el%2==0 },[3,1,4]); // returns [4]
+filter([3,1,4], function(el,ind,list){ return el%2==0 }); // returns [4]
```
## filter.async(*function*,*iterable*, *callback*)
@@ -199,14 +158,12 @@ var users = [ 3, 5, 8, 13, 21 ]; // only user#3 and user#8 have permission in th
function hasPermission(userId, callback){ ... callback(/* true or false */); }
-filter.async(hasPermission, users, function(permittedUsers){
+filter.async(users, hasPermission, function(permittedUsers){
assert.equal(permittedUsers.length, 4);
});
```
-
-
## juxt(*functions ...*)
Take a set of functions, return a function that is the juxtaposition of those
@@ -237,13 +194,54 @@ juxt.async(turkish, french, polish)("hello", function(error, results){
});
```
+## map(*function*,*iterable*)
+
+Invoke *function* once for each element of *iterable*. Creates a new iterable
+containing the values returned by the function.
+
+```javascript
+
+function square(n){
+ return n*n;
+}
+
+map([3,1,4,1,5,9], square); // returns [9,1,16,1,25,81]
+```
+
+Objects can be passed as well;
+
+```javascript
+var dict = { 'en':'hello', 'tr': 'merhaba', 'fr':'bonjour' };
+
+function capitalize(){
+ return string.charAt(0).toUpperCase() + string.slice(1);
+}
+
+map(dict, capitalize); // returns { 'en':'Hello', 'tr':'Merhaba', 'fr':'Bonjour' }
+```
+
+## map.async(*function*,*iterable*, *callback*)
+
+Apply async *function* to every item of *iterable*, receiving a callback
+function which takes error (if there is) and replacement parameters.
+
+```javascript
+function readFile(id, callback){ ... callback(undefined, data); }
+
+map.async(['./foo/bar', './foo/qux', './corge'], readFile, function(error, files){
+ if(error) throw error;
+
+ console.log(files[0]); // will put the content of ./foo/bar
+});
+```
+
## reduce(*function*,*iterable*)
Apply *function* cumulatively to the items of *iterable*, as to reduce the
*iterable* to a single value
```javascript
-reduce(function(x,y){ return x*y }, [3,1,4]); // returns 12
+reduce([3,1,4], function(x,y){ return x*y }); // returns 12
```
## reduce.async(*function*,*iterable*, *callback*)
@@ -256,13 +254,37 @@ var users = [2, 3, 5, 8, 13];
function usernames(accum, userId){ ... callback(undefined, accum + ', ' + username); }
-reduce.async(usernames, users, function(error, result){
+reduce.async(users, usernames, function(error, result){
if(error) throw error;
console.log(result); // foo, bar, qux ...
});
```
+# Testing
+
+## On NodeJS:
+
+```
+$ npm test
+```
+
+## On Browsers
+
+Run `make test` command to publish the tests on `localhost:1314`. Visit the URL using the browser on which you want to run the tests. Stop the server (Ctrl+C) when you're done with testing.
+
+To see the summary of results;
+
+```
+$ make test do=verify
+Not Tested: firefox, ie8, ie7
+Passed: ie6, webkit
+
+Revision: 1.3.0
+Results Source: test/results.json
+Config: test/config.json
+```
+
# SEE ALSO
- [Functional Programming - Eloquent JavaScript](http://eloquentjavascript.net/chapter6.html)
View
@@ -0,0 +1,36 @@
+var module = {},
+ assert = {
+ 'equal': function(a, b){
+ if( a !== b ){
+ throw new Error('Assertion Error: '+ a +' != ' + b);
+ }
+ },
+ 'ok': function(value){
+ assert.equal(value, true);
+ }
+ };
+
+function run(){
+ lowkick.signal('begin');
+
+ var tests = Object.keys(module.exports);
+
+ (function iter(i){
+
+ if(i >= tests.length){
+ lowkick.signal('end');
+ lowkick.ok();
+ return;
+ }
+
+ var name = tests[i];
+
+ lowkick.message('Running "'+name+'"');
+
+ module.exports[name](iter.bind(undefined, i+1));
+
+ }(0));
+
+}
+
+$(document).ready(run);
View
@@ -0,0 +1,27 @@
+{
+ "name": "functools test server",
+ "target": "results.json",
+ "logs": "logs",
+
+ "environ": [
+ "ie6",
+ "ie7",
+ "ie8",
+ "firefox",
+ "webkit"
+ ],
+
+ "server": {
+ "host": "localhost",
+ "port": "1314"
+ },
+
+ "scripts":[
+ "ext/es5-shim.min.js",
+ "../lib/functools.js",
+ "browser.js",
+ "main.js"
+ ]
+
+
+}
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 8217e02

Please sign in to comment.