QUnit.module("Vector2", {
    getRandomVector: function () {
        var x = Math.random() * 100000000000,
            y = Math.random() * 100000000000;
        return new Vector2(x, y);
    },
    beforeEach: function () {
        this.v1 = this.getRandomVector();
        this.x1 = this.v1.x;
        this.y1 = this.v1.y;

        this.v2 = this.getRandomVector();
        this.x2 = this.v2.x;
        this.y2 = this.v2.y;
    }
});

QUnit.test("Construction", function (assert) {
    assert.ok( this.v1.x == this.x1, "Vector creation for vector 1: x ok" );
    assert.ok( this.v1.y == this.y1, "Vector creation for vector 1: y ok" );
    assert.ok( this.v2.x == this.x2, "Vector creation for vector 2: x ok" );
    assert.ok( this.v2.y == this.y2, "Vector creation for vector 2: y ok" );
});

QUnit.test("Addition", function (assert) {
    this.v1.add(this.v2);

    assert.ok( this.v1.x == this.x1 + this.x2, "Vector addition for vector 1: x ok" );
    assert.ok( this.v1.y == this.y1 + this.y2, "Vector addition for vector 1: y ok" );
    assert.ok( this.v2.x == this.x2, "Vector addition for vector 2: x ok" );
    assert.ok( this.v2.y == this.y2, "Vector addition for vector 2: y ok" );
});

QUnit.test("Copying", function (assert) {
    var delta = Math.random() * 100000000000;
    this.v2 = this.v1.copy().add(new Vector2(delta, -delta));

    assert.ok( this.v1.x == this.x1, "Vector copying for vector 1 (unchanged): x ok" );
    assert.ok( this.v1.y == this.y1, "Vector copying for vector 1 (unchanged): y ok" );
    assert.ok( this.v2.x == this.x1 + delta, "Vector copying for vector 2 (copy): x ok" );
    assert.ok( this.v2.y == this.y1 - delta, "Vector copying for vector 2 (copy): y ok" );
});
@@ -1692,20 +1692,388 @@
 (copy): y ok%22 );%0A%7D);
+%0A%0AQUnit.test(%22Adding Invalid Objects%22, function (assert) %7B%0A    var notAVector = %7B%0A        'x' : Math.random() * 1000000,%0A        'y' : Math.random() * 1000000%0A    %7D;%0A    var vector = this.v1;%0A    %0A    assert.throws(function() %7B%0A        vector.add(notAVector);%0A    %7D, InvalidArgumentError, %22Vector addition with an invalid object throws an InvalidArgumentError: ok%22)%0A%7D)

Add a test for adding an invalid object to a vector