()
| 6200 | 3, |
| 6201 | "flat block should have 3 members, got {}", |
| 6202 | generated.len() |
| 6203 | ); |
| 6204 | } |
| 6205 | |
| 6206 | #[test] |
| 6207 | fn inline_like_rec_2_binder_count() { |
| 6208 | let mut env = inline_like_env(); |
| 6209 | let mut tc = TypeChecker::new(&mut env); |
| 6210 | tc.check_const(&mk_id("Inl")).unwrap(); |
| 6211 | tc.rec_fuel = super::super::tc::max_rec_fuel(); |
| 6212 | let block = mk_id("Inl"); |
| 6213 | if !tc.env.recursor_cache.contains_key(&block) { |
| 6214 | tc.generate_block_recursors(&block).unwrap(); |
| 6215 | } |
| 6216 | let generated = tc.env.recursor_cache.get(&block).unwrap(); |
| 6217 | |
| 6218 | let count_binders = |e: &AE| -> usize { |
| 6219 | let mut n = 0; |
| 6220 | let mut c = e.clone(); |
| 6221 | while let ExprData::All(_, _, _, b, _) = c.data() { |
| 6222 | n += 1; |
| 6223 | c = b.clone(); |
| 6224 | } |
| 6225 | n |
| 6226 | }; |
| 6227 | |
| 6228 | // Inl.rec (member 0): |
| 6229 | // 1 param(α) + 3 motives + N minors + 0 indices + 1 major |
| 6230 | // Minors: text(1f+0ih), emph(1f+1ih), other(2f+1ih), arr.mk(1f+1ih), nil(0), cons(2f+2ih) |
| 6231 | // = 6 minors |
| 6232 | // Total = 1 + 3 + 6 + 0 + 1 = 11 |
| 6233 | let n0 = count_binders(&generated[0].ty); |
| 6234 | assert_eq!(n0, 11, "Inl.rec should have 11 binders, got {n0}"); |
| 6235 | |
| 6236 | // Inl.rec_2 (member 2 = List aux): |
| 6237 | // 1 param + 3 motives + 6 minors + 0 indices + 1 major = 11 |
| 6238 | if generated.len() > 2 { |
| 6239 | let n2 = count_binders(&generated[2].ty); |
| 6240 | assert_eq!( |
| 6241 | n2, 11, |
| 6242 | "Inl.rec_2 (List aux) should have 11 binders, got {n2}" |
| 6243 | ); |
| 6244 | } |
| 6245 | |
| 6246 | // Deeper check: verify the generated Inl.rec_2 type against a manually |
| 6247 | // constructed version to catch var-index bugs. |
| 6248 | // For this we need the Inl.rec_2 stored as a Recr constant and compare. |
| 6249 | // Instead, let's just check that is_def_eq succeeds between rec[0] and |
| 6250 | // a hand-constructed Inl.rec. |
| 6251 | // This is complex, so let's at least verify that the cons minor inside |
| 6252 | // rec_2 has the right structure by inspecting its inner binders. |
| 6253 | |
| 6254 | // rec_2 = generated[2], binder layout: |
| 6255 | // 0: param (i : Sort(u+1)) |
| 6256 | // 1: motive_0 (Inl motive) |
| 6257 | // 2: motive_1 (Array aux motive) |
| 6258 | // 3: motive_2 (List aux motive) |
| 6259 | // 4-9: minors (text, emph, other, arr.mk, nil, cons) |
nothing calls this directly
no test coverage detected