summaryrefslogtreecommitdiffstats
path: root/tests/Utils
diff options
context:
space:
mode:
authorDamian Dlugosz <bigfootdd@gmail.com>2017-01-10 22:27:47 +0100
committerDamian Dlugosz <bigfootdd@gmail.com>2017-01-10 22:30:29 +0100
commit51275207ef5cc18c7905b779858cda4bca7d4c81 (patch)
tree7f062738970b8ff06932f57a91974f5bb7470f2a /tests/Utils
parent4bef088a6edf74dc3a3e95493f4ecfe31762344d (diff)
downloadsql-parser-51275207ef5cc18c7905b779858cda4bca7d4c81.zip
sql-parser-51275207ef5cc18c7905b779858cda4bca7d4c81.tar.gz
sql-parser-51275207ef5cc18c7905b779858cda4bca7d4c81.tar.bz2
Fix comment parsing
Diffstat (limited to 'tests/Utils')
-rw-r--r--tests/Utils/CLITest.php2
-rw-r--r--tests/Utils/FormatterTest.php36
2 files changed, 25 insertions, 13 deletions
diff --git a/tests/Utils/CLITest.php b/tests/Utils/CLITest.php
index a97d98f..41d3965 100644
--- a/tests/Utils/CLITest.php
+++ b/tests/Utils/CLITest.php
@@ -39,7 +39,7 @@ class CLITest extends TestCase
),
array(
array('q' => 'SELECT /* comment */ 1 /* other */', 'f' => 'text'),
- "SELECT\n /* comment */ 1 /* other */\n",
+ "SELECT\n /* comment */ 1 /* other */\n",
0,
),
array(
diff --git a/tests/Utils/FormatterTest.php b/tests/Utils/FormatterTest.php
index 60db8ca..55246e0 100644
--- a/tests/Utils/FormatterTest.php
+++ b/tests/Utils/FormatterTest.php
@@ -250,12 +250,36 @@ class FormatTest extends TestCase
array('type' => 'html'),
),
array(
+ 'SELECT /* Comment */ 1' . "\n" .
+ 'FROM tbl # Comment' . "\n" .
+ 'WHERE 1 -- Comment',
+ 'SELECT' . "\n" .
+ ' /* Comment */ 1' . "\n" .
+ 'FROM' . "\n" .
+ ' tbl # Comment' . "\n" .
+ 'WHERE' . "\n" .
+ ' 1 -- Comment',
+ array('type' => 'text'),
+ ),
+ array(
'SELECT 1 # Comment',
'<span class="sql-reserved">SELECT</span>' . '<br/>' .
'&nbsp;&nbsp;&nbsp;&nbsp;<span class="sql-number">1</span> <span class="sql-comment"># Comment</span>',
array('type' => 'html'),
),
array(
+ 'SELECT 1 -- comment',
+ '<span class="sql-reserved">SELECT</span>' . '<br/>' .
+ '&nbsp;&nbsp;&nbsp;&nbsp;<span class="sql-number">1</span> <span class="sql-comment">-- comment</span>',
+ array('type' => 'html'),
+ ),
+ array(
+ 'SELECT 1 -- comment',
+ '<span class="sql-reserved">SELECT</span>' . '<br/>' .
+ '&nbsp;&nbsp;&nbsp;&nbsp;<span class="sql-number">1</span>',
+ array('type' => 'html', 'remove_comments' => true),
+ ),
+ array(
'SELECT HEX("1")',
'<span class="sql-reserved">SELECT</span>' . '<br/>' .
'&nbsp;&nbsp;&nbsp;&nbsp;<span class="sql-keyword">HEX</span>(<span class="sql-string">"1"</span>)',
@@ -317,18 +341,6 @@ class FormatTest extends TestCase
array('type' => 'html'),
),
array(
- 'SELECT 1 -- comment',
- '<span class="sql-reserved">SELECT</span>' . '<br/>' .
- '&nbsp;&nbsp;&nbsp;&nbsp;<span class="sql-number">1</span> <span class="sql-comment">-- comment</span>',
- array('type' => 'html'),
- ),
- array(
- 'SELECT 1 -- comment',
- '<span class="sql-reserved">SELECT</span>' . '<br/>' .
- '&nbsp;&nbsp;&nbsp;&nbsp;<span class="sql-number">1</span>',
- array('type' => 'html', 'remove_comments' => true),
- ),
- array(
'CREATE TABLE IF NOT EXISTS `pma__bookmark` (' . "\n" .
' `id` int(11) NOT NULL auto_increment,' . "\n" .
' `dbase` varchar(255) NOT NULL default "",' . "\n" .