Skip to content

Commit

Permalink
reclaim t/cmd_join.t -
Browse files Browse the repository at this point in the history
  args handling, deal with empty list.
  • Loading branch information
coke committed Nov 28, 2009
1 parent e9f559a commit 232402e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions build/Makefile.in
Expand Up @@ -82,6 +82,7 @@ $(TCLLEXPAD_PIR): src/TclLexPad.pm
TEST_FILES = \
t/sanity.t \
t/cmd_llength.t \
t/cmd_join.t \
t/cmd_split.t

test: $(PMTCL_EXE)
Expand Down
11 changes: 9 additions & 2 deletions src/PmTcl/Commands.pm
Expand Up @@ -130,9 +130,16 @@ our sub incr (*@args) {
return set($var, pir::add__Nnn($lexpad{$var}, $val // 1));
}

our sub join($list, $joinString?) {
our sub join(*@args) {
if +@args < 1 || +@args > 2 {
error('wrong # args: should be "join list ?joinString?"');
}

my $list := @args[0];
my $joinString := @args[1];

my @list :=
PmTcl::Grammar.parse($list, :rule<list>, :actions(PmTcl::Actions) ).ast;
PmTcl::Grammar.parse($list, :rule<list>, :actions(PmTcl::Actions) ).ast // pir::new__Ps('TclList');

$joinString := " " unless pir::defined($joinString);

Expand Down

0 comments on commit 232402e

Please sign in to comment.