1 require File.dirname(__FILE__) + '/../spec_helper'
3 describe "The '&&' statement" do
5 it "short-circuits evaluation at the first condition to be false" do
11 it "evalutes to the first condition not to be true" do
12 ("yes" && 1 && nil && true).should == nil
13 ("yes" && 1 && false && true).should == false
16 it "evalutes to the last condition if all are true" do
17 ("yes" && 1).should == 1
18 (1 && "yes").should == "yes"
21 it "evaluates the full set of chained conditions during assignment" do
24 # "1 && y = 2" is evaluated and then assigned to x
30 describe "The 'and' statement" do
31 it "short-circuits evaluation at the first condition to be false" do
33 true and false and x = 1
37 it "evalutes to the first condition not to be true" do
38 ("yes" and 1 and nil and true).should == nil
39 ("yes" and 1 and false and true).should == false
42 it "evalutes to the last condition if all are true" do
43 ("yes" and 1).should == 1
44 (1 and "yes").should == "yes"
47 it "when used in assignment, evaluates and assigns expressions individually" do
50 # evaluates (x=1) and (y=2)