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

Function test_temp_scope_lookup_vars

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

Source from the content-addressed store, hash-verified

980
981 #[test]
982 fn test_temp_scope_lookup_vars() -> Result<()> {
983 let upcalls = HashMap::default();
984 let mut global = GlobalSymtable::new(upcalls);
985 global.put_global(SymbolKey::from("g"), SymbolPrototype::Scalar(ExprType::Integer))?;
986 let mut local = global.enter_scope();
987 local.put_local(SymbolKey::from("l"), SymbolPrototype::Scalar(ExprType::Text))?;
988
989 {
990 let temp = local.frozen();
991
992 let (reg, proto) = temp.get_local_or_global(&VarRef::new("l", None))?;
993 assert_eq!(Register::local(0).unwrap(), reg);
994 assert_eq!(SymbolPrototype::Scalar(ExprType::Text), proto);
995
996 let (reg, proto) = temp.get_local_or_global(&VarRef::new("g", None))?;
997 assert_eq!(Register::global(0).unwrap(), reg);
998 assert_eq!(SymbolPrototype::Scalar(ExprType::Integer), proto);
999 }
1000
1001 Ok(())
1002 }
1003
1004 #[test]
1005 fn test_temp_scope_lookup_callable() -> Result<()> {

Callers

nothing calls this directly

Calls 5

put_globalMethod · 0.80
enter_scopeMethod · 0.80
put_localMethod · 0.80
frozenMethod · 0.80
get_local_or_globalMethod · 0.80

Tested by

no test coverage detected