Skip to content

[Yaml] Fix wrong line number when comments are inserted in the middle of a block. #17733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next Next commit
[Yaml] Fix wrong line number when comments are inserted in the middle…
… of a block.
  • Loading branch information
paradajozsef committed May 6, 2016
commit 88d210f9a6078c20e8be9e8d6a62ff70b901010e
40 changes: 40 additions & 0 deletions src/Symfony/Component/Yaml/Tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,46 @@ public function getInvalidBinaryData()
),
);
}

/**
* @param $lineNumber
* @param $yaml
* @dataProvider parserThrowsExceptionWithCorrectLineNumberProvider
*/
public function testParserThrowsExceptionWithCorrectLineNumber($lineNumber, $yaml)
{
$this->setExpectedException(
'\Symfony\Component\Yaml\Exception\ParseException',
sprintf('Unexpected characters near "," at line %d (near "bar: "123",").', $lineNumber)
);

$this->parser->parse($yaml);
}

public function parserThrowsExceptionWithCorrectLineNumberProvider()
{
return array(
array(
4,
<<<YAML
foo:
-
# bar
bar: "123",
YAML
),
array(
5,
<<<YAML
foo:
-
# bar
# bar
bar: "123",
YAML
),
);
}
}

class B
Expand Down