Skip to content

Commit

Permalink
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spec/ruby/language/fixtures/variables.rb
Original file line number Diff line number Diff line change
@@ -78,4 +78,8 @@ def self.without_parenthesis a
a
end
end

def self.false
false
end
end
24 changes: 24 additions & 0 deletions spec/ruby/language/variables_spec.rb
Original file line number Diff line number Diff line change
@@ -750,3 +750,27 @@ module VariableSpecs
end
end
end

describe "A local variable assigned only within a conditional block" do
context "accessed from a later closure" do
it "is defined?" do
if VariablesSpecs.false
a = 1
end

1.times do
defined?(a).should == "local-variable"
end
end

it "is nil" do
if VariablesSpecs.false
a = 1
end

1.times do
a.inspect.should == "nil"
end
end
end
end

0 comments on commit 1dc3019

Please sign in to comment.