Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ cat subst-mutate-numeric.t
- use v6;
- use Test;
- plan 10;
- my $foo = 70;
- my $match = $foo.subst-mutate(7, 2);
- is $foo, 20, 'can use subst-mutate with variable of type Int';
- is $match.Str, 7, 'matched text is correct';
- isa_ok $foo, Str, 'type changed to Str after applying method subst-mutate';
- $foo = 2/5;
- $match = $foo.subst-mutate(2, 3);
- is $foo, 0.4, 'can use subst-mutate with variable of type Rat';
- isa_ok $match, Any, 'no match returned';
- isa_ok $foo, Str, 'type changed to Str after applying method subst-mutate';
- $foo = 2/5;
- $match = $foo.subst-mutate(4, 6);
- is $foo, 0.6, 'substition happens after stringification (1)';
- is $match.Str, 4, 'matched text is correct';
- $foo = pi;
- $match = $foo.subst-mutate(3, 4, :g);
- is $foo, 4.14159265458979, 'substition happens after stringification (2)';
- is $match.Str, '3 3', 'matched text is correct';
- done;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement