|
1 |
| -plan(35); |
| 1 | +plan(41); |
2 | 2 |
|
3 | 3 | ok(nqp::isnull(nqp::decont(nqp::null())), 'nqp::decont works on nqp::null');
|
4 | 4 |
|
@@ -186,4 +186,31 @@ ok(nqp::isnull(nqp::decont(nqp::null())), 'nqp::decont works on nqp::null');
|
186 | 186 | is($clone_of_cont.attr, 456, 'clone_nd container can be assigned to');
|
187 | 187 |
|
188 | 188 | is($cont.attr, 678, 'original container is independent of clone but had shared value');
|
| 189 | + |
| 190 | + class ValueWithDefined { |
| 191 | + has $!defined; |
| 192 | + method defined() { |
| 193 | + $!defined; |
| 194 | + } |
| 195 | + } |
| 196 | + |
| 197 | + |
| 198 | + my $cont_for_with_defined := nqp::create(SimpleCont); |
| 199 | + nqp::assign($cont_for_with_defined, ValueWithDefined.new(defined => 1)); |
| 200 | + |
| 201 | + my $cont_for_with_not_defined := nqp::create(SimpleCont); |
| 202 | + nqp::assign($cont_for_with_not_defined, ValueWithDefined.new(defined => 0)); |
| 203 | + |
| 204 | + my $cont_with_false_value := nqp::create(SimpleCont); |
| 205 | + nqp::assign($cont_with_false_value, 0); |
| 206 | + my $cont_for_with_container_defined := nqp::create(SimpleCont); |
| 207 | + nqp::assign($cont_for_with_container_defined, ValueWithDefined.new(defined => $cont_with_false_value)); |
| 208 | + |
| 209 | + is(nqp::with($cont_for_with_defined, "good", "bad"), "good", 'with - defined case'); |
| 210 | + is(nqp::with($cont_for_with_not_defined, "good", "bad"), "bad", 'with - undefined case'); |
| 211 | + is(nqp::with($cont_for_with_container_defined, "good", "bad"), "good", 'with - defined returns container'); |
| 212 | + |
| 213 | + is(nqp::without($cont_for_with_defined, "good", "bad"), "bad", 'without - defined case'); |
| 214 | + is(nqp::without($cont_for_with_not_defined, "good", "bad"), "good", 'without - undefined case'); |
| 215 | + is(nqp::without($cont_for_with_container_defined, "good", "bad"), "bad", 'without - defined returns container'); |
189 | 216 | }
|
0 commit comments