Sha256: 55027d906878b58694c3f78468a35d29c21ad07a2b56fc9c252dadd2f51475a8

Contents?: true

Size: 1.1 KB

Versions: 27

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

describe "TrueClass/FalseClass" do
  it 'correctly resolves a boolean class' do
    expect(true.class).to eq(TrueClass)
    expect(false.class).to eq(FalseClass)

    expect(true.class).not_to eq(false.class)
  end

  it 'correctly resolves a boolean class with #is_a?' do
    expect(true.is_a? TrueClass).to be_true
    expect(false.is_a? FalseClass).to be_true
    expect(false.is_a? TrueClass).to be_false
    expect(true.is_a? FalseClass).to be_false
  end

  it 'correctly resolves a boolean class with #===' do
    expect(TrueClass === true).to be_true
    expect(FalseClass === false).to be_true
    expect(TrueClass === false).to be_false
    expect(FalseClass === true).to be_false
    expect(TrueClass === 6).to be_false
    expect(true === true).to be_true
    expect(false === false).to be_true
  end

  it 'allows defining methods on TrueClass/FalseClass' do
    class TrueClass
      def test_opal
        false
      end
    end

    class FalseClass
      def test_opal
        true
      end
    end

    expect(true.test_opal).to be_false
    expect(false.test_opal).to be_true
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

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