Add tests for `locals_into_form_values`.

This commit is contained in:
David Wendt 2019-11-02 18:08:06 -04:00 committed by Mike Welsh
parent 97edbc98df
commit 4e16c91dbb
2 changed files with 31 additions and 1 deletions

View File

@ -21,9 +21,13 @@ mod globals;
pub mod movie_clip;
pub mod object;
mod scope;
mod value;
#[cfg(test)]
mod test_utils;
mod value;
#[cfg(test)]
mod tests;
use activation::Activation;
use scope::Scope;

26
core/src/avm1/tests.rs Normal file
View File

@ -0,0 +1,26 @@
use crate::avm1::activation::Activation;
use crate::avm1::test_utils::with_avm;
#[test]
fn locals_into_form_values() {
with_avm(19, |avm, context, _this| {
let my_activation =
Activation::from_nothing(19, avm.global_object_cell(), context.gc_context);
let my_locals = my_activation.scope().locals_cell();
my_locals
.write(context.gc_context)
.set("value1", "string", avm, context, my_locals);
my_locals
.write(context.gc_context)
.set("value2", 2.0, avm, context, my_locals);
avm.insert_stack_frame(my_activation, context);
let my_local_values = avm.locals_into_form_values(context);
assert_eq!(my_local_values.len(), 2);
assert_eq!(my_local_values.get("value1"), Some(&"string".to_string()));
assert_eq!(my_local_values.get("value2"), Some(&"2".to_string()));
});
}