wyreframe 0.1.0 → 0.1.5

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.
Files changed (58) hide show
  1. package/LICENSE +692 -0
  2. package/README.md +65 -5
  3. package/package.json +8 -7
  4. package/src/index.ts +425 -0
  5. package/src/renderer/Renderer.gen.tsx +49 -0
  6. package/src/renderer/Renderer.mjs +41 -1
  7. package/src/renderer/Renderer.res +78 -0
  8. package/src/parser/Core/__tests__/Bounds_test.mjs +0 -326
  9. package/src/parser/Core/__tests__/Bounds_test.res +0 -412
  10. package/src/parser/Core/__tests__/Grid_test.mjs +0 -322
  11. package/src/parser/Core/__tests__/Grid_test.res +0 -319
  12. package/src/parser/Core/__tests__/Types_test.mjs +0 -614
  13. package/src/parser/Core/__tests__/Types_test.res +0 -650
  14. package/src/parser/Detector/__tests__/BoxTracer_test.mjs +0 -70
  15. package/src/parser/Detector/__tests__/BoxTracer_test.res +0 -92
  16. package/src/parser/Detector/__tests__/HierarchyBuilder_test.mjs +0 -489
  17. package/src/parser/Detector/__tests__/HierarchyBuilder_test.res +0 -849
  18. package/src/parser/Detector/__tests__/ShapeDetector_test.mjs +0 -377
  19. package/src/parser/Detector/__tests__/ShapeDetector_test.res +0 -563
  20. package/src/parser/Interactions/__tests__/InteractionMerger_test.mjs +0 -576
  21. package/src/parser/Interactions/__tests__/InteractionMerger_test.res +0 -646
  22. package/src/parser/Scanner/__tests__/Grid_manual.mjs +0 -214
  23. package/src/parser/Scanner/__tests__/Grid_manual.res +0 -141
  24. package/src/parser/Semantic/Elements/__tests__/ButtonParser_test.mjs +0 -189
  25. package/src/parser/Semantic/Elements/__tests__/ButtonParser_test.res +0 -257
  26. package/src/parser/Semantic/Elements/__tests__/CheckboxParser_test.mjs +0 -202
  27. package/src/parser/Semantic/Elements/__tests__/CheckboxParser_test.res +0 -250
  28. package/src/parser/Semantic/Elements/__tests__/CodeTextParser_manual.mjs +0 -293
  29. package/src/parser/Semantic/Elements/__tests__/CodeTextParser_manual.res +0 -134
  30. package/src/parser/Semantic/Elements/__tests__/InputParser_test.mjs +0 -253
  31. package/src/parser/Semantic/Elements/__tests__/InputParser_test.res +0 -304
  32. package/src/parser/Semantic/Elements/__tests__/LinkParser_test.mjs +0 -289
  33. package/src/parser/Semantic/Elements/__tests__/LinkParser_test.res +0 -402
  34. package/src/parser/Semantic/Elements/__tests__/TextParser_test.mjs +0 -149
  35. package/src/parser/Semantic/Elements/__tests__/TextParser_test.res +0 -167
  36. package/src/parser/Semantic/__tests__/ASTBuilder_test.mjs +0 -187
  37. package/src/parser/Semantic/__tests__/ASTBuilder_test.res +0 -192
  38. package/src/parser/Semantic/__tests__/ParserRegistry_test.mjs +0 -154
  39. package/src/parser/Semantic/__tests__/ParserRegistry_test.res +0 -191
  40. package/src/parser/Semantic/__tests__/SemanticParser_integration_test.mjs +0 -768
  41. package/src/parser/Semantic/__tests__/SemanticParser_integration_test.res +0 -1069
  42. package/src/parser/Semantic/__tests__/SemanticParser_manual.mjs +0 -1329
  43. package/src/parser/Semantic/__tests__/SemanticParser_manual.res +0 -544
  44. package/src/parser/__tests__/GridScanner_integration.test.mjs +0 -632
  45. package/src/parser/__tests__/GridScanner_integration.test.res +0 -816
  46. package/src/parser/__tests__/Performance.test.mjs +0 -244
  47. package/src/parser/__tests__/Performance.test.res +0 -371
  48. package/src/parser/__tests__/PerformanceFixtures.mjs +0 -200
  49. package/src/parser/__tests__/PerformanceFixtures.res +0 -284
  50. package/src/parser/__tests__/WyreframeParser_integration.test.mjs +0 -770
  51. package/src/parser/__tests__/WyreframeParser_integration.test.res +0 -1008
  52. package/src/parser/__tests__/fixtures/alignment-test.txt +0 -9
  53. package/src/parser/__tests__/fixtures/all-elements.txt +0 -16
  54. package/src/parser/__tests__/fixtures/login-scene.txt +0 -17
  55. package/src/parser/__tests__/fixtures/multi-scene.txt +0 -25
  56. package/src/parser/__tests__/fixtures/nested-boxes.txt +0 -15
  57. package/src/parser/__tests__/fixtures/simple-box.txt +0 -5
  58. package/src/parser/__tests__/fixtures/with-dividers.txt +0 -14
