Skip to content

Commit

Permalink
fix(point): extend factory function
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTelanie committed Apr 18, 2019
1 parent 9b2276d commit 238cc16
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/point.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ function square(val) {
*/
class APoint {
/**
*
* @param {number} x
* @param {number} y
* @param {number | (() => number)} x
* @param {number} [y]
*/
constructor(x, y) {
if (typeof x === 'function') {
Expand Down
4 changes: 2 additions & 2 deletions test/point.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ const pointTest = (vec2, Vec2) => {
});

it('should be calculated by assigned statement with only numbers', () => {
const vec = calc(() => 2 * 2 + 3);
const vec = vec2(() => 2 * 2 + 3);

assert.equal(vec.x, 7);
assert.equal(vec.y, 7);
});

it('calling of calc should automatically detect assigned Point types', () => {
const pos = vec2(2, 2);
const vec = calc(() => 2 * pos + 3);
const vec = vec2(() => 2 * pos + 3);

assert.instanceOf(vec, Vec2);
assert.equal(vec.x, 7);
Expand Down

0 comments on commit 238cc16

Please sign in to comment.