Commit 7723d59
committed
Tests/Tokenizer: fix
Among other things, the RecurseScopeMapDefaultKeywordConditionsTest
::testSwitchDefault() method checks if tokens within the scope of a
`T_DEFAULT` token have `T_DEFAULT` set as one of its `conditions` array.
The test was incorrectly checking token `conditions` due to an
off-by-one error in the loop range when the `T_DEFAULT` uses curly
braces.
For a `T_DEFAULT` with curly braces, the tokenizer adds `T_DEFAULT` to
the `conditions` array of all the tokens within its scope up to the
`T_BREAK|T_RETURN|T_CONTINUE`, but the test was checking only until the
token before the `T_BREAK|T_RETURN|T_CONTINUE`. While for a `T_DEFAULT`
without curly braces, it adds to all the tokens within the scope until
the token before the scope closer.
This commit updates the test to ensure that all tokens within a
default case scope that should have the `T_DEFAULT` token in their
`conditions` array are properly checked. To achieve that the loop was
modified:
- The end point ($end) is now set to `$closer - 1` when curly braces are
not used.
- The loop condition uses inclusive comparison (<=) to ensure that the
`$end` is also checked.conditions checking range in T_DEFAULT test1 parent 08a864f commit 7723d59
File tree
1 file changed
+2
-2
lines changed- tests/Core/Tokenizers/Tokenizer
1 file changed
+2
-2
lines changedLines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
| 160 | + | |
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| |||
0 commit comments