Additional printer test

This commit is contained in:
Vladimir Razuvaev 2018-08-22 12:28:13 +07:00
parent 6e7cf27579
commit d87c1aba5c
2 changed files with 24 additions and 3 deletions

View File

@ -488,6 +488,6 @@ class Printer
return (($value[0] === ' ' || $value[0] === "\t") && strpos($value, "\n") === false)
? ('"""' . preg_replace('/"$/', "\"\n", $escaped) . '"""')
: ("\"\"\"\n" . ($isDescription ? $escaped : $this->indent($escaped)) . "\n\"\"\"");
: ('"""' . "\n" . ($isDescription ? $escaped : $this->indent($escaped)) . "\n" . '"""');
}
}

View File

@ -95,7 +95,7 @@ class PrinterTest extends TestCase
}
/**
* @it correctly prints single-line block strings with leading space
* @it correctly prints single-line with leading space
*/
public function testCorrectlyPrintsSingleLineBlockStringsWithLeadingSpace()
{
@ -110,7 +110,7 @@ class PrinterTest extends TestCase
}
/**
* @it correctly prints block strings with a first line indentation
* @it correctly prints string with a first line indentation
*/
public function testCorrectlyPrintsBlockStringsWithAFirstLineIndentation()
{
@ -134,6 +134,27 @@ class PrinterTest extends TestCase
$this->assertEquals($expected, Printer::doPrint($mutationAstWithArtifacts));
}
/**
* @it correctly prints single-line with leading space and quotation
*/
public function testCorrectlyPrintsSingleLineWithLeadingSpaceAndQuotation()
{
$mutationAstWithArtifacts = Parser::parse('
{
field(arg: """ space-led value "quoted string"
""")
}
');
$expected = <<<END
{
field(arg: """ space-led value "quoted string"
""")
}
END;
$this->assertEquals($expected, Printer::doPrint($mutationAstWithArtifacts));
}
/**
* @it Experimental: correctly prints fragment defined variables
*/