diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-10-22 02:08:07 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-10-22 02:08:07 -0400 |
commit | 7e101392f826c6fb8a6980028ff94eab61ba8f55 (patch) | |
tree | d72488d4ead82c8b57f3d1872dcddf8947cc2a6d | |
parent | 46f89f90a5eb4b8f298d5511d4f92569bc79c87e (diff) | |
download | devel-completestatement-7e101392f826c6fb8a6980028ff94eab61ba8f55.tar.gz devel-completestatement-7e101392f826c6fb8a6980028ff94eab61ba8f55.zip |
more fiddling
-rw-r--r-- | CompleteStatement.xs | 8 | ||||
-rw-r--r-- | lib/Devel/CompleteStatement.pm | 4 | ||||
-rw-r--r-- | t/basic.t | 12 |
3 files changed, 17 insertions, 7 deletions
diff --git a/CompleteStatement.xs b/CompleteStatement.xs index aee013a..503e5f2 100644 --- a/CompleteStatement.xs +++ b/CompleteStatement.xs @@ -54,7 +54,7 @@ _parse() LEAVE; -int +SV * complete_statement(str) SV *str PREINIT: @@ -116,7 +116,11 @@ complete_statement(str) call_parse(); - RETVAL = (depth == 0); + RETVAL = (PL_parser->bufptr != PL_parser->bufend) + ? &PL_sv_undef + : (depth == 0) + ? &PL_sv_yes + : &PL_sv_no; FREETMPS; LEAVE; diff --git a/lib/Devel/CompleteStatement.pm b/lib/Devel/CompleteStatement.pm index 15cc867..65e8a4a 100644 --- a/lib/Devel/CompleteStatement.pm +++ b/lib/Devel/CompleteStatement.pm @@ -1,11 +1,15 @@ package Devel::CompleteStatement; use strict; use warnings; +use 5.016; # ABSTRACT: foo use XSLoader; XSLoader::load; +use Exporter 'import'; +our @EXPORT = ('complete_statement'); + sub _call_parse { eval { _parse() }; } @@ -3,12 +3,14 @@ use strict; use warnings; use Test::More; -use Devel::CompleteStatement; +use Devel::CompleteStatement 'complete_statement'; -ok(Devel::CompleteStatement::complete_statement('if ($x) { $y }')); -ok(!Devel::CompleteStatement::complete_statement('if ($x) { $y')); +is(complete_statement('if ($x) { $y }'), 1); +is(complete_statement('if ($x) { $y'), ''); +is(complete_statement('if ($x) { $y '), ''); -ok(Devel::CompleteStatement::complete_statement('if ($x) { BEGIN { die } }')); -ok(!Devel::CompleteStatement::complete_statement('if ($x) { BEGIN { die }')); +is(complete_statement('if ($x) { $y } }'), undef); +is(complete_statement('if ($x) { BEGIN { die } }'), undef); +is(complete_statement('if ($x) { BEGIN { die }'), undef); done_testing; |