Sha256: f4f133adcf0b96be0dd52f43b94d6b3dc8ef9c2e373b6c8a9ce92084ae85e448

Contents?: true

Size: 727 Bytes

Versions: 6

Compression:

Stored size: 727 Bytes

Contents

describe "The || operator" do
  it "evaluates to true if any of its operands are true" do
    if false || true || nil
      x = true
    end
    x.should == true
  end
  
  it "evaluates to false if all of its operands are false" do
    if false || nil
      x = true
    end
    x.should == nil
  end
  
  it "is evaluated before assignment operators" do
    x = nil || true
    x.should == true
  end
  
  it "has a lower precedence than the && operator" do
    x = 1 || false && x = 2
    x.should == 1
  end
  
  it "treats empty expressions as nil" do
    (() || true).should == true
    (() || false).should == false
    (true || ()).should == true
    (false || ()).should == nil
    (() || ()).should == nil
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
opal-0.3.2 gems/core/spec/language/or_spec.rb
opal-0.3.1 gems/core/spec/language/or_spec.rb
opal-0.3.0 gems/core/spec/language/or_spec.rb
opal-0.2.2 opals/opal/opal/spec/language/or_spec.rb
opal-0.2.0 opals/opal/opal/spec/language/or_spec.rb
opal-0.1.0 opals/opal/spec/language/or_spec.rb