2019-11-02 22:08:06 +00:00
|
|
|
use crate::avm1::activation::Activation;
|
2020-06-20 23:02:45 +00:00
|
|
|
use crate::avm1::error::Error;
|
2019-11-02 22:08:06 +00:00
|
|
|
use crate::avm1::test_utils::with_avm;
|
2019-12-06 18:24:36 +00:00
|
|
|
use crate::avm1::TObject;
|
2019-10-21 22:37:04 +00:00
|
|
|
use gc_arena::GcCell;
|
2019-11-02 22:08:06 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn locals_into_form_values() {
|
2020-06-28 10:07:27 +00:00
|
|
|
with_avm(19, |activation, context, _this| -> Result<(), Error> {
|
2019-12-19 23:42:26 +00:00
|
|
|
let my_activation = Activation::from_nothing(
|
|
|
|
19,
|
2020-06-28 10:07:27 +00:00
|
|
|
activation.avm().global_object_cell(),
|
2019-12-19 23:42:26 +00:00
|
|
|
context.gc_context,
|
2020-02-24 07:41:55 +00:00
|
|
|
*context.levels.get(&0).expect("_level0 in test"),
|
2019-12-19 23:42:26 +00:00
|
|
|
);
|
2019-12-06 18:24:36 +00:00
|
|
|
let my_locals = my_activation.scope().locals().to_owned();
|
2019-11-02 22:08:06 +00:00
|
|
|
|
|
|
|
my_locals
|
2020-06-28 10:07:27 +00:00
|
|
|
.set("value1", "string".into(), activation, context)
|
|
|
|
.unwrap();
|
|
|
|
my_locals
|
|
|
|
.set("value2", 2.0.into(), activation, context)
|
2019-10-26 03:21:14 +00:00
|
|
|
.unwrap();
|
2019-11-02 22:08:06 +00:00
|
|
|
|
2020-06-28 10:07:27 +00:00
|
|
|
let my_local_values = activation.avm().run_with_stack_frame(
|
|
|
|
GcCell::allocate(context.gc_context, my_activation),
|
|
|
|
context,
|
|
|
|
|activation, context| activation.locals_into_form_values(context),
|
|
|
|
);
|
2019-11-02 22:08:06 +00:00
|
|
|
|
|
|
|
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()));
|
2020-06-20 23:02:45 +00:00
|
|
|
|
|
|
|
Ok(())
|
2019-11-02 22:08:06 +00:00
|
|
|
});
|
|
|
|
}
|