-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from cv-library/issue20
Parsing Line Termination - Issue #20
- Loading branch information
Showing
3 changed files
with
118 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use strict; | ||
use warnings; | ||
use Test::More; | ||
use Test::Deep; | ||
use App::AltSQL::Model; | ||
|
||
ok my $model = App::AltSQL::Model->new(app => 1); | ||
|
||
is $model->is_end_of_statement('test'), 0, 'Incomplete statement'; | ||
|
||
is $model->is_end_of_statement('test;'), 1, 'Semicolon completes statement'; | ||
|
||
is $model->is_end_of_statement('quit'), 1, 'quit statement'; | ||
|
||
is $model->is_end_of_statement('exit'), 1, 'exit statement'; | ||
|
||
is $model->is_end_of_statement(' '), 1, 'blank space statement'; | ||
|
||
is $model->is_end_of_statement('test\G'), 1, '\G statement'; | ||
|
||
is $model->is_end_of_statement('test\c'), 1, '\c statement'; | ||
|
||
is $model->is_end_of_statement('select * from film where title = ";'), 0, 'Semi colon in string'; | ||
is $model->is_end_of_statement(qq{select * from film where title = ";\n";}), 1, 'Tail end of statement where we were in a string'; | ||
|
||
is $model->is_end_of_statement('insert into mytab values (";",'), 0, 'Incomplete statement'; | ||
|
||
is $model->is_end_of_statement(q{select * from film where title = '\';}), 0, 'Semi colon in string'; | ||
|
||
is $model->is_end_of_statement(q{select * from film where title = "\";}), 0, 'Semi colon in string'; | ||
|
||
is $model->is_end_of_statement(q{select * from film where title = "\\\\";}), 1, 'Escaped slash, terminated string and end of statement'; | ||
|
||
is $model->is_end_of_statement(q{select * from film where title = /* "\";}), 0, 'Semi colon in comment'; | ||
is $model->is_end_of_statement(qq{select * from film where title = /* "\";\n*/ 'test';}), 1, 'Statement terminated after comment closes'; | ||
|
||
is $model->is_end_of_statement(q{select 'test'; -- a simple statement}), 1, 'Statement terminated Got a comment after'; | ||
|
||
is $model->is_end_of_statement(qq{select 'test' -- a simple statement\n;}), 1, 'Statement with -- comment terminated on next line'; | ||
|
||
done_testing; |