Permalink
Browse files

take24 test, might suffice

  • Loading branch information...
1 parent 5a0f907 commit 39f2a1027e0af1a39bcae239de58b63e6d03ffbc @substack committed Jul 10, 2011
Showing with 26 additions and 1 deletion.
  1. +26 −1 test/take.js
View
@@ -1,10 +1,35 @@
var assert = require('assert');
var mr = require('../');
-exports.take = function () {
+exports.take6 = function () {
var xs = mr.take(6);
assert.equal(xs.length, 6);
for (var i = 0; i < xs.length - 1; i++) {
assert.equal(xs[i+1].hsl()[0] - xs[i].hsl()[0], 60);
}
};
+
+exports.take24 = function () {
+ var xs = mr.take(24);
+ assert.equal(xs.length, 24);
+ for (var i = 0; i < 5; i++) {
+ assert.equal(xs[i+1].hsl()[0] - xs[i].hsl()[0], 60);
+ }
+
+ for (var i = 6; i < 11; i++) {
+ var dx = Math.abs(xs[i+1].hsl()[0] - xs[i].hsl()[0]);
+ assert.ok(dx >= 15);
+ }
+
+ for (var i = 12; i < 17; i++) {
+ var dx = xs[i+1].hsl()[0] - xs[i].hsl()[0];
+ if (dx < 0) dx = 360 - dx;
+ assert.ok(dx >= 15);
+ }
+
+ for (var i = 18; i < 23; i++) {
+ var dx = xs[i+1].hsl()[0] - xs[i].hsl()[0];
+ if (dx < 0) dx = 360 - dx;
+ assert.ok(dx >= 7);
+ }
+};

0 comments on commit 39f2a10

Please sign in to comment.