root/t/syntax/inplace.t

Revision 20490, 1.1 kB (checked in by Auzon, 8 months ago)

s/use v6-alpha;$/use v6;/;
Also catching a few other mentions of v6-alpha.

  • Property svn:mime-type set to text/plain; charset=UTF-8
  • Property svn:eol-style set to native
Line 
1use v6;
2
3use Test;
4
5plan 18;
6
7my @a = (1, 2, 3);
8ok(@a .= map:{ $_ + 1 }, '.= parses with adverbial block');
9is(@a[0], 2, 'inplace map [0]');
10is(@a[1], 3, 'inplace map [1]');
11is(@a[2], 4, 'inplace map [2]');
12
13my @b = <foo 123 bar 456 baz>;
14ok(eval('@b.=grep:{/<[a..z]>/}'), '.= parses without surrounding whitespace');
15is @b[0], 'foo', 'inplace grep [0]';
16is @b[1], 'bar', 'inplace grep [1]';
17is @b[2], 'baz', 'inplace grep [2]';
18
19my $a=3.14;
20$a .= int;
21is($a, 3, "inplace int");
22
23my $b = "a_string"; $b .= WHAT;
24my $c =         42; $c .= WHAT;
25my $d =      42.23; $d .= WHAT;
26my @e = <a b c d>;  @e .= WHAT;
27is($b,    "Str",   "inplace WHAT of a Str");
28is($c,    "Int",   "inplace WHAT of a Num");
29is($d,    "Rat",   "inplace WHAT of a Rat");
30is(@e[0], "Array", "inplace WHAT of an Array");
31
32my $f = "lowercase"; $f .= uc;
33my $g = "UPPERCASE"; $g .= lc;
34my $h = "lowercase"; $h .= ucfirst;
35my $i = "UPPERCASE"; $i .= lcfirst;
36is($f, "LOWERCASE", "inplace uc");
37is($g, "uppercase", "inplace lc");
38is($h, "Lowercase", "inplace ucfist");
39is($i, "uPPERCASE", "inplace lcfirst");
40
41# L<S12/"Mutating methods">
42my @b = <z a b d e>;
43@b .= sort;
44is ~@b, "a b d e z", "inplace sort";
Note: See TracBrowser for help on using the browser.