Skip to content

Commit

Permalink
Tests/DNFTypesTest: add extra safeguard for bitwise or within normal …
Browse files Browse the repository at this point in the history
…parentheses
  • Loading branch information
jrfnl committed May 21, 2024
1 parent 8f0d8de commit 1a44e17
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions tests/Core/Tokenizer/PHP/DNFTypesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)');
}
}
}

Expand Down

0 comments on commit 1a44e17

Please sign in to comment.