context sensitivity
[p5sagit/Eval-WithLexicals.git] / t / simple.t
index e4316f3..667a89d 100644 (file)
@@ -27,4 +27,28 @@ is_deeply(
   'Inner scope plus lexical ok'
 );
 
+is_deeply(
+  [ $eval->eval('{ my $y = 0 }; $x') ],
+  [ 1 ],
+  'Inner scope and other lexical ok'
+);
+
+is_deeply(
+  [ keys %{$eval->lexicals} ],
+  [ '$x' ],
+  'No capture of invisible $y'
+);
+
+$eval->eval('my $y = sub { $_[0]+1 }');
+
+is_deeply(
+  [ $eval->eval('$y->(2)') ],
+  [ 3 ],
+  'Sub created ok'
+);
+
+$eval->context('scalar');
+
+is($eval->eval('$y->(2)'), '3', 'Scalar eval ok');
+
 done_testing;