Skip to content

Commit

Permalink
Add spec for eval/__FILE__ stomping behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Phoenix committed Jan 5, 2010
1 parent ebf083a commit ca0efc0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions spec/ruby/core/kernel/eval_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,19 @@ class Object
end
end

# Found via Rubinius bug github:#149
it "should not alter the value of __FILE__ in the binding" do
first_time = EvalSpecs.call_eval
second_time = EvalSpecs.call_eval

# This bug is seen by calling the method twice and comparing the values
# of __FILE__ each time. If the bug is present, calling eval will set the
# value of __FILE__ to the eval's "filename" argument.

second_time.should_not == "(eval)"
first_time.should == second_time
end

deviates_on "jruby" do
it "can be aliased" do
alias aliased_eval eval
Expand Down
6 changes: 6 additions & 0 deletions spec/ruby/core/kernel/fixtures/classes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ def c
def f
yield
end

def self.call_eval
f = __FILE__
eval "true", binding, "(eval)", 1
return f
end
end

# for Kernel#sleep to have Channel in it's specs
Expand Down

0 comments on commit ca0efc0

Please sign in to comment.