diff --git a/core/tests/regression_tests.rs b/core/tests/regression_tests.rs index a21fdbbdb..70ffc9a16 100644 --- a/core/tests/regression_tests.rs +++ b/core/tests/regression_tests.rs @@ -2,7 +2,7 @@ //! //! Trace output can be compared with correct output from the official Flash Payer. -use approx::abs_diff_eq; +use approx::assert_abs_diff_eq; use log::{Metadata, Record}; use ruffle_core::backend::{ audio::NullAudioBackend, navigator::NullNavigatorBackend, render::NullRenderer, @@ -111,19 +111,23 @@ fn test_stage_object_enumerate() -> Result<(), Error> { #[test] fn test_stage_object_properties() -> Result<(), Error> { - let trace_log = run_swf("tests/swfs/avm1/stage_object_properties/test.swf", 1)?; - let actual: Vec = trace_log - .lines() - .map(|s| str::parse::(s).unwrap()) - .collect(); - let expected: Vec = - std::fs::read_to_string("tests/swfs/avm1/stage_object_properties/output.txt")? - .lines() - .map(|s| str::parse::(s).unwrap()) - .collect(); + let trace_log = run_swf("tests/swfs/avm1/stage_object_properties/test.swf", 4)?; + let expected_data = + std::fs::read_to_string("tests/swfs/avm1/stage_object_properties/output.txt")?; + assert_eq!( + trace_log.lines().count(), + expected_data.lines().count(), + "# of lines of output didn't match" + ); - for (actual, expected) in actual.into_iter().zip(expected.into_iter()) { - abs_diff_eq!(actual, expected, epsilon = 0.0001); + for (actual, expected) in trace_log.lines().zip(expected_data.lines()) { + // If these are numbers, compare using approx_eq. + if let (Ok(actual), Ok(expected)) = (actual.parse::(), expected.parse::()) { + // TODO: Lower this epsilon as the accuracy of the properties improves. + assert_abs_diff_eq!(actual, expected, epsilon = 0.5); + } else { + assert_eq!(actual, expected); + } } Ok(()) } diff --git a/core/tests/swfs/avm1/stage_object_properties/output.txt b/core/tests/swfs/avm1/stage_object_properties/output.txt new file mode 100644 index 000000000..1af484bba --- /dev/null +++ b/core/tests/swfs/avm1/stage_object_properties/output.txt @@ -0,0 +1,80 @@ +Starting properties: +289.25 +202.1 +805.95 +656.75 +-162.038711547852 +249.484237591759 +301.023390825966 +100 +true +Setting with SetMember... +Final properties: +123 +321 +673.2 +515.45 +27 +-321 +123 +50 +false +Starting properties: +123 +321 +673.2 +515.45 +27 +-321 +123 +50 +false +Setting with SetProperty... +Final properties: +100 +200 +153.3 +882 +90 +345 +-123 +25 +true +Testing ranges... +_x: +_y: +_rotation: +90 +180 +-179 +-180 +179 +_xscale: +345 +_yscale: +-123 +_scale: +-123 +_alpha: +25 +_currentframe: +1 +_totalframes: +1 +Testing width/height... +370.05 +108.1 +54.0467504391298 +100 +200.05 +108.1 +54.0467504391298 +54.05 +92.5 +200 +100 +25 +92.5 +50 +24.9966220780976 +25 diff --git a/core/tests/swfs/avm1/stage_object_properties/test.fla b/core/tests/swfs/avm1/stage_object_properties/test.fla new file mode 100644 index 000000000..4c7057764 Binary files /dev/null and b/core/tests/swfs/avm1/stage_object_properties/test.fla differ diff --git a/core/tests/swfs/avm1/stage_object_properties/test.swf b/core/tests/swfs/avm1/stage_object_properties/test.swf new file mode 100644 index 000000000..8608eb7b7 Binary files /dev/null and b/core/tests/swfs/avm1/stage_object_properties/test.swf differ