rubylexer 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
data/testdata/pre.rb ADDED
@@ -0,0 +1,33 @@
1
+ eval \
2
+ eval(\
3
+ #puts(\
4
+ #!if defined?(class ENV::FRIENDLY; end)
5
+ %{$_ =
6
+ %%%
7
+ #{(
8
+ (*
9
+ )=*$<
10
+ ).map {|$_|
11
+ ~%r ^#! messiness? sub( %r #{
12
+ %.^...% (.+) }{1} nonsense, <<' >>'.
13
+ \1
14
+ >>
15
+ delete( %%% <<'>>
16
+ ):'
17
+ ) ) : ( (
18
+ [ [ # ] ]
19
+ #breakpoint
20
+ sub( %r
21
+ ^ #{ %q
22
+ (
23
+ .. % *\\s*
24
+ } $)
25
+ xenon) { @_ = $1.inspect
26
+ %( $_ << #@_ << %####@_
27
+ )} ]
28
+ ][ 0 ])
29
+ )}}
30
+ $_})
31
+ __END__
32
+ #!end
33
+ %(%(puts %(Executing Ruby code...))))
@@ -0,0 +1,33 @@
1
+ eval \
2
+ eval(\
3
+ #puts(\
4
+ #!if defined?(class ENV::FRIENDLY; end)
5
+ %{$_ =
6
+ %%%
7
+ #{(
8
+ (*
9
+ )=*$<
10
+ ).map {|$_|
11
+ ~%r ^#! messiness? sub( %r #{
12
+ %.^...% (.+) }{1} nonsense, <<' >>'.
13
+ \1
14
+ >>
15
+ delete( %%% <<'>>
16
+ ):'
17
+ ) ) : ( (
18
+ [ [ # ] ]
19
+ #breakpoint
20
+ sub( %r
21
+ ^ #{ %q
22
+ (
23
+ .. % *\\s*
24
+ } $)
25
+ xenon) { @_ = $1.inspect
26
+ %( $_ << #@_ << %####@_
27
+ )} ]
28
+ ][ 0 ])
29
+ )}}
30
+ $_})
31
+ __END__
32
+ #!end
33
+ %(%(puts %(Executing Ruby code...))))
@@ -0,0 +1,621 @@
1
+ #!/usr/bin/ruby -w -d
2
+ require "reg"
3
+ require "regarray"
4
+ require "reglogic"
5
+ require "reghash"
6
+ require "regvar"
7
+ require "assert"
8
+ require 'getoptlong'
9
+
10
+ #require 'test/unit'
11
+ class TC_Reg #< Test::Unit::TestCase
12
+ class <<self
13
+
14
+
15
+ def randsym
16
+ as=Symbol.all_symbols
17
+ as[rand as.size]
18
+ end
19
+
20
+ def makelendata(num=20,mask=0b11111111111,mischief=false)
21
+ result=[]
22
+ (1..num).each do
23
+ begin type=rand(11) end until 0 != mask&(1<<type)
24
+ len=type==0 ? 0 : rand(4)
25
+
26
+ result<<case type
27
+ when 0 then [0]
28
+ when 1 then [len]+(1..len).map{randsym}
29
+ when 2 then (1..len).map{randsym}+[-len]
30
+ when 3 then (1..len).map{randsym}+["infix#{len}"]+(1..len).map{randsym}
31
+ when 4
32
+ [:Q] +
33
+ (1..len).map{randsym}.delete_if {|x|:Q==x} +
34
+ (1..rand(4)).map{randsym}.delete_if {|x|:Q==x} +
35
+ [:Q]
36
+ when 5
37
+ [:Q] +
38
+ (1..len).map{randsym}.delete_if {|x|:Q==x} +
39
+ [:'\\', :Q] +
40
+ (1..rand(4)).map{randsym}.delete_if {|x|:Q==x} +
41
+ [:Q]
42
+
43
+ when 6
44
+ [:q]+(1..len).map{randsym}.delete_if {|x|:q==x}+[:q]
45
+
46
+ when 7
47
+ [:begin]+
48
+ (1..len).map{randsym}.delete_if {|x| :begin==x or :end==x} +
49
+ (1..rand(4)).map{randsym}.delete_if {|x| :begin==x or :end==x} +
50
+ [:end]
51
+
52
+ when 8
53
+ [:begin]+
54
+ (1..len).map{randsym}.delete_if {|x| :begin==x or :end==x} +
55
+ [:'\\', 0==rand(1) ? :begin : :end] +
56
+ (1..rand(4)).map{randsym}.delete_if {|x| :begin==x or :end==x} +
57
+ [:end]
58
+
59
+ when 9
60
+ [:begin]+
61
+ (1..len).map{randsym}.delete_if {|x| :begin==x or :end==x} +
62
+ [:begin]+(1..len).map{randsym}.delete_if {|x| :begin==x or :end==x} +[:end]+
63
+ (1..rand(4)).map{randsym}.delete_if {|x| :begin==x or :end==x} +
64
+ [:end]
65
+
66
+ when 10
67
+ [:begin]+
68
+ (1..len).map{randsym}.delete_if {|x| :begin==x or :end==x} +
69
+ [:'\\', 0==rand(1)? :begin : :end] +
70
+ (1..rand(4)).map{randsym}.delete_if {|x| :begin==x or :end==x} +
71
+ [:begin]+(1..len).map{randsym}.delete_if {|x| :begin==x or :end==x} +[:end]+
72
+ (1..rand(4)).map{randsym}.delete_if {|x| :begin==x or :end==x} +
73
+ [:end]
74
+ end
75
+ end
76
+ mischief and result.insert(rand(result.size),mischief)
77
+ return result
78
+ end
79
+
80
+
81
+ def test_reg
82
+ lenheadalts=-[0]|-[1,OB]|-[2,OB*2]|-[3,OB*3]|-[4,OB*4]
83
+ lenheadlist=lenheadalts+1
84
+
85
+ lenheaddata=[0,0,0,1,:foo,4,:foo,:bar,:baz,:zork,3,:k,77,88]
86
+ lenheaddataj=lenheaddata+[:j]
87
+
88
+
89
+ #not used yet:
90
+ lentailalts=-[OB,-1]|-[OB*2,-2]|-[OB*3,-3]|-[OB*4,-4]
91
+ lentaildata=lenheaddata.reverse.map {|x| Integer===x ? -x : x }
92
+ infixalts=-[OB,"infix1",OB]|-[OB*2,'infix2',OB*2]|
93
+ -[OB*3,'infix3',OB*3]|-[OB*4,'infix4',OB*4]
94
+
95
+
96
+ qq=-[:q, ~(:q.reg)+0, :q]
97
+ _QQ=-[:Q, ( ~/^[Q\\]$/.sym | -[:'\\',OB] )+0, :Q]
98
+
99
+
100
+ be=-[:begin, (
101
+ ~/^(begin|end|\\)$/.sym |
102
+ -[:'\\',OB] |
103
+ innerbe=Reg.const
104
+ )+0, :end]
105
+ innerbe.set! be
106
+
107
+ lh_or_qq=lenheadalts|qq|_QQ
108
+ lhqqbe=lh_or_qq|be
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+ #broken:
118
+ #eat_unworking=<<'#end unworking'
119
+ a=[:foo]*4
120
+ x=(OB*2*(1..2)).mmatch(a,2)
121
+ assert x.next_match(a,2)==[[[[:foo, :foo]]], 2]
122
+ assert x.next_match(a,2)==nil
123
+
124
+ assert_eee OB*(1..2)*2,[:foo]*2
125
+
126
+ a=[:foo]*3
127
+ x=(OB*(1..2)*2).mmatch(a,0)
128
+ assert x.next_match(a,0)==
129
+ [[ [[:foo, :foo]], [[:foo]] ], 3]
130
+ assert x.next_match(a,0)==
131
+ [[ [[:foo]], [[:foo, :foo]] ], 3]
132
+ assert x.next_match(a,0)==
133
+ [[ [[:foo]], [[:foo]] ], 2]
134
+ assert x.next_match(a,0).nil?
135
+
136
+ a=[:foo]*6
137
+ x=(OB*2*(1..2)*2).mmatch(a,0)
138
+ assert x.next_match(a,0)==
139
+ [[ [[[:foo, :foo]], [[:foo, :foo]]], [[[:foo, :foo]]] ], 6]
140
+ assert x.next_match(a,0)==
141
+ [[ [[[:foo, :foo]]], [[[:foo, :foo]], [[:foo, :foo]]] ], 6]
142
+ assert x.next_match(a,0)==
143
+ [[ [[[:foo, :foo]]], [[[:foo, :foo]]] ], 4]
144
+ assert x.next_match(a,0).nil?
145
+
146
+ $RegTraceEnable=true
147
+ assert_eee Reg[OB*2*(1..2)*2], [:foo]*6
148
+ assert_eee Reg[OB*2*(1..2)*2, OB-1], [:foo]*7
149
+ assert_eee Reg[OB*2*(1..2)*2], [:foo]*8
150
+ assert_eee Reg[OB*2*(1..2)*2], [:foo]*4
151
+ assert_eee Reg[OB*(2..3)*(1..2)*2], [:foo]*4
152
+ assert_eee Reg[OB*(2..3)*(2..3)*(1..2)], [:foo]*4
153
+ assert_eee Reg[OB*(2..2)*(2..3)*(2..3)], [:foo]*8
154
+ assert_eee Reg[OB*(2..3)*(2..2)*(2..3)], [:foo]*8
155
+
156
+ assert_eee Reg[OB*(2..3)*(2..3)*2], [:foo]*8
157
+ assert_eee Reg[OB*(2..3)*(2..3)*(2..3)], [:foo]*8
158
+ assert_eee Reg[OB+2+2+2], [:foo]*8
159
+ assert_eee Reg[OB+2+2+2], [:foo]*9
160
+ assert_ene Reg[:foo.reg*(2..3)*(2..3)*2], [:foo]*7
161
+
162
+ assert(!(Reg[OB*1*(1..2)]===[:f]).first.empty?)
163
+ #btracing monsters
164
+ 0.upto(5) {|i|
165
+ assert_ene Reg[OB+1+3+2], [:f]*i }
166
+ 6.upto(16){|i| assert_eee Reg[OB+1+3+2], [:f]*i }
167
+
168
+ assert_ene Reg[OB+2+3+2], [:f]*11
169
+ assert_eee Reg[OB+2+3+2], [:f]*12
170
+ assert_ene Reg[OB+2+3+3], [:f]*17
171
+ assert_eee Reg[OB+2+3+3], [:f]*18
172
+ assert_ene Reg[OB+3+3+3], [:f]*26
173
+ assert_eee Reg[OB+3+3+3], [:f]*27
174
+ assert_ene Reg[OB+4+4+4], [:f]*63
175
+ assert_eee Reg[OB+4+4+4], [:f]*64
176
+ assert_ene Reg[OB+2+2+2+2], [:f]*15
177
+ assert_eee Reg[OB+2+2+2+2], [:f]*16
178
+ assert_ene Reg[OB+2+2+2+2+2+2+2+2], [:foo]*255
179
+ assert_eee Reg[OB+2+2+2+2+2+2+2+2], [:foo]*256
180
+
181
+ aaa_patho=+[-[/^a/]|-[/^.a/, OB]|-[/^..a/, OB*2]]
182
+ assert_eee aaa_patho, ["aaa"]*200
183
+
184
+
185
+
186
+ assert_ene Reg[OB+1+2+2], [:f]*3
187
+ assert_ene Reg[OB+2+1+2], [:f]*3
188
+ assert_eee Reg[OB+2+1+2], [:f]*4
189
+ assert_ene Reg[OB+2+2+2], [:f]*7
190
+ assert_eee Reg[OB+2+2+2], [:f]*8
191
+
192
+ assert_ene Reg[OB+2+2+3], [:f]*11
193
+ assert_eee Reg[OB+2+2+3], [:f]*12
194
+ assert_eee Reg[OB+2+2+3], [:f]*16
195
+
196
+ assert_ene Reg[5.reg+1+3+2], [6]+[5]*5
197
+ assert_ene Reg[5.reg+1+3+2], [5]+[6]+[5]*4
198
+ assert_ene Reg[5.reg+1+3+2], [5]*2+[6]+[5]*3
199
+ assert_ene Reg[5.reg+1+3+2], [5]*3+[6]+[5]*2
200
+ assert_ene Reg[5.reg+1+3+2], [5]*4+[6,5]
201
+ assert_ene Reg[5.reg+1+3+2], [5]*5+[6]
202
+
203
+ assert_ene Reg[OB+1+3+2], [6]+[5]*5
204
+ assert_ene Reg[OB+1+3+2], [5]+[6]+[5]*4
205
+ assert_ene Reg[OB+1+3+2], [5]*2+[6]+[5]*3
206
+ assert_ene Reg[OB+1+3+2], [5]*3+[6]+[5]*2
207
+ assert_ene Reg[OB+1+3+2], [5]*4+[6,5]
208
+ assert_ene Reg[OB+1+3+2], [5]*5+[6]
209
+
210
+
211
+ assert_eee Reg[5.reg+1+3+2], [5]*6
212
+ assert_ene Reg[5.reg+2+2+2], [5]*8+[6]
213
+ #end unworking
214
+
215
+ #working:
216
+ assert_ene Reg[OB*(2..2)*(2..3)*(2..3)], [:foo]*7
217
+ assert_ene Reg[OB*(2..3)*(2..2)*(2..3)], [:foo]*7
218
+ assert_ene Reg[OB*(1..3)*(2..3)*2], [:foo]*3
219
+ assert_ene Reg[OB*(2..3)*(1..3)*2], [:foo]*3
220
+ assert_ene Reg[OB*(2..3)*(2..3)*(1..2)], [:foo]*3
221
+
222
+ assert_ene Reg[OB*(2..3)*(2..3)*2], [:foo]*7
223
+ assert_ene Reg[OB*(2..3)*(2..3)*(2..3)], [:foo]*7
224
+ assert_ene Reg[OB+2+2+2], [:foo]*7
225
+
226
+
227
+ assert_eee Reg[OB*(1..3)*(2..3)*2], [:foo]*4
228
+ assert_eee Reg[OB*2*1*2], [:foo]*4
229
+ assert_eee Reg[OB*1*(1..2)*2], [:foo]*2
230
+ assert_eee Reg[OB*2*(1..2)*1], [:foo]*2
231
+ assert_eee Reg[OB*1*(1..2)*2], [:foo]*3
232
+ assert_ene Reg[OB*2*(1..2)*1], [:foo]*3
233
+ assert_eee Reg[OB*1*(1..2)*2], [:foo]*4
234
+ assert_eee Reg[OB*2*(1..2)*1], [:foo]*4
235
+
236
+ a=[:foo]
237
+ x=(:foo.reg-1).mmatch a,0
238
+ assert x.next_match(a,0)==[[[:foo]],1]
239
+ assert x.next_match(a,0)==[[[]],0]
240
+ assert x.next_match(a,0)==nil
241
+
242
+ x=(:foo.reg-1).mmatch a,1
243
+ assert x==[[[]],0]
244
+
245
+ a=[:foo]
246
+ x=(:foo.reg-1-1).mmatch a,0
247
+ assert x.next_match(a,0)==[[[[:foo]]],1]
248
+
249
+
250
+
251
+ a=[:foo]*3
252
+ x=(:foo.reg*(1..2)).mmatch a,0
253
+ assert x.next_match(a,0)==[[[:foo]*2],2]
254
+ assert x.next_match(a,0)==[[[:foo]],1]
255
+ assert x.next_match(a,0)==nil
256
+
257
+ x=(:foo.reg*(1..2)).mmatch a,1
258
+ assert x.next_match(a,0)==[[[:foo]*2],2]
259
+ assert x.next_match(a,0)==[[[:foo]],1]
260
+ assert x.next_match(a,0)==nil
261
+
262
+ x=(:foo.reg*(1..2)).mmatch a,2
263
+ assert x==[[[:foo]],1]
264
+
265
+ x=(:foo.reg*(1..2)).mmatch a,3
266
+ assert x.nil?
267
+
268
+ x=(:foo.reg*(1..2)*(2..3)).mmatch a,0
269
+ assert x.next_match(a,0)==[[[[:foo]*2],[[:foo]]], 3]
270
+ assert x.instance_eval{@ri}==2
271
+ assert x.next_match(a,0)==[[[[:foo]],[[:foo]*2]], 3]
272
+ assert x.instance_eval{@ri}==2
273
+ assert x.next_match(a,0)==[[[[:foo]],[[:foo]],[[:foo]]], 3]
274
+ assert x.instance_eval{@ri}==3
275
+ assert x.next_match(a,0)==[[[[:foo]],[[:foo]]], 2]
276
+ assert x.instance_eval{@ri}==2
277
+ assert x.next_match(a,0)==nil
278
+
279
+ x=(:foo.reg*(1..2)*(2..3)).mmatch a,1
280
+ assert x.next_match(a,0)==[[[[:foo]],[[:foo]]], 2]
281
+ assert x.instance_eval{@ri}==2
282
+ assert x.next_match(a,0)==nil
283
+
284
+ x=(:foo.reg*(1..2)*(2..3)).mmatch a,2
285
+ assert x.nil?
286
+
287
+ x=(:foo.reg*(1..2)*(2..3)).mmatch a,3
288
+ assert x.nil?
289
+
290
+
291
+ assert((not (:foo.reg*(1..2)*(2..3)*(2..3)).mmatch [:foo]*3,0 ))
292
+
293
+
294
+
295
+ assert_ene Reg[:foo.reg*(1..2)*(2..3)*(2..3)], [:foo]*3
296
+ assert_eee Reg[:foo.reg*(1..2)*(2..3)*(2..3)], [:foo]*4
297
+ assert_ene Reg[OB*(1..2)*(2..3)*(2..3)], [:foo]*3
298
+ assert_eee Reg[OB*(1..2)*(2..3)*(2..3)], [:foo]*4
299
+ assert_ene Reg[OB*(1..2)*(2..3)+2], [:foo]*3
300
+ assert_eee Reg[OB*(1..2)*(2..3)+2], [:foo]*4
301
+ assert_ene Reg[OB*(1..2)+2+2], [:foo]*3
302
+ assert_eee Reg[OB*(1..2)+2+2], [:foo]*4
303
+ assert_ene Reg[OB+1+2+2], [:foo]*3
304
+ assert_eee Reg[OB+1+2+2], [:foo]*4
305
+
306
+ assert_eee Reg[5.reg+2+2], [5]*4
307
+ assert_eee Reg[5.reg*(1..2)*(1..2)*(1..2)], [5]
308
+ assert_eee Reg[5.reg*(1..2)*(1..2)*(2..3)], [5]*2
309
+ assert_eee Reg[5.reg*(1..2)*(2..3)*(2..3)], [5]*4
310
+ assert_eee Reg[(5.reg+1)*(2..3)*(2..3)], [5]*4
311
+ assert_eee Reg[(5.reg+1+2)*(2..3)], [5]*4
312
+ assert_eee Reg[5.reg+1+2+2], [5]*4
313
+ assert_eee Reg[OB+3+2], [:f]*6
314
+
315
+ assert_ene Reg[-[:foo,:bar]-1], [:bar,:foo]
316
+ assert_ene Reg[-[:foo,:bar]-1], [:baz,:foo,:bar]
317
+ assert_ene Reg[-[:foo,:bar]-1], [:foo,:bar,:baz]
318
+ assert_eee Reg[-[:foo,:bar]-1], [:foo,:bar]
319
+ assert_ene Reg[-[:foo,:bar]-1], [:foo]
320
+ assert_ene Reg[-[:foo,:bar]-1], [:bar]
321
+ assert_ene Reg[-[:foo,:bar]-1], [:baz]
322
+ assert_eee Reg[-[:foo,:bar]-1], []
323
+
324
+
325
+
326
+
327
+ assert_eee Reg[(-[-[:p]*(1..2)])], [:p]
328
+ assert_eee Reg[(-[-[:p]*(1..2)])], [:p,:p]
329
+ assert_ene Reg[(-[-[:p]*(1..2)])], [:p,:q]
330
+ assert_ene Reg[(-[-[:p]*(1..2)])], [:q]
331
+ assert_ene Reg[(-[-[:p]*(1..2)])], []
332
+ assert_ene Reg[(-[-[:p]*(1..2)])], [:p,:p, :p]
333
+
334
+
335
+ assert_eee Reg[OB+1], [:foo,:foo]
336
+ assert_eee Reg[OB+1+1], [:foo,:foo]
337
+ assert_eee Reg[OB+1+1+1], [:foo,:foo]
338
+ assert_eee Reg[OB+1+1+1+1], [:foo,:foo]
339
+
340
+ assert_ene Reg[OB+2+3], [:f]*5
341
+ assert_ene Reg[OB+2+2+1], [:f]*3
342
+
343
+ assert_eee Reg[lhqqbe+0], [
344
+ :begin, :popen, :"chomp!", :-@, :end, :q, :q,
345
+ :begin, :begin, :end, :end,
346
+ :begin, :MINOR_VERSION, :"public_method_defined?", :"\\", :begin, :umask,
347
+ :debug_print_help, :geteuid, :end,
348
+ :q, :public_methods, :option_name, :MUTEX, :q,
349
+ :begin, :verbose=, :binding, :symlink, :lambda,
350
+ :emacs_editing_mode, :"dst?", :end, 0,
351
+ :begin, :test_to_s_with_iv, :"\\", :begin, :glob, :each_with_index,
352
+ :initialize_copy, :begin, :$PROGRAM_NAME, :end,
353
+ :ELIBACC, :setruid, :"success?", :end,
354
+ :begin, :__size__, :width, :"\\", :begin, :$-a, :"sort!", :waitpid, :end,
355
+ :begin, :Stat, :WadlerExample, :chr, :end,
356
+ :begin, :+, :disable, :abstract,
357
+ :begin, :__size__, :"symlink?", :"dst?", :end, :ljust, :end,
358
+ :begin, :debug_method_info, :matchary, :"\\", :begin, :ftype,
359
+ :thread_list_all, :eof, :begin, :abs, :GroupQueue, :end,
360
+ :"slice!", :ordering=, :end,
361
+ :Q, :"\\", :Q, :ELIBMAX, :GetoptLong, :nlink, :Q,
362
+ :begin, :Fixnum, :waitall, :"enclosed?", :"\\", :begin, :deep_copy,
363
+ :getpgid, :strftime, :end,
364
+ :Q, :close_obj, :Q,
365
+ 3, :basic_quote_characters=, :rmdir, :"writable_real?",
366
+ :begin, :test_hello_11_12, :utc_offset, :freeze,
367
+ :begin, :kcode, :egid=, :ARGF, :end,
368
+ :setuid, :lock, :gmtoff, :end,
369
+ :begin, :$FILENAME, :test_tree_alt_20_49,
370
+ :begin, :LOCK_SH, :EL3HLT, :end, :end,
371
+ :Q, :"\\", :Q, :ceil, :remainder, :group_sub, :Q, 0
372
+ ]
373
+
374
+ if ($Slow||=nil)
375
+ #assert_eee Reg[OB+10+10], [:f]*100 #waaaay too slow
376
+ assert_eee Reg[OB+5+5], [:f]*25
377
+ assert_ene Reg[OB+5+5], [:f]*24
378
+ assert_eee Reg[OB+6+6], [:f]*36
379
+ assert_ene Reg[OB+6+6], [:f]*35
380
+ assert_eee Reg[OB+7+7], [:f]*49 #prolly excessive
381
+ assert_ene Reg[OB+7+7], [:f]*48 #prolly excessive
382
+ end
383
+
384
+ assert_eee Reg[lhqqbe+0], [ :begin, :"\\", :rand, :end ]
385
+ #breakpoint
386
+ assert_eee +[be], [:begin, :"\\", :"\\", :end]
387
+ assert_eee +[be], [:begin, :"\\", :begin, :end]
388
+ assert_eee +[be], [:begin, :"\\", :end, :end]
389
+ assert_eee +[be], [:begin, :log, :readline, :"\\", :begin, :lh_or_qq, :test_pretty_print_inspect, :@newline, :end]
390
+ assert_eee +[be], [:begin, :lock, :rindex, :begin, :sysopen, :rename, :end, :re_exchange, :on, :end]
391
+ assert_eee +[be], [:begin, :lock, :"\\", :"\\", :begin, :rename, :end, :on, :end]
392
+ assert_eee +[be], [:begin, :begin, :foo, :end, :end]
393
+ assert_eee +[be], makelendata(1,0b11110000000).flatten
394
+ assert_eee +[be], [:begin, :end]
395
+ assert_eee +[be], [:begin, :foo, :end]
396
+ assert_eee +[be], makelendata(1,0b10000000).flatten
397
+ assert_eee Reg[lhqqbe+0], makelendata(1,0b11111110011).flatten
398
+ assert_eee Reg[lhqqbe+0], makelendata(4,0b11111110011).flatten
399
+ assert_eee Reg[lhqqbe+0], makelendata(10,0b11111110011).flatten
400
+ assert_eee Reg[lhqqbe+0], makelendata(20,0b11111110011).flatten
401
+
402
+ assert_ene Reg[:foo,OB+1], [:foo]
403
+ assert_ene Reg[OB+1,:foo], [:foo]
404
+ assert_eee Reg[OB+1], [:foo]
405
+
406
+
407
+ assert_eee Reg[OB+1+1+1+1+1+1+1+1+1+1+1+1+1+1], [:foo]
408
+
409
+ assert_ene Reg[OB+1+1+1+1], []
410
+ assert_eee Reg[OB+1+1+1+1], [:foo,:foo]
411
+ assert_ene Reg[OB+2], [:foo]
412
+ assert_ene Reg[OB+2+2], [:foo]*3
413
+ assert_ene Reg[OB+2+2+1], [:foo]*3
414
+ assert_ene Reg[OB+2+1+2], [:foo]*3
415
+
416
+
417
+ assert_eee Reg[-[1,2]|3], [1,2]
418
+ assert_eee Reg[-[1,2]|3], [3]
419
+ assert_ene Reg[-[1,2]|3], [4]
420
+ assert_ene Reg[-[1,2]|3], [2]
421
+ assert_ene Reg[-[1,2]|3], [1,3]
422
+
423
+ assert_eee Reg[lenheadlist], [1, :__id__]
424
+ assert_eee Reg[(-[0]|-[1,OB]|-[2,OB*2])*1], [2, :p, :stat]
425
+ assert_eee Reg[(-[2,OB*2])-1], [2, :p, :stat]
426
+ assert_eee Reg[(-[OB])*(1..2)], [1, :p]
427
+
428
+ assert_eee Reg[(-[-[:p]*(1..2)])], [:p]
429
+ assert_eee Reg[(-[-[:p]])*(1..2)], [:p]
430
+ assert_eee Reg[(-[-[OB]])*(1..2)], [:p]
431
+ assert_eee Reg[(-[OB*1])*(1..2)], [:p]
432
+ assert_eee Reg[(-[1,OB*1])*(1..2)], [1, :p]
433
+ assert_eee Reg[(-[2,OB*2])*(1..2)], [2, :p, :stat]
434
+ assert_eee Reg[(-[0]|-[1,OB]|-[2,OB*2])*(1..2)], [2, :p, :stat]
435
+ assert_eee Reg[(-[0]|-[1,OB]|-[2,OB*2])+1], [2, :p, :stat]
436
+ assert_eee Reg[lenheadlist], [2, :p, :stat]
437
+ assert_eee Reg[lenheadlist], [2, :p, :stat, 1, :__id__]
438
+ assert_eee Reg[lenheadlist], [2, :p, :stat, 0, 1, :__id__, 0, 0]
439
+ assert_eee Reg[lenheadlist], lenheaddata
440
+ assert_ene Reg[lenheadlist], lenheaddataj
441
+ assert_eee +[lh_or_qq+0], lenheaddata
442
+ assert_eee +[lh_or_qq+0], lenheaddata+[:q, :foo, :bar, :baz, :q]
443
+
444
+ assert_eee Reg[lenheadlist], [0]
445
+ assert_eee Reg[lenheadlist], makelendata(1,0b11).flatten
446
+ assert_eee Reg[lenheadlist], makelendata(5,0b11).flatten
447
+ assert_eee Reg[lenheadlist], makelendata(10,0b11).flatten
448
+ assert_eee Reg[lenheadlist], makelendata(20,0b11).flatten
449
+ assert_ene Reg[lenheadlist], makelendata(20,0b11).flatten+[:j]
450
+ assert_ene Reg[lenheadlist], [:j]+makelendata(20,0b11).flatten+[:j]
451
+ assert_ene Reg[lenheadlist], [:j]+makelendata(20,0b11).flatten
452
+
453
+ assert_ene Reg[lenheadlist], makelendata(20,0b11,:j).flatten
454
+ assert_eee +[lh_or_qq+0], makelendata(20,0b11).flatten
455
+ assert_eee +[lh_or_qq+0], makelendata(20,0b1000011).flatten
456
+ assert_ene +[lh_or_qq+0], makelendata(20,0b1000011).flatten+[:j]
457
+ assert_ene +[lh_or_qq+0], [:j]+makelendata(20,0b1000011).flatten+[:j]
458
+ assert_ene +[lh_or_qq+0], [:j]+makelendata(20,0b1000011).flatten
459
+
460
+
461
+
462
+ t=(1..2)
463
+ assert_eee Reg[OB*t*t*t*t], [:foo]*16
464
+ assert_ene Reg[OB*t*t*t*t], [:foo]*17
465
+ assert_eee Reg[5.reg*t], [5]
466
+ assert_eee Reg[5.reg*t*1], [5]
467
+ assert_eee Reg[5.reg*1*t], [5]
468
+ assert_eee Reg[5.reg*t*t], [5]
469
+ assert_eee Reg[5.reg*t*t*t], [5]
470
+ assert_eee Reg[5.reg*t*t*t*t], [5]
471
+ assert_eee Reg[5.reg+1+1+1], [5]
472
+ assert_eee Reg[5.reg+1+1+1+1], [5]
473
+ assert_eee Reg[OB+1+1+1], [:foo]
474
+ assert_eee Reg[OB+1+1+1+1], [:foo]
475
+ assert_eee Reg[OB+2], [:foo]*2
476
+ assert_eee Reg[OB+2+2], [:foo]*4
477
+
478
+
479
+
480
+ #btracing monsters:
481
+ assert_eee Reg[OB*2], [:foo]*2
482
+ assert_eee Reg[OB*2*2], [:foo]*4
483
+ assert_eee Reg[OB*2*2*2*2], [:foo]*16
484
+ assert_eee Reg[OB*2*2*2*2*2*2*2*2], [:foo]*256
485
+ assert_eee Reg[OB-2-2-2-2-2-2-2-2], [:foo]*256
486
+
487
+
488
+
489
+ assert_ene Reg[OB-0], [1]
490
+ assert_eee Reg[OB+0], [1]
491
+ assert_eee Reg[OB-1], [1]
492
+ assert_eee Reg[OB+1], [1]
493
+ assert_eee Reg[OB-2], [1,2]
494
+ assert_eee Reg[OB+2], [1,2]
495
+
496
+ assert_eee Reg[OB], [1]
497
+ assert_eee Reg[OB*1], [1]
498
+ assert_eee Reg[OB*2], [1,2]
499
+ assert_eee Reg[OB*4], [1,2,3,4]
500
+
501
+ abcreg=Reg[OBS,:a,:b,:c,OBS]
502
+ assert_eee abcreg, [:a,:b,:c,7,8,9]
503
+ assert_eee abcreg, [1,2,3,:a,:b,:c,7,8,9]
504
+
505
+ assert_eee abcreg, [1,2,3,:a,:b,:c]
506
+ assert_eee abcreg, [:a,:b,:c]
507
+
508
+ assert_ene abcreg, [1,2,3,:a,:b,:d]
509
+ assert_ene abcreg, [1,2,3,:a,:d,:c]
510
+ assert_ene abcreg, [1,2,3,:d,:b,:c]
511
+
512
+ assert_ene abcreg, [1,2,3]
513
+ assert_ene abcreg, [1,2,3,:a]
514
+ assert_ene abcreg, [1,2,3,:a,:b]
515
+
516
+ assert_eee Reg[:a, OB+0, :b, :b, :b, :b, :b], [:a, 1,1,1,1,1,1, :b, :b, :b, :b, :b]
517
+ assert_eee Reg[:a, OB+0, :b, :b, :b, :b, :b], [:a, 1, :b, :b, :b, :b, :b]
518
+ assert_eee Reg[:a, OB+0, :b, :b, :b, :b, :b], [:a, :b, :b, :b, :b, :b]
519
+
520
+ assert_eee Reg[:a, OB+1, :b, :b, :b, :b, :b], [:a, 1,1,1,1,1,1, :b, :b, :b, :b, :b]
521
+ assert_eee Reg[:a, OB+1, :b, :b, :b, :b, :b], [:a, 1, :b, :b, :b, :b, :b]
522
+ assert_ene Reg[:a, OB+1, :b, :b, :b, :b, :b], [:a, :b, :b, :b, :b, :b]
523
+
524
+ assert_ene Reg[:a, OB-1, :b, :b, :b, :b, :b], [:a, 1,1,1,1,1,1, :b, :b, :b, :b, :b]
525
+ assert_eee Reg[:a, OB-1, :b, :b, :b, :b, :b], [:a, 1, :b, :b, :b, :b, :b]
526
+ assert_eee Reg[:a, OB-1, :b, :b, :b, :b, :b], [:a, :b, :b, :b, :b, :b]
527
+
528
+ assert_ene Reg[:a, OB-0, :b, :b, :b, :b, :b], [:a, 1,1,1,1,1,1, :b, :b, :b, :b, :b]
529
+ assert_ene Reg[:a, OB-0, :b, :b, :b, :b, :b], [:a, 1, :b, :b, :b, :b, :b]
530
+ assert_eee Reg[:a, OB-0, :b, :b, :b, :b, :b], [:a, :b, :b, :b, :b, :b]
531
+
532
+ assert_eee Reg[-[OB*2]], [99, 99] #di not right in top level
533
+ assert_eee Reg[-[-[-[-[-[OB*2]]]]]], [99, 99] #di not right in top level?
534
+ assert_eee Reg[-[-[-[-[-[OB*1]]]]]], [99] #di not right in top level?
535
+ #RR[RR[[RR[RR[RR[RR[99,99]]]]]]]
536
+ assert_eee Reg[OB*1], [:foo]
537
+ assert_eee Reg[-[OB]], [88]
538
+ assert_ene Reg[-[0]], [88]
539
+ assert_eee Reg[-[0]], [0]
540
+ assert_eee Reg[-[OB*1]], [:foo]
541
+ assert_eee Reg[OB*1*1], [:foo]
542
+ assert_eee Reg[OB*1*1*1*1*1*1*1*1*1*1*1*1*1*1], [:foo]
543
+ assert_eee Reg[OB-1-1-1-1-1-1-1-1-1-1-1-1-1-1], [:foo]
544
+ assert_eee Reg[-[2,OB*2]], [2, 99, 99]
545
+
546
+ assert_eee RegMultiple, -[0]|-[1,2]
547
+ assert( (-[0]|-[1,2]).respond_to?( :mmatch))
548
+
549
+ assert_eee Reg[-[0],OBS], lenheaddataj
550
+ assert_eee Reg[-[0]|-[1,OB],OBS], lenheaddataj
551
+ assert_eee Reg[-[0]|-[1,OB]|-[2,OB*2],OBS], lenheaddataj
552
+ assert_eee Reg[-[0]|-[1,OB]|-[2,OB*2]|-[3,OB*3],OBS], lenheaddataj
553
+ assert_eee Reg[-[0]|-[1,OB]|-[2,OB*2]|-[3,OB*3]|-[4,OB*4],OBS], lenheaddataj
554
+
555
+
556
+
557
+ assert_eee Reg(:a=>:b), {:a=>:b} #=> true
558
+ assert_ene Reg(:a=>:b), {:a=>:c} #=> false
559
+ assert_ene Reg(:a=>:b), {} #=> false
560
+ h={}
561
+ h.default=:b
562
+ assert_eee Reg(:a=>:b), h #=> true
563
+
564
+ assert_eee Reg(/^(a|b)$/=>33), {"a"=>33} #=> true
565
+ assert_eee Reg(/^(a|b)$/=>33), {"b"=>33} #=> true
566
+ assert_ene Reg(/^(a|b)$/=>33), {"a"=>133} #=> false
567
+ assert_ene Reg(/^(a|b)$/=>33), {"b"=>133} #=> false
568
+
569
+ assert_ene Reg(/^(a|b)$/=>33), {"c"=>33} #=> false
570
+
571
+ assert_eee Reg(/^(a|b)$/=>33), {"a"=>33,"b"=>33} #=> true
572
+ assert_ene Reg(/^(a|b)$/=>33), {"a"=>33,"b"=>133} #=> false
573
+ assert_ene Reg(/^(a|b)$/=>33), {"a"=>133,"b"=>33} #=> false
574
+ assert_ene Reg(/^(a|b)$/=>33), {"a"=>133,"b"=>133} #=> false
575
+
576
+
577
+ assert_eee Reg("a"=>33)|{"b"=>33}, {"a"=>33,"b"=>33} #=> true
578
+ assert_eee Reg("a"=>33)|{"b"=>33}, {"a"=>33,"b"=>133} #=> true
579
+ assert_ene Reg("a"=>33)|{"b"=>33}, {"a"=>133,"b"=>33} #=> false
580
+ assert_ene Reg("a"=>33)|{"b"=>33}, {"a"=>133,"b"=>133} #=> false
581
+
582
+ assert_eee Reg("a"=>33)|{"b"=>33}, {"b"=>33} #=> true
583
+
584
+ assert_eee Reg(:a.reg|:b => 44), {:a => 44} #=> true
585
+ assert_eee Reg(:a.reg|:b => 44), {:b => 44} #=> true
586
+ assert_ene Reg(:a.reg|:b => 44), {:a => 144} #=> false
587
+ assert_ene Reg(:a.reg|:b => 44), {:b => 144} #=> false
588
+
589
+ print "\n"
590
+ end
591
+
592
+ def assert_eee(left,right,message='assert_eee failed')
593
+ assert(
594
+ left===right,
595
+ message+" left=#{left.inspect} right=#{right.inspect}"
596
+ )
597
+ print ".";$stdout.flush
598
+ end
599
+
600
+ def assert_ene(left,right,message='assert_ene failed')
601
+ assert(
602
+ !(left===right),
603
+ message+" left=#{left.inspect} right=#{right.inspect}"
604
+ )
605
+ print ",";$stdout.flush
606
+ end
607
+ end
608
+ end
609
+ srand;seed=srand
610
+
611
+ opts=GetoptLong.new(["--seed", "-s", GetoptLong::REQUIRED_ARGUMENT])
612
+ opts.each{|opt,arg|
613
+ opt=='--seed' or raise :impossible
614
+ seed=arg
615
+ }
616
+
617
+ print "random seed is #{seed}\n"
618
+ srand seed
619
+
620
+
621
+ TC_Reg.test_reg