Skip to content

Commit

Permalink
Fix precedence value of array
Browse files Browse the repository at this point in the history
Array must have the same precedence as const since they are
  • Loading branch information
BijanVeyssi committed Jan 3, 2024
1 parent 6fe446f commit 78db585
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/operator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl Operator {
| AndAssign | OrAssign => 50,

Tuple => 40,
Array => 45,
Array => 200,
Chain => 0,

Const { .. } => 200,
Expand Down
23 changes: 23 additions & 0 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1565,6 +1565,29 @@ fn test_array_definitions() {
);
}

#[test]
fn test_array_invalid_computation() {
assert_eq!(
eval("{}+"),
Err(EvalexprError::WrongOperatorArgumentAmount {
expected: 2,
actual: 1
})
);
assert_eq!(
eval("1+{}"),
Err(EvalexprError::ExpectedNumberOrString {
actual: Value::Array(vec![])
})
);
assert_eq!(
eval("{1, 2, 3}+2"),
Err(EvalexprError::ExpectedNumberOrString {
actual: Value::Array(vec![1.into(), 2.into(), 3.into()])
})
);
}

#[test]
fn test_tuple_definitions() {
assert_eq!(eval_empty("()"), Ok(()));
Expand Down

0 comments on commit 78db585

Please sign in to comment.