Skip to content

Commit

Permalink
make sure parentheses get closed
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertasJ committed Oct 24, 2024
1 parent d288144 commit 2c0fbe5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/torin/src/values/size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ impl<'a> DynamicCalculationEvaluator<'a> {
// function should return on DynamicCalculation::ClosedParenthesis because it does
// not have a precedence, thats how it actually works
let val = self.parse_expression(0);
if self.current != Some(&DynamicCalculation::ClosedParenthesis) {
return None;
}
self.current = self.calcs.next();
Some((val?, true))
}
Expand Down
12 changes: 12 additions & 0 deletions crates/torin/tests/size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -945,4 +945,16 @@ pub fn test_calc() {
),
Some(-1.0 * 10.0 * 20.0)
);

assert_eq!(
run_calculations(
&vec![
DynamicCalculation::OpenParenthesis,
DynamicCalculation::Pixels(10.0),
],
PARENT_VALUE,
PARENT_VALUE
),
None
);
}

0 comments on commit 2c0fbe5

Please sign in to comment.