diff options
Diffstat (limited to 't')
-rwxr-xr-x | t/conf/fail.t | 19 | ||||
-rwxr-xr-x | t/conf/param.t | 5 | ||||
-rwxr-xr-x | t/conf/parse/fail.t | 4 | ||||
-rwxr-xr-x | t/conf/parse/success.t | 6 | ||||
-rwxr-xr-x | t/conf/use.t | 9 | ||||
-rwxr-xr-x | t/fail.t | 58 |
6 files changed, 59 insertions, 42 deletions
diff --git a/t/conf/fail.t b/t/conf/fail.t index d3b8852..0a16f8e 100755 --- a/t/conf/fail.t +++ b/t/conf/fail.t @@ -12,7 +12,7 @@ use IPC::Open3 qw(open3); use Symbol qw(gensym); use Test::More; -my $tests = 7; +my $tests = 10; my $run_program_fail = sub { @@ -39,13 +39,16 @@ SKIP: { my $infile = $write_to_tmpfile->(''); my @set = ( - [ 'attr=:', 'attr conf option must be provided a string' ], - [ 'attr=bold:underscore', 'attr conf option must have strings separated by ,' ], - [ 'attr=b0ld', 'attr conf option attribute \'b0ld\' is not valid' ], - [ 'attr=b0ld,underscore', 'attr conf option attribute \'b0ld\' is not valid' ], # handle comma - [ 'attr=bold,bold', 'attr conf option has attribute \'bold\' twice or more' ], - [ 'exclude-random=random', 'exclude-random conf option must be provided a plain color' ], - [ 'omit-color-empty=unsure', 'omit-color-empty conf option is not valid' ], + [ 'attr=:', 'attr conf option must be provided a string' ], + [ 'attr=bold:underscore', 'attr conf option must have strings separated by ,' ], + [ 'attr=b0ld', 'attr conf option attribute \'b0ld\' is not valid' ], + [ 'attr=b0ld,underscore', 'attr conf option attribute \'b0ld\' is not valid' ], # handle comma + [ 'attr=bold,bold', 'attr conf option has attribute \'bold\' twice or more' ], + [ 'exclude-random=random', 'exclude-random conf option must be provided a plain color' ], + [ 'omit-color-empty=unsure', 'omit-color-empty conf option is not valid' ], + [ 'rainbow-fg=unsure', 'rainbow-fg conf option is not valid' ], + [ 'rainbow-bg=unsure', 'rainbow-bg conf option is not valid' ], + [ "rainbow-fg=yes\nrainbow-bg=no", 'mutually exclusive' ], ); foreach my $set (@set) { open(my $fh, '>', $conf_file) or die "Cannot open `$conf_file' for writing: $!\n"; diff --git a/t/conf/param.t b/t/conf/param.t index 520df2b..f8f535f 100755 --- a/t/conf/param.t +++ b/t/conf/param.t @@ -14,14 +14,15 @@ my $conf = <<'EOT'; attr=bold color=blue omit-color-empty=yes +rainbow-fg=yes EOT my $expected = <<"EOT"; \e[1;34mfoo\e[0m -\e[1;34mbar\e[0m +\e[1;35mbar\e[0m -\e[1;34mbaz\e[0m +\e[1;36mbaz\e[0m EOT plan tests => $tests; diff --git a/t/conf/parse/fail.t b/t/conf/parse/fail.t index d2988e4..f3aef48 100755 --- a/t/conf/parse/fail.t +++ b/t/conf/parse/fail.t @@ -12,7 +12,7 @@ use IPC::Open3 qw(open3); use Symbol qw(gensym); use Test::More; -my $tests = 9; +my $tests = 11; my $run_program_fail = sub { @@ -46,6 +46,8 @@ SKIP: { [ 'color1=magenta', 'option \'color1\' not recognized' ], [ 'exclude-random1=black', 'option \'exclude-random1\' not recognized' ], [ 'omit-color-empty1=yes', 'option \'omit-color-empty1\' not recognized' ], + [ 'rainbow-fg1=no', 'option \'rainbow-fg1\' not recognized' ], + [ 'rainbow-bg1=no', 'option \'rainbow-bg1\' not recognized' ], [ 'attr', 'option \'attr\' not followed by =' ], [ 'attr#', 'option \'attr\' not followed by =' ], [ 'attr bold', 'option \'attr\' not followed by =' ], diff --git a/t/conf/parse/success.t b/t/conf/parse/success.t index fe2d46d..9dd4937 100755 --- a/t/conf/parse/success.t +++ b/t/conf/parse/success.t @@ -12,7 +12,7 @@ use IPC::Open3 qw(open3); use Symbol qw(gensym); use Test::More; -my $tests = 21; +my $tests = 25; my $conf = <<'EOT'; # comment @@ -30,12 +30,16 @@ color=green color=green exclude-random=black omit-color-empty=yes +rainbow-fg=no +rainbow-bg=no attr=bold # comment attr=bold # comment attr= color= exclude-random= omit-color-empty= +rainbow-fg= +rainbow-bg= EOT my $run_program_succeed = sub diff --git a/t/conf/use.t b/t/conf/use.t index 0a695df..8c0586e 100755 --- a/t/conf/use.t +++ b/t/conf/use.t @@ -12,8 +12,9 @@ my $tests = 21; my $conf = <<'EOT'; attr=underscore -color=yellow # tested also in color.t +color=yellow/black # tested also in color.t omit-color-empty=yes +rainbow-bg=yes EOT plan tests => $tests; @@ -36,11 +37,11 @@ EOT close($fh); is(qx($program $infile1), <<"EOT", 'use config'); -\e[4;33mfoo\e[0m +\e[40m\e[4;33mfoo\e[0m -\e[4;33mbar\e[0m +\e[41m\e[4;33mbar\e[0m -\e[4;33mbaz\e[0m +\e[42m\e[4;33mbaz\e[0m EOT my $infile2 = $write_to_tmpfile->('foo'); @@ -12,7 +12,7 @@ use IPC::Open3 qw(open3); use Symbol qw(gensym); use Test::More; -my $tests = 25; +my $tests = 31; my $run_program_fail = sub { @@ -40,31 +40,37 @@ SKIP: { my $dir = tempdir(CLEANUP => true); my @set = ( - [ '--attr=:', 'must be provided a string' ], - [ '--attr=bold:underscore', 'must have strings separated by ,' ], - [ '--attr=b0ld', 'attribute \'b0ld\' is not valid' ], - [ '--attr=b0ld,underscore', 'attribute \'b0ld\' is not valid' ], # handle comma - [ '--attr=bold,bold', 'has attribute \'bold\' twice or more' ], - [ '--exclude-random=random', 'must be provided a plain color' ], - [ '--clean --clean-all', 'mutually exclusive' ], - [ '--clean file1 file2', 'more than one file' ], - [ '--clean-all file1 file2', 'more than one file' ], - [ '- file', 'hyphen cannot be used as color string' ], - [ '-', 'hyphen must be preceded by color string' ], - [ "$file file", 'cannot be used as color string' ], - [ "$file", 'must be preceded by color string' ], - [ "$dir", 'is not a valid file type' ], - [ '/black', 'foreground color missing' ], - [ 'white/', 'background color missing' ], - [ 'white/black/yellow', 'one color pair allowed only' ], - [ 'y3llow', 'cannot be made of non-alphabetic characters' ], - [ 'yEllow', 'cannot be in mixed lower/upper case' ], - [ 'None', 'cannot be bold' ], - [ 'white/Black', 'cannot be bold' ], - [ 'random/none', 'cannot be combined with' ], - [ 'random/default', 'cannot be combined with' ], - [ 'none/random', 'cannot be combined with' ], - [ 'default/random', 'cannot be combined with' ], + [ '--attr=:', 'must be provided a string' ], + [ '--attr=bold:underscore', 'must have strings separated by ,' ], + [ '--attr=b0ld', 'attribute \'b0ld\' is not valid' ], + [ '--attr=b0ld,underscore', 'attribute \'b0ld\' is not valid' ], # handle comma + [ '--attr=bold,bold', 'has attribute \'bold\' twice or more' ], + [ '--exclude-random=random', 'must be provided a plain color' ], + [ '--clean --clean-all', 'mutually exclusive' ], + [ '--clean file1 file2', 'more than one file' ], + [ '--clean-all file1 file2', 'more than one file' ], + [ '- file', 'hyphen cannot be used as color string' ], + [ '-', 'hyphen must be preceded by color string' ], + [ "$file file", 'cannot be used as color string' ], + [ "$file", 'must be preceded by color string' ], + [ "$dir", 'is not a valid file type' ], + [ '/black', 'foreground color missing' ], + [ 'white/', 'background color missing' ], + [ 'white/black/yellow', 'one color pair allowed only' ], + [ 'y3llow', 'cannot be made of non-alphabetic characters' ], + [ 'yEllow', 'cannot be in mixed lower/upper case' ], + [ 'None', 'cannot be bold' ], + [ 'white/Black', 'cannot be bold' ], + [ 'random/none', 'cannot be combined with' ], + [ 'random/default', 'cannot be combined with' ], + [ 'none/random', 'cannot be combined with' ], + [ 'default/random', 'cannot be combined with' ], + [ '--rainbow-fg --rainbow-bg', 'mutually exclusive' ], + [ 'green --rainbow-bg', 'background color required with' ], + [ 'white/none --rainbow-fg', 'cannot be used with --rainbow-fg' ], + [ 'white/default --rainbow-bg', 'cannot be used with --rainbow-bg' ], + [ 'none/white --rainbow-fg', 'cannot be used with --rainbow-fg' ], + [ 'default/white --rainbow-bg', 'cannot be used with --rainbow-bg' ], ); foreach my $set (@set) { ok($run_program_fail->($program, $set->[0], $set->[1]), $set->[1]); |