Skip to content
This repository has been archived by the owner on Nov 5, 2022. It is now read-only.

Commit

Permalink
Fix up tests in the face of native Path2d implementations.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcgregorio committed Apr 5, 2017
1 parent c71e9bd commit dce8fad
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
12 changes: 6 additions & 6 deletions canvas.js
Expand Up @@ -2161,12 +2161,12 @@ if (typeof Path2D !== 'function' ||
Path_.prototype['addPath'] = function(path, tr) {
var hasTx = false;
if (tr
&& tr.hasOwnProperty('a')
&& tr.hasOwnProperty('b')
&& tr.hasOwnProperty('c')
&& tr.hasOwnProperty('d')
&& tr.hasOwnProperty('e')
&& tr.hasOwnProperty('f')) {
&& tr.a != undefined
&& tr.b != undefined
&& tr.c != undefined
&& tr.d != undefined
&& tr.e != undefined
&& tr.f != undefined) {
hasTx = true;
this.ops_.push({type: 'save', args: []});
this.ops_.push({type: 'transform', args: [tr.a, tr.b, tr.c, tr.d, tr.e, tr.f]});
Expand Down
12 changes: 6 additions & 6 deletions canvasv5.js
Expand Up @@ -83,12 +83,12 @@ if (typeof Path2D !== 'function' ||
Path_.prototype['addPath'] = function(path, tr) {
var hasTx = false;
if (tr
&& tr.hasOwnProperty('a')
&& tr.hasOwnProperty('b')
&& tr.hasOwnProperty('c')
&& tr.hasOwnProperty('d')
&& tr.hasOwnProperty('e')
&& tr.hasOwnProperty('f')) {
&& tr.a != undefined
&& tr.b != undefined
&& tr.c != undefined
&& tr.d != undefined
&& tr.e != undefined
&& tr.f != undefined) {
hasTx = true;
this.ops_.push({type: 'save', args: []});
this.ops_.push({type: 'transform', args: [tr.a, tr.b, tr.c, tr.d, tr.e, tr.f]});
Expand Down
8 changes: 8 additions & 0 deletions test/addpath.js
Expand Up @@ -5,6 +5,10 @@ describe('AddPath Test Suite.',

it('should add paths w/o transform.', function() {
var path = new Path2D();
if (path.ops_ == undefined) {
// Don't bother testing a native Path2D impl.
return
}
var toadd = new Path2D();
toadd.rect(0, 0, 100, 100);

Expand All @@ -15,6 +19,10 @@ describe('AddPath Test Suite.',

it('should add paths with transform.', function() {
var path = new Path2D();
if (path.ops_ == undefined) {
// Don't bother testing a native Path2D impl.
return
}
var toadd = new Path2D();
toadd.rect(0, 0, 100, 100);

Expand Down
8 changes: 8 additions & 0 deletions test/path.js
Expand Up @@ -5,6 +5,10 @@ describe('Path constructors.',

it('Path copy constructor.', function() {
var path = new Path2D();
if (path.ops_ == undefined) {
// Don't bother testing a native Path2D impl.
return
}
path.rect(0, 0, 100, 100);
assert.equal(path.ops_[0].type, 'rect', 'Test the test.');

Expand All @@ -22,6 +26,10 @@ describe('Path simple methods.',

it('Simple methods.', function() {
var path = new Path2D();
if (path.ops_ == undefined) {
// Don't bother testing a native Path2D impl.
return
}
path.rect(0, 1, 2, 3);
assert.equal(path.ops_[0].type, 'rect');
assert.equal(path.ops_[0].args[0], 0);
Expand Down

0 comments on commit dce8fad

Please sign in to comment.