From 1a44e1720c80e415c9b8c696ee20acedb6840d21 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 21 May 2024 16:09:24 +0200 Subject: [PATCH] Tests/DNFTypesTest: add extra safeguard for bitwise or within normal parentheses --- tests/Core/Tokenizer/PHP/DNFTypesTest.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/Core/Tokenizer/PHP/DNFTypesTest.php b/tests/Core/Tokenizer/PHP/DNFTypesTest.php index 89895ec3dd..9d7e395b3e 100644 --- a/tests/Core/Tokenizer/PHP/DNFTypesTest.php +++ b/tests/Core/Tokenizer/PHP/DNFTypesTest.php @@ -46,11 +46,19 @@ public function testNormalParentheses($testMarker, $skipCheckInside=false) $this->assertSame(T_CLOSE_PARENTHESIS, $closer['code'], 'Token tokenized as '.$closer['type'].', not T_CLOSE_PARENTHESIS (code)'); $this->assertSame('T_CLOSE_PARENTHESIS', $closer['type'], 'Token tokenized as '.$closer['type'].', not T_CLOSE_PARENTHESIS (type)'); - for ($i = ($openPtr + 1); $i < $closePtr; $i++) { - // If there are ampersands, make sure these are tokenized as bitwise and. - if ($skipCheckInside === false && $tokens[$i]['content'] === '&') { - $this->assertSame(T_BITWISE_AND, $tokens[$i]['code'], 'Token tokenized as '.$tokens[$i]['type'].', not T_BITWISE_AND (code)'); - $this->assertSame('T_BITWISE_AND', $tokens[$i]['type'], 'Token tokenized as '.$tokens[$i]['type'].', not T_BITWISE_AND (type)'); + if ($skipCheckInside === false) { + for ($i = ($openPtr + 1); $i < $closePtr; $i++) { + // If there are ampersands, make sure these are tokenized as bitwise and. + if ($tokens[$i]['content'] === '&') { + $this->assertSame(T_BITWISE_AND, $tokens[$i]['code'], 'Token tokenized as '.$tokens[$i]['type'].', not T_BITWISE_AND (code)'); + $this->assertSame('T_BITWISE_AND', $tokens[$i]['type'], 'Token tokenized as '.$tokens[$i]['type'].', not T_BITWISE_AND (type)'); + } + + // If there are pipes, make sure these are tokenized as bitwise or. + if ($tokens[$i]['content'] === '|') { + $this->assertSame(T_BITWISE_OR, $tokens[$i]['code'], 'Token tokenized as '.$tokens[$i]['type'].', not T_BITWISE_OR (code)'); + $this->assertSame('T_BITWISE_OR', $tokens[$i]['type'], 'Token tokenized as '.$tokens[$i]['type'].', not T_BITWISE_OR (type)'); + } } }