Skip to content

test: add regression tests for #439 (logical NOT immediately after AND/OR/EQ) - #446

Open
chenjunwenhao wants to merge 1 commit into
alibaba:mainfrom
chenjunwenhao:test/issue-439-regression-logic-not-after-and
Open

test: add regression tests for #439 (logical NOT immediately after AND/OR/EQ)#446
chenjunwenhao wants to merge 1 commit into
alibaba:mainfrom
chenjunwenhao:test/issue-439-regression-logic-not-after-and

Conversation

@chenjunwenhao

Copy link
Copy Markdown
Contributor

Summary

Issue #439 reported that &&! (logical NOT immediately after logical AND, without spaces) failed to compile in QLExpress v4. The root cause was the ANTLR4 lexer's greedy longest-match rule merging &&! into a single OPID token instead of OPID("&&") + BANG("!").

The bug has been fixed in the current main branch (ANTLR4 was replaced with a hand-written lexer that explicitly handles &&, ||, ==, != as 2-character tokens). However, no regression tests existed for this edge case.

This PR adds 11 regression tests to prevent future regressions.

Changes

New file: src/test/java/com/alibaba/qlexpress4/test/issue/Issue439RegressionTest.java

Lexer-level tests (3)

Test Expression Expected Tokens
lexerShouldSplitAndBangIntoOpidAndBang &&! OPID(&&) + BANG(!)
lexerShouldSplitOrBangIntoOpidAndBang ||! OPID(||) + BANG(!)
lexerShouldSplitEqBangIntoOpidAndBang ==! OPID(==) + BANG(!)

Parser / Execution tests (8)

Test Expression Description
executeLogicalAndNotWithSpaces a && !b Baseline with spaces
executeLogicalAndNotWithoutSpaces a&&!b Core regression case
executeIfNotNullAndNotWithNoSpaces if(x!=null&&!y) Mixed operators in if
executeNestedAndNotWithoutSpaces a&&!b&&!c Chained AND-NOT
executeComplexNotNullAndNotEqualsWithoutSpaces oldObj!=null&&!oldObj.equals("test") Complex expression
executeComplexNotNullShortCircuitWhenNull same, with null oldObj Short-circuit verification
executeLogicalOrNotWithoutSpaces a||!b OR-NOT variant
executeOriginalIssuePattern Full original pattern from #439 End-to-end regression

Test Results

Issue439RegressionTest: 11 tests run, 0 failures, 0 errors
Full suite: 215 tests run, 0 failures, 0 errors, BUILD SUCCESS

Fixes #439

…tely after AND)

Issue alibaba#439 reported that expressions like `if(oldObj!=null&&!oldObj.getLong("status"))`
failed to compile in v4 due to the ANTLR4 lexer greedily merging `&&!` into a single
OPID token instead of separate `&&` + `!` tokens.

The bug has been fixed by replacing ANTLR4 with a hand-written lexer, but no regression
tests existed for this edge case. This PR adds 11 tests covering:

Lexer-level (3 tests):
- `&&!` → OPID(`&&`) + BANG(`!`)
- `||!` → OPID(`||`) + BANG(`!`)
- `==!` → OPID(`==`) + BANG(`!`)

Parser/Execution-level (8 tests):
- `a && !b` with spaces (baseline)
- `a&&!b` without spaces (core regression)
- `if(x!=null&&!y)` mixed operators
- `a&&!b&&!c` chained
- `oldObj!=null&&!oldObj.equals("test")` complex
- Short-circuit when null
- `a||!b` OR variant
- Full original issue pattern

All 215 existing tests + 11 new tests pass.

Fixes alibaba#439
@CLAassistant

CLAassistant commented Jun 20, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

升级4版本后编译报错

2 participants