forked from ewaters/altsql-shell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parsing Line Termination - Issue ewaters#20
Introducting a new method in the Model to parse a line from the command prompt and determine whether the command is complete. For example - altsql> select * from film where title = "; "; This failed because it stops at the end of the line even though we are inside quotation marks.
- Loading branch information
Matt Church
committed
May 17, 2017
1 parent
889470a
commit 2fcb2b3
Showing
3 changed files
with
110 additions
and
2 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,39 @@ | ||
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'; | ||
|
||
done_testing; |