blob: 3726ded85d02198ed9d57b78d0d7a16353deb863 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
<?php
/**
* @covers JsMinPlus
*/
class JsMinPlusTest extends PHPUnit\Framework\TestCase {
public static function provideValidInputs() {
// If an implementation matches inputs using a regex with runaway backtracking,
// then inputs with more than ~3072 repetitions are likely to fail (T299537).
$input = '"' . str_repeat( 'x', 10000 ) . '";';
yield 'double quote string 10K' => [ $input ];
$input = '\'' . str_repeat( 'x', 10000 ) . '\';';
yield 'single quote string 10K' => [ $input ];
$input = '"' . str_repeat( '\u0021', 100 ) . '";';
yield 'escaping string 100' => [ $input ];
$input = '"' . str_repeat( '\u0021', 10000 ) . '";';
yield 'escaping string 10K' => [ $input ];
$input = '/' . str_repeat( 'x', 1000 ) . '/;';
yield 'regex 1K' => [ $input ];
$input = '/' . str_repeat( 'x', 10000 ) . '/;';
yield 'regex 10K' => [ $input ];
$input = '/' . str_repeat( '\u0021', 100 ) . '/;';
yield 'escaping regex 100' => [ $input ];
$input = '/' . str_repeat( '\u0021', 10000 ) . '/;';
yield 'escaping regex 10K' => [ $input ];
}
/**
* @dataProvider provideValidInputs
* @doesNotPerformAssertions
*/
public function testLongStrings( string $input ) {
// Ensure no parse error thrown
JSMinPlus::minify( $input );
}
}
|