| 1 | use v6; |
|---|
| 2 | |
|---|
| 3 | use Test; |
|---|
| 4 | |
|---|
| 5 | plan 17; |
|---|
| 6 | |
|---|
| 7 | throws_ok { |
|---|
| 8 | die "first"; |
|---|
| 9 | die "second"; |
|---|
| 10 | }, "first", "this better work ;-)"; |
|---|
| 11 | |
|---|
| 12 | throws_ok { |
|---|
| 13 | (die "first")[die "second"]; |
|---|
| 14 | }, "first", "evaluation order of array access"; |
|---|
| 15 | |
|---|
| 16 | throws_ok { |
|---|
| 17 | (die "first"){die "second"}; |
|---|
| 18 | }, "first", "evaluation order of hash access"; |
|---|
| 19 | |
|---|
| 20 | throws_ok { |
|---|
| 21 | my @a; |
|---|
| 22 | @a[die "first"] = die "second"; |
|---|
| 23 | }, "first", "evaluation order of left/right sides of array assignment"; |
|---|
| 24 | |
|---|
| 25 | throws_ok { |
|---|
| 26 | my @a; |
|---|
| 27 | @a[die "first"] := die "second"; |
|---|
| 28 | }, "first", "evaluation order of left/right sides of array binding", :todo<bug>; |
|---|
| 29 | |
|---|
| 30 | throws_ok { |
|---|
| 31 | my sub foo ($arg) is rw { my $var }; |
|---|
| 32 | foo(die "first") = die "second"; |
|---|
| 33 | }, "first", "evaluation order of left/right sides of lvalue sub assignment (1)"; |
|---|
| 34 | |
|---|
| 35 | throws_ok { |
|---|
| 36 | my sub foo ($arg) is rw { my $var }; |
|---|
| 37 | foo(die "first") := die "second"; |
|---|
| 38 | }, "first", "evaluation order of left/right sides of lvalue sub binding (1)", :todo<bug>; |
|---|
| 39 | |
|---|
| 40 | throws_ok { |
|---|
| 41 | my sub foo ($arg) is rw { die "second"; my $var }; |
|---|
| 42 | foo(die "first") = die "third"; |
|---|
| 43 | }, "first", "evaluation order of left/right sides of lvalue sub assignment (2)"; |
|---|
| 44 | |
|---|
| 45 | throws_ok { |
|---|
| 46 | my sub foo ($arg) is rw { die "second"; my $var }; |
|---|
| 47 | foo(die "first") := die "third"; |
|---|
| 48 | }, "first", "evaluation order of left/right sides of lvalue sub binding (2)", :todo<bug>; |
|---|
| 49 | |
|---|
| 50 | throws_ok { |
|---|
| 51 | my @a = (die("first"), die("second")); |
|---|
| 52 | }, "first", "evaluation order of list context (provided by assigning to an array)"; |
|---|
| 53 | |
|---|
| 54 | throws_ok { |
|---|
| 55 | my $a = [die("first"), die("second")]; |
|---|
| 56 | }, "first", "evaluation order of list context (provided by creating an arrayref)"; |
|---|
| 57 | |
|---|
| 58 | throws_ok { |
|---|
| 59 | my %a = (die("first"), die("second")); |
|---|
| 60 | }, "first", "evaluation order of list context (provided by assigning to a hash)"; |
|---|
| 61 | |
|---|
| 62 | throws_ok { |
|---|
| 63 | my $x = die("first"), die("second"); |
|---|
| 64 | }, "first", "evaluation order of multiple items in scalar context"; |
|---|
| 65 | |
|---|
| 66 | throws_ok { |
|---|
| 67 | say(die("first"), die("second")); |
|---|
| 68 | }, "first", "evaluation in function application"; |
|---|
| 69 | |
|---|
| 70 | throws_ok { |
|---|
| 71 | die("first").say(die "second"); |
|---|
| 72 | }, "first", "evaluation in method application"; |
|---|
| 73 | |
|---|
| 74 | throws_ok { |
|---|
| 75 | (die "first")(die "second"); |
|---|
| 76 | }, "first", "evaluation order of using (die()) as subref"; |
|---|
| 77 | |
|---|
| 78 | throws_ok { |
|---|
| 79 | (die "first") += die "second"; |
|---|
| 80 | }, "first", "evaluation order of +="; |
|---|