Sha256: 7f67c99720d32b23d9a242b199131ae7af591340d334d8435204b7121a7b9009

Contents?: true

Size: 991 Bytes

Versions: 27

Compression:

Stored size: 991 Bytes

Contents

describe "Exit (Kernel#exit / Opal.exit())" do
  it "forwards the status code to Opal.exit(status)" do
    received_status { Kernel.exit }.should == 0

    received_status { Kernel.exit(0) }.should == 0
    received_status { Kernel.exit(1) }.should == 1
    received_status { Kernel.exit(2) }.should == 2
    received_status { Kernel.exit(123) }.should == 123

    received_status { Kernel.exit(true) }.should == 0
    received_status { Kernel.exit(false) }.should == 1

    lambda { received_status { Kernel.exit(Object.new) } }.should raise_error(TypeError)
    lambda { received_status { Kernel.exit([]) } }.should raise_error(TypeError)
    lambda { received_status { Kernel.exit(/123/) } }.should raise_error(TypeError)
  end

  def received_status
    received_status = nil
    original_exit = `Opal.exit`
    begin
      `Opal.exit = function(status) { #{received_status = `status`} }`
      yield
    ensure
      `Opal.exit = #{original_exit}`
    end
    received_status
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
opal-1.7.4 spec/opal/core/runtime/exit_spec.rb
opal-1.7.3 spec/opal/core/runtime/exit_spec.rb
opal-1.7.2 spec/opal/core/runtime/exit_spec.rb
opal-1.7.1 spec/opal/core/runtime/exit_spec.rb
opal-1.7.0 spec/opal/core/runtime/exit_spec.rb
opal-1.7.0.rc1 spec/opal/core/runtime/exit_spec.rb
opal-1.6.1 spec/opal/core/runtime/exit_spec.rb
opal-1.6.0 spec/opal/core/runtime/exit_spec.rb
opal-1.6.0.rc1 spec/opal/core/runtime/exit_spec.rb
opal-1.6.0.alpha1 spec/opal/core/runtime/exit_spec.rb
opal-1.5.1 spec/opal/core/runtime/exit_spec.rb
opal-1.5.0 spec/opal/core/runtime/exit_spec.rb
opal-1.5.0.rc1 spec/opal/core/runtime/exit_spec.rb
opal-1.4.1 spec/opal/core/runtime/exit_spec.rb
opal-1.4.0 spec/opal/core/runtime/exit_spec.rb
opal-1.4.0.alpha1 spec/opal/core/runtime/exit_spec.rb
opal-1.3.2 spec/opal/core/runtime/exit_spec.rb
opal-1.3.1 spec/opal/core/runtime/exit_spec.rb
opal-1.3.0 spec/opal/core/runtime/exit_spec.rb
opal-1.3.0.rc1 spec/opal/core/runtime/exit_spec.rb