Skip to content

Commit

Permalink
fix(vector): extend tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTelanie committed Sep 15, 2019
1 parent 1704f09 commit a95d12b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
25 changes: 23 additions & 2 deletions test/point.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const pointTest = (vec2, Vec2) => {
assert.closeTo(arr[1], 10, 0.1);
});

it('calc method with || should work without error', () => {
it('should work when using calc function with || should work without error', () => {
const dir0 = vec2(4, 4);
const pos0 = vec2(6, 0);

Expand All @@ -105,6 +105,15 @@ const pointTest = (vec2, Vec2) => {
assert.equal(res1.x, 6);
assert.equal(res1.y, 0);
});

it('should work when using calc function directly returns vector', () => {
const dir0 = vec2(4, 4);

const res0 = calc(() => dir0);

assert.equal(res0.x, 4);
assert.equal(res0.y, 4);
});
};

describe('standard Point test.', () => {
Expand Down Expand Up @@ -155,7 +164,7 @@ describe('special Point test.', () => {
assert.equal(pos.y, 150);
});

it('local calc method with || should work without error', () => {
it('should work when using local calc method with || should work without error', () => {
const dir0 = point(4, 4);
const pos0 = point(6, 0);

Expand All @@ -176,4 +185,16 @@ describe('special Point test.', () => {
assert.equal(res1.x, 6);
assert.equal(res1.y, 0);
});

it('should work when using local calc method directly returns vector', () => {
const dir0 = point(4, 4);
const pos0 = point(6, 0);

const res0 = pos0.calc(() => dir0);

assert.isTrue(pos0 === res0);
assert.equal(pos0, res0);
assert.equal(res0.x, 4);
assert.equal(res0.y, 4);
});
});
27 changes: 25 additions & 2 deletions test/vector.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,17 @@ const vectorTest = (vec3, Vec3) => {
assert.equal(pos.z, 6);
});

it('calc method with || should work without error', () => {
it('should work when using calc function directly returns vector', () => {
const dir0 = vec3(4, 4, 0);

const res0 = calc(() => dir0);

assert.equal(res0.x, 4);
assert.equal(res0.y, 4);
assert.equal(res0.z, 0);
});

it('should work when using calc function with || should work without error', () => {
const dir0 = vec3(4, 4, 0);
const pos0 = vec3(6, 0, 0);

Expand Down Expand Up @@ -236,7 +246,7 @@ describe('special Vector test.', () => {
assert.equal(pos.z, 175);
});

it('local calc method with || should work without error', () => {
it('should work when using local calc method with || should work without error', () => {
const dir0 = vector(4, 4, 0);
const pos0 = vector(6, 0, 0);

Expand All @@ -259,6 +269,19 @@ describe('special Vector test.', () => {
assert.equal(res1.y, 0);
assert.equal(res1.z, 0);
});

it('should work when using local calc method directly returns vector', () => {
const dir0 = vector(4, 4, 0);
const pos0 = vector(6, 0, 0);

const res0 = pos0.calc(() => dir0);

assert.isTrue(pos0 === res0);
assert.equal(pos0, res0);
assert.equal(res0.x, 4);
assert.equal(res0.y, 4);
assert.equal(res0.z, 0);
});
});

describe('calc test.', () => {
Expand Down

0 comments on commit a95d12b

Please sign in to comment.