Skip to content

Commit b71106b

Browse files
committed
chore: reformat
1 parent 93f7447 commit b71106b

20 files changed

+269
-237
lines changed

r1/Interval.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class Interval {
2626
/**
2727
* Returns true iff the interval contains the same points as oi.
2828
*/
29-
equal(oi: Interval): boolean {
29+
equals(oi: Interval): boolean {
3030
return (this.lo == oi.lo && this.hi == oi.hi) || (this.isEmpty() && oi.isEmpty())
3131
}
3232

r1/Interval_test.ts

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,26 @@ const NEG_UNIT = new Interval(-1, 0)
88
const HALF = new Interval(0.5, 0.5)
99
const EMPTY = Interval.empty()
1010

11-
test('isEmpty', t => {
11+
test('isEmpty', (t) => {
1212
ok(!UNIT.isEmpty(), 'should not be empty')
1313
ok(!NEG_UNIT.isEmpty(), 'should not be empty')
1414
ok(!HALF.isEmpty(), 'should not be empty')
1515
ok(EMPTY.isEmpty(), 'should not empty')
1616
})
1717

18-
test('center', t => {
18+
test('center', (t) => {
1919
equal(UNIT.center(), 0.5)
2020
equal(NEG_UNIT.center(), -0.5)
2121
equal(HALF.center(), 0.5)
2222
})
2323

24-
test('length', t => {
24+
test('length', (t) => {
2525
equal(UNIT.length(), 1)
2626
equal(NEG_UNIT.length(), 1)
2727
equal(HALF.length(), 0)
2828
})
2929

30-
test('contains', t => {
30+
test('contains', (t) => {
3131
ok(UNIT.contains(0.5))
3232
ok(UNIT.interiorContains(0.5))
3333

@@ -38,7 +38,7 @@ test('contains', t => {
3838
ok(!UNIT.interiorContains(1))
3939
})
4040

41-
test('operations', t => {
41+
test('operations', (t) => {
4242
ok(EMPTY.containsInterval(EMPTY))
4343
ok(EMPTY.interiorContainsInterval(EMPTY))
4444
ok(!EMPTY.intersects(EMPTY))
@@ -81,46 +81,46 @@ test('operations', t => {
8181
ok(!HALF.interiorIntersects(i))
8282
})
8383

84-
test('intersection', t => {
85-
ok(UNIT.intersection(HALF).equal(HALF))
86-
ok(UNIT.intersection(NEG_UNIT).equal(new Interval(0, 0)))
87-
ok(NEG_UNIT.intersection(HALF).equal(EMPTY))
88-
ok(UNIT.intersection(EMPTY).equal(EMPTY))
89-
ok(EMPTY.intersection(UNIT).equal(EMPTY))
84+
test('intersection', (t) => {
85+
ok(UNIT.intersection(HALF).equals(HALF))
86+
ok(UNIT.intersection(NEG_UNIT).equals(new Interval(0, 0)))
87+
ok(NEG_UNIT.intersection(HALF).equals(EMPTY))
88+
ok(UNIT.intersection(EMPTY).equals(EMPTY))
89+
ok(EMPTY.intersection(UNIT).equals(EMPTY))
9090
})
9191

92-
test('union', t => {
93-
ok(new Interval(99, 100).union(EMPTY).equal(new Interval(99, 100)))
94-
ok(EMPTY.union(new Interval(99, 100)).equal(new Interval(99, 100)))
95-
ok(new Interval(5, 3).union(new Interval(0, -2)).equal(EMPTY))
96-
ok(new Interval(0, -2).union(new Interval(5, 3)).equal(EMPTY))
97-
ok(UNIT.union(UNIT).equal(UNIT))
98-
ok(UNIT.union(NEG_UNIT).equal(new Interval(-1, 1)))
99-
ok(NEG_UNIT.union(UNIT).equal(new Interval(-1, 1)))
100-
ok(HALF.union(UNIT).equal(UNIT))
92+
test('union', (t) => {
93+
ok(new Interval(99, 100).union(EMPTY).equals(new Interval(99, 100)))
94+
ok(EMPTY.union(new Interval(99, 100)).equals(new Interval(99, 100)))
95+
ok(new Interval(5, 3).union(new Interval(0, -2)).equals(EMPTY))
96+
ok(new Interval(0, -2).union(new Interval(5, 3)).equals(EMPTY))
97+
ok(UNIT.union(UNIT).equals(UNIT))
98+
ok(UNIT.union(NEG_UNIT).equals(new Interval(-1, 1)))
99+
ok(NEG_UNIT.union(UNIT).equals(new Interval(-1, 1)))
100+
ok(HALF.union(UNIT).equals(UNIT))
101101
})
102102

103-
test('addPoint', t => {
104-
ok(EMPTY.addPoint(5).equal(new Interval(5, 5)))
105-
ok(new Interval(5, 5).addPoint(-1).equal(new Interval(-1, 5)))
106-
ok(new Interval(-1, 5).addPoint(0).equal(new Interval(-1, 5)))
107-
ok(new Interval(-1, 5).addPoint(6).equal(new Interval(-1, 6)))
103+
test('addPoint', (t) => {
104+
ok(EMPTY.addPoint(5).equals(new Interval(5, 5)))
105+
ok(new Interval(5, 5).addPoint(-1).equals(new Interval(-1, 5)))
106+
ok(new Interval(-1, 5).addPoint(0).equals(new Interval(-1, 5)))
107+
ok(new Interval(-1, 5).addPoint(6).equals(new Interval(-1, 6)))
108108
})
109109

110-
test('clampPoint', t => {
110+
test('clampPoint', (t) => {
111111
equal(new Interval(0.1, 0.4).clampPoint(0.3), 0.3)
112112
equal(new Interval(0.1, 0.4).clampPoint(-7.0), 0.1)
113113
equal(new Interval(0.1, 0.4).clampPoint(0.6), 0.4)
114114
})
115115

116-
test('expanded', t => {
117-
ok(EMPTY.expanded(0.45).equal(EMPTY))
118-
ok(UNIT.expanded(0.5).equal(new Interval(-0.5, 1.5)))
119-
ok(UNIT.expanded(-0.5).equal(new Interval(0.5, 0.5)))
120-
ok(UNIT.expanded(-0.51).equal(EMPTY))
116+
test('expanded', (t) => {
117+
ok(EMPTY.expanded(0.45).equals(EMPTY))
118+
ok(UNIT.expanded(0.5).equals(new Interval(-0.5, 1.5)))
119+
ok(UNIT.expanded(-0.5).equals(new Interval(0.5, 0.5)))
120+
ok(UNIT.expanded(-0.51).equals(EMPTY))
121121
})
122122

123-
test('approxEqual', t => {
123+
test('approxEqual', (t) => {
124124
// Choose two values lo and hi such that it's okay to shift an endpoint by
125125
// kLo (i.e., the resulting interval is equivalent) but not by kHi.
126126
const lo = 4 * 2.220446049250313e-16 // < max_error default
@@ -154,14 +154,14 @@ test('approxEqual', t => {
154154
ok(!new Interval(1 + lo, 2 - hi).approxEqual(new Interval(1, 2)))
155155
})
156156

157-
test('directedHausdorffDistance', t => {
157+
test('directedHausdorffDistance', (t) => {
158158
equal(EMPTY.directedHausdorffDistance(EMPTY), 0)
159159
equal(UNIT.directedHausdorffDistance(EMPTY), Infinity)
160160
equal(new Interval(1, 1).directedHausdorffDistance(new Interval(1, 1)), 0)
161161
equal(new Interval(1, 3).directedHausdorffDistance(new Interval(1, 1)), 2)
162162
equal(new Interval(1, 1).directedHausdorffDistance(new Interval(3, 5)), 2)
163163
})
164164

165-
test('toString', t => {
165+
test('toString', (t) => {
166166
equal(new Interval(2, 4.5).toString(), '[2.0000000, 4.5000000]')
167167
})

r1/math.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ export const findLSBSetNonZero64 = (i: bigint): number => {
4444
if (lo < 32) return 31 - lo
4545
const hi = Math.clz32(Number((lsb >> 32n) & 0xffffffffn))
4646
return 63 - hi
47-
}
47+
}

r1/math_test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import test from 'node:test'
22
import { equal, ok } from 'node:assert/strict'
33
import { remainder, nextAfter, float64Near, findLSBSetNonZero64 } from './math'
44

5-
test('remainder', t => {
5+
test('remainder', (t) => {
66
equal(remainder(5.1, 2), -0.9000000000000004)
77
equal(remainder(5.5, 2), -0.5)
88
equal(remainder(-5.5, 2), 0.5)
@@ -15,7 +15,7 @@ test('remainder', t => {
1515
equal(remainder(-5, 2), -1)
1616
})
1717

18-
test('nextAfter', t => {
18+
test('nextAfter', (t) => {
1919
equal(nextAfter(0, 1), 5e-324)
2020
equal(nextAfter(0, -1), -5e-324)
2121
equal(nextAfter(1, 2), 1.0000000000000002)
@@ -27,14 +27,14 @@ test('nextAfter', t => {
2727
equal(nextAfter(1, Number.NaN), NaN)
2828
})
2929

30-
test('float64Near', t => {
30+
test('float64Near', (t) => {
3131
ok(float64Near(0, 0, 0))
32-
ok(float64Near(1e-10, 1e-10*2, 1e-10))
32+
ok(float64Near(1e-10, 1e-10 * 2, 1e-10))
3333
ok(!float64Near(1e-10, 1e-9, 1e-10))
34-
ok(!float64Near(1e-5, 1e-4, 1e-5/10))
34+
ok(!float64Near(1e-5, 1e-4, 1e-5 / 10))
3535
})
3636

37-
test('findLSBSetNonZero64', t => {
37+
test('findLSBSetNonZero64', (t) => {
3838
equal(findLSBSetNonZero64(0b0000000000000000000000000000000000000000000000000000000000000001n), 0)
3939
equal(findLSBSetNonZero64(0b0000000000000000000000000000000000000000000000000000000000000010n), 1)
4040
equal(findLSBSetNonZero64(0b0000000000000000000000000000000000000000000000000000000000000100n), 2)
@@ -51,4 +51,4 @@ test('findLSBSetNonZero64', t => {
5151
equal(findLSBSetNonZero64(0b1000000000000000000000000000000000000000000000000000000000000000n), 63)
5252
equal(findLSBSetNonZero64(0b0000000000000000000000000000000000000000000000000000000000000000n), 64)
5353
equal(findLSBSetNonZero64(0b1000000000000000000000000000000000000000000000000000000000000000000n), 64)
54-
})
54+
})

r2/Point_test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,50 @@ import { Point } from './Point'
44

55
export const MAX_FLOAT32 = Math.pow(2, 127) * (2 - 1 / Math.pow(2, 23))
66

7-
test('add', t => {
7+
test('add', (t) => {
88
deepEqual(new Point(0, 0).add(new Point(0, 0)), new Point(0, 0))
99
deepEqual(new Point(0, 1).add(new Point(0, 0)), new Point(0, 1))
1010
deepEqual(new Point(1, 1).add(new Point(4, 3)), new Point(5, 4))
1111
deepEqual(new Point(-4, 7).add(new Point(1, 5)), new Point(-3, 12))
1212
})
1313

14-
test('sub', t => {
14+
test('sub', (t) => {
1515
deepEqual(new Point(0, 0).sub(new Point(0, 0)), new Point(0, 0))
1616
deepEqual(new Point(0, 1).sub(new Point(0, 0)), new Point(0, 1))
1717
deepEqual(new Point(1, 1).sub(new Point(4, 3)), new Point(-3, -2))
1818
deepEqual(new Point(-4, 7).sub(new Point(1, 5)), new Point(-5, 2))
1919
})
2020

21-
test('mul', t => {
21+
test('mul', (t) => {
2222
deepEqual(new Point(0, 0).mul(0), new Point(0, 0))
2323
deepEqual(new Point(0, 1).mul(1), new Point(0, 1))
2424
deepEqual(new Point(1, 1).mul(5), new Point(5, 5))
2525
})
2626

27-
test('ortho', t => {
27+
test('ortho', (t) => {
2828
deepEqual(new Point(0, 0).ortho(), new Point(-0, 0))
2929
deepEqual(new Point(0, 1).ortho(), new Point(-1, 0))
3030
deepEqual(new Point(1, 1).ortho(), new Point(-1, 1))
3131
deepEqual(new Point(-4, 7).ortho(), new Point(-7, -4))
3232
deepEqual(new Point(1, Math.sqrt(3)).ortho(), new Point(-Math.sqrt(3), 1))
3333
})
3434

35-
test('dot', t => {
35+
test('dot', (t) => {
3636
equal(new Point(0, 0).dot(new Point(0, 0)), 0)
3737
equal(new Point(0, 1).dot(new Point(0, 0)), 0)
3838
equal(new Point(1, 1).dot(new Point(4, 3)), 7)
3939
equal(new Point(-4, 7).dot(new Point(1, 5)), 31)
4040
})
4141

42-
test('cross', t => {
42+
test('cross', (t) => {
4343
equal(new Point(0, 0).cross(new Point(0, 0)), 0)
4444
equal(new Point(0, 1).cross(new Point(0, 0)), 0)
4545
equal(new Point(1, 1).cross(new Point(-1, -1)), 0)
4646
equal(new Point(1, 1).cross(new Point(4, 3)), -1)
4747
equal(new Point(1, 5).cross(new Point(-2, 3)), 13)
4848
})
4949

50-
test('norm', t => {
50+
test('norm', (t) => {
5151
equal(new Point(0, 0).norm(), 0)
5252
equal(new Point(0, 1).norm(), 1)
5353
equal(new Point(-1, 0).norm(), 1)
@@ -60,7 +60,7 @@ test('norm', t => {
6060
equal(new Point(1e14, MAX_FLOAT32 - 1).norm(), MAX_FLOAT32)
6161
})
6262

63-
test('normalize', t => {
63+
test('normalize', (t) => {
6464
deepEqual(new Point().normalize(), new Point(0, 0))
6565
deepEqual(new Point(0, 0).normalize(), new Point(0, 0))
6666
deepEqual(new Point(0, 1).normalize(), new Point(0, 1))
@@ -74,13 +74,13 @@ test('normalize', t => {
7474
deepEqual(new Point(1e4, MAX_FLOAT32 - 1).normalize().trunc(), new Point(0, 1))
7575
})
7676

77-
test('trunc', t => {
77+
test('trunc', (t) => {
7878
deepEqual(new Point().trunc(), new Point(0, 0))
7979
deepEqual(new Point(0.0000000000000001, 0.0000000000000001).trunc(), new Point(0, 0))
8080
deepEqual(new Point(0.00000000001, 0.00000000001).trunc(10), new Point(0, 0))
8181
})
8282

83-
test('toString', t => {
83+
test('toString', (t) => {
8484
equal(new Point().toString(), '(0.000000000000, 0.000000000000)')
8585
equal(new Point(0.0000000000000001, 0.0000000000000001).toString(), '(0.000000000000, 0.000000000000)')
8686
equal(new Point(-1, 1).toString(), '(-1.000000000000, 1.000000000000)')

r2/Rect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ export class Rect {
230230
static fromCenterSize(center: Point, size: Point): Rect {
231231
return new Rect(
232232
new Interval(center.x - size.x / 2, center.x + size.x / 2),
233-
new Interval(center.y - size.y / 2, center.y + size.y / 2)
233+
new Interval(center.y - size.y / 2, center.y + size.y / 2),
234234
)
235235
}
236236

0 commit comments

Comments
 (0)