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
//! Edge-case pins for `awk_intdiv` (the `Undef`-on-zero variant) and
//! `awk_strftime`'s UTC formatting path — two surfaces the existing happy-path
//! and `awk_intdiv0`-focused tests do not exercise.
//!
//! Bug classes pinned here:
//! - `awk_intdiv` truncates BOTH operands to i64 before dividing, so a nonzero
//! fractional divisor that truncates to 0 (e.g. `0.5`) hits the `bi == 0`
//! fallthrough and returns `Value::Undef`, NOT a quotient. This diverges
//! from `awk_intdiv0`, which returns `Float(0.0)` for the same input. The
//! `bi == 0` guard (distinct from the `bf == 0.0` guard) is its own branch
//! and would silently regress if a refactor collapsed the two checks or
//! forgot to truncate the divisor first.
//! - `awk_intdiv` must truncate the QUOTIENT toward zero (i64 division), not
//! floor it — `(-7) / 2 == -3`, not `-4`. A float-division refactor would
//! break sign-rounding on negative dividends.
//! - `awk_strftime` with an explicit UTC timestamp must be timezone-stable:
//! the formatted output is independent of the test host's `$TZ`. A regression
//! that dropped the `utc` flag and used `Local` would make this flaky/wrong
//! on non-UTC CI runners (the macOS matrix leg, etc.).
//!
//! `i64::MIN` overflow inputs are deliberately avoided — that panic is a known
//! bug already pinned in `awk_host_known_bugs_DO_NOT_COMMIT.rs`; reproducing it
//! here would just duplicate a failing test.
use ;
use Value;
// ───────────────────────────────────────────────────────────────────────────
// awk_intdiv: divisor-truncation divergence + quotient sign rounding
// ───────────────────────────────────────────────────────────────────────────
/// `awk_intdiv(a, 0.5)` — divisor is nonzero as a float (`bf != 0.0`) but
/// truncates to `0` as i64, so the `bi == 0` guard fires and the result is
/// `Undef`. This is the documented divergence from `awk_intdiv0`, which returns
/// `Float(0.0)` for the identical input. Pin BOTH the `Undef` result here and
/// the `bi == 0` (not `bf == 0.0`) branch that produces it.
/// Direct zero divisor (`bf == 0.0`) also yields `Undef`, via the first guard.
/// Kept distinct from the fractional case above so a refactor that removed one
/// guard but not the other is caught by exactly one of the two tests.
/// Quotient truncates toward zero, not toward negative infinity. `(-7) / 2`
/// must be `-3.0` (i64 truncation), never `-4.0` (a floor). A refactor that
/// computed `(a.to_float() / b.to_float()).floor()` instead of truncating i64
/// operands would silently produce `-4.0` here.
// ───────────────────────────────────────────────────────────────────────────
// awk_strftime: UTC path is timezone-independent
// ───────────────────────────────────────────────────────────────────────────
/// `strftime(fmt, ts, utc=1)` must format the timestamp in UTC regardless of
/// the host timezone. The 3-arg form sets the third operand truthy → UTC; the
/// epoch `0` formatted as `%Y-%m-%d %H:%M:%S` is exactly the Unix epoch in UTC.
/// This is the one strftime assertion that can be deterministic in CI without
/// pinning `$TZ`, and it guards the `utc` flag actually selecting the `Utc`
/// branch (a regression to `Local` would shift the output by the runner's
/// offset).
/// A known non-epoch UTC instant, again format-pinned to a TZ-independent shape.
/// `1000000000` seconds is 2001-09-09 01:46:40 UTC. Pins that the UTC branch
/// advances the calendar correctly (not just at the epoch boundary).