Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[S04-blocks_and_statements/{let,temp}.t] Remove ill-placed evals and …

…other minor fixes, fudge for Niecza
  • Loading branch information...
commit 0573f181fe5dd7c987e373d1f913cfc465184e38 1 parent 7d8245f
Stefan O'Rear sorear authored
Showing with 14 additions and 18 deletions.
  1. +5 −5 S04-blocks-and-statements/let.t
  2. +9 −13 S04-blocks-and-statements/temp.t
10 S04-blocks-and-statements/let.t
View
@@ -11,7 +11,7 @@ plan 11;
{
my $a = 42;
{
- is(eval('let $a = 23; $a'), 23, "let() changed the variable (1)");
+ is((let $a = 23; $a), 23, "let() changed the variable (1)");
1;
}
is $a, 23, "let() should not restore the variable, as our block exited succesfully (1)";
@@ -22,7 +22,7 @@ plan 11;
{
my $a = 42;
{
- is(eval('let $a = 23; $a'), 23, "let() changed the variable (1)");
+ is((let $a = 23; $a), 23, "let() changed the variable (1)");
Mu;
}
is $a, 42, "let() should restore the variable, as our block failed";
@@ -34,7 +34,7 @@ plan 11;
my $a = 42;
my $get_a = { $a };
{
- is(eval('let $a = 23; $a'), 23, "let() changed the variable (2-1)");
+ is((let $a = 23; $a), 23, "let() changed the variable (2-1)");
is $get_a(), 23, "let() changed the variable (2-2)";
1;
}
@@ -46,7 +46,7 @@ plan 11;
{
my $a = 42;
try {
- is(eval('let $a = 23; $a'), 23, "let() changed the variable in a try block");
+ is((let $a = 23; $a), 23, "let() changed the variable in a try block");
die 57;
};
is $a, 42, "let() restored the variable, the block was exited using an exception";
@@ -55,7 +55,7 @@ plan 11;
{
my @array = (0, 1, 2);
{
- is(eval('let @array[1] = 42; @array[1]'), 42, "let() changed our array element");
+ is((let @array[1] = 42; @array[1]), 42, "let() changed our array element");
Mu;
}
is @array[1], 1, "let() restored our array element";
22 S04-blocks-and-statements/temp.t
View
@@ -8,7 +8,7 @@ plan 31;
{
my $a = 42;
{
- is(eval('temp $a = 23; $a'), 23, "temp() changed the variable (1)");
+ is((temp $a = 23; $a), 23, "temp() changed the variable (1)");
}
is $a, 42, "temp() restored the variable (1)";
}
@@ -19,7 +19,7 @@ plan 31;
my $a = 42;
my $get_a = { $a };
{
- is(eval('temp $a = 23; $a'), 23, "temp() changed the variable (2-1)");
+ is((temp $a = 23; $a), 23, "temp() changed the variable (2-1)");
is $get_a(), 23, "temp() changed the variable (2-2)";
}
is $a, 42, "temp() restored the variable (2)";
@@ -30,14 +30,14 @@ plan 31;
my $a = 42;
my $get_a = { $a };
{
- ok(eval('temp $a = 23; $a =:= $get_a()'), "temp() shouldn't change the variable containers");
+ ok((temp $a = 23; $a =:= $get_a()), "temp() shouldn't change the variable containers");
}
}
{
our $pkgvar = 42;
{
- is(eval(q/temp $pkgvar = 'not 42'; $pkgvar/), 'not 42', "temp() changed the package variable (3-1)");
+ is((temp $pkgvar = 'not 42'; $pkgvar), 'not 42', "temp() changed the package variable (3-1)");
}
is $pkgvar, 42, "temp() restored the package variable (3-2)";
}
@@ -47,7 +47,7 @@ plan 31;
{
my $a = 42;
try {
- is(eval('temp $a = 23; $a'), 23, "temp() changed the variable in a try block");
+ is((temp $a = 23; $a), 23, "temp() changed the variable in a try block");
die 57;
};
is $a, 42, "temp() restored the variable, the block was exited using an exception";
@@ -65,7 +65,6 @@ eval('
"1 - delete this line when the parsefail eval() is removed";
') or skip("parsefail: temp \@array[1]", 2);
-eval('
{
my %hash = (:a(1), :b(2), :c(3));
{
@@ -74,10 +73,7 @@ eval('
}
is %hash<b>, 2, "temp() restored our array element";
}
-"1 - delete this line when the parsefail eval() is removed";
-') or skip("parsefail: temp \%hash<b>", 2);
-eval('
{
my $struct = [
"doesnt_matter",
@@ -94,14 +90,13 @@ eval('
temp $struct[1]<key>[1] = 23;
is $struct[1]<key>[1], 23, "temp() changed our nested arrayref/hashref element";
}
- is $struct[1]<key>[1], 1, "temp() restored our nested arrayref/hashref element";
+ is $struct[1]<key>[1], 42, "temp() restored our nested arrayref/hashref element";
}
-"1 - delete this line when the parsefail eval() is removed";
-') or skip("parsefail: temp \$struct[1]<key>[1]", 2);
# Block TEMP{}
# L<S06/Temporization/You can also modify the behaviour of temporized code structures>
# (Test is more or less directly from S06.)
+#?niecza 2 skip 'spec clarification needed'
{
my $next = 0;
@@ -146,6 +141,7 @@ eval('
# Following are OO tests, but I think they fit better in var/temp.t than in
# oo/.
# L<S06/Temporization/temp invokes its argument's .TEMP method.>
+#?niecza 2 skip 'needs clarification on correct behavior'
{
my $was_in_own_temp_handler = 0;
@@ -161,7 +157,7 @@ eval('
is $was_in_own_temp_handler, 0, ".TEMP method wasn't yet executed";
{
- is(eval('temp $a; $was_in_own_temp_handler'), 1, ".TEMP method was executed on temporization");
+ is((temp $a; $was_in_own_temp_handler), 1, ".TEMP method was executed on temporization");
}
is $was_in_own_temp_handler, 2, ".TEMP method was executed on restoration";
}
Please sign in to comment.
Something went wrong with that request. Please try again.