Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

failing test for function path element

  • Loading branch information...
commit 8e79aebaf0130971f6d4edbd5c64c062b1915e3a 1 parent 5f072de
@substack authored
Showing with 23 additions and 0 deletions.
  1. +23 −0 test/fn.js
View
23 test/fn.js
@@ -0,0 +1,23 @@
+var pathway = require('../');
+var test = require('tap').test;
+
+test('use a function to determine keys', function (t) {
+ var xs = [
+ [ 'a', 1, 'b' ],
+ [ 'c', 2 ],
+ [ 'd', 3, 'e', 4, 'f' ],
+ [],
+ [ 'g', 5, 'h' ],
+ ];
+ function True () { return true }
+ function even (n) { return n % 2 === 0 }
+ function odd (n) { return n % 2 === 1 }
+
+ var odds = pathway(xs, [ True, odd ]);
+ t.same(odds, [ 1, 2, 3, 4, 5 ]);
+
+ var evens = pathway(xs, [ True, even ]);
+ t.same(evens, [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' ]);
+
+ t.end();
+});
Please sign in to comment.
Something went wrong with that request. Please try again.