tinyexpr: report errors for extra args in parens correctly.

Usages like `math (1 1)` should report too many arguments,
same as `math 1 1`. Check for these cases and add tests.

Fixes #8511
This commit is contained in:
Aaron Gyes
2021-12-01 04:38:42 -08:00
parent abf119918f
commit de0cbd2984
2 changed files with 21 additions and 1 deletions

View File

@@ -129,6 +129,18 @@ not math '2 + 2 4'
# CHECKERR: math: Error: Too many arguments
# CHECKERR: '2 + 2 4'
# CHECKERR: ^
not math '(1 2)'
# CHECKERR: math: Error: Too many arguments
# CHECKERR: '(1 2)'
# CHECKERR: ^
not math '(1 pi)'
# CHECKERR: math: Error: Too many arguments
# CHECKERR: '(1 pi)'
# CHECKERR: ^
not math '(1 pow 1,2)'
# CHECKERR: math: Error: Too many arguments
# CHECKERR: '(1 pow 1,2)'
# CHECKERR: ^
not math
# CHECKERR: math: expected >= 1 arguments; got 0
not math -s 12
@@ -182,6 +194,11 @@ math 'log(16'
# CHECKERR: 'log(16'
# CHECKERR: ^
math '(2'
# CHECKERR: math: Error: Missing closing parenthesis
# CHECKERR: '(2'
# CHECKERR: ^
math --base=16 255 / 15
# CHECK: 0x11
math -bhex 16 x 2