Skip to content

Commit f1f8840

Browse files
committed
Make sure committable does not answer on “what,”
I've fixed this in the past, but no test was added. The result is predictable.
1 parent e85320c commit f1f8840

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Committable.p6

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ method help($msg) {
3737
Like this: {$msg.server.current-nick}: f583f22,HEAD say ‘hello’; say ‘world’
3838
}
3939

40-
multi method irc-to-me($msg where { .args[1].starts-with(any shortcuts.keys X~ :)
41-
and .text ~~ /^ \s* $<code>=.+ / }) is default {
42-
my $value = self.process: $msg, shortcuts{$msg.args[1].split(:, 2)[0]}, ~$<code>;
40+
multi method irc-to-me($msg where .args[1] ~~ ?(my $prefix = m/^ $<shortcut>=<{shortcuts.keys}>
41+
$<delim>=[‘:’ | ‘,’]/)
42+
&& .text ~~ /^ \s* $<code>=.+ /) is default {
43+
return if $prefix<delim> eq ,;
44+
my $value = self.process: $msg, shortcuts{$prefix<shortcut>}, ~$<code>;
4345
return without $value;
4446
return $value but Reply($msg)
4547
}

t/committable.t

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,16 @@ $t.test(‘“6c” query’,
175175
commit: 6c say $*PERL,
176176
/^ <{$t.our-nick}> ‘, ¦6c (’\d+‘ commits): «Perl 6 (6.c)»’ $/);
177177

178+
$t.test(“what:” query,
179+
what: say $*PERL,
180+
/^ <{$t.our-nick}> ‘, ¦6c (’\d+‘ commits): «Perl 6 (6.c)»’ $/);
181+
182+
$t.test(“what,” does not work,
183+
what, say ‘what, is actually working…’);
184+
185+
$t.test(“6c,” does not work,
186+
6c, say ‘6c, is actually working…’);
187+
178188
$t.test(“all” query (same output everywhere),
179189
commit: all say 'hi', # ASCII quotes because they are supported everywhere
180190
/^ <{$t.our-nick}> ‘, ¦all (’\d+‘ commits): «hi»’ $/,

0 commit comments

Comments
 (0)