Permalink
Browse files

partial indent

  • Loading branch information...
1 parent 4ee499a commit 243291ba31e2a77b89bd47c33aadc14cd0dd8366 @masak committed Mar 22, 2014
Showing with 13 additions and 0 deletions.
  1. +4 −0 lib/Text/Indented.pm
  2. +9 −0 t/parse-indent.t
View
@@ -5,6 +5,7 @@ class Suite {
}
class TooMuchIndent is Exception {}
+class PartialIndent is Exception {}
constant TABSTOP = 4;
@@ -29,10 +30,13 @@ regex line {
{
my $new_indent = $0.chars div TABSTOP;
+ my $partial_indent = ~$1;
my $line = ~$2;
die TooMuchIndent.new
if $new_indent > indent() + 1;
+ die PartialIndent.new
+ if $partial_indent;
if $new_indent > indent() {
my $new_suite = Suite.new;
View
@@ -94,4 +94,13 @@ sub fails_with($input, $ex_type, $message = $ex_type.^name) {
is $root.items[1].items[1].items.elems, 2, 'two lines on indent level 3';
}
+{
+ my $input = q:to/EOF/;
+ Level 1
+ Level 2 and a half!
+ EOF
+
+ fails_with($input, Text::Indented::PartialIndent);
+}
+
done;

0 comments on commit 243291b

Please sign in to comment.