empathy 0.0.1.RC0

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 (112) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.rdoc +135 -0
  5. data/Rakefile +33 -0
  6. data/TESTING.rdoc +11 -0
  7. data/empathy.gemspec +23 -0
  8. data/empathy.mspec +34 -0
  9. data/lib/empathy.rb +162 -0
  10. data/lib/empathy/em/condition_variable.rb +57 -0
  11. data/lib/empathy/em/mutex.rb +70 -0
  12. data/lib/empathy/em/queue.rb +84 -0
  13. data/lib/empathy/em/thread.rb +363 -0
  14. data/lib/empathy/object.rb +19 -0
  15. data/lib/empathy/thread.rb +8 -0
  16. data/lib/empathy/version.rb +3 -0
  17. data/mspec/lib/mspec/empathy.rb +19 -0
  18. data/mspec/lib/mspec/guards/empathy.rb +10 -0
  19. data/rubyspec/core/kernel/fixtures/__method__.rb +25 -0
  20. data/rubyspec/core/kernel/fixtures/autoload_b.rb +5 -0
  21. data/rubyspec/core/kernel/fixtures/autoload_c.rb +5 -0
  22. data/rubyspec/core/kernel/fixtures/autoload_d.rb +5 -0
  23. data/rubyspec/core/kernel/fixtures/caller_fixture1.rb +42 -0
  24. data/rubyspec/core/kernel/fixtures/caller_fixture2.rb +26 -0
  25. data/rubyspec/core/kernel/fixtures/chomp.rb +4 -0
  26. data/rubyspec/core/kernel/fixtures/chomp_f.rb +4 -0
  27. data/rubyspec/core/kernel/fixtures/chop.rb +4 -0
  28. data/rubyspec/core/kernel/fixtures/chop_f.rb +4 -0
  29. data/rubyspec/core/kernel/fixtures/classes.rb +410 -0
  30. data/rubyspec/core/kernel/fixtures/eval_locals.rb +6 -0
  31. data/rubyspec/core/kernel/fixtures/eval_return_with_lambda.rb +12 -0
  32. data/rubyspec/core/kernel/fixtures/eval_return_without_lambda.rb +14 -0
  33. data/rubyspec/core/kernel/fixtures/test.rb +362 -0
  34. data/rubyspec/core/kernel/sleep_spec.rb +43 -0
  35. data/rubyspec/core/mutex/lock_spec.rb +8 -0
  36. data/rubyspec/core/mutex/locked_spec.rb +8 -0
  37. data/rubyspec/core/mutex/sleep_spec.rb +56 -0
  38. data/rubyspec/core/mutex/synchronize_spec.rb +8 -0
  39. data/rubyspec/core/mutex/try_lock_spec.rb +8 -0
  40. data/rubyspec/core/mutex/unlock_spec.rb +8 -0
  41. data/rubyspec/core/thread/abort_on_exception_spec.rb +126 -0
  42. data/rubyspec/core/thread/add_trace_func_spec.rb +7 -0
  43. data/rubyspec/core/thread/alive_spec.rb +60 -0
  44. data/rubyspec/core/thread/allocate_spec.rb +9 -0
  45. data/rubyspec/core/thread/backtrace_spec.rb +7 -0
  46. data/rubyspec/core/thread/critical_spec.rb +96 -0
  47. data/rubyspec/core/thread/current_spec.rb +15 -0
  48. data/rubyspec/core/thread/element_reference_spec.rb +53 -0
  49. data/rubyspec/core/thread/element_set_spec.rb +46 -0
  50. data/rubyspec/core/thread/exclusive_spec.rb +20 -0
  51. data/rubyspec/core/thread/exit_spec.rb +21 -0
  52. data/rubyspec/core/thread/fixtures/classes.rb +291 -0
  53. data/rubyspec/core/thread/fork_spec.rb +9 -0
  54. data/rubyspec/core/thread/group_spec.rb +5 -0
  55. data/rubyspec/core/thread/initialize_spec.rb +26 -0
  56. data/rubyspec/core/thread/inspect_spec.rb +48 -0
  57. data/rubyspec/core/thread/join_spec.rb +63 -0
  58. data/rubyspec/core/thread/key_spec.rb +64 -0
  59. data/rubyspec/core/thread/keys_spec.rb +47 -0
  60. data/rubyspec/core/thread/kill_spec.rb +21 -0
  61. data/rubyspec/core/thread/list_spec.rb +38 -0
  62. data/rubyspec/core/thread/main_spec.rb +10 -0
  63. data/rubyspec/core/thread/new_spec.rb +56 -0
  64. data/rubyspec/core/thread/pass_spec.rb +8 -0
  65. data/rubyspec/core/thread/priority_spec.rb +9 -0
  66. data/rubyspec/core/thread/raise_spec.rb +225 -0
  67. data/rubyspec/core/thread/run_spec.rb +9 -0
  68. data/rubyspec/core/thread/safe_level_spec.rb +6 -0
  69. data/rubyspec/core/thread/set_trace_func_spec.rb +7 -0
  70. data/rubyspec/core/thread/shared/exit.rb +173 -0
  71. data/rubyspec/core/thread/shared/start.rb +51 -0
  72. data/rubyspec/core/thread/shared/wakeup.rb +59 -0
  73. data/rubyspec/core/thread/start_spec.rb +9 -0
  74. data/rubyspec/core/thread/status_spec.rb +48 -0
  75. data/rubyspec/core/thread/stop_spec.rb +66 -0
  76. data/rubyspec/core/thread/terminate_spec.rb +11 -0
  77. data/rubyspec/core/thread/value_spec.rb +36 -0
  78. data/rubyspec/core/thread/wakeup_spec.rb +7 -0
  79. data/rubyspec/empathy_spec.rb +26 -0
  80. data/rubyspec/library/conditionvariable/broadcast_spec.rb +62 -0
  81. data/rubyspec/library/conditionvariable/signal_spec.rb +64 -0
  82. data/rubyspec/library/conditionvariable/wait_spec.rb +21 -0
  83. data/rubyspec/library/mutex/lock_spec.rb +10 -0
  84. data/rubyspec/library/mutex/locked_spec.rb +10 -0
  85. data/rubyspec/library/mutex/synchronize_spec.rb +10 -0
  86. data/rubyspec/library/mutex/try_lock_spec.rb +10 -0
  87. data/rubyspec/library/mutex/unlock_spec.rb +10 -0
  88. data/rubyspec/library/queue/append_spec.rb +7 -0
  89. data/rubyspec/library/queue/clear_spec.rb +15 -0
  90. data/rubyspec/library/queue/deq_spec.rb +7 -0
  91. data/rubyspec/library/queue/empty_spec.rb +15 -0
  92. data/rubyspec/library/queue/enq_spec.rb +7 -0
  93. data/rubyspec/library/queue/length_spec.rb +7 -0
  94. data/rubyspec/library/queue/num_waiting_spec.rb +19 -0
  95. data/rubyspec/library/queue/pop_spec.rb +7 -0
  96. data/rubyspec/library/queue/push_spec.rb +7 -0
  97. data/rubyspec/library/queue/shared/deque.rb +37 -0
  98. data/rubyspec/library/queue/shared/enque.rb +10 -0
  99. data/rubyspec/library/queue/shared/length.rb +9 -0
  100. data/rubyspec/library/queue/shift_spec.rb +7 -0
  101. data/rubyspec/library/queue/size_spec.rb +7 -0
  102. data/rubyspec/shared/kernel/raise.rb +68 -0
  103. data/rubyspec/shared/mutex/lock.rb +52 -0
  104. data/rubyspec/shared/mutex/locked.rb +31 -0
  105. data/rubyspec/shared/mutex/synchronize.rb +23 -0
  106. data/rubyspec/shared/mutex/try_lock.rb +30 -0
  107. data/rubyspec/shared/mutex/unlock.rb +35 -0
  108. data/rubyspec/spec_helper.rb +48 -0
  109. data/spec/empathy_spec.rb +129 -0
  110. data/spec/library_spec.rb +79 -0
  111. data/spec/spec_helper.rb +6 -0
  112. metadata +222 -0
