Skip to content

Commit a95d12b

Browse files
committed
fix(vector): extend tests
1 parent 1704f09 commit a95d12b

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed

test/point.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const pointTest = (vec2, Vec2) => {
8888
assert.closeTo(arr[1], 10, 0.1);
8989
});
9090

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

@@ -105,6 +105,15 @@ const pointTest = (vec2, Vec2) => {
105105
assert.equal(res1.x, 6);
106106
assert.equal(res1.y, 0);
107107
});
108+
109+
it('should work when using calc function directly returns vector', () => {
110+
const dir0 = vec2(4, 4);
111+
112+
const res0 = calc(() => dir0);
113+
114+
assert.equal(res0.x, 4);
115+
assert.equal(res0.y, 4);
116+
});
108117
};
109118

110119
describe('standard Point test.', () => {
@@ -155,7 +164,7 @@ describe('special Point test.', () => {
155164
assert.equal(pos.y, 150);
156165
});
157166

158-
it('local calc method with || should work without error', () => {
167+
it('should work when using local calc method with || should work without error', () => {
159168
const dir0 = point(4, 4);
160169
const pos0 = point(6, 0);
161170

@@ -176,4 +185,16 @@ describe('special Point test.', () => {
176185
assert.equal(res1.x, 6);
177186
assert.equal(res1.y, 0);
178187
});
188+
189+
it('should work when using local calc method directly returns vector', () => {
190+
const dir0 = point(4, 4);
191+
const pos0 = point(6, 0);
192+
193+
const res0 = pos0.calc(() => dir0);
194+
195+
assert.isTrue(pos0 === res0);
196+
assert.equal(pos0, res0);
197+
assert.equal(res0.x, 4);
198+
assert.equal(res0.y, 4);
199+
});
179200
});

test/vector.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,17 @@ const vectorTest = (vec3, Vec3) => {
161161
assert.equal(pos.z, 6);
162162
});
163163

164-
it('calc method with || should work without error', () => {
164+
it('should work when using calc function directly returns vector', () => {
165+
const dir0 = vec3(4, 4, 0);
166+
167+
const res0 = calc(() => dir0);
168+
169+
assert.equal(res0.x, 4);
170+
assert.equal(res0.y, 4);
171+
assert.equal(res0.z, 0);
172+
});
173+
174+
it('should work when using calc function with || should work without error', () => {
165175
const dir0 = vec3(4, 4, 0);
166176
const pos0 = vec3(6, 0, 0);
167177

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

239-
it('local calc method with || should work without error', () => {
249+
it('should work when using local calc method with || should work without error', () => {
240250
const dir0 = vector(4, 4, 0);
241251
const pos0 = vector(6, 0, 0);
242252

@@ -259,6 +269,19 @@ describe('special Vector test.', () => {
259269
assert.equal(res1.y, 0);
260270
assert.equal(res1.z, 0);
261271
});
272+
273+
it('should work when using local calc method directly returns vector', () => {
274+
const dir0 = vector(4, 4, 0);
275+
const pos0 = vector(6, 0, 0);
276+
277+
const res0 = pos0.calc(() => dir0);
278+
279+
assert.isTrue(pos0 === res0);
280+
assert.equal(pos0, res0);
281+
assert.equal(res0.x, 4);
282+
assert.equal(res0.y, 4);
283+
assert.equal(res0.z, 0);
284+
});
262285
});
263286

264287
describe('calc test.', () => {

0 commit comments

Comments
 (0)