mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
More work on test helpers.
This commit is contained in:
parent
0fdfd0033f
commit
c0ecc7f85c
1 changed files with 21 additions and 19 deletions
|
@ -215,17 +215,12 @@ function compareSegments(segment, segment2, checkIdentity) {
|
||||||
return segment !== segment2;
|
return segment !== segment2;
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
equals(function() {
|
||||||
|
return segment.selected == segment2.selected;
|
||||||
|
}, true);
|
||||||
for (var i = 0, l = keys.length; i < l; i++) {
|
for (var i = 0, l = keys.length; i < l; i++) {
|
||||||
var key = keys[i];
|
var key = keys[i];
|
||||||
if (checkIdentity) {
|
compareSegmentPoints(segment[key], segment2[key]);
|
||||||
equals(function() {
|
|
||||||
return segment[key] !== segment2[key];
|
|
||||||
}, true, 'Strict compare Segment#' + key);
|
|
||||||
}
|
|
||||||
equals(segment[key] && segment[key].toString(),
|
|
||||||
segment2[key] && segment2[key].toString(),
|
|
||||||
'Compare Segment#' + key);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +257,7 @@ function compareItems(item, item2, checkIdentity) {
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
var itemProperties = ['opacity', 'locked', 'visible', 'blendMode', 'name',
|
var itemProperties = ['opacity', 'locked', 'visible', 'blendMode', 'name',
|
||||||
'closed', 'selected'];
|
'selected', 'clipMask'];
|
||||||
Base.each(itemProperties, function(key) {
|
Base.each(itemProperties, function(key) {
|
||||||
equals(function() {
|
equals(function() {
|
||||||
return item[key] == item2[key];
|
return item[key] == item2[key];
|
||||||
|
@ -277,6 +272,15 @@ function compareItems(item, item2, checkIdentity) {
|
||||||
|
|
||||||
equals(item.bounds.toString(), item2.bounds.toString(),
|
equals(item.bounds.toString(), item2.bounds.toString(),
|
||||||
'Compare Item#bounds');
|
'Compare Item#bounds');
|
||||||
|
|
||||||
|
if (checkIdentity) {
|
||||||
|
equals(function() {
|
||||||
|
return item.position != item2.position;
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
equals(item.position.toString(), item2.position.toString(),
|
||||||
|
'Compare Item#position');
|
||||||
|
|
||||||
if (item.matrix) {
|
if (item.matrix) {
|
||||||
if (checkIdentity) {
|
if (checkIdentity) {
|
||||||
|
@ -288,17 +292,15 @@ function compareItems(item, item2, checkIdentity) {
|
||||||
'Compare Item#matrix');
|
'Compare Item#matrix');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// PathItem specific
|
|
||||||
if (item instanceof PathItem) {
|
|
||||||
equals(function() {
|
|
||||||
return item.clockwise == item2.clockwise;
|
|
||||||
}, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Path specific
|
// Path specific
|
||||||
if (item2 instanceof Path) {
|
if (item2 instanceof Path) {
|
||||||
|
var keys = ['closed', 'fullySelected', 'clockwise', 'length'];
|
||||||
|
for (var i = 0, l = keys.length; i < l; i++) {
|
||||||
|
var key = keys[i];
|
||||||
|
equals(function() {
|
||||||
|
return item[key] == item2[key];
|
||||||
|
}, true, 'Compare Path#' + key);
|
||||||
|
}
|
||||||
compareSegmentLists(item.segments, item2.segments, checkIdentity);
|
compareSegmentLists(item.segments, item2.segments, checkIdentity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue