-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved test coverage, improved type checking
- Loading branch information
Showing
22 changed files
with
136 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Circle } from '../circle.js'; | ||
import { clone, contains, equals, intersects } from './circle.js'; | ||
|
||
it('should clone a circle', () => { | ||
const circle1 = new Circle(0, 0, 10); | ||
const circle2 = clone(circle1); | ||
expect(circle1.x).toBe(circle2.x); | ||
expect(circle1.y).toBe(circle2.y); | ||
expect(circle1.radius).toBe(circle2.radius); | ||
}); | ||
|
||
it('should contain a point in a circle', () => { | ||
const circle = new Circle(5, 5, 10); | ||
expect(contains(circle, 5, 5)).toBe(true); | ||
}); | ||
|
||
it('should match two circles', () => { | ||
const circle1 = new Circle(5, 5, 10); | ||
const circle2 = new Circle(5, 5, 10); | ||
expect(equals(circle1, circle2)).toBe(true); | ||
circle2.x = 0; | ||
expect(equals(circle1, circle2)).toBe(false); | ||
}); | ||
|
||
it('should intersects two circles', () => { | ||
const circle1 = new Circle(5, 5, 10); | ||
const circle2 = new Circle(5, 5, 5); | ||
expect(intersects(circle1, circle2)).toBe(true); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Ellipse } from '../ellipse.js'; | ||
import { contains } from './ellipse.js'; | ||
|
||
it('should contain an ellipse the given coordinates', () => { | ||
const ellipse = new Ellipse(0, 0, 10, 10); | ||
expect(contains(ellipse, 5, 5)).toBe(true); | ||
expect(contains(ellipse, 15, 15)).toBe(false); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Line } from '../line.js'; | ||
import { clone } from './line.js'; | ||
|
||
it('should clone a line', () => { | ||
const line1 = new Line(0, 0, 10, 0); | ||
const line2 = clone(line1); | ||
expect(line1.start.x).toBe(line2.start.x); | ||
expect(line1.start.y).toBe(line2.start.y); | ||
expect(line1.end.x).toBe(line2.end.x); | ||
expect(line1.end.y).toBe(line2.end.y); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Matrix } from '../matrix.js'; | ||
import { clone, getIdentityMatrix, getTempMatrix } from './matrix.js'; | ||
|
||
it('should clone a matrix', () => { | ||
const matrix1 = new Matrix(2, 0, 0, 2, 0, 0); | ||
const matrix2 = clone(matrix1); | ||
expect(matrix1.a).toBe(matrix2.a); | ||
expect(matrix1.b).toBe(matrix2.b); | ||
expect(matrix1.c).toBe(matrix2.c); | ||
expect(matrix1.d).toBe(matrix2.d); | ||
expect(matrix1.tx).toBe(matrix2.tx); | ||
expect(matrix1.ty).toBe(matrix2.ty); | ||
}); | ||
|
||
it('should create an identity matrix', () => { | ||
const matrix = getIdentityMatrix(); | ||
expect(matrix.a).toBe(1); | ||
}); | ||
|
||
it('should create a temporary matrix', () => { | ||
const matrix = getTempMatrix(); | ||
expect(matrix.a).toBe(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Point } from '../point.js'; | ||
import { clone } from './point.js'; | ||
|
||
it('should clone a point', () => { | ||
const point1 = new Point(1, 2); | ||
const point2 = clone(point1); | ||
expect(point1.x).toBe(point2.x); | ||
expect(point1.y).toBe(point2.y); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Polygon } from '../polygon.js'; | ||
import { clone } from './polygon.js'; | ||
|
||
it('should clone a polygon', () => { | ||
const polygon = new Polygon([0, 0, 1, 0, 1, 1]); | ||
const points = clone(polygon).toNumberArray(); | ||
expect(points[0]).toBe(0); | ||
expect(points[1]).toBe(0); | ||
expect(points[2]).toBe(1); | ||
expect(points[3]).toBe(0); | ||
expect(points[4]).toBe(1); | ||
expect(points[5]).toBe(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Rectangle } from '../rectangle.js'; | ||
import { clone } from './rectangle.js'; | ||
|
||
it('should clone a rectangle', () => { | ||
const rectangle1 = new Rectangle(0, 0, 10, 10); | ||
const rectangle2 = clone(rectangle1); | ||
expect(rectangle1.x).toBe(rectangle2.x); | ||
expect(rectangle1.y).toBe(rectangle2.y); | ||
expect(rectangle1.width).toBe(rectangle2.width); | ||
expect(rectangle1.height).toBe(rectangle2.height); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { RoundedRectangle } from '../rounded_rectangle.js'; | ||
import { clone } from './rounded_rectangle.js'; | ||
|
||
it('should clone a rounded rectangle', () => { | ||
const rectangle1 = new RoundedRectangle(0, 0, 10, 10, 2); | ||
const rectangle2 = clone(rectangle1); | ||
expect(rectangle1.x).toBe(rectangle2.x); | ||
expect(rectangle1.y).toBe(rectangle2.y); | ||
expect(rectangle1.width).toBe(rectangle2.width); | ||
expect(rectangle1.height).toBe(rectangle2.height); | ||
expect(rectangle1.radius).toBe(rectangle2.radius); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.