wirb 1.0.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/wirb/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wirb
2
- VERSION = '1.0.3'
2
+ VERSION = '2.0.0'.freeze
3
3
  end
data/lib/wirb/wp.rb CHANGED
@@ -1,13 +1,9 @@
1
- require File.dirname(__FILE__) + '/../wirb' unless defined? Wirb
1
+ require_relative '../wirb'
2
2
 
3
3
  module Kernel
4
4
  private
5
5
 
6
- def wp(object, color = nil)
7
- if color
8
- puts Wirb.colorize_string object.inspect, color
9
- else
10
- puts Wirb.colorize_result object.inspect
11
- end
6
+ def wp(object)
7
+ puts Wirb.colorize_result object.inspect
12
8
  end
13
9
  end
data/spec/spec_helper.rb CHANGED
@@ -1,19 +1,16 @@
1
1
  require 'wirb'
2
2
  require 'wirb/wp'
3
- require 'zucker/engine'
4
- require 'zucker/ruby_version'
5
-
6
- Wirb.start
3
+ require 'ruby_engine'
7
4
 
8
5
  # TOKENIZER
9
6
 
10
7
  def tokenizer(filename)
11
8
  filename =~ /tokenizer_(.*)_spec\.rb/
12
- "Wirb.tokenize" + ($1 ? "(#{$1})" : "")
9
+ "Wirb::Tokenizer.run" + ($1 ? "(#{$1})" : "")
13
10
  end
14
11
 
15
12
  def check_value
16
- Wirb.tokenize(@a).map{|_,c|c}.join.should == @a
13
+ Wirb::Tokenizer.run(@a).map{|_,c|c}.join.should == @a
17
14
  end
18
15
 
19
16
  def please(*args, &block)
@@ -31,63 +28,11 @@ def check_inspected(str)
31
28
  end
32
29
 
33
30
  def tokens
34
- Wirb.tokenize(@a).to_a
31
+ Wirb::Tokenizer.run(@a).to_a
35
32
  end
36
33
 
37
34
  # COLORIZER
38
35
 
