From 9950c19208be40fd6dc554577ebc4ab6145b5e9a Mon Sep 17 00:00:00 2001 From: Rex Magana Date: Thu, 16 May 2024 17:47:46 -0700 Subject: [PATCH] Add test --- crates/yarnspinner/tests/type_tests.rs | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/crates/yarnspinner/tests/type_tests.rs b/crates/yarnspinner/tests/type_tests.rs index 09eabe4b..426fe484 100644 --- a/crates/yarnspinner/tests/type_tests.rs +++ b/crates/yarnspinner/tests/type_tests.rs @@ -426,6 +426,37 @@ fn test_initial_values() -> anyhow::Result<()> { Ok(()) } +#[test] +fn test_variable_storage_extended_with_program_initial_values() { + let source = " + <> + <> + <> + "; + + let result = Compiler::from_test_source(source).compile().unwrap(); + + let mut dialogue = Dialogue::new( + Box::new(MemoryVariableStorage::new()), + Box::new(StringTableTextProvider::new()), + ); + dialogue.replace_program(result.program.unwrap()); + + let variable_storage = dialogue.variable_storage(); + assert_eq!( + variable_storage.get("$int").unwrap(), + YarnValue::Number(42.0) + ); + assert_eq!( + variable_storage.get("$str").unwrap(), + YarnValue::String("Hello".to_string()) + ); + assert_eq!( + variable_storage.get("$bool").unwrap(), + YarnValue::Boolean(true) + ); +} + #[test] fn test_explicit_types() { let result = Compiler::from_test_source(