diff options
Diffstat (limited to 'spec/ruby/core/binding')
-rw-r--r-- | spec/ruby/core/binding/eval_spec.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/spec/ruby/core/binding/eval_spec.rb b/spec/ruby/core/binding/eval_spec.rb index b36bec799e..4bb3da7a6c 100644 --- a/spec/ruby/core/binding/eval_spec.rb +++ b/spec/ruby/core/binding/eval_spec.rb @@ -93,16 +93,28 @@ describe "Binding#eval" do it "inherits __FILE__ from the enclosing scope" do obj = BindingSpecs::Demo.new(1) bind = obj.get_binding - suppress_warning {bind.eval("__FILE__")}.should == obj.get_file_of_binding + suppress_warning { bind.eval("__FILE__") }.should == obj.get_file_of_binding + end + + it "inherits __LINE__ from the enclosing scope" do + obj = BindingSpecs::Demo.new(1) + bind, line = obj.get_binding_and_line + suppress_warning { bind.eval("__LINE__") }.should == line end end ruby_version_is "3.0" do - it "Uses (eval) as __FILE__ if single argument given" do + it "uses (eval) as __FILE__ if single argument given" do obj = BindingSpecs::Demo.new(1) bind = obj.get_binding bind.eval("__FILE__").should == '(eval)' end + + it "uses 1 as __LINE__" do + obj = BindingSpecs::Demo.new(1) + bind = obj.get_binding + suppress_warning { bind.eval("__LINE__") }.should == 1 + end end it "uses the __FILE__ that is passed in" do |