Skip to content

Commit 6ed9ac8

Browse files
committed
Improve last three tests adding suggestions from code review
1 parent 75dbacb commit 6ed9ac8

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

tests/Core/Tokenizers/Tokenizer/RecurseScopeMapSwitchTokenScopeTest.inc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,24 @@ switch((function () {
3737
/* testSwitchClosureWithReturnTypeWithinCondition */
3838
switch((function (): string {
3939
return 'bar';
40-
})()) /* testSwitchClosureWithReturnTypeWithinConditionScopeOpener */ {
40+
})()) /* testSwitchClosureWithReturnTypeWithinConditionScopeOpener */ :
41+
/* testSwitchClosureWithReturnTypeWithinConditionEnsureTestWillNotPickUpWrongColon */
4142
case 1:
4243
return 'test';
4344
/* testSwitchClosureWithReturnTypeWithinConditionScopeCloser */
44-
}
45+
endswitch;
4546

4647
/* testSwitchArrowFunctionWithinCondition */
47-
switch((fn() => 'bar')()) /* testSwitchArrowFunctionWithinConditionScopeOpener */ {
48+
switch((fn() => $obj->{$foo . $bar})()) /* testSwitchArrowFunctionWithinConditionScopeOpener */ {
4849
case 1:
4950
return 'test';
5051
/* testSwitchArrowFunctionWithinConditionScopeCloser */
5152
}
5253

5354
/* testSwitchArrowFunctionWithReturnTypeWithinCondition */
54-
switch((fn(): string => 'bar')()) /* testSwitchArrowFunctionWithReturnTypeWithinConditionScopeOpener */ {
55+
switch((fn(): string => $condition ? 'foo' : 'bar')()) /* testSwitchArrowFunctionWithReturnTypeWithinConditionScopeOpener */ :
56+
/* testSwitchArrowFunctionWithReturnTypeWithinConditionEnsureTestWillNotPickUpWrongColon */
5557
case 1:
5658
return 'test';
5759
/* testSwitchArrowFunctionWithReturnTypeWithinConditionScopeCloser */
58-
}
60+
endswitch;

tests/Core/Tokenizers/Tokenizer/RecurseScopeMapSwitchTokenScopeTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function testSwitchScope($testMarker, $expectedTokens, $testOpenerMarker=
9797
public static function dataSwitchScope()
9898
{
9999
return [
100-
'switch normal syntax' => [
100+
'switch normal syntax' => [
101101
'testMarker' => '/* testSwitchNormalSyntax */',
102102
'expectedTokens' => [
103103
'scope_opener' => T_OPEN_CURLY_BRACKET,
@@ -106,7 +106,7 @@ public static function dataSwitchScope()
106106
'testOpenerMarker' => null,
107107
'testCloserMarker' => '/* testSwitchNormalSyntaxScopeCloser */',
108108
],
109-
'switch alternative syntax' => [
109+
'switch alternative syntax' => [
110110
'testMarker' => '/* testSwitchAlternativeSyntax */',
111111
'expectedTokens' => [
112112
'scope_opener' => T_COLON,
@@ -115,7 +115,7 @@ public static function dataSwitchScope()
115115
'testOpenerMarker' => null,
116116
'testCloserMarker' => '/* testSwitchAlternativeSyntaxScopeCloser */',
117117
],
118-
'switch with closure in the condition' => [
118+
'switch with closure in the condition' => [
119119
'testMarker' => '/* testSwitchClosureWithinCondition */',
120120
'expectedTokens' => [
121121
'scope_opener' => T_OPEN_CURLY_BRACKET,
@@ -124,16 +124,16 @@ public static function dataSwitchScope()
124124
'testOpenerMarker' => '/* testSwitchClosureWithinConditionScopeOpener */',
125125
'testCloserMarker' => '/* testSwitchClosureWithinConditionScopeCloser */',
126126
],
127-
'switch with closure containing return type in the condition' => [
127+
'switch alternative syntax with closure containing return type in the condition' => [
128128
'testMarker' => '/* testSwitchClosureWithReturnTypeWithinCondition */',
129129
'expectedTokens' => [
130-
'scope_opener' => T_OPEN_CURLY_BRACKET,
131-
'scope_closer' => T_CLOSE_CURLY_BRACKET,
130+
'scope_opener' => T_COLON,
131+
'scope_closer' => T_ENDSWITCH,
132132
],
133133
'testOpenerMarker' => '/* testSwitchClosureWithReturnTypeWithinConditionScopeOpener */',
134134
'testCloserMarker' => '/* testSwitchClosureWithReturnTypeWithinConditionScopeCloser */',
135135
],
136-
'switch with arrow function in the condition' => [
136+
'switch with arrow function in the condition' => [
137137
'testMarker' => '/* testSwitchArrowFunctionWithinCondition */',
138138
'expectedTokens' => [
139139
'scope_opener' => T_OPEN_CURLY_BRACKET,
@@ -142,11 +142,11 @@ public static function dataSwitchScope()
142142
'testOpenerMarker' => '/* testSwitchArrowFunctionWithinConditionScopeOpener */',
143143
'testCloserMarker' => '/* testSwitchArrowFunctionWithinConditionScopeCloser */',
144144
],
145-
'switch with arrow function containing return type in the condition' => [
145+
'switch alternative syntax with arrow function containing return type in the condition' => [
146146
'testMarker' => '/* testSwitchArrowFunctionWithReturnTypeWithinCondition */',
147147
'expectedTokens' => [
148-
'scope_opener' => T_OPEN_CURLY_BRACKET,
149-
'scope_closer' => T_CLOSE_CURLY_BRACKET,
148+
'scope_opener' => T_COLON,
149+
'scope_closer' => T_ENDSWITCH,
150150
],
151151
'testOpenerMarker' => '/* testSwitchArrowFunctionWithReturnTypeWithinConditionScopeOpener */',
152152
'testCloserMarker' => '/* testSwitchArrowFunctionWithReturnTypeWithinConditionScopeCloser */',

0 commit comments

Comments
 (0)