39
- shared_examples_for "a Wirb0 colorizer" do
40
- it "creates good color codes based on original Wirb color symbols" do
41
- # Wirb.get_color(:black).should match_colors(30)
42
- Wirb.get_color(:light_purple).should match_colors(1,35)
43
- Wirb.get_color(:brown_underline).should match_colors(4,33)
44
- Wirb.get_color(:green_background).should match_colors(42)
45
- end
46
-
47
- it "colorizes strings based on original Wirb color symbols" do
48
- Wirb.colorize_string('Mos Eisley', :blue).should match_colored_string('Mos Eisley', 34)
49
- Wirb.colorize_string('Tatooine', :light_red).should match_colored_string('Tatooine', 1, 31)
50
- Wirb.colorize_string('Bespin', :white).should match_colored_string('Bespin', 1, 37)
51
- Wirb.colorize_string('Coruscant', :cyan_underline).should match_colored_string('Coruscant', 4, 36)
52
- end
53
- end
54
-
55
- def extract_color_codes(string)
56
- res = string.scan(/\e\[(?:\d+(?:;\d+)*)?m/).map do |code_match|
57
- codes = []
58
- code_match.scan(/((?:38|48);5;\d+)|((\d+);(\d+))|(\d+)|^$/) do |code_parts|
59
- rgb_code, color_with_style, style, color, color_with_no_style = code_parts
60
- codes << if rgb_code
61
- rgb_code
62
- elsif color_with_style
63
- case style
64
- when '0'
65
- color
66
- when '7'
67
- (color.to_i+10).to_s
68
- else
69
- [style,color]
70
- end
71
- elsif color_with_no_style
72
- color_with_no_style
73
- else
74
- '0'
75
- end
76
- end
77
- codes
78
- end.flatten
79
- standardize_color_codes(res)
80
- end
81
-
82
- def standardize_color_codes(codes)
83
- codes = codes.map{|code| code.to_s}
84
- codes = codes.sort.uniq # Order of codes doesn't matter, nor does repetition
85
- if codes != ['0']
86
- codes -= ['0'] # Code '0' doesn't matter, unless it's the only one
87
- end
88
- codes
89
- end
90
-
91
36
  # MATCHER
92
37
 
93
38
  # match regex in arrays (e.g. for object ids)
@@ -128,72 +73,10 @@ RSpec::Matchers.define :be_sorted_like do |should_array|
128
73
  end
129
74
  end
130
75
 
131
- # Match the color codes from a string with an array of codes, e.g.
132
- # "\e\[1m\e\[34m".should match_colors(1,34)
133
- # Order of the codes does not matter, and repeated codes are ignored
134
- # Codes like "\e[0;32" are equivalent to "\e[0m\e[32m"
135
- # Codes like 0,34 and 34 are equivalent
136
- # Codes like 7,34 and 44 are equivalent
137
- RSpec::Matchers.define :match_colors do |*should_codes|
138
- match do |got_string|
139
- got_codes = extract_color_codes(got_string)
140
- should_codes = standardize_color_codes(should_codes.flatten)
141
-
142
- should_codes == got_codes
143
- end
144
-
145
- failure_message_for_should do |actual|
146
- "expected that #{actual.inspect} would match the color codes #{should_codes.inspect}"
147
- end
148
-
149
- failure_message_for_should_not do |actual|
150
- "expected that #{actual.inspect} would match the color codes #{should_codes.inspect}"
151
- end
152
-
153
- end
154
-
155
- # Match an encoded string:
156
- # Usage "\e[4m\e[33mStuff\e[0m".should match_colored_string('Stuff', 4, 33)
157
- RSpec::Matchers.define :match_colored_string do |*should_spec|
158
- match do |got_string|
159
- should_string = should_spec.first
160
- should_codes = should_spec[1..-1]
161
-
162
- if matches=(got_string=~/^((?:\e\[\d+(?:;\d+)*m)+)(.*)(\e\[\d+(;\d+)*m)$/)
163
- got_codes = $1
164
- got_string = $2
165
- got_terminating_code = $3
166
- end
167
-
168
-
169
- matches &&
170
- should_string == got_string &&
171
- got_codes.should(match_colors(should_codes)) &&
172
- got_terminating_code.should(match_colors(0))
173
- end
174
-
175
- failure_message_for_should do |actual|
176
- "expected that #{actual.inspect} would match the string #{should_spec.first.inspect}, colored with color codes #{should_spec[1..-1].inspect}"
177
- end
178
-
179
- failure_message_for_should_not do |actual|
180
- "expected that #{actual.inspect} would not match the string #{should_spec.first}, colored with color codes #{should_spec[1..-1].inspect}"
181
- end
182
- end
183
76
 
184
77
  # GENERAL
185
78
 
186
- def only19
187
- yield if RubyVersion == 1.9
188
- end
189
-
190
- def only18
191
- yield if RubyVersion == 1.8
192
- end
193
-
194
79
  # common regex patterns
195
80
  OBJECT_ID = /0x[0-9a-f]+/
196
81
 
197
- =begin helper method for getting tokens
198
- def ws(obj); puts Wirb.tokenize(obj.inspect).map{|*x| x.inspect + ','}*$/; end
199
- =end
82
+ def ws(obj) puts Wirb::Tokenizer.run(obj.inspect).map{|*x| x.inspect + ','}*$/ end
@@ -1,7 +1,7 @@
1
1
  describe tokenizer(__FILE__) do
2
2
  after :each do check_value end
3
3
 
4
- only19 do
4
+ if !RubyEngine.rbx?
5
5
  please do check [2,3,4].each
6
6
  tokens.should == [
7
7
  [:open_object, "#<"],
@@ -116,14 +116,16 @@ describe tokenizer(__FILE__) do
116
116
  ]
117
117
  end
118
118
 
119
- please do check Wirb.tokenize('[2,3,4]')
119
+ please do check Wirb::Tokenizer.run('[2,3,4]')
120
120
  tokens.should == [
121
121
  [:open_object, "#<"],
122
122
  [:object_class, "Enumerator"],
123
123
  [:object_description_prefix, ":"],
124
124
  [:whitespace, " "],
125
125
  [:class, "Wirb"],
126
- [:object_description, ":tokenize("],
126
+ [:class_separator, "::"],
127
+ [:class, "Tokenizer"],
128
+ [:object_description, ":run("],
127
129
  [:open_string, "\""],
128
130
  [:string, "[2,3,4]"],
129
131
  [:close_string, "\""],
@@ -132,53 +134,546 @@ describe tokenizer(__FILE__) do
132
134
  ]
133
135
  end
134
136
 
135
- require 'prime'
136
- please do check Prime.each
137
- tokens.should be_like [
137
+ please do check [{1=>2},Wirb::Tokenizer.run('2'),Set[2,3],[3,4],[5,6].each].map
138
+ tokens.should == [
138
139
  [:open_object, "#<"],
139
- [:object_class, "Prime"],
140
+ [:object_class, "Enumerator"],
141
+ [:object_description_prefix, ":"],
142
+ [:whitespace, " "],
143
+ [:open_array, "["],
144
+ [:open_hash, "{"],
145
+ [:number, "1"],
146
+ [:refers, "=>"],
147
+ [:number, "2"],
148
+ [:close_hash, "}"],
149
+ [:comma, ","],
150
+ [:whitespace, " "],
151
+ [:open_object, "#<"],
152
+ [:object_class, "Enumerator"],
153
+ [:object_description_prefix, ":"],
154
+ [:whitespace, " "],
155
+ [:class, "Wirb"],
140
156
  [:class_separator, "::"],
141
- [:object_class, "EratosthenesGenerator"],
157
+ [:class, "Tokenizer"],
158
+ [:object_description, ":run("],
159
+ [:open_string, "\""],
160
+ [:string, "2"],
161
+ [:close_string, "\""],
162
+ [:object_description, ")"],
163
+ [:close_object, ">"],
164
+ [:comma, ","],
165
+ [:whitespace, " "],
166
+ [:open_object, "#<"],
167
+ [:object_class, "Set"],
168
+ [:object_description_prefix, ":"],
169
+ [:whitespace, " "],
170
+ [:open_set, "{"],
171
+ [:number, "2"],
172
+ [:comma, ","],
173
+ [:whitespace, " "],
174
+ [:number, "3"],
175
+ [:close_set, "}"],
176
+ [:close_object, ">"],
177
+ [:comma, ","],
178
+ [:whitespace, " "],
179
+ [:open_array, "["],
180
+ [:number, "3"],
181
+ [:comma, ","],
182
+ [:whitespace, " "],
183
+ [:number, "4"],
184
+ [:close_array, "]"],
185
+ [:comma, ","],
186
+ [:whitespace, " "],
187
+ [:open_object, "#<"],
188
+ [:object_class, "Enumerator"],
189
+ [:object_description_prefix, ":"],
190
+ [:whitespace, " "],
191
+ [:open_array, "["],
192
+ [:number, "5"],
193
+ [:comma, ","],
194
+ [:whitespace, " "],
195
+ [:number, "6"],
196
+ [:close_array, "]"],
197
+ [:object_description, ":each"],
198
+ [:close_object, ">"],
199
+ [:close_array, "]"],
200
+ [:object_description, ":map"],
201
+ [:close_object, ">"],
202
+ ]
203
+ end
204
+ else # is rbx
205
+ please do check [2,3,4].each
206
+ tokens.sort.should be_like [
207
+ [:open_object, "#<"],
208
+ [:object_class, "Enumerable"],
209
+ [:class_separator, "::"],
210
+ [:object_class, "Enumerator"],
142
211
  [:object_description_prefix, ":"],
143
212
  [:object_address, /#{OBJECT_ID}/],
144
- [:object_description, ' '],
213
+ [:object_description, " "],
214
+ [:object_variable_prefix, "@"],
215
+ [:object_variable, "iter"],
216
+ [:object_description, "="],
217
+ [:symbol_prefix, ":"],
218
+ [:symbol, "each"],
219
+ [:object_description, " "],
145
220
  [:object_variable_prefix, "@"],
146
- [:object_variable, "last_prime"],
221
+ [:object_variable, "object"],
222
+ [:object_description, "="],
223
+ [:open_array, "["],
224
+ [:number, "2"],
225
+ [:comma, ","],
226
+ [:whitespace, " "],
227
+ [:number, "3"],
228
+ [:comma, ","],
229
+ [:whitespace, " "],
230
+ [:number, "4"],
231
+ [:close_array, "]"],
232
+ [:object_description, " "],
233
+ [:object_variable_prefix, "@"],
234
+ [:object_variable, "generator"],
235
+ [:object_description, "="],
236
+ [:nil, "nil"],
237
+ [:object_description, " "],
238
+ [:object_variable_prefix, "@"],
239
+ [:object_variable, "lookahead"],
240
+ [:object_description, "="],
241
+ [:open_array, "["],
242
+ [:close_array, "]"],
243
+ [:object_description, " "],
244
+ [:object_variable_prefix, "@"],
245
+ [:object_variable, "args"],
246
+ [:object_description, "="],
247
+ [:open_array, "["],
248
+ [:close_array, "]"],
249
+ [:object_description, " "],
250
+ [:object_variable_prefix, "@"],
251
+ [:object_variable, "size"],
147
252
  [:object_description, "="],
148
253
  [:nil, "nil"],
149
- [:object_description, ", "],
254
+ [:object_description, " "],
150
255
  [:object_variable_prefix, "@"],
151
- [:object_variable, "ubound"],
256
+ [:object_variable, "feedvalue"],
152
257
  [:object_description, "="],
153
258
  [:nil, "nil"],
154
259
  [:close_object, ">"],
155
- ]
260
+ ].sort
156
261
  end
157
262
 
158
- please do check [{1=>2},Wirb.tokenize('2'),Set[2,3],[3,4],[5,6].each].map
159
- tokens.should == [
263
+ please do check Set[2,3,4].map
264
+ tokens.sort.sort.should be_like [
160
265
  [:open_object, "#<"],
266
+ [:object_class, "Enumerable"],
267
+ [:class_separator, "::"],
161
268
  [:object_class, "Enumerator"],
162
269
  [:object_description_prefix, ":"],
270
+ [:object_address, /#{OBJECT_ID}/],
271
+ [:object_description, " "],
272
+ [:object_variable_prefix, "@"],
273
+ [:object_variable, "iter"],
274
+ [:object_description, "="],
275
+ [:symbol_prefix, ":"],
276
+ [:symbol, "collect"],
277
+ [:object_description, " "],
278
+ [:object_variable_prefix, "@"],
279
+ [:object_variable, "object"],
280
+ [:object_description, "="],
281
+ [:open_object, "#<"],
282
+ [:object_class, "Set"],
283
+ [:object_description_prefix, ":"],
163
284
  [:whitespace, " "],
285
+ [:open_set, "{"],
286
+ [:number, "2"],
287
+ [:comma, ","],
288
+ [:whitespace, " "],
289
+ [:number, "3"],
290
+ [:comma, ","],
291
+ [:whitespace, " "],
292
+ [:number, "4"],
293
+ [:close_set, "}"],
294
+ [:close_object, ">"],
295
+ [:object_description, " "],
296
+ [:object_variable_prefix, "@"],
297
+ [:object_variable, "generator"],
298
+ [:object_description, "="],
299
+ [:nil, "nil"],
300
+ [:object_description, " "],
301
+ [:object_variable_prefix, "@"],
302
+ [:object_variable, "lookahead"],
303
+ [:object_description, "="],
304
+ [:open_array, "["],
305
+ [:close_array, "]"],
306
+ [:object_description, " "],
307
+ [:object_variable_prefix, "@"],
308
+ [:object_variable, "args"],
309
+ [:object_description, "="],
310
+ [:open_array, "["],
311
+ [:close_array, "]"],
312
+ [:object_description, " "],
313
+ [:object_variable_prefix, "@"],
314
+ [:object_variable, "size"],
315
+ [:object_description, "="],
316
+ [:nil, "nil"],
317
+ [:object_description, " "],
318
+ [:object_variable_prefix, "@"],
319
+ [:object_variable, "feedvalue"],
320
+ [:object_description, "="],
321
+ [:nil, "nil"],
322
+ [:close_object, ">"],
323
+ ].sort
324
+ end
325
+
326
+ please do check({1=>3}.each)
327
+ tokens.sort.should be_like [
328
+ [:open_object, "#<"],
329
+ [:object_class, "Enumerable"],
330
+ [:class_separator, "::"],
331
+ [:object_class, "Enumerator"],
332
+ [:object_description_prefix, ":"],
333
+ [:object_address, /#{OBJECT_ID}/],
334
+ [:object_description, " "],
335
+ [:object_variable_prefix, "@"],
336
+ [:object_variable, "iter"],
337
+ [:object_description, "="],
338
+ [:symbol_prefix, ":"],
339
+ [:symbol, "each"],
340
+ [:object_description, " "],
341
+ [:object_variable_prefix, "@"],
342
+ [:object_variable, "object"],
343
+ [:object_description, "="],
344
+ [:open_hash, "{"],
345
+ [:number, "1"],
346
+ [:refers, "=>"],
347
+ [:number, "3"],
348
+ [:close_hash, "}"],
349
+ [:object_description, " "],
350
+ [:object_variable_prefix, "@"],
351
+ [:object_variable, "generator"],
352
+ [:object_description, "="],
353
+ [:nil, "nil"],
354
+ [:object_description, " "],
355
+ [:object_variable_prefix, "@"],
356
+ [:object_variable, "lookahead"],
357
+ [:object_description, "="],
358
+ [:open_array, "["],
359
+ [:close_array, "]"],
360
+ [:object_description, " "],
361
+ [:object_variable_prefix, "@"],
362
+ [:object_variable, "args"],
363
+ [:object_description, "="],
364
+ [:open_array, "["],
365
+ [:close_array, "]"],
366
+ [:object_description, " "],
367
+ [:object_variable_prefix, "@"],
368
+ [:object_variable, "size"],
369
+ [:object_description, "="],
370
+ [:nil, "nil"],
371
+ [:object_description, " "],
372
+ [:object_variable_prefix, "@"],
373
+ [:object_variable, "feedvalue"],
374
+ [:object_description, "="],
375
+ [:nil, "nil"],
376
+ [:close_object, ">"],
377
+ ].sort
378
+ end
379
+
380
+ please do check({1=>3}.each.map)
381
+ tokens.sort.should be_like [
382
+ [:open_object, "#<"],
383
+ [:object_class, "Enumerable"],
384
+ [:class_separator, "::"],
385
+ [:object_class, "Enumerator"],
386
+ [:object_description_prefix, ":"],
387
+ [:object_address, /#{OBJECT_ID}/],
388
+ [:object_description, " "],
389
+ [:object_variable_prefix, "@"],
390
+ [:object_variable, "iter"],
391
+ [:object_description, "="],
392
+ [:symbol_prefix, ":"],
393
+ [:symbol, "collect"],
394
+ [:object_description, " "],
395
+ [:object_variable_prefix, "@"],
396
+ [:object_variable, "object"],
397
+ [:object_description, "="],
398
+ [:open_object, "#<"],
399
+ [:object_class, "Enumerable"],
400
+ [:class_separator, "::"],
401
+ [:object_class, "Enumerator"],
402
+ [:object_description_prefix, ":"],
403
+ [:object_address, /#{OBJECT_ID}/],
404
+ [:object_description, " "],
405
+ [:object_variable_prefix, "@"],
406
+ [:object_variable, "iter"],
407
+ [:object_description, "="],
408
+ [:symbol_prefix, ":"],
409
+ [:symbol, "each"],
410
+ [:object_description, " "],
411
+ [:object_variable_prefix, "@"],
412
+ [:object_variable, "object"],
413
+ [:object_description, "="],
414
+ [:open_hash, "{"],
415
+ [:number, "1"],
416
+ [:refers, "=>"],
417
+ [:number, "3"],
418
+ [:close_hash, "}"],
419
+ [:object_description, " "],
420
+ [:object_variable_prefix, "@"],
421
+ [:object_variable, "generator"],
422
+ [:object_description, "="],
423
+ [:nil, "nil"],
424
+ [:object_description, " "],
425
+ [:object_variable_prefix, "@"],
426
+ [:object_variable, "lookahead"],
427
+ [:object_description, "="],
164
428
  [:open_array, "["],
429
+ [:close_array, "]"],
430
+ [:object_description, " "],
431
+ [:object_variable_prefix, "@"],
432
+ [:object_variable, "args"],
433
+ [:object_description, "="],
434
+ [:open_array, "["],
435
+ [:close_array, "]"],
436
+ [:object_description, " "],
437
+ [:object_variable_prefix, "@"],
438
+ [:object_variable, "size"],
439
+ [:object_description, "="],
440
+ [:nil, "nil"],
441
+ [:object_description, " "],
442
+ [:object_variable_prefix, "@"],
443
+ [:object_variable, "feedvalue"],
444
+ [:object_description, "="],
445
+ [:nil, "nil"],
446
+ [:close_object, ">"],
447
+ [:object_description, " "],
448
+ [:object_variable_prefix, "@"],
449
+ [:object_variable, "generator"],
450
+ [:object_description, "="],
451
+ [:nil, "nil"],
452
+ [:object_description, " "],
453
+ [:object_variable_prefix, "@"],
454
+ [:object_variable, "lookahead"],
455
+ [:object_description, "="],
456
+ [:open_array, "["],
457
+ [:close_array, "]"],
458
+ [:object_description, " "],
459
+ [:object_variable_prefix, "@"],
460
+ [:object_variable, "args"],
461
+ [:object_description, "="],
462
+ [:open_array, "["],
463
+ [:close_array, "]"],
464
+ [:object_description, " "],
465
+ [:object_variable_prefix, "@"],
466
+ [:object_variable, "size"],
467
+ [:object_description, "="],
468
+ [:nil, "nil"],
469
+ [:object_description, " "],
470
+ [:object_variable_prefix, "@"],
471
+ [:object_variable, "feedvalue"],
472
+ [:object_description, "="],
473
+ [:nil, "nil"],
474
+ [:close_object, ">"],
475
+ ].sort
476
+ end
477
+
478
+ please do check [2,Set[{1=>2}],4].map
479
+ tokens.sort.should be_like [
480
+ [:open_object, "#<"],
481
+ [:object_class, "Enumerable"],
482
+ [:class_separator, "::"],
483
+ [:object_class, "Enumerator"],
484
+ [:object_description_prefix, ":"],
485
+ [:object_address, /#{OBJECT_ID}/],
486
+ [:object_description, " "],
487
+ [:object_variable_prefix, "@"],
488
+ [:object_variable, "iter"],
489
+ [:object_description, "="],
490
+ [:symbol_prefix, ":"],
491
+ [:symbol, "map"],
492
+ [:object_description, " "],
493
+ [:object_variable_prefix, "@"],
494
+ [:object_variable, "object"],
495
+ [:object_description, "="],
496
+ [:open_array, "["],
497
+ [:number, "2"],
498
+ [:comma, ","],
499
+ [:whitespace, " "],
500
+ [:open_object, "#<"],
501
+ [:object_class, "Set"],
502
+ [:object_description_prefix, ":"],
503
+ [:whitespace, " "],
504
+ [:open_set, "{"],
165
505
  [:open_hash, "{"],
166
506
  [:number, "1"],
167
507
  [:refers, "=>"],
168
508
  [:number, "2"],
169
509
  [:close_hash, "}"],
510
+ [:close_set, "}"],
511
+ [:close_object, ">"],
170
512
  [:comma, ","],
171
513
  [:whitespace, " "],
514
+ [:number, "4"],
515
+ [:close_array, "]"],
516
+ [:object_description, " "],
517
+ [:object_variable_prefix, "@"],
518
+ [:object_variable, "generator"],
519
+ [:object_description, "="],
520
+ [:nil, "nil"],
521
+ [:object_description, " "],
522
+ [:object_variable_prefix, "@"],
523
+ [:object_variable, "lookahead"],
524
+ [:object_description, "="],
525
+ [:open_array, "["],
526
+ [:close_array, "]"],
527
+ [:object_description, " "],
528
+ [:object_variable_prefix, "@"],
529
+ [:object_variable, "args"],
530
+ [:object_description, "="],
531
+ [:open_array, "["],
532
+ [:close_array, "]"],
533
+ [:object_description, " "],
534
+ [:object_variable_prefix, "@"],
535
+ [:object_variable, "size"],
536
+ [:object_description, "="],
537
+ [:nil, "nil"],
538
+ [:object_description, " "],
539
+ [:object_variable_prefix, "@"],
540
+ [:object_variable, "feedvalue"],
541
+ [:object_description, "="],
542
+ [:nil, "nil"],
543
+ [:close_object, ">"],
544
+ ].sort
545
+ end
546
+
547
+ please do check Wirb::Tokenizer.run('[2,3,4]')
548
+ tokens.sort.should be_like [
172
549
  [:open_object, "#<"],
550
+ [:object_class, "Enumerable"],
551
+ [:class_separator, "::"],
173
552
  [:object_class, "Enumerator"],
174
553
  [:object_description_prefix, ":"],
554
+ [:object_address, /#{OBJECT_ID}/],
555
+ [:object_description, " "],
556
+ [:object_variable_prefix, "@"],
557
+ [:object_variable, "iter"],
558
+ [:object_description, "="],
559
+ [:symbol_prefix, ":"],
560
+ [:symbol, "run"],
561
+ [:object_description, " "],
562
+ [:object_variable_prefix, "@"],
563
+ [:object_variable, "object"],
564
+ [:object_description, "="],
565
+ [:class, "Wirb"],
566
+ [:class_separator, "::"],
567
+ [:class, "Tokenizer"],
568
+ [:object_description, " "],
569
+ [:object_variable_prefix, "@"],
570
+ [:object_variable, "generator"],
571
+ [:object_description, "="],
572
+ [:nil, "nil"],
573
+ [:object_description, " "],
574
+ [:object_variable_prefix, "@"],
575
+ [:object_variable, "lookahead"],
576
+ [:object_description, "="],
577
+ [:open_array, "["],
578
+ [:close_array, "]"],
579
+ [:object_description, " "],
580
+ [:object_variable_prefix, "@"],
581
+ [:object_variable, "args"],
582
+ [:object_description, "="],
583
+ [:open_array, "["],
584
+ [:open_string, "\""],
585
+ [:string, "[2,3,4]"],
586
+ [:close_string, "\""],
587
+ [:close_array, "]"],
588
+ [:object_description, " "],
589
+ [:object_variable_prefix, "@"],
590
+ [:object_variable, "size"],
591
+ [:object_description, "="],
592
+ [:nil, "nil"],
593
+ [:object_description, " "],
594
+ [:object_variable_prefix, "@"],
595
+ [:object_variable, "feedvalue"],
596
+ [:object_description, "="],
597
+ [:nil, "nil"],
598
+ [:close_object, ">"],
599
+ ].sort
600
+ end
601
+
602
+ please do check [{1=>2},Wirb::Tokenizer.run('2'),Set[2,3],[3,4],[5,6].each].map
603
+ tokens.sort.should be_like [
604
+ [:open_object, "#<"],
605
+ [:object_class, "Enumerable"],
606
+ [:class_separator, "::"],
607
+ [:object_class, "Enumerator"],
608
+ [:object_description_prefix, ":"],
609
+ [:object_address, /#{OBJECT_ID}/],
610
+ [:object_description, " "],
611
+ [:object_variable_prefix, "@"],
612
+ [:object_variable, "iter"],
613
+ [:object_description, "="],
614
+ [:symbol_prefix, ":"],
615
+ [:symbol, "map"],
616
+ [:object_description, " "],
617
+ [:object_variable_prefix, "@"],
618
+ [:object_variable, "object"],
619
+ [:object_description, "="],
620
+ [:open_array, "["],
621
+ [:open_hash, "{"],
622
+ [:number, "1"],
623
+ [:refers, "=>"],
624
+ [:number, "2"],
625
+ [:close_hash, "}"],
626
+ [:comma, ","],
175
627
  [:whitespace, " "],
628
+ [:open_object, "#<"],
629
+ [:object_class, "Enumerable"],
630
+ [:class_separator, "::"],
631
+ [:object_class, "Enumerator"],
632
+ [:object_description_prefix, ":"],
633
+ [:object_address, /#{OBJECT_ID}/],
634
+ [:object_description, " "],
635
+ [:object_variable_prefix, "@"],
636
+ [:object_variable, "iter"],
637
+ [:object_description, "="],
638
+ [:symbol_prefix, ":"],
639
+ [:symbol, "run"],
640
+ [:object_description, " "],
641
+ [:object_variable_prefix, "@"],
642
+ [:object_variable, "object"],
643
+ [:object_description, "="],
176
644
  [:class, "Wirb"],
177
- [:object_description, ":tokenize("],
645
+ [:class_separator, "::"],
646
+ [:class, "Tokenizer"],
647
+ [:object_description, " "],
648
+ [:object_variable_prefix, "@"],
649
+ [:object_variable, "generator"],
650
+ [:object_description, "="],
651
+ [:nil, "nil"],
652
+ [:object_description, " "],
653
+ [:object_variable_prefix, "@"],
654
+ [:object_variable, "lookahead"],
655
+ [:object_description, "="],
656
+ [:open_array, "["],
657
+ [:close_array, "]"],
658
+ [:object_description, " "],
659
+ [:object_variable_prefix, "@"],
660
+ [:object_variable, "args"],
661
+ [:object_description, "="],
662
+ [:open_array, "["],
178
663
  [:open_string, "\""],
179
664
  [:string, "2"],
180
665
  [:close_string, "\""],
181
- [:object_description, ")"],
666
+ [:close_array, "]"],
667
+ [:object_description, " "],
668
+ [:object_variable_prefix, "@"],
669
+ [:object_variable, "size"],
670
+ [:object_description, "="],
671
+ [:nil, "nil"],
672
+ [:object_description, " "],
673
+ [:object_variable_prefix, "@"],
674
+ [:object_variable, "feedvalue"],
675
+ [:object_description, "="],
676
+ [:nil, "nil"],
182
677
  [:close_object, ">"],
183
678
  [:comma, ","],
184
679
  [:whitespace, " "],
@@ -204,37 +699,85 @@ describe tokenizer(__FILE__) do
204
699
  [:comma, ","],
205
700
  [:whitespace, " "],
206
701
  [:open_object, "#<"],
702
+ [:object_class, "Enumerable"],
703
+ [:class_separator, "::"],
207
704
  [:object_class, "Enumerator"],
208
705
  [:object_description_prefix, ":"],
209
- [:whitespace, " "],
706
+ [:object_address, /#{OBJECT_ID}/],
707
+ [:object_description, " "],
708
+ [:object_variable_prefix, "@"],
709
+ [:object_variable, "iter"],
710
+ [:object_description, "="],
711
+ [:symbol_prefix, ":"],
712
+ [:symbol, "each"],
713
+ [:object_description, " "],
714
+ [:object_variable_prefix, "@"],
715
+ [:object_variable, "object"],
716
+ [:object_description, "="],
210
717
  [:open_array, "["],
211
718
  [:number, "5"],
212
719
  [:comma, ","],
213
720
  [:whitespace, " "],
214
721
  [:number, "6"],
215
722
  [:close_array, "]"],
216
- [:object_description, ":each"],
723
+ [:object_description, " "],
724
+ [:object_variable_prefix, "@"],
725
+ [:object_variable, "generator"],
726
+ [:object_description, "="],
727
+ [:nil, "nil"],
728
+ [:object_description, " "],
729
+ [:object_variable_prefix, "@"],
730
+ [:object_variable, "lookahead"],
731
+ [:object_description, "="],
732
+ [:open_array, "["],
733
+ [:close_array, "]"],
734
+ [:object_description, " "],
735
+ [:object_variable_prefix, "@"],
736
+ [:object_variable, "args"],
737
+ [:object_description, "="],
738
+ [:open_array, "["],
739
+ [:close_array, "]"],
740
+ [:object_description, " "],
741
+ [:object_variable_prefix, "@"],
742
+ [:object_variable, "size"],
743
+ [:object_description, "="],
744
+ [:nil, "nil"],
745
+ [:object_description, " "],
746
+ [:object_variable_prefix, "@"],
747
+ [:object_variable, "feedvalue"],
748
+ [:object_description, "="],
749
+ [:nil, "nil"],
217
750
  [:close_object, ">"],
218
751
  [:close_array, "]"],
219
- [:object_description, ":map"],
752
+ [:object_description, " "],
753
+ [:object_variable_prefix, "@"],
754
+ [:object_variable, "generator"],
755
+ [:object_description, "="],
756
+ [:nil, "nil"],
757
+ [:object_description, " "],
758
+ [:object_variable_prefix, "@"],
759
+ [:object_variable, "lookahead"],
760
+ [:object_description, "="],
761
+ [:open_array, "["],
762
+ [:close_array, "]"],
763
+ [:object_description, " "],
764
+ [:object_variable_prefix, "@"],
765
+ [:object_variable, "args"],
766
+ [:object_description, "="],
767
+ [:open_array, "["],
768
+ [:close_array, "]"],
769
+ [:object_description, " "],
770
+ [:object_variable_prefix, "@"],
771
+ [:object_variable, "size"],
772
+ [:object_description, "="],
773
+ [:nil, "nil"],
774
+ [:object_description, " "],
775
+ [:object_variable_prefix, "@"],
776
+ [:object_variable, "feedvalue"],
777
+ [:object_description, "="],
778
+ [:nil, "nil"],
220
779
  [:close_object, ">"],
221
- ]
222
- end
223
- end
224
-
225
- only18 do
226
- if !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby' # TODO tests for jruby + rbx
227
- please do check [3,4,5].each
228
- tokens.should be_like [
229
- [:open_object, "#<"],
230
- [:object_class, "Enumerable"],
231
- [:class_separator, "::"],
232
- [:object_class, "Enumerator"],
233
- [:object_description_prefix, ":"],
234
- [:object_address, /#{OBJECT_ID}/],
235
- [:close_object, ">"],
236
- ]
237
- end
780
+ ].sort
238
781
  end
239
782
  end
240
783
  end