summaryrefslogtreecommitdiff
path: root/spec/ruby/core/kernel/eval_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/kernel/eval_spec.rb')
-rw-r--r--spec/ruby/core/kernel/eval_spec.rb65
1 files changed, 39 insertions, 26 deletions
diff --git a/spec/ruby/core/kernel/eval_spec.rb b/spec/ruby/core/kernel/eval_spec.rb
index c53e51e430..1e2764a4de 100644
--- a/spec/ruby/core/kernel/eval_spec.rb
+++ b/spec/ruby/core/kernel/eval_spec.rb
@@ -228,6 +228,17 @@ describe "Kernel#eval" do
ruby_exe(code).chomp.should == "a,b,c,e,LocalJumpError,f"
end
+ it "can be called with Method#call" do
+ method(:eval).call("2 * 3").should == 6
+ end
+
+ it "has the correct default definee when called through Method#call" do
+ class EvalSpecs
+ method(:eval).call("def eval_spec_method_call; end")
+ EvalSpecs.should have_instance_method(:eval_spec_method_call)
+ end
+ end
+
# See language/magic_comment_spec.rb for more magic comments specs
describe "with a magic encoding comment" do
it "uses the magic comment encoding for the encoding of literal strings" do
@@ -374,43 +385,45 @@ CODE
end
end
- it "activates refinements from the eval scope" do
- refinery = Module.new do
- refine EvalSpecs::A do
- def foo
- "bar"
+ describe 'with refinements' do
+ it "activates refinements from the eval scope" do
+ refinery = Module.new do
+ refine EvalSpecs::A do
+ def foo
+ "bar"
+ end
end
end
- end
- result = nil
+ result = nil
- Module.new do
- using refinery
+ Module.new do
+ using refinery
- result = eval "EvalSpecs::A.new.foo"
- end
+ result = eval "EvalSpecs::A.new.foo"
+ end
- result.should == "bar"
- end
+ result.should == "bar"
+ end
- it "activates refinements from the binding" do
- refinery = Module.new do
- refine EvalSpecs::A do
- def foo
- "bar"
+ it "activates refinements from the binding" do
+ refinery = Module.new do
+ refine EvalSpecs::A do
+ def foo
+ "bar"
+ end
end
end
- end
- b = nil
- m = Module.new do
- using refinery
- b = binding
- end
+ b = nil
+ m = Module.new do
+ using refinery
+ b = binding
+ end
- result = eval "EvalSpecs::A.new.foo", b
+ result = eval "EvalSpecs::A.new.foo", b
- result.should == "bar"
+ result.should == "bar"
+ end
end
end