binding_of_caller 0.7.1 → 1.0.0

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.
Files changed (70) hide show
  1. checksums.yaml +5 -5
  2. data/.gemtest +0 -0
  3. data/.github/workflows/test.yml +103 -0
  4. data/.gitignore +13 -7
  5. data/.yardopts +0 -0
  6. data/Gemfile +6 -1
  7. data/HISTORY +35 -0
  8. data/LICENSE +0 -0
  9. data/README.md +19 -7
  10. data/Rakefile +4 -132
  11. data/binding_of_caller.gemspec +33 -35
  12. data/lib/binding_of_caller.rb +9 -10
  13. data/lib/binding_of_caller/jruby_interpreted.rb +123 -0
  14. data/lib/binding_of_caller/{mri2.rb → mri.rb} +9 -15
  15. data/lib/binding_of_caller/rubinius.rb +26 -36
  16. data/lib/binding_of_caller/version.rb +1 -1
  17. metadata +34 -109
  18. data/.travis.yml +0 -22
  19. data/examples/example.rb +0 -41
  20. data/ext/binding_of_caller/binding_of_caller.c +0 -225
  21. data/ext/binding_of_caller/extconf.rb +0 -33
  22. data/ext/binding_of_caller/ruby_headers/192/debug.h +0 -36
  23. data/ext/binding_of_caller/ruby_headers/192/dln.h +0 -41
  24. data/ext/binding_of_caller/ruby_headers/192/eval_intern.h +0 -232
  25. data/ext/binding_of_caller/ruby_headers/192/gc.h +0 -77
  26. data/ext/binding_of_caller/ruby_headers/192/id.h +0 -173
  27. data/ext/binding_of_caller/ruby_headers/192/iseq.h +0 -104
  28. data/ext/binding_of_caller/ruby_headers/192/method.h +0 -103
  29. data/ext/binding_of_caller/ruby_headers/192/node.h +0 -483
  30. data/ext/binding_of_caller/ruby_headers/192/regenc.h +0 -211
  31. data/ext/binding_of_caller/ruby_headers/192/regint.h +0 -841
  32. data/ext/binding_of_caller/ruby_headers/192/regparse.h +0 -354
  33. data/ext/binding_of_caller/ruby_headers/192/thread_pthread.h +0 -27
  34. data/ext/binding_of_caller/ruby_headers/192/thread_win32.h +0 -33
  35. data/ext/binding_of_caller/ruby_headers/192/timev.h +0 -21
  36. data/ext/binding_of_caller/ruby_headers/192/transcode_data.h +0 -109
  37. data/ext/binding_of_caller/ruby_headers/192/version.h +0 -63
  38. data/ext/binding_of_caller/ruby_headers/192/vm_core.h +0 -703
  39. data/ext/binding_of_caller/ruby_headers/192/vm_exec.h +0 -184
  40. data/ext/binding_of_caller/ruby_headers/192/vm_insnhelper.h +0 -208
  41. data/ext/binding_of_caller/ruby_headers/192/vm_opts.h +0 -51
  42. data/ext/binding_of_caller/ruby_headers/193/addr2line.h +0 -21
  43. data/ext/binding_of_caller/ruby_headers/193/atomic.h +0 -56
  44. data/ext/binding_of_caller/ruby_headers/193/constant.h +0 -34
  45. data/ext/binding_of_caller/ruby_headers/193/debug.h +0 -41
  46. data/ext/binding_of_caller/ruby_headers/193/dln.h +0 -50
  47. data/ext/binding_of_caller/ruby_headers/193/encdb.h +0 -167
  48. data/ext/binding_of_caller/ruby_headers/193/eval_intern.h +0 -234
  49. data/ext/binding_of_caller/ruby_headers/193/gc.h +0 -98
  50. data/ext/binding_of_caller/ruby_headers/193/id.h +0 -175
  51. data/ext/binding_of_caller/ruby_headers/193/internal.h +0 -227
  52. data/ext/binding_of_caller/ruby_headers/193/iseq.h +0 -125
  53. data/ext/binding_of_caller/ruby_headers/193/method.h +0 -105
  54. data/ext/binding_of_caller/ruby_headers/193/node.h +0 -503
  55. data/ext/binding_of_caller/ruby_headers/193/parse.h +0 -186
  56. data/ext/binding_of_caller/ruby_headers/193/regenc.h +0 -219
  57. data/ext/binding_of_caller/ruby_headers/193/regint.h +0 -851
  58. data/ext/binding_of_caller/ruby_headers/193/regparse.h +0 -362
  59. data/ext/binding_of_caller/ruby_headers/193/revision.h +0 -1
  60. data/ext/binding_of_caller/ruby_headers/193/thread_pthread.h +0 -51
  61. data/ext/binding_of_caller/ruby_headers/193/thread_win32.h +0 -40
  62. data/ext/binding_of_caller/ruby_headers/193/timev.h +0 -21
  63. data/ext/binding_of_caller/ruby_headers/193/transcode_data.h +0 -117
  64. data/ext/binding_of_caller/ruby_headers/193/transdb.h +0 -189
  65. data/ext/binding_of_caller/ruby_headers/193/version.h +0 -52
  66. data/ext/binding_of_caller/ruby_headers/193/vm_core.h +0 -755
  67. data/ext/binding_of_caller/ruby_headers/193/vm_exec.h +0 -184
  68. data/ext/binding_of_caller/ruby_headers/193/vm_insnhelper.h +0 -220
  69. data/ext/binding_of_caller/ruby_headers/193/vm_opts.h +0 -51
  70. data/test/test_binding_of_caller.rb +0 -149
