Skip to content

Commit

Permalink
Implement String#prepend (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
awncorp committed Jan 17, 2022
1 parent b5febfe commit 27afa09
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/Venus/String.pm
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ sub lowercase {
return CORE::lc($data);
}

sub prepend {
my ($self, @args) = @_;

my $data = $self->get;

return CORE::join(' ', @args, $data);
}

sub render {
my ($self, $tokens) = @_;

Expand Down
32 changes: 32 additions & 0 deletions t/Venus_String.t
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,38 @@ $test->for('example', 2, 'lines', sub {
$result
});

=method prepend
The prepend method prepends arugments to the string using spaces.
=signature prepend
prepend(Str @parts) (Str)
=metadata prepend
{
since => '0.01',
}
=example-1 prepend
# given: synopsis;
my $prepend = $string->prepend('welcome');
# "welcome hello world"
=cut

$test->for('example', 1, 'prepend', sub {
my ($tryable) = @_;
ok my $result = $tryable->result;
ok $result eq "welcome hello world";

$result
});

=method lowercase
The lowercase method is an alias to the lc method.
Expand Down

0 comments on commit 27afa09

Please sign in to comment.