annotate vendor/nikic/php-parser/test/PhpParser/CommentTest.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 129ea1e6d783
children
rev   line source
Chris@13 1 <?php declare(strict_types=1);
Chris@0 2
Chris@0 3 namespace PhpParser;
Chris@0 4
Chris@17 5 class CommentTest extends \PHPUnit\Framework\TestCase
Chris@0 6 {
Chris@0 7 public function testGetSet() {
Chris@13 8 $comment = new Comment('/* Some comment */', 1, 10, 2);
Chris@0 9
Chris@0 10 $this->assertSame('/* Some comment */', $comment->getText());
Chris@0 11 $this->assertSame('/* Some comment */', (string) $comment);
Chris@0 12 $this->assertSame(1, $comment->getLine());
Chris@0 13 $this->assertSame(10, $comment->getFilePos());
Chris@13 14 $this->assertSame(2, $comment->getTokenPos());
Chris@0 15 }
Chris@0 16
Chris@0 17 /**
Chris@0 18 * @dataProvider provideTestReformatting
Chris@0 19 */
Chris@0 20 public function testReformatting($commentText, $reformattedText) {
Chris@0 21 $comment = new Comment($commentText);
Chris@0 22 $this->assertSame($reformattedText, $comment->getReformattedText());
Chris@0 23 }
Chris@0 24
Chris@0 25 public function provideTestReformatting() {
Chris@13 26 return [
Chris@13 27 ['// Some text' . "\n", '// Some text'],
Chris@13 28 ['/* Some text */', '/* Some text */'],
Chris@13 29 [
Chris@0 30 '/**
Chris@0 31 * Some text.
Chris@0 32 * Some more text.
Chris@0 33 */',
Chris@0 34 '/**
Chris@0 35 * Some text.
Chris@0 36 * Some more text.
Chris@0 37 */'
Chris@13 38 ],
Chris@13 39 [
Chris@0 40 '/*
Chris@0 41 Some text.
Chris@0 42 Some more text.
Chris@0 43 */',
Chris@0 44 '/*
Chris@0 45 Some text.
Chris@0 46 Some more text.
Chris@0 47 */'
Chris@13 48 ],
Chris@13 49 [
Chris@0 50 '/* Some text.
Chris@0 51 More text.
Chris@0 52 Even more text. */',
Chris@0 53 '/* Some text.
Chris@0 54 More text.
Chris@0 55 Even more text. */'
Chris@13 56 ],
Chris@13 57 [
Chris@0 58 '/* Some text.
Chris@0 59 More text.
Chris@0 60 Indented text. */',
Chris@0 61 '/* Some text.
Chris@0 62 More text.
Chris@0 63 Indented text. */',
Chris@13 64 ],
Chris@0 65 // invalid comment -> no reformatting
Chris@13 66 [
Chris@0 67 'hallo
Chris@0 68 world',
Chris@0 69 'hallo
Chris@0 70 world',
Chris@13 71 ],
Chris@13 72 ];
Chris@0 73 }
Chris@13 74 }