@@ -1,149 +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
- class Module
8
- public :remove_const
9
- end
10
-
11
- puts "Testing binding_of_caller version #{BindingOfCaller::VERSION}..."
12
- puts "Ruby version: #{RUBY_VERSION}"
13
-
14
- describe BindingOfCaller do
15
- describe "of_caller" do
16
- it "should fetch immediate caller's binding when 0 is passed" do
17
- o = Object.new
18
- def o.a
19
- var = 1
20
- binding.of_caller(0).eval('var')
21
- end
22
-
23
- o. a.should == 1
24
- end
25
-
26
- it "should fetch parent of caller's binding when 1 is passed" do
27
- o = Object.new
28
- def o.a
29
- var = 1
30
- b
31
- end
32
-
33
- def o.b
34
- binding.of_caller(1).eval('var')
35
- end
36
-
37
- o.a.should == 1
38
- end
39
-
40
- it "should modify locals in parent of caller's binding" do
41
- o = Object.new
42
- def o.a
43
- var = 1
44
- b
45
- var
46
- end
47
-
48
- def o.b
49
- binding.of_caller(1).eval('var = 20')
50
- end
51
-
52
- o.a.should == 20
53
- end
54
-
55
- it "should raise an exception when retrieving an out of band binding" do
56
- o = Object.new
57
- def o.a
58
- binding.of_caller(100)
59
- end
60
-
61
- lambda { o.a }.should.raise RuntimeError
62
- end
63
- end
64
-
65
- describe "callers" do
66
- before do
67
- @o = Object.new
68
- end
69
-
70
- it 'should return the first non-internal binding when using callers.first' do
71
- def @o.meth
72
- x = :a_local
73
- [binding.callers.first, binding.of_caller(0)]
74
- end
75
-
76
- b1, b2 = @o.meth
77
- b1.eval("x").should == :a_local
78
- b2.eval("x").should == :a_local
79
- end
80
- end
81
-
82
- describe "frame_count" do
83
- it 'frame_count should equal callers.count' do
84
- binding.frame_count.should == binding.callers.count
85
- end
86
- end
87
-
88
- describe "frame_descripton" do
89
- it 'can be called on ordinary binding without raising' do
90
- lambda { binding.frame_description }.should.not.raise
91
- end
92
-
93
- it 'describes a block frame' do
94
- binding.of_caller(0).frame_description.should =~ /block/
95
- end
96
-
97
- it 'describes a method frame' do
98
- o = Object.new
99
- def o.horsey_malone
100
- binding.of_caller(0).frame_description.should =~ /horsey_malone/
101
- end
102
- o.horsey_malone
103
- end
104
-
105
- it 'describes a class frame' do
106
- class HorseyMalone
107
- binding.of_caller(0).frame_description.should =~ /class/
108
- end
109
- Object.remove_const(:HorseyMalone)
110
- end
111
- end
112
-
113
- describe "frame_type" do
114
- it 'can be called on ordinary binding without raising' do
115
- lambda { binding.frame_type }.should.not.raise
116
- end
117
-
118
- it 'should return the correct frame types' do
119
- o = Object.new
120
-
121
- # method frame
122
- def o.a
123
- b
124
- end
125
-
126
- # method frame
127
- def o.b
128
- # block frame
129
- proc do
130
- binding.callers
131
- end.call
132
- end
133
- caller_bindings = o.a
134
- caller_bindings[0].frame_type.should == :block
135
- caller_bindings[1].frame_type.should == :method
136
- caller_bindings[2].frame_type.should == :method
137
- end
138
-
139
- it 'identifies a class frame' do
140
- class HorseyMalone
141
- binding.of_caller(0).frame_type.should == :class
142
- end
143
-
144
- Object.remove_const(:HorseyMalone)
145
- end
146
-
147
- end
148
- end
149
-