-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Coverage + fixes for empty arcs transforms
- Loading branch information
Vitaly Puzrin
committed
Apr 16, 2015
1 parent
c5f3eb4
commit aed6826
Showing
6 changed files
with
133 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
globals: | ||
describe: false | ||
it: false | ||
before: false | ||
beforeEach: false | ||
after: false | ||
afterEach: false |
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,67 @@ | ||
'use strict'; | ||
|
||
|
||
var assert = require('assert'); | ||
var matrix = require('../lib/matrix'); | ||
|
||
var m; | ||
|
||
describe('Matrix', function () { | ||
|
||
it('ignore empty actions', function () { | ||
m = matrix(); | ||
|
||
m.matrix([ 1, 0, 0, 1, 0, 0 ]); | ||
assert.equal(m.queue.length, 0); | ||
|
||
m.translate(0, 0); | ||
assert.equal(m.queue.length, 0); | ||
|
||
m.scale(1, 1); | ||
assert.equal(m.queue.length, 0); | ||
|
||
m.rotate(0); | ||
assert.equal(m.queue.length, 0); | ||
|
||
m.skewX(0); | ||
assert.equal(m.queue.length, 0); | ||
|
||
m.skewY(0); | ||
assert.equal(m.queue.length, 0); | ||
}); | ||
|
||
it('do nothing on empty queue', function () { | ||
assert.deepEqual(matrix().calc(10, 11, false), [ 10, 11 ]); | ||
assert.deepEqual(matrix().toArray(), [ 1, 0, 0, 1, 0, 0 ]); | ||
}); | ||
|
||
it('compose', function () { | ||
m = matrix() | ||
.translate(10, 10) | ||
.translate(-10, -10) | ||
.rotate(180, 10, 10) | ||
.rotate(180, 10, 10) | ||
.toArray(); | ||
|
||
// Need to round errors prior to compare | ||
assert.equal(+m[0].toFixed(2), 1); | ||
assert.equal(+m[1].toFixed(2), 0); | ||
assert.equal(+m[2].toFixed(2), 0); | ||
assert.equal(+m[3].toFixed(2), 1); | ||
assert.equal(+m[4].toFixed(2), 0); | ||
assert.equal(+m[5].toFixed(2), 0); | ||
}); | ||
|
||
it('cache', function () { | ||
m = matrix() | ||
.translate(10, 20) | ||
.scale(2, 3); | ||
|
||
assert.strictEqual(m.cache, null); | ||
assert.deepEqual(m.toArray(), [ 2, 0, 0, 3, 10, 20 ]); | ||
assert.deepEqual(m.cache, [ 2, 0, 0, 3, 10, 20 ]); | ||
m.cache = [ 1, 2, 3, 4, 5, 6 ]; | ||
assert.deepEqual(m.toArray(), [ 1, 2, 3, 4, 5, 6 ]); | ||
}); | ||
|
||
}); |
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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
/*global describe, it*/ | ||
|
||
'use strict'; | ||
|
||
|
||
|
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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
/*global describe, it*/ | ||
|
||
'use strict'; | ||
|
||
|
||
|