()
| 567 | |
| 568 | #[test] |
| 569 | fn test_global_put_and_get() -> Result<()> { |
| 570 | let upcalls = HashMap::default(); |
| 571 | let mut global = GlobalSymtable::new(upcalls); |
| 572 | |
| 573 | let reg = |
| 574 | global.put_global(SymbolKey::from("x"), SymbolPrototype::Scalar(ExprType::Integer))?; |
| 575 | assert_eq!(Register::global(0).unwrap(), reg); |
| 576 | |
| 577 | let reg = |
| 578 | global.put_global(SymbolKey::from("y"), SymbolPrototype::Scalar(ExprType::Text))?; |
| 579 | assert_eq!(Register::global(1).unwrap(), reg); |
| 580 | |
| 581 | // Lookup with untyped ref succeeds. |
| 582 | let (reg, proto) = global.get_global(&VarRef::new("x", None))?; |
| 583 | assert_eq!(Register::global(0).unwrap(), reg); |
| 584 | assert_eq!(SymbolPrototype::Scalar(ExprType::Integer), proto); |
| 585 | |
| 586 | // Lookup with matching typed ref succeeds. |
| 587 | let (reg, proto) = global.get_global(&VarRef::new("y", Some(ExprType::Text)))?; |
| 588 | assert_eq!(Register::global(1).unwrap(), reg); |
| 589 | assert_eq!(SymbolPrototype::Scalar(ExprType::Text), proto); |
| 590 | |
| 591 | Ok(()) |
| 592 | } |
| 593 | |
| 594 | #[test] |
| 595 | fn test_global_get_case_insensitive() -> Result<()> { |
nothing calls this directly
no test coverage detected