@flighthq/clip 0.3.0-next.1315.1d4eb64 → 0.3.0-next.1392.f0bd0cc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/clipRegion.test.ts +24 -10
- package/src/enableClipGuards.test.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/clip",
|
|
3
|
-
"version": "0.3.0-next.
|
|
3
|
+
"version": "0.3.0-next.1392.f0bd0cc",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/flighthq/flight.git",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@flighthq/geometry": "0.3.0-next.
|
|
40
|
-
"@flighthq/log": "0.3.0-next.
|
|
41
|
-
"@flighthq/path": "0.3.0-next.
|
|
42
|
-
"@flighthq/types": "0.3.0-next.
|
|
39
|
+
"@flighthq/geometry": "0.3.0-next.1392.f0bd0cc",
|
|
40
|
+
"@flighthq/log": "0.3.0-next.1392.f0bd0cc",
|
|
41
|
+
"@flighthq/path": "0.3.0-next.1392.f0bd0cc",
|
|
42
|
+
"@flighthq/types": "0.3.0-next.1392.f0bd0cc"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"typescript": "^5.3.0"
|
package/src/clipRegion.test.ts
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
clipRegionContainsPoint,
|
|
7
7
|
clipRegionContainsRectangle,
|
|
8
8
|
clipRegionIntersectsRectangle,
|
|
9
|
-
equalsClipRegion,
|
|
10
9
|
cloneClipRegion,
|
|
11
10
|
copyClipRegion,
|
|
12
11
|
createClipRegionFromCircle,
|
|
@@ -15,6 +14,7 @@ import {
|
|
|
15
14
|
createClipRegionFromPath,
|
|
16
15
|
createClipRegionFromRectangle,
|
|
17
16
|
createClipRegionFromRoundedRectangle,
|
|
17
|
+
equalsClipRegion,
|
|
18
18
|
getClipRegionBounds,
|
|
19
19
|
intersectClipRegions,
|
|
20
20
|
invalidateClipRegion,
|
|
@@ -503,27 +503,41 @@ describe('releaseClipRegion', () => {
|
|
|
503
503
|
});
|
|
504
504
|
|
|
505
505
|
describe('setClipRegionReleaseGuard', () => {
|
|
506
|
-
it('
|
|
507
|
-
const
|
|
508
|
-
setClipRegionReleaseGuard((
|
|
506
|
+
it('reports a double release, which would otherwise corrupt the pool in silence', () => {
|
|
507
|
+
const doubled: number[] = [];
|
|
508
|
+
setClipRegionReleaseGuard(() => doubled.push(1));
|
|
509
509
|
try {
|
|
510
510
|
const region = acquireClipRegion();
|
|
511
511
|
releaseClipRegion(region);
|
|
512
512
|
releaseClipRegion(region);
|
|
513
|
-
expect(
|
|
513
|
+
expect(doubled.length).toBe(1);
|
|
514
514
|
} finally {
|
|
515
515
|
setClipRegionReleaseGuard(null);
|
|
516
|
+
// Undo the damage this test deliberately caused: the region is now in the pool TWICE, and both
|
|
517
|
+
// copies must be drawn out or a later test acquires the same object twice and sees phantom double
|
|
518
|
+
// releases. That leak is precisely the corruption the guard reports, so leaving it would be ironic
|
|
519
|
+
// as well as wrong.
|
|
520
|
+
acquireClipRegion();
|
|
521
|
+
acquireClipRegion();
|
|
516
522
|
}
|
|
517
523
|
});
|
|
518
524
|
|
|
519
|
-
it('
|
|
520
|
-
const
|
|
521
|
-
setClipRegionReleaseGuard((
|
|
522
|
-
|
|
525
|
+
it('stays silent for correctly paired acquire/release, and once uninstalled', () => {
|
|
526
|
+
const doubled: number[] = [];
|
|
527
|
+
setClipRegionReleaseGuard(() => doubled.push(1));
|
|
528
|
+
try {
|
|
529
|
+
releaseClipRegion(acquireClipRegion());
|
|
530
|
+
releaseClipRegion(acquireClipRegion());
|
|
531
|
+
} finally {
|
|
532
|
+
setClipRegionReleaseGuard(null);
|
|
533
|
+
}
|
|
534
|
+
expect(doubled).toEqual([]);
|
|
535
|
+
|
|
536
|
+
// Uninstalled: the pool is still corrupted by a double release, but nothing is reported.
|
|
523
537
|
const region = acquireClipRegion();
|
|
524
538
|
releaseClipRegion(region);
|
|
525
539
|
releaseClipRegion(region);
|
|
526
|
-
expect(
|
|
540
|
+
expect(doubled).toEqual([]);
|
|
527
541
|
});
|
|
528
542
|
});
|
|
529
543
|
|
|
@@ -17,13 +17,13 @@ function captureLog(run: () => void): readonly LogEntry[] {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
describe('disableClipGuards', () => {
|
|
20
|
-
it('uninstalls the guard so a
|
|
20
|
+
it('uninstalls the guard, so a double release goes back to being silent', () => {
|
|
21
21
|
const entries = captureLog(() => {
|
|
22
22
|
enableClipGuards();
|
|
23
23
|
disableClipGuards();
|
|
24
24
|
const region = acquireClipRegion();
|
|
25
25
|
releaseClipRegion(region);
|
|
26
|
-
releaseClipRegion(region);
|
|
26
|
+
releaseClipRegion(region); // still corrupts the pool; simply no longer reported
|
|
27
27
|
});
|
|
28
28
|
expect(entries.length).toBe(0);
|
|
29
29
|
});
|