File tree Expand file tree Collapse file tree 1 file changed +64
-10
lines changed Expand file tree Collapse file tree 1 file changed +64
-10
lines changed Original file line number Diff line number Diff line change @@ -2,19 +2,73 @@ use v6;
2
2
3
3
use Test ;
4
4
5
- plan 1 ;
5
+ plan 13 ;
6
6
7
- my $ foo = 42 ;
8
- with 0 -> $ pos {
9
- $ foo = $ pos ;
7
+ for
8
+ 0 , 1 ,0
9
+ , 1 , 0 ,1
10
+ ,Int , 0 ,0
11
+ # ,Int,Str,2 # enable when todo is fixed
12
+
13
+ -> $ with , $ orwith , $ expected {
14
+
15
+ my $ foo = 42 ;
16
+ with $ with {
17
+ $ foo = $ _ ;
18
+ }
19
+ orwith $ orwith {
20
+ $ foo = $ _ ;
21
+ }
22
+ else {
23
+ $ foo = 2 ;
24
+ }
25
+ # ?rakudo todo '$_ not yet set in with/without block'
26
+ is $ foo , $ expected , " \$_: with on { $ with // $ with .^ name } , orwith on { $ orwith // $ orwith .^ name } " ;
27
+ }
28
+
29
+ for
30
+ 0 , 1 ,0
31
+ , 1 , 0 ,1
32
+ ,Int , 0 ,0
33
+ ,Int ,Str ,2
34
+
35
+ -> $ with , $ orwith , $ expected {
36
+
37
+ my $ foo = 42 ;
38
+ with $ with -> $ pos {
39
+ $ foo = $ pos ;
40
+ }
41
+ orwith $ orwith -> $ pos {
42
+ $ foo = $ pos ;
43
+ }
44
+ else {
45
+ $ foo = 2 ;
46
+ }
47
+ is $ foo , $ expected , " \$pos: with on { $ with // $ with .^ name } , orwith on { $ orwith // $ orwith .^ name } " ;
10
48
}
11
- orwith 1 -> $ pos {
12
- $ foo = $ pos ;
49
+
50
+ for
51
+ 0 , 0
52
+ , 1 , 1
53
+ ,Int , 42
54
+
55
+ -> $ with , $ expected {
56
+
57
+ my $ foo = 42 ;
58
+ $ foo = $ _ with $ with ;
59
+ is $ foo , $ expected , " postfix with on { $ with // $ with .^ name } " ;
13
60
}
14
- else {
15
- $ foo = " bar" ;
61
+
62
+ for
63
+ 0 , 42
64
+ , 1 , 42
65
+ ,Int ,Int
66
+
67
+ -> $ without , $ expected {
68
+
69
+ my $ foo = 42 ;
70
+ $ foo = $ _ without $ without ;
71
+ is $ foo , $ expected , " postfix without on { $ without // $ without .^ name } " ;
16
72
}
17
- # ?rakudo todo 'with semantics not yet fully implemented'
18
- is $ foo , 0 , ' with on a false defined value triggers' ;
19
73
20
74
# vim: ft=perl6
You can’t perform that action at this time.
0 commit comments