IronRuby.Tests.Tests.EvalNext1 C# (CSharp) Method

EvalNext1() public method

public EvalNext1 ( ) : void
return void
        public void EvalNext1() {
            // next in loop:
            AssertOutput(() => CompilerTest(@"
$x = 0
while (puts('in condition'); true)
  puts 'in loop'
  eval('module M; next; end') if ($x += 1) < 2
  break
end
"), @"
in condition
in loop
in condition
in loop
");

            // next in block:
            AssertOutput(() => CompilerTest(@"
$x = 0
2.times do |i|
  puts 'in block ' + i.to_s
  eval('module M; next; end') if ($x += 1) < 2
end
"), @"
in block 0
in block 1
");

            // next in define_method block:
            AssertOutput(() => CompilerTest(@"
$x = 0
class C
  define_method :foo do
    puts 'in block'
    eval('module M; next; end') if ($x += 1) < 2
    puts 'unreachable'
  end
end
C.new.foo
"), @"
in block
");
            // next returning a value:
            AssertOutput(() => CompilerTest(@"
class C
  define_method :foo do
    eval('next 123')
  end
end

p C.new.foo
"), @"
123
");
        }
Tests