Implement unit test for

Currently failing.
This commit is contained in:
Jürg Lehni 2016-01-08 12:28:43 +01:00
parent 5060e83095
commit 61f5f9bcfa

View file

@ -28,7 +28,7 @@ function compareBoolean(actual, expected, message, options) {
}
actual.style = expected.style = {
strokeColor: 'black',
fillColor: 'yellow'
fillColor: expected.closed ? 'yellow' : null
};
equals(actual, expected, message, options || { rasterize: true });
}
@ -120,6 +120,37 @@ test('#719', function() {
compareBoolean(result, expected);
});
test('#757 (support for open paths)', function() {
var rect = new Path.Rectangle({
from: [100, 250],
to: [350, 350]
});
var line = new Path({
segments: [
[100, 200],
[150, 400],
[200, 200],
[250, 400],
[300, 200],
[350, 400]
]
});
var res = line.intersect(rect);
var children = res.removeChildren();
var first = children[0];
for (var i = 1; i < children.length; i++) {
first.join(children[i]);
}
first.insertAbove(res);
res.remove();
res = first;
compareBoolean(res,
'M112.5,250l25,100l25,0l25,-100l25,0l25,100l25,0l25,-100l25,0l25,100');
});
test('#784', function() {
var path1 = createPath('M495.9,1693.5c-42.2-203.5-64.5-304.9-78-299.9 c-1.7,0.6-0.3,6.7,5.3,22.5l209.4-74.8l75.8,303.9L495.9,1693.5z');
var path2 = createPath('M632.6,1341.2l-209.4,74.9c95.4,267,135.6,201-60.1-144.5l202.9-85.7 L632.6,1341.2z');
@ -329,7 +360,7 @@ test('#885', function() {
compareBoolean(function() { return p1.exclude(p2); }, empty);
});
test('#889 & #890', function() {
test('#889', function() {
var cp = new CompoundPath([
new Path({ segments: [ [340.26, 358.4], [576, 396.8], [345.78, 396.8] ], closed: true }),
new Path({ segments: [ [691.2, 685.76], [672, 550.4, 0, 0, 10, 0], [729.6, 608, 0, -20, 0, 0] ], closed: true })
@ -337,7 +368,9 @@ test('#889 & #890', function() {
var p = new Path({ segments: [ [739, 418], [637, 704], [205, 704], [204.30709922574619, 356.553500194953] ], closed: true });
compareBoolean(function() { return cp.subtract(p); },
'M340.26,358.4l235.74,38.4l-21.47738,0l-212.24889,-24.39148z M691.2,685.76l-13.57151,-95.67911l11.09506,-31.10967c17.43794,12.2938 40.87645,34.99446 40.87645,49.02878z');
});
test('#890', function() {
var cp = new CompoundPath([
new Path({ segments: [ [676, 396.8], [445.78, 396.8], [426, 260] ], closed: true }),
new Path({ segments: [ [672, 550.4, 0, 0, 31.74000000000001, 0], [633.5999999999999, 732.8, 0, 26.519999999999982] ], closed: true })