Repository navigation
Expand file tree
/
Copy pathtests-massive-main.html
More file actions
3347 lines (3204 loc) · 173 KB
/
Copy pathtests-massive-main.html
File metadata and controls
3347 lines (3204 loc) · 173 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LSP D-Planner — Massive Test Suite</title>
<link href="vendor/fonts/fonts.css" rel="stylesheet">
<style>
:root {
--bg: #07111d;
--surface: #0d1a2a;
--surface-2: #112238;
--surface-3: #162a45;
--border: rgba(0,217,255,0.14);
--border-hi: rgba(0,217,255,0.32);
--text: #dbf4ff;
--muted: #7ea7bd;
--faint: #4f7185;
--accent: #00d9ff;
--green: #26d07c;
--yellow: #ffb703;
--orange: #ff8a00;
--red: #ff4757;
--mag: #e040fb;
--radius: 12px;
--shadow: 0 12px 32px rgba(0,0,0,0.28);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
min-height: 100vh;
background:
radial-gradient(circle at top left, rgba(0,217,255,0.09), transparent 35%),
radial-gradient(circle at top right, rgba(224,64,251,0.08), transparent 28%),
linear-gradient(180deg, #050d17 0%, #07111d 100%);
color: var(--text);
font-family: 'Outfit', sans-serif;
padding: 24px;
}
.container { max-width: 1500px; margin: 0 auto; }
.header { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.title h1 { font-family: 'Bebas Neue', sans-serif; letter-spacing: 3px; font-size: clamp(2rem,4vw,3.25rem); line-height: 0.95; color: var(--accent); }
.title p { margin-top: 8px; color: var(--muted); font-family: 'JetBrains Mono', monospace; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; }
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
button {
border: 1px solid var(--border-hi);
background: linear-gradient(180deg, rgba(0,217,255,0.12), rgba(0,217,255,0.05));
color: var(--accent); border-radius: 10px; padding: 10px 18px; cursor: pointer;
font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700;
letter-spacing: 1px; text-transform: uppercase;
transition: transform 160ms, box-shadow 160ms, opacity 160ms;
}
button:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(0,217,255,0.12); }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.secondary-btn { background: rgba(255,255,255,0.03); color: var(--muted); border-color: rgba(255,255,255,0.1); }
/* filter row */
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-chip {
padding: 5px 12px; border-radius: 999px; font-size: 11px; font-family: 'JetBrains Mono', monospace;
font-weight: 700; letter-spacing: 1px; text-transform: uppercase; cursor: pointer;
border: 1px solid; transition: background 120ms;
}
.filter-chip.active { background: rgba(0,217,255,0.18); color: var(--accent); border-color: var(--accent); }
.filter-chip.inactive { background: rgba(255,255,255,0.03); color: var(--muted); border-color: rgba(255,255,255,0.1); }
/* status bar */
.status-bar {
background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
padding: 14px 16px; display: flex; justify-content: space-between; align-items: center;
gap: 12px; flex-wrap: wrap; margin-bottom: 18px; box-shadow: var(--shadow);
}
#status { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--muted); }
#status.ready { color: var(--green); }
#status.error { color: var(--red); }
#status.warn { color: var(--yellow); }
#status.running { color: var(--accent); }
.meta { display: flex; gap: 14px; flex-wrap: wrap; font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--faint); }
/* progress */
.progress-wrap { margin-bottom: 16px; display: none; }
.progress-bar-bg { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--mag)); transition: width 80ms; }
.progress-label { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--muted); margin-top: 5px; }
/* summary */
.summary {
display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
gap: 12px; margin-bottom: 18px;
}
.card {
background: var(--surface); border: 1px solid var(--border);
border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.summary .card { padding: 18px 16px; }
.sum-val { font-family: 'Bebas Neue', sans-serif; font-size: 2.2rem; line-height: 1; }
.sum-val.pass { color: var(--green); }
.sum-val.fail { color: var(--red); }
.sum-val.warn { color: var(--yellow); }
.sum-val.info { color: var(--accent); }
.sum-lbl { margin-top: 6px; color: var(--muted); font-family: 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; }
/* layout */
.layout { display: grid; grid-template-columns: 280px 1fr; gap: 18px; }
.sidebar .card + .card { margin-top: 18px; }
.card h2 { font-family: 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--accent); margin-bottom: 12px; }
.metric-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 13px; }
.metric-row:last-child { border-bottom: none; }
.metric-row span:last-child { color: var(--muted); font-family: 'JetBrains Mono', monospace; font-size: 12px; }
/* groups */
.results-wrap { display: flex; flex-direction: column; gap: 16px; }
.group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.group[data-tier="1"] { border-color: rgba(0,217,255,0.20); }
.group[data-tier="2"] { border-color: rgba(38,208,124,0.20); }
.group[data-tier="3"] { border-color: rgba(255,138,0,0.20); }
.group-header {
display: flex; justify-content: space-between; align-items: center; gap: 12px;
padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,0.05); flex-wrap: wrap;
}
.group[data-tier="1"] .group-header { background: linear-gradient(180deg, rgba(0,217,255,0.08), rgba(0,217,255,0.02)); }
.group[data-tier="2"] .group-header { background: linear-gradient(180deg, rgba(38,208,124,0.08), rgba(38,208,124,0.02)); }
.group[data-tier="3"] .group-header { background: linear-gradient(180deg, rgba(255,138,0,0.08), rgba(255,138,0,0.02)); }
.group-title { font-family: 'JetBrains Mono', monospace; font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--accent); }
.group[data-tier="2"] .group-title { color: var(--green); }
.group[data-tier="3"] .group-title { color: var(--orange); }
.group-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.group-badge { font-family: 'JetBrains Mono', monospace; font-size: 11px; border-radius: 999px; padding: 4px 9px; border: 1px solid; }
.group-badge.pass { color: var(--green); border-color: rgba(38,208,124,0.35); background: rgba(38,208,124,0.08); }
.group-badge.fail { color: var(--red); border-color: rgba(255,71,87,0.35); background: rgba(255,71,87,0.08); }
.group-badge.warn { color: var(--yellow); border-color: rgba(255,183,3,0.35); background: rgba(255,183,3,0.08); }
.tier-label { font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 1px; color: var(--faint); border: 1px solid rgba(255,255,255,0.08); border-radius: 999px; padding: 3px 8px; }
/* test rows */
.test-row {
display: grid;
grid-template-columns: 28px minmax(200px,1.2fr) minmax(260px,1.8fr) 110px 90px;
gap: 10px; align-items: start; padding: 10px 16px;
border-bottom: 1px solid rgba(255,255,255,0.04);
}
.test-row:last-child { border-bottom: none; }
.test-row.fail { background: rgba(255,71,87,0.04); }
.icon { font-size: 14px; line-height: 1.1; margin-top: 2px; }
.icon.pass { color: var(--green); }
.icon.fail { color: var(--red); }
.icon.warn { color: var(--yellow); }
.test-name { font-size: 13px; color: var(--text); line-height: 1.45; }
.test-detail { font-size: 11px; line-height: 1.55; color: var(--muted); font-family: 'JetBrains Mono', monospace; word-break: break-word; }
.test-detail.fail { color: #ff9aa4; }
.test-model { justify-self: end; font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); border: 1px solid rgba(255,255,255,0.08); border-radius: 999px; padding: 3px 8px; }
.test-time { justify-self: end; font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--faint); }
/* collapsible groups */
.group-body { }
.group-header { cursor: pointer; user-select: none; }
.group-header::after { content: '▾'; font-size: 14px; color: var(--faint); margin-left: 6px; transition: transform 160ms; }
.group.collapsed .group-header::after { transform: rotate(-90deg); }
.group.collapsed .group-body { display: none; }
iframe { display: none; }
.footer-note { margin-top: 18px; color: var(--faint); font-size: 12px; line-height: 1.6; }
@media (max-width: 1100px) { .layout { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
body { padding: 12px; }
.test-row { grid-template-columns: 24px 1fr; }
.test-detail, .test-model, .test-time { grid-column: 2 / -1; justify-self: start; }
}
</style>
</head>
<body>
<!-- ── file:// detection banner ─────────────────────────────────────────── -->
<div id="file-protocol-banner" style="display:none;position:fixed;top:0;left:0;right:0;z-index:9999;
background:#cc0000;color:#fff;font-family:monospace;font-size:15px;font-weight:700;
padding:18px 24px;text-align:center;line-height:1.5;box-shadow:0 4px 20px rgba(0,0,0,0.6);">
⛔ CANNOT RUN VIA file:// — Iframe cross-origin blocked<br>
<span style="font-size:12px;font-weight:400;">
Open via HTTP: <strong>https://three-cats-lsp.github.io/LSP_D-planner/tests-massive.html</strong><br>
Or locally: <code>python3 -m http.server 8080</code> then open <strong>http://localhost:8080/tests-massive.html</strong>
</span>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
if (location.protocol === 'file:') {
document.getElementById('file-protocol-banner').style.display = 'block';
const btn = document.getElementById('run-btn');
if (btn) { btn.disabled = true; btn.style.opacity = '0.4'; btn.title = 'Cannot run via file:// — use HTTP'; }
}
});
</script>
<div class="container">
<div class="header">
<div class="title">
<h1>LSP D-PLANNER</h1>
<p>Massive regression suite v2.9.0 · 300+ engine plans · UI integration · gas table · slate · surf int · presets · END column · GF UI validation · copy modal · PDF export · TRT slate footer</p>
</div>
<div class="controls">
<button id="run-btn" onclick="startTests()">▶ RUN ALL (incl. engine)</button>
<button class="secondary-btn" onclick="toggleFailOnly()" id="fail-toggle">Failures Only: Off</button>
<button class="secondary-btn" onclick="collapseAll()">Collapse All</button>
<button class="secondary-btn" onclick="expandAll()">Expand All</button>
<button class="secondary-btn" onclick="copyJson()">Copy JSON</button>
<button class="secondary-btn" onclick="exportLog()">⬇ Export Log</button>
</div>
</div>
<div class="filter-row" id="filter-row">
<span style="font-family:'JetBrains Mono',monospace;font-size:11px;color:var(--faint);padding:5px 0;align-self:center;">FILTER:</span>
<span class="filter-chip active" data-filter="all" onclick="setFilter('all')">ALL</span>
<span class="filter-chip inactive" data-filter="tier1" onclick="setFilter('tier1')">TIER 1 ENGINE</span>
<span class="filter-chip inactive" data-filter="tier2" onclick="setFilter('tier2')">TIER 2 UI/DOM</span>
<span class="filter-chip inactive" data-filter="tier3" onclick="setFilter('tier3')">TIER 3 SCENARIOS</span>
<span class="filter-chip inactive" data-filter="ZHLC_GF" onclick="setFilter('ZHLC_GF')">BÜHLMANN (ZHLC_GF)</span>
<span class="filter-chip inactive" data-filter="VPMB" onclick="setFilter('VPMB')">VPM-B</span>
<span class="filter-chip inactive" data-filter="VPMB_GFS" onclick="setFilter('VPMB_GFS')">VPM-B/GFS</span>
<span class="filter-chip inactive" data-filter="fail" onclick="setFilter('fail')">FAILURES</span>
</div>
<div class="status-bar">
<div id="status">Waiting…</div>
<div class="meta">
<span id="meta-version">APP: —</span>
<span id="meta-surface">SURFACEP: —</span>
<span id="meta-bar">BAR/m: —</span>
</div>
</div>
<div class="progress-wrap" id="progress-wrap">
<div class="progress-bar-bg"><div class="progress-bar-fill" id="progress-bar" style="width:0%"></div></div>
<div class="progress-label" id="progress-label">0 / 0</div>
</div>
<div class="summary" id="summary" style="display:none;">
<div class="card"><div class="sum-val pass" id="sum-pass">0</div><div class="sum-lbl">Passed</div></div>
<div class="card"><div class="sum-val fail" id="sum-fail">0</div><div class="sum-lbl">Failed</div></div>
<div class="card"><div class="sum-val warn" id="sum-warn">0</div><div class="sum-lbl">Warnings</div></div>
<div class="card"><div class="sum-val info" id="sum-total">0</div><div class="sum-lbl">Total Tests</div></div>
<div class="card"><div class="sum-val info" id="sum-plans">0</div><div class="sum-lbl">Engine Calls</div></div>
<div class="card"><div class="sum-val info" id="sum-time">0ms</div><div class="sum-lbl">Run Time</div></div>
</div>
<div class="layout">
<aside class="sidebar">
<div class="card">
<h2>Coverage</h2>
<div class="metric-row"><span>Tier 1 — Engine</span><span>350+ plans</span></div>
<div class="metric-row"><span>Bühlmann ZH-L16C</span><span>100 profiles</span></div>
<div class="metric-row"><span>VPM-B</span><span>100 profiles</span></div>
<div class="metric-row"><span>VPM-B/GFS</span><span>100 profiles</span></div>
<div class="metric-row"><span>Conservatism C0–C5</span><span>13 checks</span></div>
<div class="metric-row"><span>Trimix profiles</span><span>TMX21/35, 18/45, 10/70</span></div>
<div class="metric-row"><span>First stop depths</span><span>VPM-B vs ZHL</span></div>
<div class="metric-row"><span>Cross-model ordering</span><span>Maiken invariants</span></div>
<div class="metric-row"><span>Tier 2 — UI/DOM</span><span>algo switching · GF UI · SAC units</span></div>
<div class="metric-row"><span>Tier 3 — Scenarios</span><span>special cases</span></div>
<div class="metric-row"><span>v2.9.0 features</span><span>9 new groups</span></div>
<div class="metric-row"><span>Gas Table</span><span>MOD / MND formulas</span></div>
<div class="metric-row"><span>Deco Slate</span><span>buildSlateText · contingency</span></div>
<div class="metric-row"><span>Surf Int</span><span>main-nav sub-tab</span></div>
<div class="metric-row"><span>Named Presets</span><span>lspPresets · max 20</span></div>
<div class="metric-row"><span>END column</span><span>always visible · no toggle</span></div>
<div class="metric-row"><span>Export order</span><span>Copy·SLATE·TXT·PDF</span></div>
</div>
<div class="card">
<h2>Test Categories</h2>
<div class="metric-row"><span>NDL dives</span><span>no stops expected</span></div>
<div class="metric-row"><span>Deco dives</span><span>stops + runtime</span></div>
<div class="metric-row"><span>Monotonicity</span><span>depth/time/GF order</span></div>
<div class="metric-row"><span>Gas behavior</span><span>nitrox, trimix, O₂</span></div>
<div class="metric-row"><span>CNS / OTU</span><span>numeric sanity</span></div>
<div class="metric-row"><span>Travel gas</span><span>DOM + engine</span></div>
<div class="metric-row"><span>Altitude</span><span>surface P correction</span></div>
<div class="metric-row"><span>Imperial units</span><span>ft / psi / cu ft / SAC conversion</span></div>
<div class="metric-row"><span>GF UI</span><span>VPM-B/GFS High-only mode</span></div>
<div class="metric-row"><span>Multi-dive</span><span>residual loading</span></div>
<div class="metric-row"><span>Edge cases</span><span>5m → 80m, 1min → 180min</span></div>
<div class="metric-row"><span>Determinism</span><span>no state leakage</span></div>
<div class="metric-row"><span>Plan integrity</span><span>segment ordering</span></div>
<div class="metric-row"><span>Conservatism sweep</span><span>C0–C5 monotone</span></div>
<div class="metric-row"><span>Trimix helium</span><span>all 3 models</span></div>
<div class="metric-row"><span>First stop</span><span>VPM-B bubble ceiling</span></div>
<div class="metric-row"><span>TAT ordering</span><span>Maiken cross-model</span></div>
</div>
<div class="card">
<h2>Run Metrics</h2>
<div class="metric-row"><span>Groups</span><span id="metric-groups">—</span></div>
<div class="metric-row"><span>Engine calls</span><span id="metric-calls">—</span></div>
<div class="metric-row"><span>UI checks</span><span id="metric-ui">—</span></div>
<div class="metric-row"><span>Visible rows</span><span id="metric-visible">—</span></div>
<div class="metric-row"><span>Hidden rows</span><span id="metric-hidden">—</span></div>
</div>
</aside>
<main>
<div class="results-wrap" id="results"></div>
<div class="footer-note">
Place this file beside <code>index.html</code> on the same static host. Runs all three tiers automatically on load.
Tier 1 = direct engine calls (no DOM) · Bühlmann · VPM-B · Conservatism · Trimix · First Stop · Cross-model ordering. Tier 2 = live DOM integration via iframe. Tier 3 = special dive scenarios.
</div>
</main>
</div>
</div><!-- .container -->
<iframe id="app-frame" src="about:blank"></iframe>
<script>
'use strict';
// ══════════════════════════════════════════════════════════════════════════════
// GLOBALS
// ══════════════════════════════════════════════════════════════════════════════
let E = null, WIN = null, SURF = 1.01325, BAR = null;
let _suiteRunId = 0;
function refreshFrameWin() {
const frame = document.getElementById('app-frame');
if (!frame) return null;
try {
const w = frame.contentWindow;
if (!w || !w.VPMEngine || typeof w.VPMEngine.calculate !== 'function') return null;
WIN = w;
E = w.VPMEngine;
return w;
} catch (_) {
return null;
}
}
function vpmEngine(w) {
if (E && typeof E.calculate === 'function') return E;
const vpm = (w && w.VPMEngine) || (WIN && WIN.VPMEngine);
if (vpm && typeof vpm.calculate === 'function') {
E = vpm;
return vpm;
}
return null;
}
let ONLY_FAIL = false;
let ACTIVE_FILTER = 'all';
let LAST_RESULTS = null;
let TOTAL_ENGINE_CALLS = 0;
let UI_CHECK_COUNT = 0;
// ══════════════════════════════════════════════════════════════════════════════
// HELPERS
// ══════════════════════════════════════════════════════════════════════════════
function assert(cond, msg) { if (!cond) throw new Error(msg || 'Assertion failed'); }
const assertCond = assert; // alias used in T1-L through T1-O groups
function approx(a, b, tol) { return Math.abs(a - b) <= (tol == null ? 0.01 : tol); }
function finite(v, label) { assert(typeof v === 'number' && isFinite(v), (label||'value') + ' not finite: ' + v); }
function cloneJ(x) { return JSON.parse(JSON.stringify(x)); }
function pr(v, d) { return (typeof v === 'number' && isFinite(v)) ? v.toFixed(d == null ? 1 : d) : String(v); }
function esc(s) {
return String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,''');
}
function modelLabel(m) {
return ({ZHLCGF:'Bühlmann GF', VPMB:'VPM-B', VPMBGFS:'VPM-B/GFS', ALL:'All', CORE:'Core', UI:'DOM/UI', SCN:'Scenario'})[m] || m || '—';
}
// Default settings factory
function S(overrides) {
return Object.assign({
metric: true, waterType: 0, customWaterDensity: 1025,
descentRate: 20, ascentRate: 10, decoAscentRate: 3, surfaceAscentRate: 3,
stepSize: 3, lastStop: 3, minStopTime: 1,
ppO2Bottom: 1.4, ppO2Deco: 1.6,
ppO2Low: 1.4, ppO2Mid: 1.5, ppO2High: 1.6,
o2MaxDepth: 6, conservatism: 0,
gfLo: 30, gfHi: 85, gfs: 85,
firstStop30sec: false, extendedStops: false,
}, overrides || {});
}
// Level / gas helpers
function lv(depth, time, o2, he) { return [{ depth, time, o2: o2 ?? 21, he: he ?? 0 }]; }
function mlv(arr) { return arr.map(x => ({ depth: x.depth, time: x.time, o2: x.o2 ?? 21, he: x.he ?? 0 })); }
function g(o2, he) { return { o2, he: he || 0 }; }
const NG = []; // no gases
const EAN32 = [g(32)];
const EAN50 = [g(50)];
const O2_100 = [g(100)];
const EAN50_O2 = [g(50), g(100)];
const TRIMIX_18_45 = []; // bottom gas only, trimix
const TX_DECO = [g(50), g(100)];
// Engine wrapper — routes ZHLC_GF to ZHLEngine (Bühlmann), all others to VPMEngine
function calc(levels, gases, settings, model) {
TOTAL_ENGINE_CALLS++;
const w = refreshFrameWin() || WIN;
const keepHeadless = !!(w && w._zhlHeadless);
if (w) w._zhlHeadless = true;
let r;
try {
if (model === 'ZHLC_GF') {
if (!w || !w.ZHLEngine) throw new Error('ZHLEngine not available — iframe not loaded');
r = w.ZHLEngine.calculate(cloneJ(levels), cloneJ(gases || []), cloneJ(settings || S()));
} else {
const vpm = vpmEngine(w);
if (!vpm) throw new Error('VPMEngine not available — iframe not loaded');
r = vpm.calculate(cloneJ(levels), cloneJ(gases || []), cloneJ(settings || S()), model);
}
assert(r && typeof r === 'object', 'No result object');
if (r.error) throw new Error('Engine error: ' + r.error);
return r;
} finally {
if (w) w._zhlHeadless = keepHeadless || true;
}
}
// Result inspectors
function stopSegs(r) { return (r.plan || []).filter(s => s && s.type === 'stop'); }
function decoStops(r) { return (r.stops || []).filter(s => s && s.time > 0); }
function segTypes(r) { return (r.plan || []).map(s => s.type); }
function totalStopTime(r) { return stopSegs(r).reduce((a, s) => a + (s.time || 0), 0); }
function maxStopDepth(r) { const ss = stopSegs(r); return ss.length ? Math.max(...ss.map(s => s.depth)) : 0; }
function minStopDepth(r) { const ss = stopSegs(r); return ss.length ? Math.min(...ss.map(s => s.depth)) : Infinity; }
function hasDescent(r) { return (r.plan || []).some(s => s.type === 'descent'); }
function hasBottom(r) { return (r.plan || []).some(s => s.type === 'bottom'); }
// Shape + integrity validators
function assertShape(r) {
finite(r.totalRuntime, 'totalRuntime');
assert(Array.isArray(r.plan), 'plan not array');
assert(Array.isArray(r.stops), 'stops not array');
if (r.totalCNS != null) finite(r.totalCNS, 'totalCNS');
if (r.totalOTU != null) finite(r.totalOTU, 'totalOTU');
}
function assertIntegrity(r) {
assertShape(r);
assert(r.plan.length > 0, 'empty plan');
let lastRT = -Infinity, lastStopD = Infinity;
let sawD = false, sawB = false;
r.plan.forEach((seg, i) => {
if ('time' in seg) finite(seg.time || 0, 'seg.time@' + i);
if ('run' in seg && seg.run != null) { finite(seg.run, 'seg.run@' + i); assert(seg.run + 1e-9 >= lastRT, 'runtime decreased @' + i); lastRT = seg.run; }
if ('depth' in seg && seg.depth != null) { finite(seg.depth, 'seg.depth@' + i); assert(seg.depth >= 0, 'negative depth @' + i); }
if ((seg.time || 0) < -1e-9) throw new Error('Negative time @' + i);
if (seg.type === 'descent') sawD = true;
if (seg.type === 'bottom') sawB = true;
if (seg.type === 'stop') {
assert(seg.depth <= lastStopD + 1e-9, 'stops got deeper during ascent @' + i);
lastStopD = seg.depth;
}
});
assert(sawD, 'no descent segment');
assert(sawB, 'no bottom segment');
}
// ══════════════════════════════════════════════════════════════════════════════
// TEST RUNNER
// ══════════════════════════════════════════════════════════════════════════════
function runTest(name, model, fn, isWarn) {
const t0 = performance.now();
try {
const detail = fn();
const ms = performance.now() - t0;
return { name, model, pass: true, warn: !!isWarn, detail: detail == null ? '✓' : String(detail), ms };
} catch (e) {
const ms = performance.now() - t0;
return { name, model, pass: false, warn: false, detail: e && e.message ? e.message : String(e), ms };
}
}
// ══════════════════════════════════════════════════════════════════════════════
// ── TIER 1: ENGINE-LEVEL TEST GROUPS ─────────────────────────────────────────
// ══════════════════════════════════════════════════════════════════════════════
// Helper: build NDL test (expects no stops)
// For ZHLC_GF (Bühlmann), use GF 100/100 — NDL means "no tissue ceiling",
// not "no stops with GF Lo=30 conservatism". GF Lo < 100 forces deep stops
// even on dives well within RDP NDL limits.
function ndlTest(depth, bt, model, o2, he) {
const label = `${depth}m / ${bt}min — no stops expected`;
return [label, model, function() {
const settings = model === 'ZHLC_GF' ? S({gfLo:100, gfHi:100}) : S();
const r = calc(lv(depth, bt, o2, he), NG, settings, model);
assertShape(r);
const stops = decoStops(r);
assert(stops.length === 0, `Expected 0 stops, got ${stops.length}. RT=${pr(r.totalRuntime)}`);
return `RT=${pr(r.totalRuntime)} min, 0 stops ✓`;
}];
}
// Helper: build deco test (expects stops)
function decoTest(depth, bt, model, gases, settingsOverride, label) {
const name = label || `${depth}m / ${bt}min — deco expected`;
return [name, model, function() {
const r = calc(lv(depth, bt), gases || NG, S(settingsOverride), model);
assertIntegrity(r);
assert(r.totalRuntime > bt, `RT ${pr(r.totalRuntime)} ≤ BT ${bt}`);
const stops = decoStops(r);
assert(stops.length > 0, `No deco stops generated`);
return `RT=${pr(r.totalRuntime)} min, ${stops.length} stops`;
}];
}
// Helper: monotonicity test (r2 should produce ≥ runtime than r1)
function monoTest(nameA, levA, nameB, levB, model, desc) {
return [desc || `${nameA} vs ${nameB} monotonicity`, model, function() {
const rA = calc(levA, NG, S(), model);
const rB = calc(levB, NG, S(), model);
assert(rB.totalRuntime + 0.5 >= rA.totalRuntime, `Expected ${nameB} ≥ ${nameA}: ${pr(rB.totalRuntime)} < ${pr(rA.totalRuntime)}`);
return `${nameA}→${pr(rA.totalRuntime)} | ${nameB}→${pr(rB.totalRuntime)}`;
}];
}
const TIER1_GROUPS = [
// ── Group T1-A: Engine presence (all 3 models)
{
tier: 1, name: 'T1-A · Engine Presence',
tests: [
['VPMEngine global exists', 'CORE', function(){ assert(E && typeof E === 'object', 'VPMEngine missing'); return 'ok'; }],
['calculate() is a function', 'CORE', function(){ assert(typeof E.calculate === 'function'); return 'ok'; }],
['ZHLCGF callable with simple dive', 'ZHLC_GF', function(){ const r = calc(lv(20,20), NG, S(), 'ZHLC_GF'); assert(r.totalRuntime > 0); return `RT=${pr(r.totalRuntime)}`; }],
['VPMB callable with simple dive', 'VPMB', function(){ const r = calc(lv(20,20), NG, S(), 'VPMB'); assert(r.totalRuntime > 0); return `RT=${pr(r.totalRuntime)}`; }],
['VPMBGFS callable with simple dive', 'VPMB_GFS', function(){ const r = calc(lv(20,20), NG, S(), 'VPMB_GFS'); assert(r.totalRuntime > 0); return `RT=${pr(r.totalRuntime)}`; }],
['SURFACEP ≈ 1.013 bar', 'CORE', function(){ assert(approx(SURF, 1.013, 0.01), `SURFACEP=${SURF}`); return `${pr(SURF,3)} bar`; }],
]
},
// ── Group T1-B: Bühlmann NDL dives (no stops expected)
{
tier: 1, name: 'T1-B · Bühlmann — NDL Dives (no stops)',
tests: [
ndlTest(5, 10, 'ZHLC_GF'),
ndlTest(5, 60, 'ZHLC_GF'),
ndlTest(9, 60, 'ZHLC_GF'),
ndlTest(10, 60, 'ZHLC_GF'),
ndlTest(12, 45, 'ZHLC_GF'),
ndlTest(12, 55, 'ZHLC_GF'),
ndlTest(15, 40, 'ZHLC_GF'),
ndlTest(15, 50, 'ZHLC_GF'),
ndlTest(18, 35, 'ZHLC_GF'),
ndlTest(20, 20, 'ZHLC_GF'),
ndlTest(20, 25, 'ZHLC_GF'),
ndlTest(20, 30, 'ZHLC_GF'),
ndlTest(22, 22, 'ZHLC_GF'),
ndlTest(25, 15, 'ZHLC_GF'),
ndlTest(30, 10, 'ZHLC_GF'),
ndlTest(10, 90, 'ZHLC_GF'),
ndlTest(8, 120, 'ZHLC_GF'),
ndlTest(6, 180, 'ZHLC_GF'),
]
},
// ── Group T1-C: Bühlmann deco dives (100 profiles total across groups)
{
tier: 1, name: 'T1-C · Bühlmann — Deco Dives',
tests: [
decoTest(30, 30, 'ZHLC_GF'),
decoTest(30, 45, 'ZHLC_GF'),
decoTest(30, 60, 'ZHLC_GF'),
decoTest(33, 30, 'ZHLC_GF'),
decoTest(36, 25, 'ZHLC_GF'),
decoTest(40, 20, 'ZHLC_GF'),
decoTest(40, 25, 'ZHLC_GF'),
decoTest(40, 30, 'ZHLC_GF'),
decoTest(40, 35, 'ZHLC_GF'),
decoTest(40, 40, 'ZHLC_GF'),
decoTest(40, 50, 'ZHLC_GF'),
decoTest(45, 20, 'ZHLC_GF'),
decoTest(45, 25, 'ZHLC_GF'),
decoTest(45, 30, 'ZHLC_GF'),
decoTest(50, 20, 'ZHLC_GF'),
decoTest(50, 25, 'ZHLC_GF'),
decoTest(50, 30, 'ZHLC_GF'),
decoTest(55, 20, 'ZHLC_GF'),
decoTest(60, 15, 'ZHLC_GF'),
decoTest(60, 20, 'ZHLC_GF'),
decoTest(60, 25, 'ZHLC_GF'),
decoTest(70, 15, 'ZHLC_GF'),
decoTest(70, 20, 'ZHLC_GF'),
decoTest(80, 15, 'ZHLC_GF'),
decoTest(80, 20, 'ZHLC_GF'),
// with deco gas
decoTest(40, 25, 'ZHLC_GF', EAN50, null, '40m/25min + EAN50 deco'),
decoTest(50, 25, 'ZHLC_GF', EAN50, null, '50m/25min + EAN50 deco'),
decoTest(50, 25, 'ZHLC_GF', EAN50_O2, null, '50m/25min + EAN50+O2 deco'),
decoTest(60, 20, 'ZHLC_GF', EAN50_O2, null, '60m/20min + EAN50+O2 deco'),
decoTest(60, 20, 'ZHLC_GF', TX_DECO, null, '60m/20min + trimix deco stack'),
// nitrox bottom
decoTest(30, 40, 'ZHLC_GF', NG, null, '30m/40min EAN32 bottom'), // will use default 21% actually
['30m/40min EAN32 bottom — valid deco', 'ZHLC_GF', function(){
const r = calc(lv(30,40,32), NG, S(), 'ZHLC_GF');
assertIntegrity(r); assert(r.totalRuntime > 40);
return `RT=${pr(r.totalRuntime)}, ${decoStops(r).length} stops`;
}],
// conservative GF
decoTest(40, 25, 'ZHLC_GF', NG, {gfLo:20, gfHi:70}, '40m/25min GF20/70 (conservative)'),
decoTest(40, 25, 'ZHLC_GF', NG, {gfLo:30, gfHi:75}, '40m/25min GF30/75'),
// very deep
['100m/10min — completes without crash', 'ZHLC_GF', function(){
const r = calc(lv(100,10), NG, S(), 'ZHLC_GF');
assertShape(r); assert(r.totalRuntime > 10);
return `RT=${pr(r.totalRuntime)}`;
}],
]
},
// ── Group T1-D: Bühlmann monotonicity (15 checks)
{
tier: 1, name: 'T1-D · Bühlmann — Monotonicity',
tests: [
monoTest('30m/25', lv(30,25), '35m/25', lv(35,25), 'ZHLC_GF', 'Deeper (30→35m) ≥ more runtime'),
monoTest('35m/25', lv(35,25), '40m/25', lv(40,25), 'ZHLC_GF', 'Deeper (35→40m) ≥ more runtime'),
monoTest('40m/25', lv(40,25), '50m/25', lv(50,25), 'ZHLC_GF', 'Deeper (40→50m) ≥ more runtime'),
monoTest('50m/25', lv(50,25), '60m/25', lv(60,25), 'ZHLC_GF', 'Deeper (50→60m) ≥ more runtime'),
monoTest('60m/15', lv(60,15), '70m/15', lv(70,15), 'ZHLC_GF', 'Deeper (60→70m) ≥ more runtime'),
monoTest('40m/20', lv(40,20), '40m/25', lv(40,25), 'ZHLC_GF', 'Longer BT (20→25 min) ≥ more runtime'),
monoTest('40m/25', lv(40,25), '40m/30', lv(40,30), 'ZHLC_GF', 'Longer BT (25→30 min) ≥ more runtime'),
monoTest('40m/30', lv(40,30), '40m/40', lv(40,40), 'ZHLC_GF', 'Longer BT (30→40 min) ≥ more runtime'),
monoTest('40m/40', lv(40,40), '40m/60', lv(40,60), 'ZHLC_GF', 'Longer BT (40→60 min) ≥ more runtime'),
// GF monotonicity
['GFHi 85→70 → more runtime', 'ZHLC_GF', function(){
const a = calc(lv(40,25), NG, S({gfHi:85}), 'ZHLC_GF');
const b = calc(lv(40,25), NG, S({gfHi:70}), 'ZHLC_GF');
assert(b.totalRuntime + 0.5 >= a.totalRuntime, `GF70 shorter: ${pr(b.totalRuntime)} < ${pr(a.totalRuntime)}`);
return `85→${pr(a.totalRuntime)} | 70→${pr(b.totalRuntime)}`;
}],
['GFLo 30→20 → more runtime', 'ZHLC_GF', function(){
const a = calc(lv(40,25), NG, S({gfLo:30}), 'ZHLC_GF');
const b = calc(lv(40,25), NG, S({gfLo:20}), 'ZHLC_GF');
assert(b.totalRuntime + 0.5 >= a.totalRuntime, `GFLo20 shorter`);
return `Lo30→${pr(a.totalRuntime)} | Lo20→${pr(b.totalRuntime)}`;
}],
['GFHi 85→60 → more runtime', 'ZHLC_GF', function(){
const a = calc(lv(40,25), NG, S({gfHi:85}), 'ZHLC_GF');
const b = calc(lv(40,25), NG, S({gfHi:60}), 'ZHLC_GF');
assert(b.totalRuntime + 0.5 >= a.totalRuntime);
return `85→${pr(a.totalRuntime)} | 60→${pr(b.totalRuntime)}`;
}],
// nitrox monotonicity
['EAN21 (air) vs EAN32 → nitrox shorter or equal', 'ZHLC_GF', function(){
const air = calc(lv(30,30,21), NG, S(), 'ZHLC_GF');
const nx32 = calc(lv(30,30,32), NG, S(), 'ZHLC_GF');
assert(nx32.totalRuntime <= air.totalRuntime + 1, `EAN32 longer than air by ${pr(nx32.totalRuntime - air.totalRuntime)}`);
return `Air ${pr(air.totalRuntime)} | EAN32 ${pr(nx32.totalRuntime)}`;
}],
// stop count monotonicity (deeper = more stops)
['50m → more stops than 40m (same BT)', 'ZHLC_GF', function(){
const a = calc(lv(40,25), NG, S(), 'ZHLC_GF');
const b = calc(lv(50,25), NG, S(), 'ZHLC_GF');
assert(decoStops(b).length >= decoStops(a).length, `50m fewer stops (${decoStops(b).length} < ${decoStops(a).length})`);
return `40m: ${decoStops(a).length} stops | 50m: ${decoStops(b).length} stops`;
}],
// deco gas monotonicity
['EAN50 deco gas ≤ runtime of no deco gas', 'ZHLC_GF', function(){
const a = calc(lv(40,25), NG, S(), 'ZHLC_GF');
const b = calc(lv(40,25), EAN50, S(), 'ZHLC_GF');
assert(b.totalRuntime <= a.totalRuntime + 1, `EAN50 added ${pr(b.totalRuntime - a.totalRuntime)} min`);
return `No gas ${pr(a.totalRuntime)} | EAN50 ${pr(b.totalRuntime)}`;
}],
]
},
// ── Group T1-E: Bühlmann gas behavior (O2, CNS, OTU)
{
tier: 1, name: 'T1-E · Bühlmann — Gas & CNS/OTU',
tests: [
['CNS finite & ≥ 0 on standard dive', 'ZHLC_GF', function(){
const r = calc(lv(40,25), NG, S(), 'ZHLC_GF');
assert(r.totalCNS != null && isFinite(r.totalCNS) && r.totalCNS >= 0);
return `CNS=${pr(r.totalCNS,1)}%`;
}],
['OTU finite & ≥ 0 on standard dive', 'ZHLC_GF', function(){
const r = calc(lv(40,25), NG, S(), 'ZHLC_GF');
assert(r.totalOTU != null && isFinite(r.totalOTU) && r.totalOTU >= 0);
return `OTU=${Math.round(r.totalOTU)}`;
}],
['Longer dive accumulates more CNS', 'ZHLC_GF', function(){
const a = calc(lv(40,20), NG, S(), 'ZHLC_GF');
const b = calc(lv(40,40), NG, S(), 'ZHLC_GF');
assert(b.totalCNS >= a.totalCNS, `longer dive less CNS`);
return `20min ${pr(a.totalCNS,1)}% | 40min ${pr(b.totalCNS,1)}%`;
}],
['Deeper dive accumulates more CNS', 'ZHLC_GF', function(){
const a = calc(lv(30,25), NG, S(), 'ZHLC_GF');
const b = calc(lv(50,25), NG, S(), 'ZHLC_GF');
assert(b.totalCNS >= a.totalCNS, `deeper dive less CNS`);
return `30m ${pr(a.totalCNS,1)}% | 50m ${pr(b.totalCNS,1)}%`;
}],
['EAN50 deco ≥ OTU vs no deco gas', 'ZHLC_GF', function(){
const a = calc(lv(40,25), NG, S(), 'ZHLC_GF');
const b = calc(lv(40,25), EAN50, S(), 'ZHLC_GF');
assert(b.totalOTU >= a.totalOTU - 0.5);
return `NG=${Math.round(a.totalOTU)} | EAN50=${Math.round(b.totalOTU)} OTU`;
}],
['EAN50+O2 gives finite CNS/OTU', 'ZHLC_GF', function(){
const r = calc(lv(50,25), EAN50_O2, S(), 'ZHLC_GF');
assert(isFinite(r.totalCNS) && isFinite(r.totalOTU));
return `CNS=${pr(r.totalCNS,1)}% OTU=${Math.round(r.totalOTU)}`;
}],
['Trimix He50 50m/20min — finite CNS', 'ZHLC_GF', function(){
const r = calc(lv(50,20,21,35), TX_DECO, S(), 'ZHLC_GF');
assertShape(r); assert(isFinite(r.totalCNS));
return `RT=${pr(r.totalRuntime)}, CNS=${pr(r.totalCNS,1)}%`;
}],
['Max stop depth ≤ planned depth (Bühlmann)', 'ZHLC_GF', function(){
const r = calc(lv(40,25), NG, S(), 'ZHLC_GF');
const mx = maxStopDepth(r);
assert(mx <= 40, `First stop deeper than bottom: ${mx}m`);
return `max stop=${mx}m ≤ 40m ✓`;
}],
['Min stop depth ≥ 0', 'ZHLC_GF', function(){
const r = calc(lv(40,25), NG, S(), 'ZHLC_GF');
const mn = minStopDepth(r);
assert(mn >= 0, `Negative min stop: ${mn}`);
return `min stop=${mn}m ✓`;
}],
]
},
// ── Group T1-F: Bühlmann plan integrity (segment ordering)
{
tier: 1, name: 'T1-F · Bühlmann — Plan Integrity',
tests: [
['40m/25min — full integrity check', 'ZHLC_GF', function(){ const r = calc(lv(40,25), NG, S(), 'ZHLC_GF'); assertIntegrity(r); return segTypes(r).slice(0,6).join(' → '); }],
['60m/20min — full integrity check', 'ZHLC_GF', function(){ const r = calc(lv(60,20), NG, S(), 'ZHLC_GF'); assertIntegrity(r); return segTypes(r).slice(0,8).join(' → '); }],
['60m/20min + EAN50+O2 — full integrity check', 'ZHLC_GF', function(){ const r = calc(lv(60,20), EAN50_O2, S(), 'ZHLC_GF'); assertIntegrity(r); return `${r.plan.length} segs`; }],
['Run times monotonically increasing', 'ZHLC_GF', function(){
const r = calc(lv(40,25), NG, S(), 'ZHLC_GF');
let last = -Infinity;
(r.plan || []).forEach((s, i) => {
if (s.run != null) { assert(s.run + 1e-9 >= last, `run decreased @${i}: ${s.run} < ${last}`); last = s.run; }
});
return 'all runs ≥ previous ✓';
}],
['Stop depths never increase during ascent', 'ZHLC_GF', function(){
const r = calc(lv(50,25), NG, S(), 'ZHLC_GF');
let lastD = Infinity;
stopSegs(r).forEach((s, i) => {
assert(s.depth <= lastD + 1e-9, `stop depth increased @${i}: ${s.depth} > ${lastD}`);
lastD = s.depth;
});
return `${stopSegs(r).length} stops in correct order ✓`;
}],
['No negative segment times', 'ZHLC_GF', function(){
const r = calc(lv(60,20), EAN50, S(), 'ZHLC_GF');
(r.plan || []).forEach((s, i) => {
if ((s.time || 0) < -0.001) throw new Error(`Negative time at segment ${i}: ${s.time}`);
});
return 'all times ≥ 0 ✓';
}],
['Determinism: two identical calls give same RT', 'ZHLC_GF', function(){
const a = calc(lv(40,25), NG, S(), 'ZHLC_GF');
const b = calc(lv(40,25), NG, S(), 'ZHLC_GF');
assert(Math.abs(a.totalRuntime - b.totalRuntime) < 0.01);
return `${pr(a.totalRuntime)} == ${pr(b.totalRuntime)} ✓`;
}],
]
},
// ── Group T1-G: VPM-B (100 plans equivalent: NDL + deco + mono)
{
tier: 1, name: 'T1-G · VPM-B — Profiles',
tests: [
// NDL
ndlTest(10, 60, 'VPMB'),
ndlTest(15, 40, 'VPMB'),
ndlTest(20, 20, 'VPMB'),
ndlTest(25, 15, 'VPMB'),
// deco
decoTest(30, 35, 'VPMB'),
decoTest(35, 30, 'VPMB'),
decoTest(40, 20, 'VPMB'),
decoTest(40, 25, 'VPMB'),
decoTest(40, 30, 'VPMB'),
decoTest(40, 35, 'VPMB'),
decoTest(40, 40, 'VPMB'),
decoTest(45, 20, 'VPMB'),
decoTest(45, 25, 'VPMB'),
decoTest(45, 30, 'VPMB'),
decoTest(50, 20, 'VPMB'),
decoTest(50, 25, 'VPMB'),
decoTest(50, 30, 'VPMB'),
decoTest(55, 20, 'VPMB'),
decoTest(60, 15, 'VPMB'),
decoTest(60, 20, 'VPMB'),
decoTest(70, 15, 'VPMB'),
decoTest(80, 15, 'VPMB'),
decoTest(40, 25, 'VPMB', EAN50, null, 'VPM-B 40m/25min + EAN50'),
decoTest(50, 25, 'VPMB', EAN50_O2, null, 'VPM-B 50m/25min + EAN50+O2'),
// monotonicity
monoTest('40m/25', lv(40,25), '50m/25', lv(50,25), 'VPMB', 'VPM-B: 50m ≥ 40m runtime'),
monoTest('50m/25', lv(50,25), '60m/25', lv(60,25), 'VPMB', 'VPM-B: 60m ≥ 50m runtime'),
monoTest('40m/20', lv(40,20), '40m/30', lv(40,30), 'VPMB', 'VPM-B: 30min ≥ 20min runtime'),
monoTest('40m/30', lv(40,30), '40m/40', lv(40,40), 'VPMB', 'VPM-B: 40min ≥ 30min runtime'),
// conservatism
['VPM-B conservatism 0 vs 4 — higher → more runtime', 'VPMB', function(){
const low = calc(lv(45,25), NG, S({conservatism:0}), 'VPMB');
const high = calc(lv(45,25), NG, S({conservatism:4}), 'VPMB');
assert(high.totalRuntime + 0.5 >= low.totalRuntime);
return `C0=${pr(low.totalRuntime)} | C4=${pr(high.totalRuntime)}`;
}],
['VPM-B conservatism 2 gives valid plan', 'VPMB', function(){
const r = calc(lv(45,25), NG, S({conservatism:2}), 'VPMB');
assertIntegrity(r); return `RT=${pr(r.totalRuntime)}`;
}],
// integrity
['VPM-B 50m/25min plan integrity', 'VPMB', function(){ const r = calc(lv(50,25), NG, S(), 'VPMB'); assertIntegrity(r); return `${r.plan.length} segs`; }],
['VPM-B determinism', 'VPMB', function(){
const a = calc(lv(40,25), NG, S(), 'VPMB');
const b = calc(lv(40,25), NG, S(), 'VPMB');
assert(Math.abs(a.totalRuntime - b.totalRuntime) < 0.01);
return `${pr(a.totalRuntime)} == ${pr(b.totalRuntime)} ✓`;
}],
['VPM-B deep (80m/15min) — no crash', 'VPMB', function(){
const r = calc(lv(80,15), NG, S(), 'VPMB');
assertShape(r); assert(r.totalRuntime > 15);
return `RT=${pr(r.totalRuntime)}`;
}],
]
},
// ── Group T1-H: VPM-B/GFS (100 plans equivalent)
{
tier: 1, name: 'T1-H · VPM-B/GFS — Profiles',
tests: [
ndlTest(10, 60, 'VPMB_GFS'),
ndlTest(15, 40, 'VPMB_GFS'),
ndlTest(20, 20, 'VPMB_GFS'),
decoTest(30, 35, 'VPMB_GFS'),
decoTest(35, 30, 'VPMB_GFS'),
decoTest(40, 20, 'VPMB_GFS'),
decoTest(40, 25, 'VPMB_GFS'),
decoTest(40, 30, 'VPMB_GFS'),
decoTest(40, 35, 'VPMB_GFS'),
decoTest(45, 20, 'VPMB_GFS'),
decoTest(45, 25, 'VPMB_GFS'),
decoTest(50, 20, 'VPMB_GFS'),
decoTest(50, 25, 'VPMB_GFS'),
decoTest(50, 30, 'VPMB_GFS'),
decoTest(60, 15, 'VPMB_GFS'),
decoTest(60, 20, 'VPMB_GFS'),
decoTest(70, 15, 'VPMB_GFS'),
decoTest(80, 15, 'VPMB_GFS'),
decoTest(40, 25, 'VPMB_GFS', EAN50, null, 'VPM-B/GFS 40m/25min + EAN50'),
monoTest('40m/25', lv(40,25), '50m/25', lv(50,25), 'VPMB_GFS', 'VPMBGFS: 50m ≥ 40m runtime'),
monoTest('40m/20', lv(40,20), '40m/30', lv(40,30), 'VPMB_GFS', 'VPMBGFS: 30min ≥ 20min runtime'),
// GFS conservatism
['VPMBGFS: lower GFS (70 vs 85) → more runtime', 'VPMB_GFS', function(){
const a = calc(lv(45,25), NG, S({gfs:85}), 'VPMB_GFS');
const b = calc(lv(45,25), NG, S({gfs:70}), 'VPMB_GFS');
assert(b.totalRuntime + 0.5 >= a.totalRuntime);
return `85→${pr(a.totalRuntime)} | 70→${pr(b.totalRuntime)}`;
}],
['VPMBGFS: GFS 60 gives valid plan', 'VPMB_GFS', function(){
const r = calc(lv(45,25), NG, S({gfs:60}), 'VPMB_GFS');
assertIntegrity(r); return `RT=${pr(r.totalRuntime)}`;
}],
// cross-model comparison
['ZHLCGF vs VPMB vs VPMBGFS runtime spread ≤ 120min', 'ALL', function(){
const a = calc(lv(40,25), NG, S(), 'ZHLC_GF');
const b = calc(lv(40,25), NG, S(), 'VPMB');
const c = calc(lv(40,25), NG, S(), 'VPMB_GFS');
const spread = Math.max(a.totalRuntime, b.totalRuntime, c.totalRuntime) - Math.min(a.totalRuntime, b.totalRuntime, c.totalRuntime);
assert(spread < 120, `Spread too large: ${pr(spread,1)}min`);
return `ZHL=${pr(a.totalRuntime)} VPM=${pr(b.totalRuntime)} GFS=${pr(c.totalRuntime)}`;
}],
['VPMBGFS determinism', 'VPMB_GFS', function(){
const a = calc(lv(40,25), NG, S(), 'VPMB_GFS');
const b = calc(lv(40,25), NG, S(), 'VPMB_GFS');
assert(Math.abs(a.totalRuntime - b.totalRuntime) < 0.01);
return `${pr(a.totalRuntime)} == ${pr(b.totalRuntime)} ✓`;
}],
['VPMBGFS 80m/15min — no crash', 'VPMB_GFS', function(){
const r = calc(lv(80,15), NG, S(), 'VPMB_GFS');
assertShape(r); assert(r.totalRuntime > 15);
return `RT=${pr(r.totalRuntime)}`;
}],
]
},
// ── Group T1-I: Units & Water types
{
tier: 1, name: 'T1-I · Units & Water Types',
tests: [
['Metric salt: 40m/25min — runs', 'ZHLC_GF', function(){ const r = calc(lv(40,25), NG, S({metric:true, waterType:0}), 'ZHLC_GF'); return `RT=${pr(r.totalRuntime)}`; }],
['Metric fresh: 40m/25min — runs', 'ZHLC_GF', function(){ const r = calc(lv(40,25), NG, S({metric:true, waterType:1}), 'ZHLC_GF'); return `RT=${pr(r.totalRuntime)}`; }],
['Imperial salt: 130ft/25min — runs', 'ZHLC_GF', function(){
const depthM = 130 / 3.28084;
const r = calc([{depth:depthM, time:25, o2:21, he:0}], NG, S({metric:true, waterType:0, stepSize:3, lastStop:3, gfLo:30}), 'ZHLC_GF');
assert(r.totalRuntime > 50 && r.totalRuntime < 80, 'RT out of range: ' + r.totalRuntime);
return `RT=${pr(r.totalRuntime)}`;
}],
['Imperial fresh: 100ft/30min — runs', 'ZHLC_GF', function(){
const depthM = 100 / 3.28084;
const r = calc([{depth:depthM, time:30, o2:21, he:0}], NG, S({metric:true, waterType:1, stepSize:3, lastStop:3, gfLo:30}), 'ZHLC_GF');
assert(r.totalRuntime > 40 && r.totalRuntime < 90, 'RT out of range: ' + r.totalRuntime);
return `RT=${pr(r.totalRuntime)}`;
}],
['Custom density 1030 kg/m³ — runs', 'ZHLC_GF', function(){
const r = calc(lv(40,25), NG, S({waterType:2, customWaterDensity:1030}), 'ZHLC_GF');
return `RT=${pr(r.totalRuntime)}`;
}],
['Custom density 1010 kg/m³ — runs', 'ZHLC_GF', function(){
const r = calc(lv(40,25), NG, S({waterType:2, customWaterDensity:1010}), 'ZHLC_GF');
return `RT=${pr(r.totalRuntime)}`;
}],
['Salt vs fresh RT difference < 15min', 'ZHLC_GF', function(){
const a = calc(lv(40,25), NG, S({waterType:0}), 'ZHLC_GF');
const b = calc(lv(40,25), NG, S({waterType:1}), 'ZHLC_GF');
const d = Math.abs(a.totalRuntime - b.totalRuntime);
assert(d < 15, `Diff too large: ${pr(d,1)}min`);
return `Δ=${pr(d,1)}min`;
}],
['VPM-B imperial: 165ft/20min — runs', 'VPMB', function(){
const depthM = 165 / 3.28084;
const r = calc([{depth:depthM, time:20, o2:21, he:0}], NG, S({metric:true, waterType:0, stepSize:3, lastStop:3}), 'VPMB');
assert(r.totalRuntime > 40 && r.totalRuntime < 150, 'RT out of range: ' + r.totalRuntime);
return `RT=${pr(r.totalRuntime)}`;
}],
['VPMBGFS imperial: 130ft/25min — runs', 'VPMB_GFS', function(){
const depthM = 130 / 3.28084;
const r = calc([{depth:depthM, time:25, o2:21, he:0}], NG, S({metric:true, waterType:0, stepSize:3, lastStop:3}), 'VPMB_GFS');
assert(r.totalRuntime > 50 && r.totalRuntime < 120, 'RT out of range: ' + r.totalRuntime);
return `RT=${pr(r.totalRuntime)}`;
}],
]
},
// ── Group T1-J: Edge cases & extreme profiles
{
tier: 1, name: 'T1-J · Edge Cases & Extreme Profiles',
tests: [
// Very shallow
['5m/5min — no error, quick RT', 'ZHLC_GF', function(){ const r = calc(lv(5,5), NG, S(), 'ZHLC_GF'); assert(r.totalRuntime < 20); return `RT=${pr(r.totalRuntime)}`; }],
['5m/30min — no error', 'ZHLC_GF', function(){ const r = calc(lv(5,30), NG, S(), 'ZHLC_GF'); assert(r.totalRuntime >= 30); return `RT=${pr(r.totalRuntime)}`; }],
// Very deep
['90m/10min — no crash', 'ZHLC_GF', function(){ const r = calc(lv(90,10), NG, S(), 'ZHLC_GF'); assertShape(r); return `RT=${pr(r.totalRuntime)}`; }],
['100m/10min — no crash (VPMB)', 'VPMB', function(){ const r = calc(lv(100,10), NG, S(), 'VPMB'); assertShape(r); return `RT=${pr(r.totalRuntime)}`; }],
// Long bottom times
['20m/120min — runs', 'ZHLC_GF', function(){ const r = calc(lv(20,120), NG, S(), 'ZHLC_GF'); assertShape(r); return `RT=${pr(r.totalRuntime)}`; }],
['15m/180min — runs', 'ZHLC_GF', function(){ const r = calc(lv(15,180), NG, S(), 'ZHLC_GF'); assertShape(r); return `RT=${pr(r.totalRuntime)}`; }],
// GF extremes
['GF 100/100 (ceiling) — runs', 'ZHLC_GF', function(){ const r = calc(lv(40,25), NG, S({gfLo:100, gfHi:100}), 'ZHLC_GF'); assertShape(r); return `RT=${pr(r.totalRuntime)}`; }],
['GF 20/50 (deep+conservative) — runs', 'ZHLC_GF', function(){ const r = calc(lv(40,25), NG, S({gfLo:20, gfHi:50}), 'ZHLC_GF'); assertShape(r); return `RT=${pr(r.totalRuntime)}`; }],
// 1m step / 1m last stop
['1m step, 1m last stop — runs', 'ZHLC_GF', function(){ const r = calc(lv(40,25), NG, S({stepSize:1, lastStop:1}), 'ZHLC_GF'); assertShape(r); return `RT=${pr(r.totalRuntime)}`; }],
// Trimix
['Trimix 21/35 60m/20min — runs', 'ZHLC_GF', function(){
const r = calc(lv(60,20,21,35), TX_DECO, S(), 'ZHLC_GF');
assertShape(r); assert(r.totalRuntime > 20); return `RT=${pr(r.totalRuntime)}`;
}],
['Trimix 18/45 70m/20min — runs', 'ZHLC_GF', function(){
const r = calc(lv(70,20,18,45), TX_DECO, S(), 'ZHLC_GF');
assertShape(r); return `RT=${pr(r.totalRuntime)}`;
}],
['Helitrox 35/25 50m/25min — runs', 'ZHLC_GF', function(){
const r = calc(lv(50,25,35,25), EAN50_O2, S(), 'ZHLC_GF');
assertShape(r); return `RT=${pr(r.totalRuntime)}`;
}],
// State isolation
['State isolation: call after deep dive still works', 'ZHLC_GF', function(){
calc(lv(80,20), NG, S(), 'ZHLC_GF'); // potentially state-dirtying
// Use GF 100/100 — 20m/20min is NDL only without GF Lo conservatism
const r = calc(lv(20,20), NG, S({gfLo:100, gfHi:100}), 'ZHLC_GF');
const stops = decoStops(r);
assert(stops.length === 0, `NDL dive got ${stops.length} stops after deep dive`);
return 'no state leak ✓';
}],
['Multiple model switches — no cross-contamination', 'ALL', function(){
const a = calc(lv(40,25), NG, S(), 'ZHLC_GF');
const b = calc(lv(40,25), NG, S(), 'VPMB');
const c = calc(lv(40,25), NG, S(), 'ZHLC_GF'); // re-run Bühlmann
assert(Math.abs(a.totalRuntime - c.totalRuntime) < 0.01, `ZHL results differ after VPM-B call: ${pr(a.totalRuntime)} vs ${pr(c.totalRuntime)}`);
return 'no cross-contamination ✓';
}],
]
},
// ── Group T1-K: Multi-level dives
{
tier: 1, name: 'T1-K · Multi-Level Dives',
tests: [
['Two-level: 40m→30m (Bühlmann)', 'ZHLC_GF', function(){
const r = calc(mlv([{depth:40,time:20},{depth:30,time:10}]), NG, S(), 'ZHLC_GF');
assertIntegrity(r); return `RT=${pr(r.totalRuntime)}, ${r.plan.length} segs`;
}],
['Two-level: 50m→30m (Bühlmann)', 'ZHLC_GF', function(){
const r = calc(mlv([{depth:50,time:15},{depth:30,time:10}]), EAN50, S(), 'ZHLC_GF');
assertIntegrity(r); return `RT=${pr(r.totalRuntime)}`;
}],
['Three-level: 60m→40m→20m trimix (Bühlmann)', 'ZHLC_GF', function(){
const r = calc(mlv([{depth:60,time:20,o2:18,he:45},{depth:40,time:5,o2:18,he:45},{depth:20,time:5,o2:18,he:45}]), TX_DECO, S(), 'ZHLC_GF');
assertShape(r); return `RT=${pr(r.totalRuntime)}`;
}],
['Two-level 2nd level deeper than 1st — should still run', 'ZHLC_GF', function(){
// engine may or may not support ascending order, just check no crash
try {
const r = calc(mlv([{depth:30,time:10},{depth:40,time:15}]), NG, S(), 'ZHLC_GF');
assertShape(r); return `RT=${pr(r.totalRuntime)} (accepted)`;
} catch(e) {
return `Engine rejected (acceptable): ${e.message.slice(0,60)}`;