@@ -0,0 +1,6 @@
1
+ begin
2
+ eval("a = 2")
3
+ eval("p a")
4
+ rescue Object => e
5
+ puts e.class
6
+ end
@@ -0,0 +1,12 @@
1
+ print "a,"
2
+ x = lambda do
3
+ print "b,"
4
+ Proc.new do
5
+ print "c,"
6
+ eval("return :eval")
7
+ print "d,"
8
+ end.call
9
+ print "e,"
10
+ end.call
11
+ print x, ","
12
+ print "f"
@@ -0,0 +1,14 @@
1
+ print "a,"
2
+ begin
3
+ print "b,"
4
+ x = Proc.new do
5
+ print "c,"
6
+ eval("return :eval")
7
+ print "d,"
8
+ end.call
9
+ print x, ","
10
+ rescue LocalJumpError => e
11
+ print "e,"
12
+ print e.class, ","
13
+ end
14
+ print "f"
@@ -0,0 +1,362 @@
1
+ def foo1
2
+ end
3
+
4
+ def foo2
5
+ end
6
+
7
+ def foo3
8
+ end
9
+
10
+ def foo4
11
+ end
12
+
13
+ def foo5
14
+ end
15
+
16
+ def foo6
17
+ end
18
+
19
+ def foo7
20
+ end
21
+
22
+ def foo8
23
+ end
24
+
25
+ def foo9
26
+ end
27
+
28
+ def foo10
29
+ end
30
+
31
+ def foo11
32
+ end
33
+
34
+ def foo12
35
+ end
36
+
37
+ def foo13
38
+ end
39
+
40
+ def foo14
41
+ end
42
+
43
+ def foo15
44
+ end
45
+
46
+ def foo16
47
+ end
48
+
49
+ def foo17
50
+ end
51
+
52
+ def foo18
53
+ end
54
+
55
+ def foo19
56
+ end
57
+
58
+ def foo20
59
+ end
60
+
61
+ def foo21
62
+ end
63
+
64
+ def foo22
65
+ end
66
+
67
+ def foo23
68
+ end
69
+
70
+ def foo24
71
+ end
72
+
73
+ def foo25
74
+ end
75
+
76
+ def foo26
77
+ end
78
+
79
+ def foo27
80
+ end
81
+
82
+ def foo28
83
+ end
84
+
85
+ def foo29
86
+ end
87
+
88
+ def foo30
89
+ end
90
+
91
+ def foo31
92
+ end
93
+
94
+ def foo32
95
+ end
96
+
97
+ def foo33
98
+ end
99
+
100
+ def foo34
101
+ end
102
+
103
+ def foo35
104
+ end
105
+
106
+ def foo36
107
+ end
108
+
109
+ def foo37
110
+ end
111
+
112
+ def foo38
113
+ end
114
+
115
+ def foo39
116
+ end
117
+
118
+ def foo40
119
+ end
120
+
121
+ def foo41
122
+ end
123
+
124
+ def foo42
125
+ end
126
+
127
+ def foo43
128
+ end
129
+
130
+ def foo44
131
+ end
132
+
133
+ def foo45
134
+ end
135
+
136
+ def foo46
137
+ end
138
+
139
+ def foo47
140
+ end
141
+
142
+ def foo48
143
+ end
144
+
145
+ def foo49
146
+ end
147
+
148
+ def foo50
149
+ end
150
+
151
+ def foo51
152
+ end
153
+
154
+ def foo52
155
+ end
156
+
157
+ def foo53
158
+ end
159
+
160
+ def foo54
161
+ end
162
+
163
+ def foo55
164
+ end
165
+
166
+ def foo56
167
+ end
168
+
169
+ def foo57
170
+ end
171
+
172
+ def foo58
173
+ end
174
+
175
+ def foo59
176
+ end
177
+
178
+ def foo60
179
+ end
180
+
181
+ def foo61
182
+ end
183
+
184
+ def foo62
185
+ end
186
+
187
+ def foo63
188
+ end
189
+
190
+ def foo64
191
+ end
192
+
193
+ def foo65
194
+ end
195
+
196
+ def foo66
197
+ end
198
+
199
+ def foo67
200
+ end
201
+
202
+ def foo68
203
+ end
204
+
205
+ def foo69
206
+ end
207
+
208
+ def foo70
209
+ end
210
+
211
+ def foo71
212
+ end
213
+
214
+ def foo72
215
+ end
216
+
217
+ def foo73
218
+ end
219
+
220
+ def foo74
221
+ end
222
+
223
+ def foo75
224
+ end
225
+
226
+ def foo76
227
+ end
228
+
229
+ def foo77
230
+ end
231
+
232
+ def foo78
233
+ end
234
+
235
+ def foo79
236
+ end
237
+
238
+ def foo80
239
+ end
240
+
241
+ def foo81
242
+ end
243
+
244
+ def foo82
245
+ end
246
+
247
+ def foo83
248
+ end
249
+
250
+ def foo84
251
+ end
252
+
253
+ def foo85
254
+ end
255
+
256
+ def foo86
257
+ end
258
+
259
+ def foo87
260
+ end
261
+
262
+ def foo88
263
+ end
264
+
265
+ def foo89
266
+ end
267
+
268
+ def foo90
269
+ end
270
+
271
+ def foo91
272
+ end
273
+
274
+ def foo92
275
+ end
276
+
277
+ def foo93
278
+ end
279
+
280
+ def foo94
281
+ end
282
+
283
+ def foo95
284
+ end
285
+
286
+ def foo96
287
+ end
288
+
289
+ def foo97
290
+ end
291
+
292
+ def foo98
293
+ end
294
+
295
+ def foo99
296
+ end
297
+
298
+ def foo100
299
+ end
300
+
301
+ def foo101
302
+ end
303
+
304
+ def foo102
305
+ end
306
+
307
+ def foo103
308
+ end
309
+
310
+ def foo104
311
+ end
312
+
313
+ def foo105
314
+ end
315
+
316
+ def foo106
317
+ end
318
+
319
+ def foo107
320
+ end
321
+
322
+ def foo108
323
+ end
324
+
325
+ def foo109
326
+ end
327
+
328
+ def foo110
329
+ end
330
+
331
+ def foo111
332
+ end
333
+
334
+ def foo112
335
+ end
336
+
337
+ def foo113
338
+ end
339
+
340
+ def foo114
341
+ end
342
+
343
+ def foo115
344
+ end
345
+
346
+ def foo116
347
+ end
348
+
349
+ def foo117
350
+ end
351
+
352
+ def foo118
353
+ end
354
+
355
+ def foo119
356
+ end
357
+
358
+ def foo120
359
+ end
360
+
361
+ def foo121
362
+ end
@@ -0,0 +1,43 @@
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
+ require File.expand_path('../fixtures/classes', __FILE__)
3
+
4
+ describe "Kernel#sleep" do
5
+ it "is a private method" do
6
+ Kernel.should have_private_instance_method(:sleep)
7
+ end
8
+
9
+ it "pauses execution for approximately the duration requested" do
10
+ duration = 0.1
11
+ start = Time.now
12
+ sleep duration
13
+ (Time.now - start).should be_close(duration, 0.1)
14
+ end
15
+
16
+ it "returns the rounded number of seconds asleep" do
17
+ sleep(0.01).should be_kind_of(Integer)
18
+ end
19
+
20
+ it "raises a TypeError when passed a non-numeric duration" do
21
+ lambda { sleep(nil) }.should raise_error(TypeError)
22
+ lambda { sleep('now') }.should raise_error(TypeError)
23
+ lambda { sleep('2') }.should raise_error(TypeError)
24
+ end
25
+
26
+ it "pauses execution indefinitely if not given a duration" do
27
+ lock = Channel.new
28
+ t = Thread.new do
29
+ lock << :ready
30
+ sleep
31
+ 5
32
+ end
33
+ lock.receive.should == :ready
34
+ # wait until the thread has gone to sleep
35
+ Thread.pass while t.status and t.status != "sleep"
36
+ t.run
37
+ t.value.should == 5
38
+ end
39
+ end
40
+
41
+ describe "Kernel.sleep" do
42
+ it "needs to be reviewed for spec completeness"
43
+ end
@@ -0,0 +1,8 @@
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
+ require File.expand_path('../../../shared/mutex/lock', __FILE__)
3
+
4
+ ruby_version_is "1.9" do
5
+ describe "Mutex#lock" do
6
+ it_behaves_like :mutex_lock, :lock
7
+ end
8
+ end