Skip to content

Commit

Permalink
refactor(geom): update imports, fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jan 11, 2019
1 parent cdd8659 commit c41b96f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 40 deletions.
3 changes: 2 additions & 1 deletion packages/geom2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"scripts": {
"build": "yarn clean && yarn build:es6 && yarn build:bundle",
"build:es6": "tsc --declaration",
"build:bundle": "../../scripts/bundle-module geom2 api checks defmulti equiv hiccup hiccup-svg malloc math matrices transducers vectors3",
"build:bundle": "../../scripts/bundle-module geom2 api checks defmulti equiv errors hiccup hiccup-svg malloc math matrices transducers vectors3",
"test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js",
"clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib",
"cover": "yarn test && nyc report --reporter=lcov",
Expand All @@ -36,6 +36,7 @@
"@thi.ng/checks": "^1.5.14",
"@thi.ng/defmulti": "^0.7.0",
"@thi.ng/equiv": "^0.1.15",
"@thi.ng/errors": "^0.1.12",
"@thi.ng/hiccup": "^2.7.2",
"@thi.ng/hiccup-svg": "^2.0.10",
"@thi.ng/malloc": "^0.2.1",
Expand Down
3 changes: 1 addition & 2 deletions packages/geom2/src/bezier.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { isNumber } from "@thi.ng/checks/is-number";
import { isPlainObject } from "@thi.ng/checks/is-plain-object";
import { isNumber, isPlainObject } from "@thi.ng/checks";
import { implementations } from "@thi.ng/defmulti";
import { clamp01, mixCubic as _mixC, mixQuadratic as _mixQ } from "@thi.ng/math";
import { Mat } from "@thi.ng/matrices";
Expand Down
79 changes: 43 additions & 36 deletions packages/geom2/test/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ describe("api", () => {
it("area", () =>
checkImpls(area, [
_DEFAULT,
Type.CIRCLE2,
Type.ELLIPSE2,
Type.CIRCLE,
Type.ELLIPSE,
Type.GROUP,
Type.POLYGON2,
Type.QUAD2,
Type.RECT2,
Type.RECT,
Type.TRIANGLE2,
]));

Expand All @@ -78,7 +78,7 @@ describe("api", () => {
it("asPolygon", () =>
checkImpls(asPolygon, [
_DEFAULT,
Type.ELLIPSE2,
Type.ELLIPSE,
Type.PATH2,
Type.POLYGON2,
]));
Expand All @@ -95,9 +95,9 @@ describe("api", () => {
it("bounds", () =>
checkImpls(bounds, [
Type.ARC2,
Type.CIRCLE2,
Type.CIRCLE,
Type.CUBIC2,
Type.ELLIPSE2,
Type.ELLIPSE,
Type.GROUP,
Type.LINE2,
Type.PATH2,
Expand All @@ -106,49 +106,49 @@ describe("api", () => {
Type.POLYLINE2,
Type.QUAD2,
Type.QUADRATIC2,
Type.RECT2,
Type.RECT,
Type.TRIANGLE2,
]));

it("center", () =>
checkImpls(center, [
_DEFAULT,
Type.CIRCLE2,
Type.ELLIPSE2
Type.CIRCLE,
Type.ELLIPSE
]));

it("centroid", () =>
checkImpls(centroid, [
Type.ARC2,
Type.CIRCLE2,
Type.ELLIPSE2,
Type.CIRCLE,
Type.ELLIPSE,
Type.GROUP,
Type.LINE2,
Type.PATH2,
Type.POINTS2,
Type.POLYGON2,
Type.POLYLINE2,
Type.QUAD2,
Type.RECT2,
Type.RECT,
Type.TRIANGLE2,
]));

it("classifyPoint", () =>
checkImpls(classifyPoint, [
Type.CIRCLE2,
Type.CIRCLE,
Type.TRIANGLE2,
]));

it("closestPoint", () =>
checkImpls(closestPoint, [
Type.CIRCLE2,
Type.CIRCLE,
]));

it("clipConvex", () =>
checkImpls(clipConvex, [
Type.POLYGON2,
Type.QUAD2,
Type.RECT2,
Type.RECT,
Type.TRIANGLE2,
]));

Expand Down Expand Up @@ -176,7 +176,7 @@ describe("api", () => {
Type.POLYGON2,
Type.POLYLINE2,
Type.QUAD2,
Type.RECT2,
Type.RECT,
Type.TRIANGLE2,
]));

Expand Down Expand Up @@ -207,6 +207,10 @@ describe("api", () => {

it("intersectShape", () =>
checkImpls(intersectShape, [
"rect-circle",
"rect-rect",
"sphere-ray",
"sphere-sphere"
]));

it("intersectLine", () =>
Expand All @@ -216,7 +220,7 @@ describe("api", () => {

it("mapPoint", () =>
checkImpls(mapPoint, [
Type.RECT2
Type.RECT
]));

it("normalAt", () =>
Expand All @@ -234,33 +238,35 @@ describe("api", () => {

it("perimeter", () =>
checkImpls(perimeter, [
Type.CIRCLE2,
Type.ELLIPSE2,
Type.CIRCLE,
Type.ELLIPSE,
Type.LINE2,
Type.POLYGON2,
Type.POLYLINE2,
Type.QUAD2,
Type.RECT2,
Type.RECT,
Type.TRIANGLE2,
]));

it("pointAt", () =>
checkImpls(pointAt, [
Type.ARC2,
Type.CIRCLE2,
Type.CIRCLE,
Type.CUBIC2,
Type.ELLIPSE2,
Type.ELLIPSE,
Type.LINE2,
Type.POLYGON2,
Type.QUADRATIC2,
Type.RECT2,
Type.RAY,
Type.RECT,
]));

it("pointInside", () =>
checkImpls(pointInside, [
Type.CIRCLE2,
Type.CIRCLE,
Type.POLYGON2,
Type.TRIANGLE2,
Type.RECT2,
Type.RECT,
]));

it("resample", () =>
Expand All @@ -269,7 +275,7 @@ describe("api", () => {
Type.POLYGON2,
Type.POLYLINE2,
Type.QUAD2,
Type.RECT2,
Type.RECT,
Type.TRIANGLE2,
]));

Expand All @@ -294,6 +300,7 @@ describe("api", () => {

it("tangentAt", () =>
checkImpls(tangentAt, [
Type.CIRCLE,
Type.LINE2,
Type.POLYGON2,
Type.POLYLINE2,
Expand All @@ -303,7 +310,7 @@ describe("api", () => {
checkImpls(tessellate, [
Type.POLYGON2,
Type.QUAD2,
Type.RECT2,
Type.RECT,
Type.TRIANGLE2,
]));

Expand All @@ -317,48 +324,48 @@ describe("api", () => {
Type.POLYLINE2,
Type.QUAD2,
Type.QUADRATIC2,
Type.RECT2,
Type.RECT,
Type.TRIANGLE2,
]));

it("translate", () =>
checkImpls(translate, [
Type.CIRCLE2,
Type.ELLIPSE2,
Type.CIRCLE,
Type.ELLIPSE,
Type.PATH2,
Type.POLYGON2,
Type.POLYLINE2,
Type.QUAD2,
Type.RECT2,
Type.RECT,
Type.TRIANGLE2
]));

it("union", () =>
checkImpls(union, [
Type.POLYGON2,
Type.RECT2,
Type.RECT,
]));

it("unmapPoint", () =>
checkImpls(unmapPoint, [
Type.QUAD2,
Type.RECT2,
Type.RECT,
]));

it("vertices", () =>
checkImpls(vertices, [
Type.ARC2,
Type.CIRCLE2,
Type.CIRCLE,
Type.CUBIC2,
Type.ELLIPSE2,
Type.ELLIPSE,
Type.LINE2,
Type.PATH2,
Type.POINTS2,
Type.POLYGON2,
Type.POLYLINE2,
Type.QUAD2,
Type.QUADRATIC2,
Type.RECT2,
Type.RECT,
Type.TRIANGLE2,
]));

Expand Down
2 changes: 1 addition & 1 deletion packages/geom2/test/clip.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { translation23 } from "@thi.ng/matrices/translation";
import { translation23 } from "@thi.ng/matrices";
import * as fs from "fs";
import * as g from "../src";

Expand Down

0 comments on commit c41b96f

Please sign in to comment.