Advertisement
Guest User

Untitled

a guest
Jan 29th, 2015
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. $ cat subst-mutate-numeric.t
  2. use v6;
  3. use Test;
  4.  
  5. plan 10;
  6.  
  7. my $foo = 70;
  8. my $match = $foo.subst-mutate(7, 2);
  9. is $foo, 20, 'can use subst-mutate with variable of type Int';
  10. is $match.Str, 7, 'matched text is correct';
  11. isa_ok $foo, Str, 'type changed to Str after applying method subst-mutate';
  12.  
  13. $foo = 2/5;
  14. $match = $foo.subst-mutate(2, 3);
  15. is $foo, 0.4, 'can use subst-mutate with variable of type Rat';
  16. isa_ok $match, Any, 'no match returned';
  17. isa_ok $foo, Str, 'type changed to Str after applying method subst-mutate';
  18.  
  19. $foo = 2/5;
  20. $match = $foo.subst-mutate(4, 6);
  21. is $foo, 0.6, 'substition happens after stringification (1)';
  22. is $match.Str, 4, 'matched text is correct';
  23.  
  24. $foo = pi;
  25. $match = $foo.subst-mutate(3, 4, :g);
  26. is $foo, 4.14159265458979, 'substition happens after stringification (2)';
  27. is $match.Str, '3 3', 'matched text is correct';
  28.  
  29. done;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement