local_eval 0.2.4 → 0.2.5

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.
data/Rakefile CHANGED
@@ -7,7 +7,8 @@ require "#{direc}/lib/local_eval/version"
7
7
 
8
8
  CLOBBER.include("**/*.#{dlext}", "**/*~", "**/*#*", "**/*.log", "**/*.o")
9
9
  CLEAN.include("ext/**/*.#{dlext}", "ext/**/*.log", "ext/**/*.o",
10
- "ext/**/*~", "ext/**/*#*", "ext/**/*.obj", "ext/**/*.def", "ext/**/*.pdb")
10
+ "ext/**/*~", "ext/**/*#*", "ext/**/*.obj",
11
+ "ext/**/*.def", "ext/**/*.pdb", "**/*_flymake*.*")
11
12
 
12
13
  def apply_spec_defaults(s)
13
14
  s.name = "local_eval"
@@ -1,3 +1,3 @@
1
1
  module LocalEval
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 4
9
- version: 0.2.4
8
+ - 5
9
+ version: 0.2.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - John Mair (banisterfiend)
@@ -57,12 +57,9 @@ extra_rdoc_files: []
57
57
 
58
58
  files:
59
59
  - lib/local_eval/version.rb
60
- - lib/local_eval/version_flymake.rb
61
60
  - lib/local_eval.rb
62
61
  - test/helper1.rb
63
- - test/helper1_flymake.rb
64
62
  - test/test.rb
65
- - test/test_flymake.rb
66
63
  - test/test_segfault.rb
67
64
  - test/test_segfault2.rb
68
65
  - CHANGELOG
