You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An open parenthesis in an expression should always have a matching close parenthesis. In the initial implementation in PR #1 , it was noted that a mismatch was silently ignored and swallowed at least the next following token. This leads to an invalid set of tokens instead of an error message.
Expected Behavior
When a matching close parenthesis is not in an expression, an error message should be returned from the scan function.
Proposed New Test
Add the following test (and perhaps other variations) to test for unmatched parentheses to the TestScan function in scan_test.go.
{"operator error - malformed parenthetical", "(MIT",
[]token{}, errors.New("open parenthesis does not have a matching close parenthesis")},
Results with current code
expected: *errors.errorString(&errors.errorString{s:"open parenthesis does not have a matching close parenthesis"})
actual : <nil>(<nil>)
expected: <nil>(<nil>)
actual : []spdxexp.token{spdxexp.token{role:0x0, value:"("}, spdxexp.token{role:0x3, value:"MIT"}}
The text was updated successfully, but these errors were encountered:
fixes#4
The issue suggested fixing this at the scan level, but scan is just a tokenizer. Parse knows what is expected syntactically. The fix was made at the parse level and tests for malformed expressions were added.
fixes#4
The issue suggested fixing this at the scan level, but scan is just a tokenizer. Parse knows what is expected syntactically. The fix was made at the parse level and tests for malformed expressions were added.
Description
An open parenthesis in an expression should always have a matching close parenthesis. In the initial implementation in PR #1 , it was noted that a mismatch was silently ignored and swallowed at least the next following token. This leads to an invalid set of tokens instead of an error message.
Expected Behavior
When a matching close parenthesis is not in an expression, an error message should be returned from the
scan
function.Proposed New Test
Add the following test (and perhaps other variations) to test for unmatched parentheses to the
TestScan
function inscan_test.go
.Results with current code
The text was updated successfully, but these errors were encountered: