Skip to content

Commit

Permalink
update to v2.1.0\nremove failure for valid comment lines
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrowder committed Feb 12, 2020
1 parent 603cb75 commit e373220
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 21 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [v2.1.0] - 2020-02-12
- remove the sub strip-comment check and fail lines with only the
comment char at the beginning of the line and no other content
- modify tests to check the new behavior

## [v2.0.1] - 2019-12-18
- add test to ensure tabs are handled properly
- note that v2.0.0 was never uploaded to CPAN
Expand Down
2 changes: 1 addition & 1 deletion META6.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"perl" : "6.*",
"name" : "Text::Utils",
"version" : "2.0.1",
"version" : "2.1.0",
"api" : "2",
"description" : "Provides some additional text functions (replaces module Text::More)",
"auth" : "github:tbrowder",
Expand Down
11 changes: 0 additions & 11 deletions lib/Text/Utils.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ multi strip-comment($line is copy, #= string of text with possible comment
:$normalize, #= if true, normalize returned strings
:$last, #= if true, use the last instead of first comment char
) is export(:strip-comment) {
# failure condition:
if $line eq $mark {
die "FATAL: The input line is the same as the comment char: '$line'";
}
my $comment = '';
my $clen = $mark.chars;
my $idx = $last ?? rindex $line, $mark
Expand All @@ -74,13 +70,6 @@ multi strip-comment($line is copy, #= string of text with possible comment
:$normalize, #= if true, normalize returned strings
:$last, #= if true, use the last instead of first comment char
) is export(:strip-comment) {
# failure condition:
if $line eq $comment-char {
note "FATAL: The input line is the same as the comment char: '$line'";
note " This signature is deprecated.";
note " Use the ':mark<$line>' named param for the comment char.";
die "DEPRECATED SIGNATURE--USE THE MARK NOTATION IN THE FUTURE";
}
my $comment = '';
my $clen = $comment-char.chars;
my $idx = $last ?? rindex $line, $comment-char
Expand Down
15 changes: 6 additions & 9 deletions t/020-strip-comment.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ my (@s, @stripped);
'some text',
'text # coment...',
' #comment',
'more text'
'more text',
'#',
);

@stripped = (
'some text',
'text ',
' ',
'more text'
'more text',
'',
);

# return the stripped strings
Expand All @@ -36,7 +38,8 @@ for 0..^+@s -> $i {
'some text',
'text ; coment...',
' ;comment',
'more text'
'more text',
';',
);

# return the stripped strings
Expand Down Expand Up @@ -96,16 +99,10 @@ is $comm, ' some comment ';
is $text, 'some text %% text';
is $comm, 'some comment';

# bad input by user
dies-ok { $text = strip-comment '#'; }, 'dies when line is same as comment char';

#===== END OF ORIGINAL SIGNATURE IS DEPRECATED =====

# test the new signature

# bad input by user
dies-ok { $text = strip-comment '%', :mark<%>; }, 'dies when line is same as comment (:mark) char';

($text, $comm) = strip-comment $tstr, :mark<%%>, :last, :save-comment, :normalize;
is $text, 'some text %% text';
is $comm, 'some comment';
Expand Down

0 comments on commit e373220

Please sign in to comment.