@@ -1,3 +0,0 @@
1
- module LocalEval
2
- VERSION = "0.2.0"
3
- end
@@ -1,84 +0,0 @@
1
- class Module
2
- public :remove_const, :include, :remove_method
3
- end
4
-
5
- Reset = proc do
6
- O = Object.new
7
- O2 = Object.new
8
- O3 = Object.new
9
-
10
- class A
11
- def self.a
12
- :a
13
- end
14
- end
15
-
16
- class B
17
- def self.b
18
- :b
19
- end
20
- end
21
-
22
- class << O
23
- def hello
24
- :o
25
- end
26
-
27
- def ivar_set1(var, val)
28
- instance_variable_set(var, val)
29
- end
30
-
31
- def receiver_ivar_set
32
- capture {
33
- @receiver_ivar = :receiver
34
- }
35
- end
36
-
37
- end
38
-
39
- class << O2
40
- def receiver_ivar_set2
41
- capture {
42
- @receiver_ivar2 = :receiver2
43
- }
44
- end
45
- end
46
-
47
- class << O3
48
- def receiver_ivar_set3
49
- capture {
50
- @receiver_ivar3 = :receiver3
51
- }
52
- @ivar3 = :ivar3
53
- end
54
- end
55
-
56
-
57
- class C
58
- def self.build_proc
59
- proc { love }
60
- end
61
-
62
- def self.hello
63
- :c
64
- end
65
-
66
- def self.c
67
- :c
68
- end
69
-
70
- def self.ivar(v)
71
- v
72
- end
73
- end
74
-
75
- module M
76
- def self.hello
77
- :m
78
- end
79
-
80
- def m
81
- :m
82
- end
83
- end
84
- end
data/test/test_flymake.rb DELETED
@@ -1,168 +0,0 @@
1
- direc = File.dirname(__FILE__)
2
-
3
- require 'rubygems'
4
- require "#{direc}/../lib/local_eval"
5
- require "#{direc}/helper1"
6
-
7
- puts "Testing LocalEval version #{LocalEval::VERSION}..."
8
- puts "With Remix version #{Remix::VERSION} and Object2module version #{Object2module::VERSION}"
9
- puts "Ruby version #{RUBY_VERSION}"
10
-
11
- describe LocalEval do
12
- before do
13
- Reset.call
14
- end
15
-
16
- after do
17
- [:A, :B, :C, :M, :O, :O2, :O3].each do |c|
18
- Object.remove_const(c)
19
- end
20
- end
21
-
22
- describe 'mixing in an object' do
23
- it 'should mix in and mixout the object and make functionality available to block' do
24
- lambda { hello }.should.raise NameError
25
- O.local_eval { hello }.should == :o
26
- lambda { hello }.should.raise NameError
27
- end
28
-
29
- it 'should not error when receiver is the same as block context' do
30
- lambda { local_eval { :hello } }.should.not.raise ArgumentError
31
- local_eval { :hello }.should == :hello
32
- end
33
-
34
- it 'should mix implicit self into context of block' do
35
- def self.love; :love; end
36
- local_eval(&C.build_proc).should == :love
37
- self.singleton_class.remove_method(:love)
38
- end
39
-
40
- it 'should not segfault when inspecting self inside a local_eval' do
41
- O2.local_eval { self.inspect }
42
- end
43
-
44
- end
45
-
46
- describe 'local_eval_with' do
47
- it 'should mix in multiple objects and make functionality available to the block' do
48
- lambda { a }.should.raise NameError
49
- lambda { b }.should.raise NameError
50
- lambda { local_eval_with(A, B) { a; b; } }.should.not.raise NameError
51
- lambda { a }.should.raise NameError
52
- lambda { b }.should.raise NameError
53
- end
54
-
55
- it 'should not error when mixing in multiple objects that include the context of the block' do
56
- lambda { local_eval_with(self, A, B) { a; b } }.should.not.raise NameError
57
- end
58
- end
59
-
60
- describe 'mixing in a class' do
61
- it 'should mix in and mixout the class' do
62
- lambda { hello }.should.raise NameError
63
- C.local_eval { c }.should == :c
64
- lambda { hello }.should.raise NameError
65
- end
66
-
67
- it 'should mixin and mixout a class/module chain' do
68
- C.extend M
69
- lambda { c }.should.raise NameError
70
- lambda { m }.should.raise NameError
71
- C.local_eval { c.should == :c; m.should == :m }
72
- lambda { c }.should.raise NameError
73
- lambda { m }.should.raise NameError
74
- end
75
- end
76
-
77
- describe 'ivars in the block' do
78
- it 'should make ivars accessible to, and modifiable by, block' do
79
- O.local_eval { @x = 5 }
80
- @x.should == 5
81
- end
82
-
83
- it 'should make the method set a local ivar' do
84
- instance_variable_defined?(:@v).should == false
85
- lambda { ivar_set1 }.should.raise NameError
86
- O.local_eval { ivar_set1(:@v, 10) }
87
- lambda { ivar_set1 }.should.raise NameError
88
- @v.should == 10
89
- end
90
-
91
- it 'should make local ivars accessible to mixed in methods' do
92
- @y = 10
93
- lambda { ivar(@y) }.should.raise NameError
94
- C.local_eval { ivar(@y) }.should == 10
95
- @y.should == 10
96
- lambda { ivar(@y) }.should.raise NameError
97
- end
98
- end
99
-
100
- describe 'capture block' do
101
- it 'should make capture evaluate the method in receiver context' do
102
- instance_variable_defined?(:@receiver_ivar).should == false
103
- lambda { receiver_ivar_set }.should.raise NameError
104
- O.local_eval { receiver_ivar_set }
105
- instance_variable_defined?(:@receiver_ivar).should == false
106
- O.instance_variable_get(:@receiver_ivar).should == :receiver
107
- end
108
-
109
- it 'should redirect methods to appropriate receivers' do
110
- O.instance_variable_defined?(:@receiver_ivar2).should == false
111
- O2.instance_variable_defined?(:@receiver_ivar2).should == false
112
- instance_variable_defined?(:@receiver_ivar).should == false
113
- instance_variable_defined?(:@receiver_ivar2).should == false
114
- lambda { receiver_ivar_set; receiver_ivar_set2 }.should.raise NameError
115
- local_eval_with(O, O2) { receiver_ivar_set; receiver_ivar_set2 }
116
- instance_variable_defined?(:@receiver_ivar).should == false
117
- instance_variable_defined?(:@receiver_ivar2).should == false
118
- O.instance_variable_get(:@receiver_ivar).should == :receiver
119
- O2.instance_variable_get(:@receiver_ivar2).should == :receiver2
120
- end
121
-
122
- it 'should not prevent method lookup on capture-methods on objects that are not involved in the local_eval' do
123
- O2.instance_variable_defined?(:@receiver_ivar2).should == false
124
- O.local_eval { O2.receiver_ivar_set2.should == :receiver2 }
125
- O2.instance_variable_get(:@receiver_ivar2).should == :receiver2
126
- end
127
-
128
- it 'should work properly with nested local_evals' do
129
- O.local_eval do
130
- O2.local_eval { receiver_ivar_set2 }
131
- lambda { receiver_ivar_set2 }.should.raise NameError
132
- receiver_ivar_set
133
- end
134
-
135
- O2.instance_variable_get(:@receiver_ivar2).should == :receiver2
136
- O.instance_variable_get(:@receiver_ivar).should == :receiver
137
- end
138
-
139
- it 'should separate the two different selves in a method when using capture' do
140
- O3.instance_variable_defined?(:@receiver_ivar).should == false
141
- instance_variable_defined?(:@ivar3).should == false
142
- O3.local_eval { receiver_ivar_set3 }
143
- O3.instance_variable_get(:@receiver_ivar3).should == :receiver3
144
- instance_variable_get(:@ivar3).should == :ivar3
145
- remove_instance_variable(:@ivar3)
146
- end
147
-
148
- it 'should work in an instance_eval' do
149
- o = Object.new
150
- o.instance_eval do
151
- O3.local_eval { receiver_ivar_set3 }
152
- O3.instance_variable_get(:@receiver_ivar3).should == :receiver3
153
- instance_variable_get(:@ivar3).should == :ivar3
154
- end
155
- end
156
-
157
-
158
-
159
- end
160
-
161
- describe 'mixing in a module' do
162
- it 'should mix in and mixout the module' do
163
- lambda { hello }.should.raise NameError
164
- M.local_eval { hello }.should == :m
165
- lambda { hello }.should.raise NameError
166
- end
167
- end
168
- end