Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
stargazing-dino committed May 17, 2024
1 parent af0991d commit 9950c19
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions crates/yarnspinner/tests/type_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,37 @@ fn test_initial_values() -> anyhow::Result<()> {
Ok(())
}

#[test]
fn test_variable_storage_extended_with_program_initial_values() {
let source = "
<<declare $int = 42>>
<<declare $str = \"Hello\">>
<<declare $bool = true>>
";

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(
Expand Down

0 comments on commit 9950c19

Please sign in to comment.