mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-08-28 22:08:54 -04:00
Use comparePoints() helper in Point tests.
This commit is contained in:
parent
8f20dabf4d
commit
9bcfae8661
1 changed files with 15 additions and 11 deletions
|
@ -13,45 +13,45 @@
|
|||
module('Point');
|
||||
test('new Point(10, 20)', function() {
|
||||
var point = new Point(10, 20);
|
||||
equals(point.toString(), '{ x: 10, y: 20 }');
|
||||
comparePoints(point, { x: 10, y: 20 });
|
||||
});
|
||||
|
||||
test('new Point([10, 20])', function() {
|
||||
var point = new Point([10, 20]);
|
||||
equals(point.toString(), '{ x: 10, y: 20 }');
|
||||
comparePoints(point, { x: 10, y: 20 });
|
||||
});
|
||||
|
||||
test('new Point({x: 10, y: 20})', function() {
|
||||
var point = new Point({x: 10, y: 20});
|
||||
equals(point.toString(), '{ x: 10, y: 20 }');
|
||||
comparePoints(point, { x: 10, y: 20 });
|
||||
});
|
||||
|
||||
test('new Point(new Size(10, 20))', function() {
|
||||
var point = new Point(new Size(10, 20));
|
||||
equals(point.toString(), '{ x: 10, y: 20 }');
|
||||
comparePoints(point, { x: 10, y: 20 });
|
||||
});
|
||||
|
||||
test('new Point({ width: 10, height: 20})', function() {
|
||||
var point = new Point({width: 10, height: 20});
|
||||
equals(point.toString(), '{ x: 10, y: 20 }');
|
||||
comparePoints(point, { x: 10, y: 20 });
|
||||
});
|
||||
|
||||
test('new Point({ angle: 45, length: 20})', function() {
|
||||
var point = new Point({angle: 40, length: 20});
|
||||
equals(point.toString(), '{ x: 15.32089, y: 12.85575 }');
|
||||
var point = new Point({ angle: 40, length: 20 });
|
||||
comparePoints(point, new Point(15.32089, 12.85575));
|
||||
});
|
||||
|
||||
module('Point vector operations');
|
||||
|
||||
test('normalize(length)', function() {
|
||||
var point = new Point(0, 10).normalize(20)
|
||||
equals(point.toString(), '{ x: 0, y: 20 }');
|
||||
var point = new Point(0, 10).normalize(20);
|
||||
comparePoints(point, { x: 0, y: 20 });
|
||||
});
|
||||
|
||||
test('set length', function() {
|
||||
var point = new Point(0, 10);
|
||||
point.length = 20;
|
||||
equals(point.toString(), '{ x: 0, y: 20 }');
|
||||
comparePoints(point, { x: 0, y: 20 });
|
||||
});
|
||||
|
||||
test('get angle', function() {
|
||||
|
@ -66,13 +66,17 @@ test('getAngle(point)', function() {
|
|||
|
||||
test('rotate(degrees)', function() {
|
||||
var point = new Point(100, 50).rotate(90);
|
||||
equals(point.toString(), '{ x: -50, y: 100 }');
|
||||
comparePoints(point, { x: -50, y: 100 });
|
||||
});
|
||||
|
||||
test('set angle', function() {
|
||||
var point = new Point(10, 20);
|
||||
point.angle = 92;
|
||||
equals(point.angle, 92);
|
||||
comparePoints(point, new Point({
|
||||
angle: 92,
|
||||
length: Math.sqrt(10 * 10 + 20 * 20)
|
||||
}));
|
||||
});
|
||||
|
||||
test('set angle & length', function() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue