MCPcopy Index your code
hub / github.com/endbasic/endbasic / test_local_put_and_get

Function test_local_put_and_get

core/src/compiler/syms.rs:631–649  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

629
630 #[test]
631 fn test_local_put_and_get() -> Result<()> {
632 let upcalls = HashMap::default();
633 let mut global = GlobalSymtable::new(upcalls);
634 let mut local = global.enter_scope();
635
636 let reg =
637 local.put_local(SymbolKey::from("a"), SymbolPrototype::Scalar(ExprType::Boolean))?;
638 assert_eq!(Register::local(0).unwrap(), reg);
639
640 let reg =
641 local.put_local(SymbolKey::from("b"), SymbolPrototype::Scalar(ExprType::Double))?;
642 assert_eq!(Register::local(1).unwrap(), reg);
643
644 let (reg, proto) = local.get_local_or_global(&VarRef::new("a", None))?;
645 assert_eq!(Register::local(0).unwrap(), reg);
646 assert_eq!(SymbolPrototype::Scalar(ExprType::Boolean), proto);
647
648 Ok(())
649 }
650
651 #[test]
652 fn test_local_shadows_global() -> Result<()> {

Callers

nothing calls this directly

Calls 3

enter_scopeMethod · 0.80
put_localMethod · 0.80
get_local_or_globalMethod · 0.80

Tested by

no test coverage detected