()
| 4350 | let level = Level::param(name.clone()); |
| 4351 | let mut cache = BlockCache::default(); |
| 4352 | let univ = compile_univ(&level, &[name], &mut cache).unwrap(); |
| 4353 | assert!(matches!(univ.as_ref(), Univ::Var(0))); |
| 4354 | } |
| 4355 | |
| 4356 | #[test] |
| 4357 | fn test_compile_univ_max() { |
| 4358 | let level = Level::max(Level::zero(), Level::succ(Level::zero())); |
| 4359 | let mut cache = BlockCache::default(); |
| 4360 | let univ = compile_univ(&level, &[], &mut cache).unwrap(); |
| 4361 | match univ.as_ref() { |
| 4362 | Univ::Max(a, b) => { |
| 4363 | assert!(matches!(a.as_ref(), Univ::Zero)); |
| 4364 | match b.as_ref() { |
| 4365 | Univ::Succ(inner) => assert!(matches!(inner.as_ref(), Univ::Zero)), |
| 4366 | _ => panic!("expected Succ"), |
| 4367 | } |
| 4368 | }, |
| 4369 | _ => panic!("expected Max"), |
| 4370 | } |
| 4371 | } |
| 4372 | |
| 4373 | #[test] |
| 4374 | fn test_store_string() { |
| 4375 | let stt = CompileState::default(); |
| 4376 | let addr1 = store_string("hello", &stt); |
| 4377 | let addr2 = store_string("hello", &stt); |
| 4378 | // Same content should give same address |
| 4379 | assert_eq!(addr1, addr2); |
| 4380 | // Check we can retrieve it |
| 4381 | let bytes = stt.env.get_blob(&addr1).unwrap(); |
| 4382 | assert_eq!(bytes, b"hello"); |
| 4383 | } |
| 4384 | |
| 4385 | #[test] |
| 4386 | fn test_store_nat() { |
| 4387 | let stt = CompileState::default(); |
| 4388 | let n = Nat::from(42u64); |
| 4389 | let addr = store_nat(&n, &stt); |
| 4390 | let bytes = stt.env.get_blob(&addr).unwrap(); |
| 4391 | let n2 = Nat::from_le_bytes(&bytes); |
| 4392 | assert_eq!(n, n2); |
| 4393 | } |
| 4394 | |
| 4395 | #[test] |
| 4396 | fn test_compile_name_anon() { |
| 4397 | let stt = CompileState::default(); |
| 4398 | let name = Name::anon(); |
| 4399 | let addr = compile_name(&name, &stt); |
| 4400 | // Name is stored in env.names, not blobs |
| 4401 | let stored_name = stt.env.names.get(&addr).unwrap(); |
| 4402 | assert_eq!(*stored_name, name); |
| 4403 | } |
| 4404 | |
| 4405 | #[test] |
| 4406 | fn test_compile_name_str() { |
nothing calls this directly
no test coverage detected