Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[S04-phasers] Fudge pre-post, enter-leave, and keep-undo for niecza

  • Loading branch information...
commit 7d8245f16a6f72c38a7a5405afd280e5d9cd76db 1 parent e52f458
sorear authored August 04, 2011
13  S04-phasers/enter-leave.t
@@ -55,10 +55,10 @@ plan 19;
55 55
 # L<S04/Phasers/ENTER "repeats on loop blocks">
56 56
 {
57 57
     my $str;
58  
-    for 1..2 {
  58
+    for 1..2 -> $x {
59 59
         $str ~= ',';
60  
-        ENTER { $str ~= "E$_" }
61  
-        LEAVE { $str ~= "L$_ " }
  60
+        ENTER { $str ~= "E$x" }
  61
+        LEAVE { $str ~= "L$x " }
62 62
     }
63 63
     is $str, 'E1,L1 E2,L2 ', 'ENTER/LEAVE repeats on loop blocks';
64 64
 }
@@ -80,6 +80,7 @@ plan 19;
80 80
 }
81 81
 
82 82
 # normal closure:
  83
+#?niecza skip 'leave'
83 84
 {
84 85
     is eval(q{
85 86
         my $a;
@@ -103,6 +104,7 @@ plan 19;
103 104
     is $str, '(x)', 'die calls LEAVE blocks';
104 105
 }
105 106
 
  107
+#?niecza 2 skip 'dubious'
106 108
 {
107 109
     my $str;
108 110
     try {
@@ -115,9 +117,9 @@ plan 19;
115 117
 {
116 118
     my $str;
117 119
     {
118  
-        LEAVE { $str ~= (defined $! ?? 'yes' !! 'no') }
  120
+        LEAVE { $str ~= (defined($!) ?? 'yes' !! 'no') }
119 121
         try { die 'foo' }
120  
-        $str ~= (defined $! ?? 'aye' !! 'nay');
  122
+        $str ~= (defined($!) ?? 'aye' !! 'nay');
121 123
     }
122 124
     is $str, 'ayeno', '$! not set in LEAVE if exception not thrown';
123 125
 }
@@ -171,6 +173,7 @@ plan 19;
171 173
     is $str, '1', 'die aborts ENTER queue';
172 174
 }
173 175
 
  176
+#?niecza skip '@!'
174 177
 {
175 178
     my $str;
176 179
     try {
22  S04-phasers/pre-post.t
@@ -11,7 +11,7 @@ use Test;
11 11
 
12 12
 plan 25;
13 13
 
14  
-sub foo(Num $i) {
  14
+sub foo(Int $i) {
15 15
     PRE {
16 16
         $i < 5
17 17
     }
@@ -33,7 +33,7 @@ dies_ok { bar(10) }, 'Violated POST throws (catchable) exception';
33 33
 
34 34
 # multiple PREs und POSTs
35 35
 
36  
-sub baz (Num $i) {
  36
+sub baz (Int $i) {
37 37
 	PRE {
38 38
 		$i > 0
39 39
 	}
@@ -48,7 +48,7 @@ dies_ok  { baz(-1)}, 'sub with two PREs fails when first is violated';
48 48
 dies_ok  { baz(42)}, 'sub with two PREs fails when second is violated';
49 49
 
50 50
 
51  
-sub qox (Num $i) {
  51
+sub qox (Int $i) {
52 52
 	return 1;
53 53
 	POST {
54 54
 		$i > 0
@@ -65,7 +65,7 @@ dies_ok( { qox(123)}, "sub with two POSTs fails if second POST is violated");
65 65
 # inheritance
66 66
 
67 67
 class PRE_Parent {
68  
-    method test(Num $i) {
  68
+    method test(Int $i) {
69 69
         PRE {
70 70
             $i < 23
71 71
         }
@@ -74,7 +74,7 @@ class PRE_Parent {
74 74
 }
75 75
 
76 76
 class PRE_Child is PRE_Parent {
77  
-    method test(Num $i){
  77
+    method test(Int $i){
78 78
         PRE {
79 79
             $i > 0;
80 80
         }
@@ -86,11 +86,12 @@ my $foo = PRE_Child.new;
86 86
 
87 87
 lives_ok { $foo.test(5)    }, 'PRE in methods compiles and runs';
88 88
 dies_ok  { $foo.test(-42)  }, 'PRE in child throws';
  89
+#?niecza skip 'PRE inheritance'
89 90
 dies_ok  { $foo.test(78)   }, 'PRE in parent throws';
90 91
 
91 92
 
92 93
 class POST_Parent {
93  
-    method test(Num $i) {
  94
+    method test(Int $i) {
94 95
         return 1;
95 96
         POST {
96 97
             $i > 23
@@ -99,7 +100,7 @@ class POST_Parent {
99 100
 }
100 101
 
101 102
 class POST_Child is POST_Parent {
102  
-    method test(Num $i){
  103
+    method test(Int $i){
103 104
         return 1;
104 105
         POST {
105 106
             $i < -23
@@ -108,12 +109,13 @@ class POST_Child is POST_Parent {
108 109
 }
109 110
 my $mp = POST_Child.new;
110 111
 
  112
+#?niecza 2 skip 'unspecced'
111 113
 lives_ok  { $mp.test(-42) }, "It's enough if we satisfy one of the POST blocks (Child)";
112 114
 lives_ok  { $mp.test(42)  }, "It's enough if we satisfy one of the POST blocks (Parent)";
113 115
 dies_ok   { $mp.test(12) }, 'Violating poth POST blocks throws an error';
114 116
 
115 117
 class Another {
116  
-    method test(Num $x) {
  118
+    method test(Int $x) {
117 119
         return 3 * $x;
118 120
         POST {
119 121
             $_ > 4
@@ -162,6 +164,7 @@ dies_ok  { $pt.test(1) }, 'POST receives return value as $_ (failure)';
162 164
     is $str, '(', 'failing PRE runs nothing else';
163 165
 }
164 166
 
  167
+#?niecza skip 'I think POST runs LIFO by spec?'
165 168
 {
166 169
     my $str;
167 170
     try {
@@ -174,6 +177,7 @@ dies_ok  { $pt.test(1) }, 'POST receives return value as $_ (failure)';
174 177
     is $str, 'yx', 'failing POST runs LEAVE but not more POSTs';
175 178
 }
176 179
 
  180
+#?niecza skip 'unspecced'
177 181
 {
178 182
     my $str;
179 183
     try {
@@ -183,6 +187,7 @@ dies_ok  { $pt.test(1) }, 'POST receives return value as $_ (failure)';
183 187
     ok $str ~~ /foo/, 'POST runs on exception, with correct $!';
184 188
 }
185 189
 
  190
+#?niecza skip 'unspecced'
186 191
 {
187 192
     my $str;
188 193
     try {
@@ -193,6 +198,7 @@ dies_ok  { $pt.test(1) }, 'POST receives return value as $_ (failure)';
193 198
     is $str, 'ayeno', 'POST has undefined $! on no exception';
194 199
 }
195 200
 
  201
+#?niecza skip 'unspecced'
196 202
 {
197 203
     try {
198 204
         POST { 0 }

0 notes on commit 7d8245f

Please sign in to comment.
Something went wrong with that request. Please try again.