()
| 5508 | let def = DefinitionVal { |
| 5509 | cnst, |
| 5510 | value, |
| 5511 | hints: ReducibilityHints::Abbrev, |
| 5512 | safety: DefinitionSafety::Safe, |
| 5513 | all: vec![name.clone()], |
| 5514 | }; |
| 5515 | |
| 5516 | let mut lean_env = LeanEnv::default(); |
| 5517 | lean_env.insert(name.clone(), LeanConstantInfo::DefnInfo(def)); |
| 5518 | let lean_env = Arc::new(lean_env); |
| 5519 | |
| 5520 | let stt = CompileState::default(); |
| 5521 | let mut cache = BlockCache::default(); |
| 5522 | let mut all = NameSet::default(); |
| 5523 | all.insert(name.clone()); |
| 5524 | |
| 5525 | // This should work because it's a single self-referential def |
| 5526 | let result = compile_const( |
| 5527 | &name, |
| 5528 | &all, |
| 5529 | &lean_env, |
| 5530 | &mut cache, |
| 5531 | &stt, |
| 5532 | &mut KernelCtx::new(), |
| 5533 | ); |
| 5534 | assert!(result.is_ok(), "compile_const failed: {:?}", result.err()); |
| 5535 | |
| 5536 | let addr = result.unwrap(); |
| 5537 | assert!(stt.name_to_addr.contains_key(&name)); |
| 5538 | |
| 5539 | // Check the constant was stored |
| 5540 | let cnst = stt.env.get_const(&addr); |
| 5541 | assert!(cnst.is_some()); |
| 5542 | match cnst.unwrap().as_ref() { |
| 5543 | Constant { info: ConstantInfo::Defn(d), .. } => { |
| 5544 | // Value should be a Rec(0) since it's self-referential in a single-element block |
| 5545 | match d.value.as_ref() { |
| 5546 | Expr::Rec(0, _) => {}, // Expected |
| 5547 | other => panic!("Expected Rec(0), got {:?}", other), |
| 5548 | } |
| 5549 | }, |
| 5550 | other => panic!("Expected Defn, got {:?}", other), |
| 5551 | } |
| 5552 | } |
| 5553 | |
| 5554 | #[test] |
| 5555 | fn test_compile_env_single_axiom() { |
| 5556 | use ix_common::env::{AxiomVal, ConstantVal}; |
| 5557 | |
| 5558 | // Create a minimal environment with just one axiom |
| 5559 | let name = Name::str(Name::anon(), "myAxiom".to_string()); |
| 5560 | let typ = LeanExpr::sort(Level::succ(Level::zero())); // Type 0 |
| 5561 | let cnst = ConstantVal { name: name.clone(), level_params: vec![], typ }; |
| 5562 | let axiom = AxiomVal { cnst, is_unsafe: false }; |
| 5563 | |
| 5564 | let mut lean_env = LeanEnv::default(); |
| 5565 | lean_env.insert(name.clone(), LeanConstantInfo::AxiomInfo(axiom)); |
| 5566 | let lean_env = Arc::new(lean_env); |
| 5567 |
nothing calls this directly
no test coverage detected