@@ -18,21 +18,23 @@ final class BackfillNumericSeparatorTest extends AbstractMethodUnitTest
18
18
/**
19
19
* Test that numbers using numeric separators are tokenized correctly.
20
20
*
21
- * @param array $testData The data required for the specific test case.
21
+ * @param string $marker The comment which prefaces the target token in the test file.
22
+ * @param string $type The expected token type.
23
+ * @param string $value The expected token content.
22
24
*
23
25
* @dataProvider dataTestBackfill
24
26
* @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize
25
27
*
26
28
* @return void
27
29
*/
28
- public function testBackfill ($ testData )
30
+ public function testBackfill ($ marker , $ type , $ value )
29
31
{
30
32
$ tokens = self ::$ phpcsFile ->getTokens ();
31
- $ number = $ this ->getTargetToken ($ testData [ ' marker ' ] , [T_LNUMBER , T_DNUMBER ]);
33
+ $ number = $ this ->getTargetToken ($ marker , [T_LNUMBER , T_DNUMBER ]);
32
34
33
- $ this ->assertSame (constant ($ testData [ ' type ' ] ), $ tokens [$ number ]['code ' ]);
34
- $ this ->assertSame ($ testData [ ' type ' ] , $ tokens [$ number ]['type ' ]);
35
- $ this ->assertSame ($ testData [ ' value ' ] , $ tokens [$ number ]['content ' ]);
35
+ $ this ->assertSame (constant ($ type ), $ tokens [$ number ]['code ' ]);
36
+ $ this ->assertSame ($ type , $ tokens [$ number ]['type ' ]);
37
+ $ this ->assertSame ($ value , $ tokens [$ number ]['content ' ]);
36
38
37
39
}//end testBackfill()
38
40
@@ -63,95 +65,69 @@ public static function dataTestBackfill()
63
65
64
66
return [
65
67
[
66
- [
67
- 'marker ' => '/* testSimpleLNumber */ ' ,
68
- 'type ' => 'T_LNUMBER ' ,
69
- 'value ' => '1_000_000_000 ' ,
70
- ],
68
+ 'marker ' => '/* testSimpleLNumber */ ' ,
69
+ 'type ' => 'T_LNUMBER ' ,
70
+ 'value ' => '1_000_000_000 ' ,
71
71
],
72
72
[
73
- [
74
- 'marker ' => '/* testSimpleDNumber */ ' ,
75
- 'type ' => 'T_DNUMBER ' ,
76
- 'value ' => '107_925_284.88 ' ,
77
- ],
73
+ 'marker ' => '/* testSimpleDNumber */ ' ,
74
+ 'type ' => 'T_DNUMBER ' ,
75
+ 'value ' => '107_925_284.88 ' ,
78
76
],
79
77
[
80
- [
81
- 'marker ' => '/* testFloat */ ' ,
82
- 'type ' => 'T_DNUMBER ' ,
83
- 'value ' => '6.674_083e-11 ' ,
84
- ],
78
+ 'marker ' => '/* testFloat */ ' ,
79
+ 'type ' => 'T_DNUMBER ' ,
80
+ 'value ' => '6.674_083e-11 ' ,
85
81
],
86
82
[
87
- [
88
- 'marker ' => '/* testFloat2 */ ' ,
89
- 'type ' => 'T_DNUMBER ' ,
90
- 'value ' => '6.674_083e+11 ' ,
91
- ],
83
+ 'marker ' => '/* testFloat2 */ ' ,
84
+ 'type ' => 'T_DNUMBER ' ,
85
+ 'value ' => '6.674_083e+11 ' ,
92
86
],
93
87
[
94
- [
95
- 'marker ' => '/* testFloat3 */ ' ,
96
- 'type ' => 'T_DNUMBER ' ,
97
- 'value ' => '1_2.3_4e1_23 ' ,
98
- ],
88
+ 'marker ' => '/* testFloat3 */ ' ,
89
+ 'type ' => 'T_DNUMBER ' ,
90
+ 'value ' => '1_2.3_4e1_23 ' ,
99
91
],
100
92
[
101
- [
102
- 'marker ' => '/* testHex */ ' ,
103
- 'type ' => $ testHexType ,
104
- 'value ' => '0xCAFE_F00D ' ,
105
- ],
93
+ 'marker ' => '/* testHex */ ' ,
94
+ 'type ' => $ testHexType ,
95
+ 'value ' => '0xCAFE_F00D ' ,
106
96
],
107
97
[
108
- [
109
- 'marker ' => '/* testHexMultiple */ ' ,
110
- 'type ' => $ testHexMultipleType ,
111
- 'value ' => '0x42_72_6F_77_6E ' ,
112
- ],
98
+ 'marker ' => '/* testHexMultiple */ ' ,
99
+ 'type ' => $ testHexMultipleType ,
100
+ 'value ' => '0x42_72_6F_77_6E ' ,
113
101
],
114
102
[
115
- [
116
- 'marker ' => '/* testHexInt */ ' ,
117
- 'type ' => 'T_LNUMBER ' ,
118
- 'value ' => '0x42_72_6F ' ,
119
- ],
103
+ 'marker ' => '/* testHexInt */ ' ,
104
+ 'type ' => 'T_LNUMBER ' ,
105
+ 'value ' => '0x42_72_6F ' ,
120
106
],
121
107
[
122
- [
123
- 'marker ' => '/* testBinary */ ' ,
124
- 'type ' => 'T_LNUMBER ' ,
125
- 'value ' => '0b0101_1111 ' ,
126
- ],
108
+ 'marker ' => '/* testBinary */ ' ,
109
+ 'type ' => 'T_LNUMBER ' ,
110
+ 'value ' => '0b0101_1111 ' ,
127
111
],
128
112
[
129
- [
130
- 'marker ' => '/* testOctal */ ' ,
131
- 'type ' => 'T_LNUMBER ' ,
132
- 'value ' => '0137_041 ' ,
133
- ],
113
+ 'marker ' => '/* testOctal */ ' ,
114
+ 'type ' => 'T_LNUMBER ' ,
115
+ 'value ' => '0137_041 ' ,
134
116
],
135
117
[
136
- [
137
- 'marker ' => '/* testExplicitOctal */ ' ,
138
- 'type ' => 'T_LNUMBER ' ,
139
- 'value ' => '0o137_041 ' ,
140
- ],
118
+ 'marker ' => '/* testExplicitOctal */ ' ,
119
+ 'type ' => 'T_LNUMBER ' ,
120
+ 'value ' => '0o137_041 ' ,
141
121
],
142
122
[
143
- [
144
- 'marker ' => '/* testExplicitOctalCapitalised */ ' ,
145
- 'type ' => 'T_LNUMBER ' ,
146
- 'value ' => '0O137_041 ' ,
147
- ],
123
+ 'marker ' => '/* testExplicitOctalCapitalised */ ' ,
124
+ 'type ' => 'T_LNUMBER ' ,
125
+ 'value ' => '0O137_041 ' ,
148
126
],
149
127
[
150
- [
151
- 'marker ' => '/* testIntMoreThanMax */ ' ,
152
- 'type ' => $ testIntMoreThanMaxType ,
153
- 'value ' => '10_223_372_036_854_775_807 ' ,
154
- ],
128
+ 'marker ' => '/* testIntMoreThanMax */ ' ,
129
+ 'type ' => $ testIntMoreThanMaxType ,
130
+ 'value ' => '10_223_372_036_854_775_807 ' ,
155
131
],
156
132
];
157
133
0 commit comments