Sha256: 22ac1aabb71ba6a5449c1f44b31f840a15bdf633886b1ce048188a545f4e16e3

Contents?: true

Size: 559 Bytes

Versions: 33

Compression:

Stored size: 559 Bytes

Contents

describe "The while expression" do
  it "restarts the current iteration without reevaluating condition with redo" do
    a = []
    i = 0
    j = 0
    while (i+=1)<3
      a << i
      j+=1
      redo if j<3
      a << 5
    end
    a.should == [1, 1, 1, 5, 2, 5]
  end

  it "restarts the current iteration without evaluation the code below redo" do
    a = []
    i = 0
    while true
      i += 1
      a << i
      if i < 3
        redo
      else
        break
      end
      a << 5 # should never get here
    end
    a.should == [1, 2, 3]
  end

end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
opal-1.8.3.rc1 spec/opal/core/language/while_spec.rb
opal-1.8.2 spec/opal/core/language/while_spec.rb
opal-1.8.1 spec/opal/core/language/while_spec.rb
opal-1.8.0 spec/opal/core/language/while_spec.rb
opal-1.8.0.beta1 spec/opal/core/language/while_spec.rb
opal-1.7.4 spec/opal/core/language/while_spec.rb
opal-1.8.0.alpha1 spec/opal/core/language/while_spec.rb
opal-1.7.3 spec/opal/core/language/while_spec.rb
opal-1.7.2 spec/opal/core/language/while_spec.rb
opal-1.7.1 spec/opal/core/language/while_spec.rb
opal-1.7.0 spec/opal/core/language/while_spec.rb
opal-1.7.0.rc1 spec/opal/core/language/while_spec.rb
opal-1.6.1 spec/opal/core/language/while_spec.rb
opal-1.6.0 spec/opal/core/language/while_spec.rb
opal-1.6.0.rc1 spec/opal/core/language/while_spec.rb
opal-1.6.0.alpha1 spec/opal/core/language/while_spec.rb
opal-1.5.1 spec/opal/core/language/while_spec.rb
opal-1.5.0 spec/opal/core/language/while_spec.rb
opal-1.5.0.rc1 spec/opal/core/language/while_spec.rb
opal-1.4.1 spec/opal/core/language/while_spec.rb