binding_of_caller 0.6.3 → 0.7.3.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gemtest +0 -0
- data/.gitignore +8 -7
- data/.travis.yml +31 -0
- data/.yardopts +0 -0
- data/Gemfile +2 -0
- data/HISTORY +35 -0
- data/LICENSE +0 -0
- data/README.md +10 -5
- data/Rakefile +134 -112
- data/binding_of_caller.gemspec +39 -0
- data/examples/benchmark.rb +63 -0
- data/ext/binding_of_caller/binding_of_caller.c +9 -4
- data/ext/binding_of_caller/extconf.rb +25 -10
- data/ext/binding_of_caller/ruby_headers/192/version.h +0 -8
- data/lib/binding_of_caller/jruby_interpreted.rb +64 -0
- data/lib/binding_of_caller/mri2.rb +69 -0
- data/lib/binding_of_caller/rubinius.rb +67 -0
- data/lib/binding_of_caller/version.rb +3 -3
- data/lib/binding_of_caller.rb +12 -78
- data/test/test_binding_of_caller.rb +161 -0
- metadata +60 -26
- data/lib/binding_of_caller.bundle +0 -0
- data/lib/tester.rb +0 -15
- data/test/test.rb +0 -91
- /data/ext/binding_of_caller/ruby_headers/192/{gc.h → rubys_gc.h} +0 -0
- /data/ext/binding_of_caller/ruby_headers/193/{gc.h → rubys_gc.h} +0 -0
data/test/test.rb
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
unless Object.const_defined? :BindingOfCaller
|
|
2
|
-
$:.unshift File.expand_path '../../lib', __FILE__
|
|
3
|
-
require 'binding_of_caller'
|
|
4
|
-
require 'binding_of_caller/version'
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
puts "Testing binding_of_caller version #{BindingOfCaller::VERSION}..."
|
|
8
|
-
puts "Ruby version: #{RUBY_VERSION}"
|
|
9
|
-
|
|
10
|
-
describe BindingOfCaller do
|
|
11
|
-
describe "of_caller" do
|
|
12
|
-
it "should fetch immediate caller's binding when 0 is passed" do
|
|
13
|
-
o = Object.new
|
|
14
|
-
def o.a
|
|
15
|
-
var = 1
|
|
16
|
-
binding.of_caller(0).eval('var')
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
o. a.should == 1
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "should fetch parent of caller's binding when 1 is passed" do
|
|
23
|
-
o = Object.new
|
|
24
|
-
def o.a
|
|
25
|
-
var = 1
|
|
26
|
-
b
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def o.b
|
|
30
|
-
binding.of_caller(1).eval('var')
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
o.a.should == 1
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it "should modify locals in parent of caller's binding" do
|
|
37
|
-
o = Object.new
|
|
38
|
-
def o.a
|
|
39
|
-
var = 1
|
|
40
|
-
b
|
|
41
|
-
var
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def o.b
|
|
45
|
-
binding.of_caller(1).eval('var = 20')
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
o.a.should == 20
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it "should raise an exception when retrieving an out of band binding" do
|
|
52
|
-
o = Object.new
|
|
53
|
-
def o.a
|
|
54
|
-
binding.of_caller(100)
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
lambda { o.a }.should.raise RuntimeError
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
describe "frame_count" do
|
|
62
|
-
it 'frame_count should equal callers.count' do
|
|
63
|
-
binding.frame_count.should == binding.callers.count
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
describe "frame_type" do
|
|
68
|
-
it 'should return the correct frame types' do
|
|
69
|
-
o = Object.new
|
|
70
|
-
|
|
71
|
-
# method frame
|
|
72
|
-
def o.a
|
|
73
|
-
b
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
# method frame
|
|
77
|
-
def o.b
|
|
78
|
-
# block frame
|
|
79
|
-
proc do
|
|
80
|
-
binding.callers
|
|
81
|
-
end.call
|
|
82
|
-
end
|
|
83
|
-
caller_bindings = o.a
|
|
84
|
-
caller_bindings[0].frame_type.should == :block
|
|
85
|
-
caller_bindings[1].frame_type.should == :method
|
|
86
|
-
caller_bindings[2].frame_type.should == :method
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
File without changes
|
|
File without changes
|