Skip to content
Browse files

initial

  • Loading branch information...
0 parents commit c540c0d3da1fd72b829cdd60d141a4f3d656efec @dominictarr committed Aug 15, 2011
Showing with 131 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +32 −0 anon.expresso.js
  3. +85 −0 curry.expresso.js
  4. +11 −0 package.json
  5. 0 readme.markdown
3 .gitignore
@@ -0,0 +1,3 @@
+node_modules
+node_modules/*
+npm_debug.log
32 anon.expresso.js
@@ -0,0 +1,32 @@
+var assert = require('assert');
+var curry = require('curry');
+var spawn = require('child_process').spawn;
+
+exports.anon = function () {
+ assert.eql(
+ curry([3], function (x,y) { return x * 2 + y })(4),
+ 3 * 2 + 4
+ );
+};
+
+exports.repl = function () {
+ var node = spawn('node');
+ node.stdout.on('data', function (buf) {
+ node.stdin.write(
+ 'require("curry")([3], function (x,y) { return x * 2 + y })(4)\n'
+ );
+
+ node.stdout.removeListener('data',arguments.callee)
+
+ node.stdout.on('data', function (buf) {
+ node.stdin.end();
+
+ var s = buf.toString();
+ if (!s.match(/^10\s+/)) {
+ console.error(s);
+ assert.fail('Invalid response');
+ }
+ node.stdout.removeListener('data',arguments.callee)
+ })
+ });
+};
85 curry.expresso.js
@@ -0,0 +1,85 @@
+var assert = require('assert')
+ , curry = require('curry')
+
+ function x (a,b,c){
+ return [a,b,c]
+ }
+ function y (a,b,c){
+ return {self: this, args: [a,b,c]}
+ }
+
+
+function beF (x){
+ assert.equal(typeof x,'function')
+}
+exports ['can curry a function'] = function (){
+ var cx = curry([1],x)
+
+ beF(cx)
+
+ assert.deepEqual(cx(),[1,undefined,undefined])
+
+ var xc = curry(x,[1])
+
+ //if you don't pass in any args is does matter if it's left or right curried.
+ beF(xc)
+
+ assert.deepEqual(xc(),[1,undefined,undefined])
+
+}
+
+exports ['can curry a function, and args are in right place'] = function (){
+
+ var cx = curry([1],x)
+
+ beF(cx)
+
+ assert.deepEqual(cx('X'),[1,'X',undefined])
+
+ var xc = curry(x,[1])
+
+ //if you don't pass in any args is does matter if it's left or right curried.
+ beF(xc)
+
+ assert.deepEqual(xc('X'),['X',1,undefined])
+
+}
+
+
+exports ['can curry a function, this passed in'] = function (){
+ var s = {helo: 'asdfvnurowfn249r00jy4'}
+ var ys = curry(y,s)
+ var cys = curry([1],y,s)
+ var ycs = curry(y,[2],s)
+ var cycs = curry([1],y,[2],s)
+ beF(ys)
+
+ assert.deepEqual(ys('X'),{self: s, args: ['X',undefined,undefined]})
+
+
+ assert.deepEqual(cys('X'),{self: s, args: [1,'X',undefined]})
+
+ assert.deepEqual(ycs('X'),{self: s, args: ['X',2,undefined]})
+
+ assert.deepEqual(cycs('X'),{self: s, args: [1,'X',2]})
+
+/*
+ that was easy!
+*/
+
+}
+
+exports ['right curry'] = function (){
+
+ function callback() {
+// assert.finish()
+ }
+ var fn = curry(x,['callback:',callback])
+ , list = [1,2,3,4,5]
+ , r = fn(list)
+
+ assert.deepEqual(r,[list,'callback:',callback])
+ assert.deepEqual(r[2],callback)
+ r[2]()
+}
+
11 package.json
@@ -0,0 +1,11 @@
+{ "name": "curry_tests"
+, "version": "0.0.0"
+, "description": "tests for the curry module"
+, "homepage": "http://github.com/dominictarr/curry_tests"
+, "repository":
+ { "type": "git"
+ , "url": "https://github.com/dominictarr/curry_tests.git" }
+, "dependencies": {}
+, "devDependencies": {}
+, "author": "Dominic Tarr <dominic.tarr@gmail.com> (http://bit.ly/dominictarr)"
+, "scripts": { "test": "meta-test test/*.js" } }
0 readme.markdown
No changes.

0 comments on commit c540c0d

Please sign in to comment.
Something went wrong with that request. Please try again.