module("Point");

test("Check Creation", function(){
	var empty = new Atom();
	var p = new Point(13, 17);
	expect(4);
    equals(0, empty.x, 'Check empty x');
	equals(0, empty.y, 'Check empty y');
    equals(13, p.x, 'Check x');
	equals(17, p.y, 'Check y');
});

test("Check Addition", function(){
	var p1 = new Point(13, 17);
	var p2 = new Point(-9, 44);
	expect(4);
	p1.add(p2);
    equals(4, p1.x, 'Check p1.x');
	equals(61, p1.y, 'Check p1.y');
	p2.add(p1);
    equals(-5, p2.x, 'Check p2.x');
	equals(105, p2.y, 'Check p2.y');
});

test("Check Subtraction", function(){
	var p1 = new Point(13, 17);
	var p2 = new Point(-9, 44);
	expect(4);
	p1.sub(p2);
    equals(22, p1.x, 'Check p1.x');
	equals(-27, p1.y, 'Check p1.y');
	p2.sub(p1);
    equals(-31, p2.x, 'Check p2.x');
	equals(71, p2.y, 'Check p2.y');
});

test("Check Distance", function(){
	expect(4);
    equals(0, new Point(0,0).distance(new Point(0,0)), 'Check overlapping');
    equals(5, new Point(0,0).distance(new Point(3,4)), 'Check 3-4-5');
    equals(Math.sqrt(2), new Point(0,0).distance(new Point(1,1)), 'Check 1-1-sqrt(2)');
    equals(10, new Point(0,0).distance(new Point(0,10)), 'Check linear');
});

test("Check Angle", function(){
	expect(5);
    equals(0, new Point(0,0).angle(new Point(0,0)), 'Check overlapping');
    equals(0, new Point(0,0).angle(new Point(1,0)), 'Check 0');
	// y is upside down to account for the inverted canvas
    equals(Math.PI/2, new Point(0,0).angle(new Point(0,-1)), 'Check 90');
    equals(Math.PI, new Point(0,0).angle(new Point(-1,0)), 'Check 180');
    equals(3*Math.PI/2, new Point(0,0).angle(new Point(0,1)), 'Check 270');
});
