Skip to content

Commit

Permalink
Remove unnecessary empty lines between //when and //then
Browse files Browse the repository at this point in the history
  • Loading branch information
danon committed Apr 7, 2023
1 parent 1aba394 commit ef2caff
Show file tree
Hide file tree
Showing 37 changed files with 0 additions and 251 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ public function test(int $times, string $expected)
'(\s+|\?)',
];
$pattern = Pattern::list(\array_slice($patterns, 0, $times));

// when
$replaced = $pattern
->replace("Do you think that's air you're breathing now?")
->callback(Functions::constant('__'));

// then
$this->assertSame($expected, $replaced);
}
Expand Down Expand Up @@ -64,14 +62,12 @@ public function shouldInvokeCallbackForOnePattern()
$replace = $pattern->replace('a 1 b 2 c 3');
$matches = [];
$subjects = [];

// when
$result = $replace->callback(function (Detail $detail) use (&$matches, &$subjects) {
$matches[] = $detail->text();
$subjects[] = $detail->subject();
return '_';
});

// then
$first = 'a 1 b 2 c 3';
$second = '_ 1 _ 2 _ 3';
Expand Down
1 change: 0 additions & 1 deletion test/Feature/CleanRegex/_delimiter/PatternTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public function test(string $input)
{
// when
$pattern = Pattern::of("\Q$input\E");

// then
$this->assertConsumesFirst($input, $pattern);
}
Expand Down
11 changes: 0 additions & 11 deletions test/Feature/CleanRegex/_extended/_reset/PatternTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public function shouldAddComment_ResetButSetAgain()
{
// when
$pattern = Pattern::inject("(?^x)#@\n", []);

// then
$this->assertPatternIs("/(?^x)#@\n/", $pattern);
}
Expand All @@ -29,7 +28,6 @@ public function shouldUsePlaceholder_PatternExtended_Reset()
{
// when
$pattern = Pattern::inject("(?^)#@\n", ['Foo'], 'x');

// then
$this->assertConsumesFirstPcre2("#Foo\n", $pattern);
$this->assertPatternIs("/(?^)#(?>Foo)\n/x", $pattern);
Expand All @@ -42,7 +40,6 @@ public function shouldUsePlaceholder_PatternExtended_ResetShort()
{
// when
$pattern = Pattern::inject("(?^:#@\n)", ['Foo'], 'x');

// then
$this->assertConsumesFirstPcre2("#Foo\n", $pattern);
$this->assertPatternIs("/(?^:#(?>Foo)\n)/x", $pattern);
Expand All @@ -55,7 +52,6 @@ public function shouldUsePlaceholder_SubpatternExtended_Reset()
{
// when
$pattern = Pattern::inject("(?x)(?^:#@\n)", ['Foo']);

// then
$this->assertConsumesFirstPcre2("#Foo\n", $pattern);
$this->assertPatternIs("/(?x)(?^:#(?>Foo)\n)/", $pattern);
Expand All @@ -70,7 +66,6 @@ public function shouldAddComment_ResetButSetAgainCaseSensitiveFlag()
{
// when
$pattern = Pattern::inject("(?^X)#@\n", ['Bar']);

// then
$this->assertPatternIs("/(?^X)#(?>Bar)\n/", $pattern);
}
Expand All @@ -84,7 +79,6 @@ public function shouldAddComment_ResetButSetAgainExtraExtended()
{
// when
$pattern = Pattern::inject("(?^xx)#@\n", []);

// then
$this->assertPatternIs("/(?^xx)#@\n/", $pattern);
}
Expand All @@ -98,7 +92,6 @@ public function shouldAddComment_ResetButSetAgainCombination()
{
// when
$pattern = Pattern::inject("(?^imx)#@\n", []);

// then
$this->assertPatternIs("/(?^imx)#@\n/", $pattern);
}
Expand All @@ -112,7 +105,6 @@ public function shouldUsePlaceholder_SetExtendedResetOtherSubpattern()
{
// when
$pattern = Pattern::inject("(?x:(?^))#@\n", ['Bar']);

// then
$this->assertConsumesFirstPcre2("#Bar\n", $pattern);
$this->assertPatternIs("/(?x:(?^))#(?>Bar)\n/", $pattern);
Expand All @@ -127,7 +119,6 @@ public function shouldUsePlaceholder_SetExtendedResetSubpattern()
{
// when
$pattern = Pattern::inject("(?ix:(?^)#@\n)", ['Bar']);

// then
$this->assertConsumesFirstPcre2("#Bar\n", $pattern);
$this->assertPatternIs("/(?ix:(?^)#(?>Bar)\n)/", $pattern);
Expand All @@ -142,7 +133,6 @@ public function shouldAddComment_SetExtendedReset()
{
// when
$pattern = Pattern::inject("(?x)((?^))#@\n", []);

// then
$this->assertPatternIs("/(?x)((?^))#@\n/", $pattern);
}
Expand All @@ -156,7 +146,6 @@ public function shouldAddComment_SetExtendedResetShort()
{
// when
$pattern = Pattern::inject("(?x)(?^:)#@\n", []);

// then
$this->assertPatternIs("/(?x)(?^:)#@\n/", $pattern);
}
Expand Down
3 changes: 0 additions & 3 deletions test/Feature/CleanRegex/_extended/_whitespace/PatternTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public function shouldInject()
{
// when
$pattern = Pattern::inject("@:bar", ["user\ninput"]);

// then
$this->assertConsumesFirst("user\ninput:bar", $pattern);
}
Expand All @@ -28,7 +27,6 @@ public function shouldInject_ExtendedMode()
{
// when
$pattern = Pattern::inject("@:bar", ["user\n\vinput"], 'x');

// then
$this->assertConsumesFirst("user\n\vinput:bar", $pattern);
}
Expand All @@ -40,7 +38,6 @@ public function shouldTemplateLiteral_ExtendedMode()
{
// when
$pattern = Pattern::template('@:bar', 'x')->literal("user\n\vinput");

// then
$this->assertConsumesFirst("user\n\vinput:bar", $pattern);
}
Expand Down
5 changes: 0 additions & 5 deletions test/Feature/CleanRegex/_flags/PatternTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ public function shouldBuild_inject()
{
// given
$pattern = Pattern::inject('Foo@', ['Bar'], 'i');

// when
$flagIsAdded = $pattern->test('foobar');

// then
$this->assertTrue($flagIsAdded);
}
Expand All @@ -31,10 +29,8 @@ public function shouldBuild_template_literal()
{
// given
$pattern = Pattern::template('Foo@', 'i')->literal('Bar');

// when
$flagIsAdded = $pattern->test('foobar');

// then
$this->assertTrue($flagIsAdded);
}
Expand All @@ -46,7 +42,6 @@ public function shouldBuild_mask()
{
// when
$pattern = Pattern::mask('Cat:%w', ['%w' => 'Foo'], 'i');

// then
$this->assertConsumesFirst('cat:foo', $pattern);
}
Expand Down
9 changes: 0 additions & 9 deletions test/Feature/CleanRegex/_prepared/builder/PatternTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public function shouldNotMistakeLiteralForPlaceholder(string $pattern, string $e
{
// when
$pattern = Pattern::builder($pattern)->build();

// then
$this->assertPatternIs($expected, $pattern);
}
Expand Down Expand Up @@ -87,11 +86,9 @@ public function shouldThrowForSuperfluousTemplateMask()
{
// given
$builder = Pattern::builder('Foo')->mask('foo', ['foo', 'bar']);

// then
$this->expectException(PlaceholderFigureException::class);
$this->expectExceptionMessage("Supplied a superfluous figure. Used 0 placeholders, but 1 figures supplied.");

// when
$builder->build();
}
Expand All @@ -103,11 +100,9 @@ public function shouldThrowForSuperfluousBuilderTemplateAlteration()
{
// given
$builder = Pattern::builder('Foo')->alteration(['foo', 'bar']);

// then
$this->expectException(PlaceholderFigureException::class);
$this->expectExceptionMessage("Supplied a superfluous figure. Used 0 placeholders, but 1 figures supplied.");

// when
$builder->build();
}
Expand All @@ -133,11 +128,9 @@ public function shouldThrowForSuperfluousTemplatePattern()
{
// given
$builder = Pattern::builder('Foo')->pattern('bar');

// then
$this->expectException(PlaceholderFigureException::class);
$this->expectExceptionMessage('Supplied a superfluous figure. Used 0 placeholders, but 1 figures supplied.');

// when
$builder->build();
}
Expand All @@ -149,11 +142,9 @@ public function shouldThrowForRequiredExplicitDelimiter()
{
// given
$builder = Pattern::builder("s~i/e#++m%a!\@*`_-;=,\1");

// then
$this->expectException(ExplicitDelimiterRequiredException::class);
$this->expectExceptionMessage("Failed to select a distinct delimiter to enable template in its entirety");

// when
$builder->build();
}
Expand Down
16 changes: 0 additions & 16 deletions test/Feature/CleanRegex/_prepared/inject/PatternTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public function shouldUsePlaceholder(string $pattern, string $expected)
{
// when
$pattern = Pattern::inject($pattern, ['X']);

// then
$this->assertPatternIs($expected, $pattern);
}
Expand All @@ -45,7 +44,6 @@ public function shouldNotMistakeLiteralForPlaceholder(string $pattern, string $e
{
// when
$pattern = Pattern::inject($pattern, []);

// then
$this->assertPatternIs($expected, $pattern);
}
Expand All @@ -69,7 +67,6 @@ public function shouldIgnorePlaceholderInGroupComment()
{
// when
$pattern = Pattern::inject('foo(?#@', []);

// then
$this->assertPatternIs('/foo(?#@/', $pattern);
}
Expand All @@ -81,7 +78,6 @@ public function shouldIncludeRemainderInPattern()
{
// when
$pattern = Pattern::inject("(?x)#@\n", []);

// then
$this->assertPatternIs("/(?x)#@\n/", $pattern);
}
Expand All @@ -94,7 +90,6 @@ public function shouldCloseRemainder()
{
// when
$pattern = Pattern::inject("(#@\n(?x)#@\n)#@\n", ['One', 'Three']);

// then
$this->assertConsumesFirst("#One\n#Three\n", $pattern);
$this->assertPatternIs("/(#(?>One)\n(?x)#@\n)#(?>Three)\n/", $pattern);
Expand All @@ -108,7 +103,6 @@ public function shouldCloseRemainderAndParentPattern()
{
// when
$pattern = Pattern::inject("(?x:(?x))#@\n", ['Bar']);

// then
$this->assertConsumesFirst("#Bar\n", $pattern);
$this->assertPatternIs("/(?x:(?x))#(?>Bar)\n/", $pattern);
Expand All @@ -122,7 +116,6 @@ public function shouldIncludeRemainderInSubpattern()
{
// when
$pattern = Pattern::inject("(?x)(#@\n)", []);

// then
$this->assertPatternIs("/(?x)(#@\n)/", $pattern);
}
Expand All @@ -135,7 +128,6 @@ public function shouldIncludeRemainderInNextPattern()
{
// when
$pattern = Pattern::inject("(?x)()#@\n", []);

// then
$this->assertPatternIs("/(?x)()#@\n/", $pattern);
}
Expand All @@ -149,7 +141,6 @@ public function shouldIncludeRemainderInNextSubpattern()
{
// when
$pattern = Pattern::inject("(?x)()(#@\n)", []);

// then
$this->assertPatternIs("/(?x)()(#@\n)/", $pattern);
}
Expand All @@ -162,7 +153,6 @@ public function shouldIncludeRemainderInNextSubpatternBeforeGroupNull()
{
// when
$pattern = Pattern::inject("(?x)(?:)(#@\n)", []);

// then
$this->assertPatternIs("/(?x)(?:)(#@\n)/", $pattern);
}
Expand All @@ -175,7 +165,6 @@ public function shouldIncludeRemainderInNextSubpatternBeforeGroupNullShort()
{
// when
$pattern = Pattern::inject("(?x)(?)(#@\n)", []);

// then
$this->assertPatternIs("/(?x)(?)(#@\n)/", $pattern);
}
Expand All @@ -188,7 +177,6 @@ public function shouldIncludeRemainderInNextSubpatternBeforeGroupComment()
{
// when
$pattern = Pattern::inject("(?x)(?#)#@\n", []);

// then
$this->assertPatternIs("/(?x)(?#)#@\n/", $pattern);
}
Expand All @@ -201,7 +189,6 @@ public function shouldCloseRemainderInNextPattern()
{
// when
$pattern = Pattern::inject("((?x))#@\n", ['Bar']);

// then
$this->assertPatternIs("/((?x))#(?>Bar)\n/", $pattern);
}
Expand All @@ -214,7 +201,6 @@ public function shouldCloseRemainderInNextSubpattern()
{
// when
$pattern = Pattern::inject("((?x))(#@\n)", ['Bar']);

// then
$this->assertPatternIs("/((?x))(#(?>Bar)\n)/", $pattern);
}
Expand All @@ -227,7 +213,6 @@ public function shouldIncludeManyRemainders()
{
// when
$pattern = Pattern::inject("(?x)(?-x)(#@\n)", ['Bar']);

// then
$this->assertPatternIs("/(?x)(?-x)(#(?>Bar)\n)/", $pattern);
}
Expand All @@ -240,7 +225,6 @@ public function shouldCancelManyRemainders()
{
// when
$pattern = Pattern::inject("((?x)(?-x))#@\n", ['Bar']);

// then
$this->assertPatternIs("/((?x)(?-x))#(?>Bar)\n/", $pattern);
}
Expand Down
Loading

0 comments on commit ef2caff

Please sign in to comment.