2011-02-07 13:28:09 -05:00
|
|
|
function compareSegmentLists(list1, list2) {
|
2011-02-13 09:35:48 -05:00
|
|
|
equals(list1.length, list2.length, 'segment count');
|
2011-02-13 11:26:24 -05:00
|
|
|
if (list1.length == list2.length) {
|
|
|
|
for (var i = 0, l = list1.length; i < l; i++) {
|
2011-02-07 13:28:09 -05:00
|
|
|
compareSegments(list1[i], list2[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function compareSegments(segment1, segment2) {
|
2011-02-13 10:09:24 -05:00
|
|
|
// Convert comparison value through Segment.read, to not have to provide
|
|
|
|
// all handles all the time.
|
|
|
|
segment2 = Segment.read([segment2]);
|
2011-02-07 13:28:09 -05:00
|
|
|
var points = ['point', 'handleIn', 'handleOut'];
|
2011-02-13 11:26:24 -05:00
|
|
|
for (var i = 0; i < 3; i++) {
|
2011-02-07 13:28:09 -05:00
|
|
|
equals(!!segment1[points[i]], !!segment2[points[i]], 'have ' + points[i]);
|
2011-02-13 11:26:24 -05:00
|
|
|
if (segment1[points[i]] && segment2[points[i]])
|
2011-02-07 13:28:09 -05:00
|
|
|
comparePoints(segment1[points[i]], segment2[points[i]], points[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-13 10:48:20 -05:00
|
|
|
function compareNumbers(number1, number2, message) {
|
|
|
|
equals(Math.round(number1 * 100) / 100, Math.round(number2 * 100) / 100,
|
|
|
|
message);
|
|
|
|
}
|
|
|
|
|
2011-02-07 13:28:09 -05:00
|
|
|
function comparePoints(point1, point2, message) {
|
2011-02-13 10:48:20 -05:00
|
|
|
compareNumbers(point1.x, point2.x, message ? message + ' x' : undefined);
|
|
|
|
compareNumbers(point1.y, point2.y, message ? message + ' y' : undefined);
|
2011-02-13 09:35:48 -05:00
|
|
|
}
|
|
|
|
|
2011-02-13 10:48:20 -05:00
|
|
|
function compareRectangles(rect1, rect2, message) {
|
|
|
|
compareNumbers(rect1.x, rect2.x, message ? message + ' x' : undefined);
|
|
|
|
compareNumbers(rect1.y, rect2.y, message ? message + ' y' : undefined);
|
|
|
|
compareNumbers(rect1.width, rect2.width,
|
|
|
|
message ? message + ' width' : undefined);
|
|
|
|
compareNumbers(rect1.height, rect2.height,
|
|
|
|
message ? message + ' height' : undefined);
|
|
|
|
}
|