Skip to content

Instantly share code, notes, and snippets.

@leocassarani
Created June 22, 2011 03:51
Show Gist options
  • Save leocassarani/1039472 to your computer and use it in GitHub Desktop.
Save leocassarani/1039472 to your computer and use it in GitHub Desktop.
describe "Operator precedence" do
let(:a) { rand(100).to_f + 1 }
let(:b) { rand(100) + 1 }
describe "a + 1 / b + 1" do
let(:c) { a + 1 / b + 1 }
it "is not the same as (a + 1) / (b + 1)" do
d = (a + 1) / (b + 1)
d.should_not eql(c)
end
it "is the same as a + (1 / b) + 1" do
d = a + (1 / b) + 1
d.should eql(c)
end
end
describe "a + 1 / b" do
let(:c) { a + 1 / b }
it "is not the same as (a + 1) / b" do
d = (a + 1) / b
d.should_not eql(c)
end
it "is the same as a + (1 / b)" do
d = a + (1 / b)
d.should eql(c)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment