oneliner 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,50 @@
1
+
2
+ require File.join(File.dirname(__FILE__), 'test_helper')
3
+
4
+ class SuperStringTest < Test::Unit::TestCase
5
+
6
+ def test_decoding
7
+ 1.upto(8) do |i|
8
+ print "[#{5 ** i}]"
9
+ STDOUT.flush
10
+ size_test(5 ** i)
11
+ end
12
+ end
13
+
14
+ def test_hack
15
+ 20.times do
16
+ size = rand(1024)
17
+ s = "x" * size
18
+ bites = rand(128) + 1
19
+ l = s.hack(bites)
20
+ assert_equal((size.to_f / bites).ceil, l.size)
21
+ assert_equal(s, l.join)
22
+ l.each_with_index do |e, index|
23
+ if index == l.size - 1
24
+ assert(e.size <= bites)
25
+ else
26
+ assert_equal(bites, e.size, "element #{index} of #{l.inspect} should be of size #{bites}")
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ def test_weird_string
33
+ s = Oneliner::SuperString.new(open(File.join(File.dirname(__FILE__), 'weird_string')).read)
34
+ s.encode(20)
35
+ end
36
+
37
+ private
38
+
39
+ def size_test(size)
40
+ s = Oneliner::SuperString.new(" " * size)
41
+ s2 = Oneliner::SuperString.new
42
+ assert(!s2.decode!(s.encode(s.size + 8)))
43
+ while !s2.decode!(s.encode((s.size * (0.1)).ceil + 8))
44
+ print "."
45
+ STDOUT.flush
46
+ end
47
+ assert_equal(s, s2)
48
+ end
49
+
50
+ end
@@ -0,0 +1,35 @@
1
+
2
+ home = File.expand_path(File.dirname(__FILE__))
3
+ $: << File.join(home, "..", "lib")
4
+
5
+ require 'pp'
6
+ require 'test/unit'
7
+ require 'benchmark'
8
+ require 'oneliner'
9
+
10
+ def bm(label = "", options = {})
11
+ n = options[:n] || 1000
12
+ width = options[:width] || 50
13
+ Benchmark.benchmark(" " * width + Benchmark::Tms::CAPTION, width, Benchmark::Tms::FMTSTR, "ms/call") do |b|
14
+ times = b.report("#{n}x#{label}") do
15
+ n.times do
16
+ yield
17
+ end
18
+ end
19
+ [times * 1000 / n.to_f]
20
+ end
21
+ end
22
+
23
+ class Test::Unit::TestCase
24
+
25
+ def assert_within(timeout, &block)
26
+ t = Time.new
27
+ rval = yield
28
+ while !rval && t > Time.new - timeout
29
+ rval = yield
30
+ sleep(0.05)
31
+ end
32
+ assert(rval)
33
+ end
34
+
35
+ end
@@ -0,0 +1,473 @@
1
+ --- !ruby/object:Archipelago::Pirate::Captain
2
+ chest_eval_files:
3
+ - ./script/overloads.rb
4
+ chests_having_evaluated:
5
+ ?
6
+ - 3c9722f35eb844bd09cc8563ce359ae9fa209107
7
+ - 2007-03-15 14:29:26.778436 +01:00
8
+ : !ruby/object:Set
9
+ hash:
10
+ ./script/overloads.rb: true
11
+
12
+ initial_lookup_timeout: 5
13
+ initial_service_update_interval: 1
14
+ jockey: &id005 !ruby/object:Archipelago::Disco::Jockey
15
+ incoming: !ruby/object:Queue
16
+ que: []
17
+
18
+ waiting:
19
+ - &id001 !ruby/object:Thread {}
20
+
21
+ initial_lookup_standoff: 0.1
22
+ listener: !ruby/object:UDPSocket {}
23
+
24
+ listener_thread: !ruby/object:Thread {}
25
+
26
+ local_services: !ruby/object:Archipelago::Disco::ServiceLocker
27
+ hash: {}
28
+
29
+ jockey: *id005
30
+ lookup_timeout: 10
31
+ multiaddress: 234.2.4.2
32
+ multiport: 25242
33
+ new_service_semaphore: !ruby/object:MonitorMixin::ConditionVariable
34
+ monitor: !ruby/object:Archipelago::Current::Lock
35
+ archipelago_current_synchronized_lock_by_object: {}
36
+
37
+ mon_count: 0
38
+ mon_entering_queue: []
39
+
40
+ mon_owner: !ruby/object:Thread {}
41
+
42
+ mon_waiting_queue: []
43
+
44
+ waiters: []
45
+
46
+ outgoing: !ruby/object:Queue
47
+ que: []
48
+
49
+ waiting:
50
+ - &id012 !ruby/object:Thread {}
51
+
52
+ picker_thread: *id001
53
+ remote_services: !ruby/object:Archipelago::Disco::ServiceLocker
54
+ hash:
55
+ 41559f282ebdfc7348a43aba911d05252b74b742: !ruby/object:Archipelago::Disco::Record
56
+ attributes:
57
+ :service: &id002 !ruby/object:DRb::DRbObject
58
+ ref: 9827790
59
+ uri: druby://dhcp1-150.local.adocca.net:53830
60
+ :class: Archipelago::Tranny::Manager
61
+ :validator: *id002
62
+ :published_at: 2007-03-15 14:29:26.584411 +01:00
63
+ :service_id: 41559f282ebdfc7348a43aba911d05252b74b742
64
+ 49d4d1383d4e9ec41c38bdd2659d7041fc9ffbec: !ruby/object:Archipelago::Disco::Record
65
+ attributes:
66
+ :service: &id003 !ruby/object:DRb::DRbObject
67
+ ref: 9527210
68
+ uri: druby://dhcp1-150.local.adocca.net:53830
69
+ :class: Archipelago::Dump::Site
70
+ :validator: *id003
71
+ :published_at: 2007-03-15 14:29:26.737298 +01:00
72
+ :service_id: 49d4d1383d4e9ec41c38bdd2659d7041fc9ffbec
73
+ 3c9722f35eb844bd09cc8563ce359ae9fa209107: !ruby/object:Archipelago::Disco::Record
74
+ attributes:
75
+ :service: &id004 !ruby/object:DRb::DRbObject
76
+ ref: 9521410
77
+ uri: druby://dhcp1-150.local.adocca.net:53830
78
+ :class: Archipelago::Treasure::Chest
79
+ :validator: *id004
80
+ :published_at: 2007-03-15 14:29:26.778436 +01:00
81
+ :service_id: 3c9722f35eb844bd09cc8563ce359ae9fa209107
82
+ jockey: *id005
83
+ sender: !ruby/object:UDPSocket {}
84
+
85
+ service_change_subscribers_by_event_type:
86
+ :found:
87
+ ?
88
+ - !ruby/object:Archipelago::Disco::Query
89
+ attributes: &id007 !ruby/object:Archipelago::Disco::Query
90
+ attributes:
91
+ :class: Archipelago::Dump::Site
92
+ :unicast_reply: dhcp1-150.local.adocca.net:25244
93
+ - 11204190
94
+ : !ruby/object:Proc {}
95
+
96
+ ?
97
+ - !ruby/object:Archipelago::Disco::Query
98
+ attributes: &id010
99
+ :class: Archipelago::Treasure::Chest
100
+ :unicast_reply: dhcp1-150.local.adocca.net:25244
101
+ - 11399580
102
+ : !ruby/object:Proc {}
103
+
104
+ ?
105
+ - !ruby/object:Archipelago::Disco::Query
106
+ attributes: &id011
107
+ :class: Archipelago::Tranny::Manager
108
+ :unicast_reply: dhcp1-150.local.adocca.net:25244
109
+ - 11399580
110
+ : !ruby/object:Proc {}
111
+
112
+ ?
113
+ - !ruby/object:Archipelago::Disco::Query
114
+ attributes: &id009
115
+ :class: Archipelago::Tranny::Manager
116
+ :unicast_reply: dhcp1-150.local.adocca.net:25244
117
+ - 11380640
118
+ : !ruby/object:Proc {}
119
+
120
+ ?
121
+ - !ruby/object:Archipelago::Disco::Query
122
+ attributes: &id006 !ruby/object:Archipelago::Disco::Query
123
+ attributes:
124
+ :class: Archipelago::Dump::Site
125
+ :unicast_reply: dhcp1-150.local.adocca.net:25244
126
+ - 11213820
127
+ : !ruby/object:Proc {}
128
+
129
+ ?
130
+ - !ruby/object:Archipelago::Disco::Query
131
+ attributes: &id008
132
+ :class: Archipelago::Treasure::Chest
133
+ :unicast_reply: dhcp1-150.local.adocca.net:25244
134
+ - 11380640
135
+ : !ruby/object:Proc {}
136
+
137
+ :lost:
138
+ ?
139
+ - !ruby/object:Archipelago::Disco::Query
140
+ attributes: *id006
141
+ - 11213820
142
+ : !ruby/object:Proc {}
143
+
144
+ ?
145
+ - !ruby/object:Archipelago::Disco::Query
146
+ attributes: *id007
147
+ - 11204190
148
+ : !ruby/object:Proc {}
149
+
150
+ ?
151
+ - !ruby/object:Archipelago::Disco::Query
152
+ attributes: *id008
153
+ - 11380640
154
+ : !ruby/object:Proc {}
155
+
156
+ ?
157
+ - !ruby/object:Archipelago::Disco::Query
158
+ attributes: *id009
159
+ - 11380640
160
+ : !ruby/object:Proc {}
161
+
162
+ ?
163
+ - !ruby/object:Archipelago::Disco::Query
164
+ attributes: *id010
165
+ - 11399580
166
+ : !ruby/object:Proc {}
167
+
168
+ ?
169
+ - !ruby/object:Archipelago::Disco::Query
170
+ attributes: *id011
171
+ - 11399580
172
+ : !ruby/object:Proc {}
173
+
174
+ shouter_thread: *id012
175
+ subscribed_services: !ruby/object:Set
176
+ hash:
177
+ !ruby/object:Archipelago::Disco::Query ?
178
+ attributes: *id011
179
+ : true
180
+
181
+ !ruby/object:Archipelago::Disco::Query ?
182
+ attributes: *id011
183
+ : true
184
+
185
+ !ruby/object:Archipelago::Disco::Query ?
186
+ attributes: *id007
187
+ : true
188
+
189
+ !ruby/object:Archipelago::Disco::Query ?
190
+ attributes: *id010
191
+ : true
192
+
193
+ !ruby/object:Archipelago::Disco::Query ?
194
+ attributes: *id011
195
+ : true
196
+
197
+ !ruby/object:Archipelago::Disco::Query ?
198
+ attributes: *id007
199
+ : true
200
+
201
+ !ruby/object:Archipelago::Disco::Query ?
202
+ attributes: *id009
203
+ : true
204
+
205
+ !ruby/object:Archipelago::Disco::Query ?
206
+ attributes: *id009
207
+ : true
208
+
209
+ !ruby/object:Archipelago::Disco::Query ?
210
+ attributes: *id008
211
+ : true
212
+
213
+ !ruby/object:Archipelago::Disco::Query ?
214
+ attributes: *id011
215
+ : true
216
+
217
+ !ruby/object:Archipelago::Disco::Query ?
218
+ attributes: *id010
219
+ : true
220
+
221
+ !ruby/object:Archipelago::Disco::Query ?
222
+ attributes: *id006
223
+ : true
224
+
225
+ !ruby/object:Archipelago::Disco::Query ?
226
+ attributes: *id008
227
+ : true
228
+
229
+ !ruby/object:Archipelago::Disco::Query ?
230
+ attributes: *id008
231
+ : true
232
+
233
+ !ruby/object:Archipelago::Disco::Query ?
234
+ attributes: *id007
235
+ : true
236
+
237
+ !ruby/object:Archipelago::Disco::Query ?
238
+ attributes: *id008
239
+ : true
240
+
241
+ !ruby/object:Archipelago::Disco::Query ?
242
+ attributes: *id007
243
+ : true
244
+
245
+ !ruby/object:Archipelago::Disco::Query ?
246
+ attributes: *id006
247
+ : true
248
+
249
+ !ruby/object:Archipelago::Disco::Query ?
250
+ attributes: *id009
251
+ : true
252
+
253
+ !ruby/object:Archipelago::Disco::Query ?
254
+ attributes: *id009
255
+ : true
256
+
257
+ !ruby/object:Archipelago::Disco::Query ?
258
+ attributes: *id011
259
+ : true
260
+
261
+ !ruby/object:Archipelago::Disco::Query ?
262
+ attributes: *id010
263
+ : true
264
+
265
+ !ruby/object:Archipelago::Disco::Query ?
266
+ attributes: *id008
267
+ : true
268
+
269
+ !ruby/object:Archipelago::Disco::Query ?
270
+ attributes: *id010
271
+ : true
272
+
273
+ !ruby/object:Archipelago::Disco::Query ?
274
+ attributes: *id009
275
+ : true
276
+
277
+ !ruby/object:Archipelago::Disco::Query ?
278
+ attributes: *id011
279
+ : true
280
+
281
+ !ruby/object:Archipelago::Disco::Query ?
282
+ attributes: *id009
283
+ : true
284
+
285
+ !ruby/object:Archipelago::Disco::Query ?
286
+ attributes: *id006
287
+ : true
288
+
289
+ !ruby/object:Archipelago::Disco::Query ?
290
+ attributes: *id009
291
+ : true
292
+
293
+ !ruby/object:Archipelago::Disco::Query ?
294
+ attributes: *id006
295
+ : true
296
+
297
+ !ruby/object:Archipelago::Disco::Query ?
298
+ attributes: *id007
299
+ : true
300
+
301
+ !ruby/object:Archipelago::Disco::Query ?
302
+ attributes: *id009
303
+ : true
304
+
305
+ !ruby/object:Archipelago::Disco::Query ?
306
+ attributes: *id009
307
+ : true
308
+
309
+ !ruby/object:Archipelago::Disco::Query ?
310
+ attributes: *id008
311
+ : true
312
+
313
+ !ruby/object:Archipelago::Disco::Query ?
314
+ attributes: *id011
315
+ : true
316
+
317
+ !ruby/object:Archipelago::Disco::Query ?
318
+ attributes: *id011
319
+ : true
320
+
321
+ !ruby/object:Archipelago::Disco::Query ?
322
+ attributes: *id009
323
+ : true
324
+
325
+ !ruby/object:Archipelago::Disco::Query ?
326
+ attributes: *id009
327
+ : true
328
+
329
+ !ruby/object:Archipelago::Disco::Query ?
330
+ attributes: *id010
331
+ : true
332
+
333
+ !ruby/object:Archipelago::Disco::Query ?
334
+ attributes: *id006
335
+ : true
336
+
337
+ !ruby/object:Archipelago::Disco::Query ?
338
+ attributes: *id010
339
+ : true
340
+
341
+ !ruby/object:Archipelago::Disco::Query ?
342
+ attributes: *id008
343
+ : true
344
+
345
+ !ruby/object:Archipelago::Disco::Query ?
346
+ attributes: *id007
347
+ : true
348
+
349
+ !ruby/object:Archipelago::Disco::Query ?
350
+ attributes: *id006
351
+ : true
352
+
353
+ !ruby/object:Archipelago::Disco::Query ?
354
+ attributes: *id008
355
+ : true
356
+
357
+ !ruby/object:Archipelago::Disco::Query ?
358
+ attributes: *id011
359
+ : true
360
+
361
+ !ruby/object:Archipelago::Disco::Query ?
362
+ attributes: *id007
363
+ : true
364
+
365
+ !ruby/object:Archipelago::Disco::Query ?
366
+ attributes: *id011
367
+ : true
368
+
369
+ !ruby/object:Archipelago::Disco::Query ?
370
+ attributes: *id010
371
+ : true
372
+
373
+ !ruby/object:Archipelago::Disco::Query ?
374
+ attributes: *id007
375
+ : true
376
+
377
+ !ruby/object:Archipelago::Disco::Query ?
378
+ attributes: *id007
379
+ : true
380
+
381
+ !ruby/object:Archipelago::Disco::Query ?
382
+ attributes: *id006
383
+ : true
384
+
385
+ !ruby/object:Archipelago::Disco::Query ?
386
+ attributes: *id006
387
+ : true
388
+
389
+ !ruby/object:Archipelago::Disco::Query ?
390
+ attributes: *id006
391
+ : true
392
+
393
+ !ruby/object:Archipelago::Disco::Query ?
394
+ attributes: *id008
395
+ : true
396
+
397
+ !ruby/object:Archipelago::Disco::Query ?
398
+ attributes: *id007
399
+ : true
400
+
401
+ !ruby/object:Archipelago::Disco::Query ?
402
+ attributes: *id007
403
+ : true
404
+
405
+ !ruby/object:Archipelago::Disco::Query ?
406
+ attributes: *id006
407
+ : true
408
+
409
+ !ruby/object:Archipelago::Disco::Query ?
410
+ attributes: *id010
411
+ : true
412
+
413
+ !ruby/object:Archipelago::Disco::Query ?
414
+ attributes: *id010
415
+ : true
416
+
417
+ !ruby/object:Archipelago::Disco::Query ?
418
+ attributes: *id008
419
+ : true
420
+
421
+ !ruby/object:Archipelago::Disco::Query ?
422
+ attributes: *id011
423
+ : true
424
+
425
+ !ruby/object:Archipelago::Disco::Query ?
426
+ attributes: *id010
427
+ : true
428
+
429
+ !ruby/object:Archipelago::Disco::Query ?
430
+ attributes: *id006
431
+ : true
432
+
433
+ !ruby/object:Archipelago::Disco::Query ?
434
+ attributes: *id008
435
+ : true
436
+
437
+ !ruby/object:Archipelago::Disco::Query ?
438
+ attributes: *id010
439
+ : true
440
+
441
+ thrifty_caching: true
442
+ thrifty_publishing: false
443
+ thrifty_replying: true
444
+ unicast_address: dhcp1-150.local.adocca.net:25244
445
+ unilistener: !ruby/object:UDPSocket {}
446
+
447
+ unilistener_thread: !ruby/object:Thread {}
448
+
449
+ unisender: !ruby/object:UDPSocket {}
450
+
451
+ valid: true
452
+ validation_interval: 30
453
+ validator_thread: !ruby/object:Thread {}
454
+
455
+ jockey_options: {}
456
+
457
+ maximum_service_update_interval: 60
458
+ service_descriptions:
459
+ :chests: *id008
460
+ :trannies: *id009
461
+ service_update_thread: !ruby/object:Thread {}
462
+
463
+ services:
464
+ :chests: !ruby/object:Archipelago::Disco::ServiceLocker
465
+ hash: !ruby/object:RBTree {}
466
+
467
+ jockey:
468
+ :trannies: !ruby/object:Archipelago::Disco::ServiceLocker
469
+ hash: !ruby/object:RBTree {}
470
+
471
+ jockey:
472
+ transaction:
473
+ yar_counter: 0