Skip to content
Browse files

add tests for vec3.add

  • Loading branch information...
1 parent ffac4c4 commit d26993ced7829ec3a7c35c6a9fc492ce9a77cde8 @sinisterchipmunk sinisterchipmunk committed Nov 28, 2011
Showing with 27 additions and 1 deletion.
  1. +27 −1 spec/javascripts/vec3_spec.js
View
28 spec/javascripts/vec3_spec.js
@@ -1,5 +1,5 @@
describe("vec3", function() {
- var vec;
+ var vec, dest;
describe("when Float32Array is not supported", function() {
beforeEach(function() { setMatrixArrayType(Array); });
@@ -33,4 +33,30 @@ describe("vec3", function() {
expect(vec[2]).toEqual(3);
});
});
+
+ describe("add", function() {
+ beforeEach(function() { vec = vec3.create([1,2,3]); });
+
+ it("should modify original vector if dest not given", function() {
+ vec3.add(vec, [3,4,5]);
+ expect(vec).toBeEqualish([4,6,8]);
+ });
+
+ it("should modify original vector if dest is original vector", function() {
+ vec3.add(vec, [3,4,5], vec);
+ expect(vec).toBeEqualish([4,6,8]);
+ });
+
+ describe("if dest vector given", function() {
+ beforeEach(function() { vec3.add(vec, [3,4,5], dest = vec3.create()); });
+
+ it("should not modify original vector", function() {
+ expect(vec).toBeEqualish([3,4,5]);
+ });
+
+ it("should modify dest vector", function() {
+ expect(dest).toBeEqualish([4,6,8]);
+ });
+ });
+ });
});

0 comments on commit d26993c

Please sign in to comment.
Something went wrong with that request. Please try again.