Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement sub form of &trans, mainly to support feed operators. #5532

Merged
merged 2 commits into from Feb 28, 2024

Conversation

gfldex
Copy link
Contributor

@gfldex gfldex commented Feb 25, 2024

Tests:

use v6.*;
use Test;

my @with-pair;
<abc bbc cbc> ==> trans('b' => 'B') ==> @with-pair;
is-deeply @with-pair, <aBc BBc cBc>.Array, 'trans with feed operator and pair';

my @with-positional;
<abc bbc cbc> ==> trans(['a' => 'A', 'c' => 'C']) ==> @with-positional;
is-deeply @with-positional, <AbC bbC CbC>.Array, 'trans with feed operator and Array';
@with-positional = ();
<abc bbc cbc> ==> trans(('a' => 'A', 'c' => 'C')) ==> @with-positional;
is-deeply @with-positional, <AbC bbC CbC>.Array, 'trans with feed operator and List';

my @with-flags;
<a111bc b222bc c333bc> ==> trans('a'..'z' => 'x', :complement, :squash) ==> @with-flags;
is-deeply @with-flags, ["axbc", "bxbc", "cxbc"], 'trans with feed operator and named flags';

@gfldex
Copy link
Contributor Author

gfldex commented Feb 25, 2024

Updated Tests:

my @with-pair;
<abc bbc cbc> ==> trans('b' => 'B') ==> @with-pair;
is-deeply @with-pair, <aBc BBc cBc>.Array, 'trans with feed operator and pair';

my @with-positional;
<abc bbc cbc> ==> trans('a' => 'A', 'c' => 'C') ==> @with-positional;
is-deeply @with-positional, <AbC bbC CbC>.Array, 'trans with feed operator and many args';

my @with-flags;
<a111bc b222bc c333bc> ==> trans('a'..'z' => 'x', :complement, :squash) ==> @with-flags;
is-deeply @with-flags, ["axbc", "bxbc", "cxbc"], 'trans with feed operator and named flags';

is trans('a' => 'A', 'abc'), 'Abc', 'trans as function call and single Str';
is trans('a' => 'A', 'b' => 'B', 'abc'), 'ABc', 'trans as function call with multiple replacements and single Str';
is-deeply trans('a' => 'A', <abc bbc cbc>), <Abc bbc cbc>, 'trans as function call with Array of Str';

@lizmat lizmat merged commit b238fad into rakudo:main Feb 28, 2024
7 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants