diff --git a/api/sixtyfps-cpp/include/sixtyfps_properties.h b/api/sixtyfps-cpp/include/sixtyfps_properties.h index adf5d4ac4..85fbcbf66 100644 --- a/api/sixtyfps-cpp/include/sixtyfps_properties.h +++ b/api/sixtyfps-cpp/include/sixtyfps_properties.h @@ -43,6 +43,6 @@ struct Property private: internal::PropertyHandleOpaque inner; - mutable T value; + mutable T value{}; }; } diff --git a/tests/cases/conditional_expr.60 b/tests/cases/conditional_expr.60 index 129f971a4..3a7c57208 100644 --- a/tests/cases/conditional_expr.60 +++ b/tests/cases/conditional_expr.60 @@ -1,14 +1,21 @@ TestCase := Rectangle { property condition; property test_value: condition ? 1 : 2; + property condition2; + property test_value2: condition ? condition2 ? 1 : 2 : condition2 ? 3 : 4; + } /* ```cpp TestCase instance; instance.set_condition(true); assert(instance.get_test_value() == 1); +assert(instance.get_test_value2() == 2); instance.set_condition(false); assert(instance.get_test_value() == 2); +assert(instance.get_test_value2() == 4); +instance.set_condition2(true); +assert(instance.get_test_value2() == 3); ``` @@ -16,8 +23,12 @@ assert(instance.get_test_value() == 2); let instance = TestCase::default(); instance.set_condition(true); assert_eq!(instance.get_test_value(), 1); +assert_eq!(instance.get_test_value2(), 2); instance.set_condition(false); assert_eq!(instance.get_test_value(), 2); +assert_eq!(instance.get_test_value2(), 4); +instance.set_condition2(true); +assert_eq!(instance.get_test_value2(), 3); ``` ```js diff --git a/tests/driver/cpp.rs b/tests/driver/cpp.rs index 1505d5fd8..0610a3823 100644 --- a/tests/driver/cpp.rs +++ b/tests/driver/cpp.rs @@ -1,6 +1,7 @@ use sixtyfps_compilerlib::*; use std::error::Error; use std::io::Write; +use std::ops::Deref; pub fn test(testcase: &test_driver_lib::TestCase) -> Result<(), Box> { let source = std::fs::read_to_string(&testcase.absolute_path)?; @@ -82,20 +83,23 @@ pub fn test(testcase: &test_driver_lib::TestCase) -> Result<(), Box> return Err("C++ Compilation error (see stdout)".to_owned().into()); } - std::process::Command::new(binary_path.clone()) + let output = std::process::Command::new(binary_path.deref()) + .stdout(std::process::Stdio::piped()) + .stderr(std::process::Stdio::piped()) .spawn() .map_err(|err| format!("Error launching testcase binary: {}", err))? - .wait() - .map_err(|err| format!("Test case could not be run: {}", err)) - .and_then(|status| { - if status.success() { - Ok(()) - } else if let Some(exit_code) = status.code() { - Err(format!("Test case exited with non-zero code: {}", exit_code)) - } else { - Err("Test case exited by signal".into()) - } - })?; + .wait_with_output() + .map_err(|err| format!("Test case could not be run: {}", err))?; + + if !output.status.success() { + print!("{}", String::from_utf8_lossy(output.stdout.as_ref())); + print!("{}", String::from_utf8_lossy(output.stderr.as_ref())); + if let Some(exit_code) = output.status.code() { + return Err(format!("Test case exited with non-zero code: {}", exit_code).into()); + } else { + return Err("Test case exited by signal".into()); + } + } if keep_temp_files { println!(