diff --git a/challenges/declaring-variables/src/lib.rs b/challenges/declaring-variables/src/lib.rs index 4e13e25..a1c34cc 100644 --- a/challenges/declaring-variables/src/lib.rs +++ b/challenges/declaring-variables/src/lib.rs @@ -1,11 +1,6 @@ pub fn calculate_area() -> u32 { - // Declare width and height as immutable variables let width = 10; let height = 5; - // Calculate the area of the rectangle - let area = width * height; - - // Return the calculated area - area + width * height } diff --git a/challenges/declaring-variables/tests/tests.rs b/challenges/declaring-variables/tests/tests.rs index 36d74ba..ec15ebe 100644 --- a/challenges/declaring-variables/tests/tests.rs +++ b/challenges/declaring-variables/tests/tests.rs @@ -1,5 +1,5 @@ use declaring_variables::*; -use syntest::Syntest; +use syntest::{LocalValue, Syntest}; #[test] fn test_calculate_area() { @@ -9,4 +9,13 @@ fn test_calculate_area() { #[test] fn test_variable_width() { let syntest = Syntest::from("./src/lib.rs"); + + assert_eq!( + syntest.get_local_value("calculate_area", "width").unwrap(), + LocalValue::Int(10) + ); + assert_eq!( + syntest.get_local_value("calculate_area", "height").unwrap(), + LocalValue::Int(5) + ); }