MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / test_inject_variables

Function test_inject_variables

aiscript-vm/src/vm/extra.rs:96–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

94
95 #[test]
96 fn test_inject_variables() {
97 let mut vm = Vm::default();
98 vm.inject_variables({
99 let mut map = HashMap::new();
100 map.insert("test".into(), "abc".into());
101 map.insert("test2".into(), 123.into());
102 map.insert("test3".into(), true.into());
103 map
104 });
105 vm.compile("return test;").unwrap();
106 let result = vm.interpret().unwrap();
107 assert_eq!(result, ReturnValue::String("abc".into()));
108 vm.compile("return test2;").unwrap();
109 let result = vm.interpret().unwrap();
110 assert_eq!(result, ReturnValue::Number(123.0));
111 vm.compile("return test3;").unwrap();
112 let result = vm.interpret().unwrap();
113 assert_eq!(result, ReturnValue::Boolean(true));
114 }
115
116 #[test]
117 fn test_inject_instance() {

Callers

nothing calls this directly

Calls 3

inject_variablesMethod · 0.80
compileMethod · 0.80
interpretMethod · 0.80

Tested by

no test coverage detected