@@ -1,412 +0,0 @@
1
- // Bounds_test.res
2
- // Comprehensive unit tests for Bounds module covering all functions and edge cases
3
-
4
- open Vitest
5
-
6
- describe("Bounds.make", () => {
7
- test("creates valid bounds when top < bottom and left < right", t => {
8
- let result = Bounds.make(~top=0, ~left=0, ~bottom=10, ~right=10)
9
-
10
- switch result {
11
- | Some(bounds) => {
12
- t->expect(bounds.top)->Expect.toBe(0)
13
- t->expect(bounds.left)->Expect.toBe(0)
14
- t->expect(bounds.bottom)->Expect.toBe(10)
15
- t->expect(bounds.right)->Expect.toBe(10)
16
- }
17
- | None => t->expect(true)->Expect.toBe(false) // fail
18
- }
19
- })
20
-
21
- test("returns None when top >= bottom", t => {
22
- let result = Bounds.make(~top=10, ~left=0, ~bottom=10, ~right=10)
23
- t->expect(result)->Expect.toBe(None)
24
- })
25
-
26
- test("returns None when top > bottom", t => {
27
- let result = Bounds.make(~top=15, ~left=0, ~bottom=10, ~right=10)
28
- t->expect(result)->Expect.toBe(None)
29
- })
30
-
31
- test("returns None when left >= right", t => {
32
- let result = Bounds.make(~top=0, ~left=10, ~bottom=10, ~right=10)
33
- t->expect(result)->Expect.toBe(None)
34
- })
35
-
36
- test("returns None when left > right", t => {
37
- let result = Bounds.make(~top=0, ~left=15, ~bottom=10, ~right=10)
38
- t->expect(result)->Expect.toBe(None)
39
- })
40
-
41
- test("handles negative coordinates", t => {
42
- let result = Bounds.make(~top=-10, ~left=-10, ~bottom=0, ~right=0)
43
-
44
- switch result {
45
- | Some(bounds) => {
46
- t->expect(bounds.top)->Expect.toBe(-10)
47
- t->expect(bounds.left)->Expect.toBe(-10)
48
- t->expect(bounds.bottom)->Expect.toBe(0)
49
- t->expect(bounds.right)->Expect.toBe(0)
50
- }
51
- | None => t->expect(true)->Expect.toBe(false) // fail
52
- }
53
- })
54
-
55
- test("creates minimal 1x1 bounds", t => {
56
- let result = Bounds.make(~top=0, ~left=0, ~bottom=1, ~right=1)
57
-
58
- switch result {
59
- | Some(bounds) => {
60
- t->expect(Bounds.width(bounds))->Expect.toBe(1)
61
- t->expect(Bounds.height(bounds))->Expect.toBe(1)
62
- }
63
- | None => t->expect(true)->Expect.toBe(false) // fail
64
- }
65
- })
66
- })
67
-
68
- describe("Bounds.width", () => {
69
- test("calculates width correctly", t => {
70
- let bounds = Bounds.make(~top=0, ~left=0, ~bottom=10, ~right=20)->Option.getExn
71
- t->expect(Bounds.width(bounds))->Expect.toBe(20)
72
- })
73
-
74
- test("calculates width for single column", t => {
75
- let bounds = Bounds.make(~top=0, ~left=5, ~bottom=10, ~right=6)->Option.getExn
76
- t->expect(Bounds.width(bounds))->Expect.toBe(1)
77
- })
78
-
79
- test("handles negative coordinates", t => {
80
- let bounds = Bounds.make(~top=0, ~left=-5, ~bottom=10, ~right=5)->Option.getExn
81
- t->expect(Bounds.width(bounds))->Expect.toBe(10)
82
- })
83
-
84
- test("calculates width for large bounds", t => {
85
- let bounds = Bounds.make(~top=0, ~left=0, ~bottom=10, ~right=1000)->Option.getExn
86
- t->expect(Bounds.width(bounds))->Expect.toBe(1000)
87
- })
88
- })
89
-
90
- describe("Bounds.height", () => {
91
- test("calculates height correctly", t => {
92
- let bounds = Bounds.make(~top=0, ~left=0, ~bottom=15, ~right=10)->Option.getExn
93
- t->expect(Bounds.height(bounds))->Expect.toBe(15)
94
- })
95
-
96
- test("calculates height for single row", t => {
97
- let bounds = Bounds.make(~top=5, ~left=0, ~bottom=6, ~right=10)->Option.getExn
98
- t->expect(Bounds.height(bounds))->Expect.toBe(1)
99
- })
100
-
101
- test("handles negative coordinates", t => {
102
- let bounds = Bounds.make(~top=-5, ~left=0, ~bottom=5, ~right=10)->Option.getExn
103
- t->expect(Bounds.height(bounds))->Expect.toBe(10)
104
- })
105
-
106
- test("calculates height for tall bounds", t => {
107
- let bounds = Bounds.make(~top=0, ~left=0, ~bottom=1000, ~right=10)->Option.getExn
108
- t->expect(Bounds.height(bounds))->Expect.toBe(1000)
109
- })
110
- })
111
-
112
- describe("Bounds.area", () => {
113
- test("calculates area correctly", t => {
114
- let bounds = Bounds.make(~top=0, ~left=0, ~bottom=10, ~right=20)->Option.getExn
115
- t->expect(Bounds.area(bounds))->Expect.toBe(200)
116
- })
117
-
118
- test("calculates area for 1x1 box", t => {
119
- let bounds = Bounds.make(~top=0, ~left=0, ~bottom=1, ~right=1)->Option.getExn
120
- t->expect(Bounds.area(bounds))->Expect.toBe(1)
121
- })
122
-
123
- test("calculates area for narrow box", t => {
124
- let bounds = Bounds.make(~top=0, ~left=0, ~bottom=100, ~right=1)->Option.getExn
125
- t->expect(Bounds.area(bounds))->Expect.toBe(100)
126
- })
127
-
128
- test("calculates area for wide box", t => {
129
- let bounds = Bounds.make(~top=0, ~left=0, ~bottom=1, ~right=100)->Option.getExn
130
- t->expect(Bounds.area(bounds))->Expect.toBe(100)
131
- })
132
-
133
- test("calculates area with negative coordinates", t => {
134
- let bounds = Bounds.make(~top=-10, ~left=-20, ~bottom=10, ~right=20)->Option.getExn
135
- // width = 20 - (-20) = 40, height = 10 - (-10) = 20
136
- t->expect(Bounds.area(bounds))->Expect.toBe(800)
137
- })
138
-
139
- test("calculates area for very large bounds", t => {
140
- let bounds = Bounds.make(~top=0, ~left=0, ~bottom=1000, ~right=1000)->Option.getExn
141
- t->expect(Bounds.area(bounds))->Expect.toBe(1000000)
142
- })
143
- })
144
-
145
- describe("Bounds.contains", () => {
146
- test("returns true when outer completely contains inner", t => {
147
- let outer = Bounds.make(~top=0, ~left=0, ~bottom=20, ~right=20)->Option.getExn
148
- let inner = Bounds.make(~top=5, ~left=5, ~bottom=15, ~right=15)->Option.getExn
149
-
150
- t->expect(Bounds.contains(outer, inner))->Expect.toBe(true)
151
- })
152
-
153
- test("returns false when boxes are equal", t => {
154
- let a = Bounds.make(~top=0, ~left=0, ~bottom=10, ~right=10)->Option.getExn
155
- let b = Bounds.make(~top=0, ~left=0, ~bottom=10, ~right=10)->Option.getExn
156
-
157
- t->expect(Bounds.contains(a, b))->Expect.toBe(false)
158
- })
159
-
160
- test("returns false when inner top edge touches outer top edge", t => {
161
- let outer = Bounds.make(~top=0, ~left=0, ~bottom=20, ~right=20)->Option.getExn
162
- let inner = Bounds.make(~top=0, ~left=5, ~bottom=15, ~right=15)->Option.getExn
163
-
164
- t->expect(Bounds.contains(outer, inner))->Expect.toBe(false)
165
- })
166
-
167
- test("returns false when inner left edge touches outer left edge", t => {
168
- let outer = Bounds.make(~top=0, ~left=0, ~bottom=20, ~right=20)->Option.getExn
169
- let inner = Bounds.make(~top=5, ~left=0, ~bottom=15, ~right=15)->Option.getExn
170
-
171
- t->expect(Bounds.contains(outer, inner))->Expect.toBe(false)
172
- })
173
-
174
- test("returns false when inner bottom edge touches outer bottom edge", t => {
175
- let outer = Bounds.make(~top=0, ~left=0, ~bottom=20, ~right=20)->Option.getExn
176
- let inner = Bounds.make(~top=5, ~left=5, ~bottom=20, ~right=15)->Option.getExn
177
-
178
- t->expect(Bounds.contains(outer, inner))->Expect.toBe(false)
179
- })
180
-
181
- test("returns false when inner right edge touches outer right edge", t => {
182
- let outer = Bounds.make(~top=0, ~left=0, ~bottom=20, ~right=20)->Option.getExn
183
- let inner = Bounds.make(~top=5, ~left=5, ~bottom=15, ~right=20)->Option.getExn
184
-
185
- t->expect(Bounds.contains(outer, inner))->Expect.toBe(false)
186
- })
187
-
188
- test("returns false when boxes are disjoint", t => {
189
- let a = Bounds.make(~top=0, ~left=0, ~bottom=10, ~right=10)->Option.getExn
190
- let b = Bounds.make(~top=20, ~left=20, ~bottom=30, ~right=30)->Option.getExn
191
-
192
- t->expect(Bounds.contains(a, b))->Expect.toBe(false)
193
- })
194
-
195
- test("returns false when inner is larger than outer", t => {
196
- let outer = Bounds.make(~top=5, ~left=5, ~bottom=15, ~right=15)->Option.getExn
197
- let inner = Bounds.make(~top=0, ~left=0, ~bottom=20, ~right=20)->Option.getExn
198
-
199
- t->expect(Bounds.contains(outer, inner))->Expect.toBe(false)
200
- })
201
-
202
- test("returns false when boxes partially overlap", t => {
203
- let a = Bounds.make(~top=0, ~left=0, ~bottom=15, ~right=15)->Option.getExn
204
- let b = Bounds.make(~top=10, ~left=10, ~bottom=20, ~right=20)->Option.getExn
205
-
206
- t->expect(Bounds.contains(a, b))->Expect.toBe(false)
207
- })
208
-
209
- test("handles negative coordinates correctly", t => {
210
- let outer = Bounds.make(~top=-20, ~left=-20, ~bottom=20, ~right=20)->Option.getExn
211
- let inner = Bounds.make(~top=-5, ~left=-5, ~bottom=5, ~right=5)->Option.getExn
212
-
213
- t->expect(Bounds.contains(outer, inner))->Expect.toBe(true)
214
- })
215
-
216
- test("returns true when inner is minimal 1-pixel margin inside outer", t => {
217
- let outer = Bounds.make(~top=0, ~left=0, ~bottom=10, ~right=10)->Option.getExn
218
- let inner = Bounds.make(~top=1, ~left=1, ~bottom=9, ~right=9)->Option.getExn
219
-
220
- t->expect(Bounds.contains(outer, inner))->Expect.toBe(true)
221
- })
222
- })
223
-
224
- describe("Bounds.overlaps", () => {
225
- test("returns true when boxes partially overlap", t => {
226
- let a = Bounds.make(~top=0, ~left=0, ~bottom=15, ~right=15)->Option.getExn
227
- let b = Bounds.make(~top=10, ~left=10, ~bottom=20, ~right=20)->Option.getExn
228
-
229
- t->expect(Bounds.overlaps(a, b))->Expect.toBe(true)
230
- })
231
-
232
- test("returns true when one box completely contains another", t => {
233
- let outer = Bounds.make(~top=0, ~left=0, ~bottom=20, ~right=20)->Option.getExn
234
- let inner = Bounds.make(~top=5, ~left=5, ~bottom=15, ~right=15)->Option.getExn
235
-
236
- t->expect(Bounds.overlaps(outer, inner))->Expect.toBe(true)
237
- t->expect(Bounds.overlaps(inner, outer))->Expect.toBe(true)
238
- })
239
-
240
- test("returns true when boxes are equal", t => {
241
- let a = Bounds.make(~top=0, ~left=0, ~bottom=10, ~right=10)->Option.getExn
242
- let b = Bounds.make(~top=0, ~left=0, ~bottom=10, ~right=10)->Option.getExn
243
-
244
- t->expect(Bounds.overlaps(a, b))->Expect.toBe(true)
245
- })
246
-
247
- test("returns false when boxes are disjoint horizontally", t => {
248
- let a = Bounds.make(~top=0, ~left=0, ~bottom=10, ~right=10)->Option.getExn
249
- let b = Bounds.make(~top=0, ~left=20, ~bottom=10, ~right=30)->Option.getExn
250
-
251
- t->expect(Bounds.overlaps(a, b))->Expect.toBe(false)
252
- })
253
-
254
- test("returns false when boxes are disjoint vertically", t => {
255
- let a = Bounds.make(~top=0, ~left=0, ~bottom=10, ~right=10)->Option.getExn
256
- let b = Bounds.make(~top=20, ~left=0, ~bottom=30, ~right=10)->Option.getExn
257
-
258
- t->expect(Bounds.overlaps(a, b))->Expect.toBe(false)
259
- })
260
-
261
- test("returns false when boxes touch at edges horizontally", t => {
262
- let a = Bounds.make(~top=0, ~left=0, ~bottom=10, ~right=10)->Option.getExn
263
- let b = Bounds.make(~top=0, ~left=10, ~bottom=10, ~right=20)->Option.getExn
264
-
265
- t->expect(Bounds.overlaps(a, b))->Expect.toBe(false)
266
- })
267
-
268
- test("returns false when boxes touch at edges vertically", t => {
269
- let a = Bounds.make(~top=0, ~left=0, ~bottom=10, ~right=10)->Option.getExn
270
- let b = Bounds.make(~top=10, ~left=0, ~bottom=20, ~right=10)->Option.getExn
271
-
272
- t->expect(Bounds.overlaps(a, b))->Expect.toBe(false)
273
- })
274
-
275
- test("returns false when boxes are completely separated", t => {
276
- let a = Bounds.make(~top=0, ~left=0, ~bottom=5, ~right=5)->Option.getExn
277
- let b = Bounds.make(~top=10, ~left=10, ~bottom=15, ~right=15)->Option.getExn
278
-
279
- t->expect(Bounds.overlaps(a, b))->Expect.toBe(false)
280
- })
281
-
282
- test("returns true when boxes overlap at corner", t => {
283
- let a = Bounds.make(~top=0, ~left=0, ~bottom=11, ~right=11)->Option.getExn
284
- let b = Bounds.make(~top=10, ~left=10, ~bottom=20, ~right=20)->Option.getExn
285
-
286
- t->expect(Bounds.overlaps(a, b))->Expect.toBe(true)
287
- })
288
-
289
- test("returns true for L-shaped overlap", t => {
290
- let a = Bounds.make(~top=0, ~left=0, ~bottom=15, ~right=10)->Option.getExn
291
- let b = Bounds.make(~top=5, ~left=5, ~bottom=10, ~right=20)->Option.getExn
292
-
293
- t->expect(Bounds.overlaps(a, b))->Expect.toBe(true)
294
- })
295
-
296
- test("returns true for T-shaped overlap", t => {
297
- let a = Bounds.make(~top=0, ~left=5, ~bottom=10, ~right=15)->Option.getExn
298
- let b = Bounds.make(~top=5, ~left=0, ~bottom=15, ~right=20)->Option.getExn
299
-
300
- t->expect(Bounds.overlaps(a, b))->Expect.toBe(true)
301
- })
302
-
303
- test("handles negative coordinates correctly", t => {
304
- let a = Bounds.make(~top=-10, ~left=-10, ~bottom=0, ~right=0)->Option.getExn
305
- let b = Bounds.make(~top=-5, ~left=-5, ~bottom=5, ~right=5)->Option.getExn
306
-
307
- t->expect(Bounds.overlaps(a, b))->Expect.toBe(true)
308
- })
309
-
310
- test("returns false for disjoint bounds with negative coordinates", t => {
311
- let a = Bounds.make(~top=-20, ~left=-20, ~bottom=-10, ~right=-10)->Option.getExn
312
- let b = Bounds.make(~top=10, ~left=10, ~bottom=20, ~right=20)->Option.getExn
313
-
314
- t->expect(Bounds.overlaps(a, b))->Expect.toBe(false)
315
- })
316
-
317
- test("is symmetric (order doesn't matter)", t => {
318
- let a = Bounds.make(~top=0, ~left=0, ~bottom=10, ~right=10)->Option.getExn
319
- let b = Bounds.make(~top=5, ~left=5, ~bottom=15, ~right=15)->Option.getExn
320
-
321
- t->expect(Bounds.overlaps(a, b))->Expect.toBe(Bounds.overlaps(b, a))
322
- })
323
- })
324
-
325
- describe("Bounds.toString", () => {
326
- test("formats bounds as string correctly", t => {
327
- let bounds = Bounds.make(~top=1, ~left=2, ~bottom=10, ~right=20)->Option.getExn
328
- let str = Bounds.toString(bounds)
329
-
330
- t->expect(str)->Expect.toBe("Bounds{top: 1, left: 2, bottom: 10, right: 20}")
331
- })
332
-
333
- test("handles negative coordinates in string", t => {
334
- let bounds = Bounds.make(~top=-5, ~left=-10, ~bottom=5, ~right=10)->Option.getExn
335
- let str = Bounds.toString(bounds)
336
-
337
- t->expect(str)->Expect.toBe("Bounds{top: -5, left: -10, bottom: 5, right: 10}")
338
- })
339
- })
340
-
341
- describe("Bounds.equals", () => {
342
- test("returns true for equal bounds", t => {
343
- let a = Bounds.make(~top=0, ~left=0, ~bottom=10, ~right=10)->Option.getExn
344
- let b = Bounds.make(~top=0, ~left=0, ~bottom=10, ~right=10)->Option.getExn
345
-
346
- t->expect(Bounds.equals(a, b))->Expect.toBe(true)
347
- })
348
-
349
- test("returns false for different bounds", t => {
350
- let a = Bounds.make(~top=0, ~left=0, ~bottom=10, ~right=10)->Option.getExn
351
- let b = Bounds.make(~top=0, ~left=0, ~bottom=10, ~right=11)->Option.getExn
352
-
353
- t->expect(Bounds.equals(a, b))->Expect.toBe(false)
354
- })
355
-
356
- test("returns false when only one field differs", t => {
357
- let base = Bounds.make(~top=0, ~left=0, ~bottom=10, ~right=10)->Option.getExn
358
-
359
- let diffTop = Bounds.make(~top=1, ~left=0, ~bottom=10, ~right=10)->Option.getExn
360
- t->expect(Bounds.equals(base, diffTop))->Expect.toBe(false)
361
-
362
- let diffLeft = Bounds.make(~top=0, ~left=1, ~bottom=10, ~right=10)->Option.getExn
363
- t->expect(Bounds.equals(base, diffLeft))->Expect.toBe(false)
364
-
365
- let diffBottom = Bounds.make(~top=0, ~left=0, ~bottom=11, ~right=10)->Option.getExn
366
- t->expect(Bounds.equals(base, diffBottom))->Expect.toBe(false)
367
-
368
- let diffRight = Bounds.make(~top=0, ~left=0, ~bottom=10, ~right=11)->Option.getExn
369
- t->expect(Bounds.equals(base, diffRight))->Expect.toBe(false)
370
- })
371
- })
372
-
373
- describe("Bounds edge cases", () => {
374
- test("handles zero-width bounds validation", t => {
375
- let result = Bounds.make(~top=0, ~left=5, ~bottom=10, ~right=5)
376
- t->expect(result)->Expect.toBe(None)
377
- })
378
-
379
- test("handles zero-height bounds validation", t => {
380
- let result = Bounds.make(~top=5, ~left=0, ~bottom=5, ~right=10)
381
- t->expect(result)->Expect.toBe(None)
382
- })
383
-
384
- test("handles inverted bounds", t => {
385
- let result = Bounds.make(~top=10, ~left=0, ~bottom=5, ~right=10)
386
- t->expect(result)->Expect.toBe(None)
387
- })
388
-
389
- test("handles very large coordinate values", t => {
390
- let bounds = Bounds.make(~top=0, ~left=0, ~bottom=1000000, ~right=1000000)->Option.getExn
391
- t->expect(Bounds.area(bounds))->Expect.toBe(1000000000000)
392
- })
393
-
394
- test("handles single pixel bounds", t => {
395
- let bounds = Bounds.make(~top=0, ~left=0, ~bottom=1, ~right=1)->Option.getExn
396
- t->expect(Bounds.width(bounds))->Expect.toBe(1)
397
- t->expect(Bounds.height(bounds))->Expect.toBe(1)
398
- t->expect(Bounds.area(bounds))->Expect.toBe(1)
399
- })
400
-
401
- test("handles thin horizontal line", t => {
402
- let bounds = Bounds.make(~top=0, ~left=0, ~bottom=1, ~right=100)->Option.getExn
403
- t->expect(Bounds.height(bounds))->Expect.toBe(1)
404
- t->expect(Bounds.area(bounds))->Expect.toBe(100)
405
- })
406
-
407
- test("handles thin vertical line", t => {
408
- let bounds = Bounds.make(~top=0, ~left=0, ~bottom=100, ~right=1)->Option.getExn
409
- t->expect(Bounds.width(bounds))->Expect.toBe(1)
410
- t->expect(Bounds.area(bounds))->Expect.toBe(100)
411
- })
412
- })