re2 2.23.0-arm-linux-gnu → 2.24.0-arm-linux-gnu

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/lib/3.1/re2.so CHANGED
Binary file
data/lib/3.2/re2.so CHANGED
Binary file
data/lib/3.3/re2.so CHANGED
Binary file
data/lib/3.4/re2.so CHANGED
Binary file
data/lib/4.0/re2.so CHANGED
Binary file
data/lib/re2/version.rb CHANGED
@@ -10,5 +10,5 @@
10
10
 
11
11
 
12
12
  module RE2
13
- VERSION = "2.23.0"
13
+ VERSION = "2.24.0"
14
14
  end
@@ -10,6 +10,55 @@ RSpec.describe RE2::MatchData do
10
10
  expect(ObjectSpace.memsize_of(matches1)).to be < ObjectSpace.memsize_of(matches2)
11
11
  end
12
12
 
13
+ describe "#dup" do
14
+ it "returns a copy of the match data" do
15
+ md = RE2::Regexp.new('(\d+) (\d+)').match("123 456")
16
+ copy = md.dup
17
+
18
+ expect(copy.to_a).to eq(["123 456", "123", "456"])
19
+ end
20
+
21
+ it "returns a different object" do
22
+ md = RE2::Regexp.new('(\d+) (\d+)').match("123 456")
23
+ copy = md.dup
24
+
25
+ expect(copy).to_not equal(md)
26
+ end
27
+
28
+ it "preserves the original string" do
29
+ str = "bob 123"
30
+ md = RE2::Regexp.new('(\d+)').match(str)
31
+ copy = md.dup
32
+
33
+ expect(copy.string).to equal(str)
34
+ end
35
+
36
+ it "preserves the original regexp" do
37
+ re = RE2::Regexp.new('(\d+)')
38
+ md = re.match("123")
39
+ copy = md.dup
40
+
41
+ expect(copy.regexp).to equal(re)
42
+ end
43
+
44
+ it "raises an error when called on an uninitialized object" do
45
+ expect { described_class.allocate.dup }.to raise_error(TypeError, /uninitialized RE2::MatchData/)
46
+ end
47
+ end
48
+
49
+ describe "#clone" do
50
+ it "returns a copy of the match data" do
51
+ md = RE2::Regexp.new('(\d+) (\d+)').match("123 456")
52
+ copy = md.clone
53
+
54
+ expect(copy.to_a).to eq(["123 456", "123", "456"])
55
+ end
56
+
57
+ it "raises an error when called on an uninitialized object" do
58
+ expect { described_class.allocate.clone }.to raise_error(TypeError, /uninitialized RE2::MatchData/)
59
+ end
60
+ end
61
+
13
62
  describe "#to_a" do
14
63
  it "is populated with the match and capturing groups" do
15
64
  a = RE2::Regexp.new('w(o)(o)').match('woo').to_a
@@ -34,6 +83,10 @@ RSpec.describe RE2::MatchData do
34
83
 
35
84
  expect(a.map(&:encoding)).to all eq(Encoding::ISO_8859_1)
36
85
  end
86
+
87
+ it "raises an error when called on an uninitialized object" do
88
+ expect { described_class.allocate.to_a }.to raise_error(TypeError, /uninitialized RE2::MatchData/)
89
+ end
37
90
  end
38
91
 
39
92
  describe "#[]" do
@@ -140,6 +193,10 @@ RSpec.describe RE2::MatchData do
140
193
 
141
194
  expect(md[1]).to eq("woo")
142
195
  end
196
+
197
+ it "raises an error when called on an uninitialized object" do
198
+ expect { described_class.allocate[0] }.to raise_error(TypeError, /uninitialized RE2::MatchData/)
199
+ end
143
200
  end
144
201
 
145
202
  describe "#string" do
@@ -168,6 +225,10 @@ RSpec.describe RE2::MatchData do
168
225
 
169
226
  expect(re.string).to equal(string)
170
227
  end
228
+
229
+ it "raises an error when called on an uninitialized object" do
230
+ expect { described_class.allocate.string }.to raise_error(TypeError, /uninitialized RE2::MatchData/)
231
+ end
171
232
  end
172
233
 
173
234
  describe "#size" do
@@ -176,6 +237,10 @@ RSpec.describe RE2::MatchData do
176
237
 
177
238
  expect(md.size).to eq(3)
178
239
  end
240
+
241
+ it "raises an error when called on an uninitialized object" do
242
+ expect { described_class.allocate.size }.to raise_error(TypeError, /uninitialized RE2::MatchData/)
243
+ end
179
244
  end
180
245
 
181
246
  describe "#length" do
@@ -184,6 +249,10 @@ RSpec.describe RE2::MatchData do
184
249
 
185
250
  expect(md.length).to eq(3)
186
251
  end
252
+
253
+ it "raises an error when called on an uninitialized object" do
254
+ expect { described_class.allocate.length }.to raise_error(TypeError, /uninitialized RE2::MatchData/)
255
+ end
187
256
  end
188
257
 
189
258
  describe "#regexp" do
@@ -193,6 +262,10 @@ RSpec.describe RE2::MatchData do
193
262
 
194
263
  expect(md.regexp).to equal(re)
195
264
  end
265
+
266
+ it "raises an error when called on an uninitialized object" do
267
+ expect { described_class.allocate.regexp }.to raise_error(TypeError, /uninitialized RE2::MatchData/)
268
+ end
196
269
  end
197
270
 
198
271
  describe "#inspect" do
@@ -213,6 +286,10 @@ RSpec.describe RE2::MatchData do
213
286
 
214
287
  expect(md.inspect).to eq("#<RE2::MatchData \"a\0b c\0d\" 1:\"a\0b\" 2:\"c\0d\">")
215
288
  end
289
+
290
+ it "raises an error when called on an uninitialized object" do
291
+ expect { described_class.allocate.inspect }.to raise_error(TypeError, /uninitialized RE2::MatchData/)
292
+ end
216
293
  end
217
294
 
218
295
  describe "#to_s" do
@@ -221,6 +298,10 @@ RSpec.describe RE2::MatchData do
221
298
 
222
299
  expect(md.to_s).to eq("23456")
223
300
  end
301
+
302
+ it "raises an error when called on an uninitialized object" do
303
+ expect { described_class.allocate.to_s }.to raise_error(TypeError, /uninitialized RE2::MatchData/)
304
+ end
224
305
  end
225
306
 
226
307
  describe "#to_ary" do
@@ -301,6 +382,10 @@ RSpec.describe RE2::MatchData do
301
382
 
302
383
  expect(md.string[md.begin(0)..-1]).to eq('woohoo' * 5)
303
384
  end
385
+
386
+ it "raises an error when called on an uninitialized object" do
387
+ expect { described_class.allocate.begin(0) }.to raise_error(TypeError, /uninitialized RE2::MatchData/)
388
+ end
304
389
  end
305
390
 
306
391
  describe "#end" do
@@ -370,6 +455,10 @@ RSpec.describe RE2::MatchData do
370
455
 
371
456
  expect(md.string[0...md.end(0)]).to eq('woo')
372
457
  end
458
+
459
+ it "raises an error when called on an uninitialized object" do
460
+ expect { described_class.allocate.end(0) }.to raise_error(TypeError, /uninitialized RE2::MatchData/)
461
+ end
373
462
  end
374
463
 
375
464
  describe "#deconstruct" do
@@ -384,6 +473,10 @@ RSpec.describe RE2::MatchData do
384
473
 
385
474
  expect(md.deconstruct).to eq(['o', 'o', nil])
386
475
  end
476
+
477
+ it "raises an error when called on an uninitialized object" do
478
+ expect { described_class.allocate.deconstruct }.to raise_error(TypeError, /uninitialized RE2::MatchData/)
479
+ end
387
480
  end
388
481
 
389
482
  describe "#deconstruct_keys" do
@@ -428,5 +521,9 @@ RSpec.describe RE2::MatchData do
428
521
 
429
522
  expect { md.deconstruct_keys([0]) }.to raise_error(TypeError)
430
523
  end
524
+
525
+ it "raises an error when called on an uninitialized object" do
526
+ expect { described_class.allocate.deconstruct_keys(nil) }.to raise_error(TypeError, /uninitialized RE2::MatchData/)
527
+ end
431
528
  end
432
529
  end
@@ -41,6 +41,53 @@ RSpec.describe RE2::Regexp do
41
41
  end
42
42
  end
43
43
 
44
+ describe "#dup" do
45
+ it "returns a copy with the same pattern" do
46
+ re = described_class.new('(\d+)')
47
+ copy = re.dup
48
+
49
+ expect(copy.to_s).to eq('(\d+)')
50
+ end
51
+
52
+ it "returns a different object" do
53
+ re = described_class.new('(\d+)')
54
+ copy = re.dup
55
+
56
+ expect(copy).to_not equal(re)
57
+ end
58
+
59
+ it "returns a valid copy" do
60
+ re = described_class.new('(\d+)')
61
+ copy = re.dup
62
+
63
+ expect(copy.ok?).to eq(true)
64
+ end
65
+
66
+ it "copies options from the original" do
67
+ re = described_class.new('(\d+)', case_sensitive: false)
68
+ copy = re.dup
69
+
70
+ expect(copy).to_not be_case_sensitive
71
+ end
72
+
73
+ it "raises an error when called on an uninitialized object" do
74
+ expect { described_class.allocate.dup }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
75
+ end
76
+ end
77
+
78
+ describe "#clone" do
79
+ it "returns a copy with the same pattern" do
80
+ re = described_class.new('woo')
81
+ copy = re.clone
82
+
83
+ expect(copy.to_s).to eq('woo')
84
+ end
85
+
86
+ it "raises an error when called on an uninitialized object" do
87
+ expect { described_class.allocate.clone }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
88
+ end
89
+ end
90
+
44
91
  describe ".compile" do
45
92
  it "returns an instance given only a pattern" do
46
93
  re = RE2::Regexp.compile('woo')
@@ -102,6 +149,10 @@ RSpec.describe RE2::Regexp do
102
149
 
103
150
  expect(options).to include(case_sensitive: false)
104
151
  end
152
+
153
+ it "raises an error when called on an uninitialized object" do
154
+ expect { described_class.allocate.options }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
155
+ end
105
156
  end
106
157
 
107
158
  describe "#error" do
@@ -117,6 +168,10 @@ RSpec.describe RE2::Regexp do
117
168
 
118
169
  expect(error).to eq("missing ): wo(o")
119
170
  end
171
+
172
+ it "raises an error when called on an uninitialized object" do
173
+ expect { described_class.allocate.error }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
174
+ end
120
175
  end
121
176
 
122
177
  describe "#error_arg" do
@@ -131,6 +186,10 @@ RSpec.describe RE2::Regexp do
131
186
 
132
187
  expect(error_arg).to eq("wo(o")
133
188
  end
189
+
190
+ it "raises an error when called on an uninitialized object" do
191
+ expect { described_class.allocate.error_arg }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
192
+ end
134
193
  end
135
194
 
136
195
  describe "#program_size" do
@@ -145,6 +204,10 @@ RSpec.describe RE2::Regexp do
145
204
 
146
205
  expect(program_size).to eq(-1)
147
206
  end
207
+
208
+ it "raises an error when called on an uninitialized object" do
209
+ expect { described_class.allocate.program_size }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
210
+ end
148
211
  end
149
212
 
150
213
  describe "#to_str" do
@@ -159,6 +222,10 @@ RSpec.describe RE2::Regexp do
159
222
 
160
223
  expect(string).to eq("???")
161
224
  end
225
+
226
+ it "raises an error when called on an uninitialized object" do
227
+ expect { described_class.allocate.to_str }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
228
+ end
162
229
  end
163
230
 
164
231
  describe "#pattern" do
@@ -173,6 +240,10 @@ RSpec.describe RE2::Regexp do
173
240
 
174
241
  expect(pattern).to eq("???")
175
242
  end
243
+
244
+ it "raises an error when called on an uninitialized object" do
245
+ expect { described_class.allocate.pattern }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
246
+ end
176
247
  end
177
248
 
178
249
  describe "#inspect" do
@@ -187,6 +258,10 @@ RSpec.describe RE2::Regexp do
187
258
 
188
259
  expect(string.encoding).to eq(Encoding::ISO_8859_1)
189
260
  end
261
+
262
+ it "raises an error when called on an uninitialized object" do
263
+ expect { described_class.allocate.inspect }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
264
+ end
190
265
  end
191
266
 
192
267
  describe "#utf8?" do
@@ -199,6 +274,10 @@ RSpec.describe RE2::Regexp do
199
274
 
200
275
  expect(re).to_not be_utf8
201
276
  end
277
+
278
+ it "raises an error when called on an uninitialized object" do
279
+ expect { described_class.allocate.utf8? }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
280
+ end
202
281
  end
203
282
 
204
283
  describe "#posix_syntax?" do
@@ -211,6 +290,10 @@ RSpec.describe RE2::Regexp do
211
290
 
212
291
  expect(re).to be_posix_syntax
213
292
  end
293
+
294
+ it "raises an error when called on an uninitialized object" do
295
+ expect { described_class.allocate.posix_syntax? }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
296
+ end
214
297
  end
215
298
 
216
299
  describe "#literal?" do
@@ -223,6 +306,10 @@ RSpec.describe RE2::Regexp do
223
306
 
224
307
  expect(re).to be_literal
225
308
  end
309
+
310
+ it "raises an error when called on an uninitialized object" do
311
+ expect { described_class.allocate.literal? }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
312
+ end
226
313
  end
227
314
 
228
315
  describe "#never_nl?" do
@@ -235,6 +322,10 @@ RSpec.describe RE2::Regexp do
235
322
 
236
323
  expect(re).to be_never_nl
237
324
  end
325
+
326
+ it "raises an error when called on an uninitialized object" do
327
+ expect { described_class.allocate.never_nl? }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
328
+ end
238
329
  end
239
330
 
240
331
  describe "#case_sensitive?" do
@@ -246,6 +337,10 @@ RSpec.describe RE2::Regexp do
246
337
  re = RE2::Regexp.new('woo', case_sensitive: false)
247
338
  expect(re).to_not be_case_sensitive
248
339
  end
340
+
341
+ it "raises an error when called on an uninitialized object" do
342
+ expect { described_class.allocate.case_sensitive? }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
343
+ end
249
344
  end
250
345
 
251
346
  describe "#case_insensitive?" do
@@ -258,6 +353,10 @@ RSpec.describe RE2::Regexp do
258
353
 
259
354
  expect(re).to be_case_insensitive
260
355
  end
356
+
357
+ it "raises an error when called on an uninitialized object" do
358
+ expect { described_class.allocate.case_insensitive? }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
359
+ end
261
360
  end
262
361
 
263
362
  describe "#casefold?" do
@@ -270,6 +369,10 @@ RSpec.describe RE2::Regexp do
270
369
 
271
370
  expect(re).to be_casefold
272
371
  end
372
+
373
+ it "raises an error when called on an uninitialized object" do
374
+ expect { described_class.allocate.casefold? }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
375
+ end
273
376
  end
274
377
 
275
378
  describe "#longest_match?" do
@@ -282,6 +385,10 @@ RSpec.describe RE2::Regexp do
282
385
 
283
386
  expect(re).to be_longest_match
284
387
  end
388
+
389
+ it "raises an error when called on an uninitialized object" do
390
+ expect { described_class.allocate.longest_match? }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
391
+ end
285
392
  end
286
393
 
287
394
  describe "#log_errors?" do
@@ -294,6 +401,10 @@ RSpec.describe RE2::Regexp do
294
401
 
295
402
  expect(re).to_not be_log_errors
296
403
  end
404
+
405
+ it "raises an error when called on an uninitialized object" do
406
+ expect { described_class.allocate.log_errors? }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
407
+ end
297
408
  end
298
409
 
299
410
  describe "#perl_classes?" do
@@ -306,6 +417,10 @@ RSpec.describe RE2::Regexp do
306
417
 
307
418
  expect(re).to be_perl_classes
308
419
  end
420
+
421
+ it "raises an error when called on an uninitialized object" do
422
+ expect { described_class.allocate.perl_classes? }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
423
+ end
309
424
  end
310
425
 
311
426
  describe "#word_boundary?" do
@@ -318,6 +433,10 @@ RSpec.describe RE2::Regexp do
318
433
 
319
434
  expect(re).to be_word_boundary
320
435
  end
436
+
437
+ it "raises an error when called on an uninitialized object" do
438
+ expect { described_class.allocate.word_boundary? }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
439
+ end
321
440
  end
322
441
 
323
442
  describe "#one_line?" do
@@ -330,6 +449,10 @@ RSpec.describe RE2::Regexp do
330
449
 
331
450
  expect(re).to be_one_line
332
451
  end
452
+
453
+ it "raises an error when called on an uninitialized object" do
454
+ expect { described_class.allocate.one_line? }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
455
+ end
333
456
  end
334
457
 
335
458
  describe "#max_mem" do
@@ -342,6 +465,10 @@ RSpec.describe RE2::Regexp do
342
465
 
343
466
  expect(re.max_mem).to eq(1024)
344
467
  end
468
+
469
+ it "raises an error when called on an uninitialized object" do
470
+ expect { described_class.allocate.max_mem }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
471
+ end
345
472
  end
346
473
 
347
474
  describe "#match" do
@@ -612,6 +739,10 @@ RSpec.describe RE2::Regexp do
612
739
 
613
740
  expect(re.match("one two three", nil)).to be_a(RE2::MatchData)
614
741
  end
742
+
743
+ it "raises an error when called on an uninitialized object" do
744
+ expect { described_class.allocate.match("test") }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
745
+ end
615
746
  end
616
747
 
617
748
  describe "#match?" do
@@ -633,6 +764,10 @@ RSpec.describe RE2::Regexp do
633
764
 
634
765
  expect { re.match?(0) }.to raise_error(TypeError)
635
766
  end
767
+
768
+ it "raises an error when called on an uninitialized object" do
769
+ expect { described_class.allocate.match?("test") }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
770
+ end
636
771
  end
637
772
 
638
773
  describe "#partial_match?" do
@@ -661,6 +796,10 @@ RSpec.describe RE2::Regexp do
661
796
 
662
797
  expect { re.partial_match?(0) }.to raise_error(TypeError)
663
798
  end
799
+
800
+ it "raises an error when called on an uninitialized object" do
801
+ expect { described_class.allocate.partial_match?("test") }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
802
+ end
664
803
  end
665
804
 
666
805
  describe "#=~" do
@@ -689,6 +828,10 @@ RSpec.describe RE2::Regexp do
689
828
 
690
829
  expect { re =~ 0 }.to raise_error(TypeError)
691
830
  end
831
+
832
+ it "raises an error when called on an uninitialized object" do
833
+ expect { described_class.allocate =~ "test" }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
834
+ end
692
835
  end
693
836
 
694
837
  describe "#===" do
@@ -710,6 +853,10 @@ RSpec.describe RE2::Regexp do
710
853
 
711
854
  expect { re === 0 }.to raise_error(TypeError)
712
855
  end
856
+
857
+ it "raises an error when called on an uninitialized object" do
858
+ expect { described_class.allocate === "test" }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
859
+ end
713
860
  end
714
861
 
715
862
  describe "#full_match?" do
@@ -738,6 +885,10 @@ RSpec.describe RE2::Regexp do
738
885
 
739
886
  expect { re.full_match?(0) }.to raise_error(TypeError)
740
887
  end
888
+
889
+ it "raises an error when called on an uninitialized object" do
890
+ expect { described_class.allocate.full_match?("test") }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
891
+ end
741
892
  end
742
893
 
743
894
  describe "#ok?" do
@@ -752,6 +903,10 @@ RSpec.describe RE2::Regexp do
752
903
  expect(RE2::Regexp.new('wo[o', log_errors: false)).to_not be_ok
753
904
  expect(RE2::Regexp.new('*', log_errors: false)).to_not be_ok
754
905
  end
906
+
907
+ it "raises an error when called on an uninitialized object" do
908
+ expect { described_class.allocate.ok? }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
909
+ end
755
910
  end
756
911
 
757
912
  describe ".escape" do
@@ -776,6 +931,10 @@ RSpec.describe RE2::Regexp do
776
931
  it "returns -1 for an invalid pattern" do
777
932
  expect(RE2::Regexp.new('???', log_errors: false).number_of_capturing_groups).to eq(-1)
778
933
  end
934
+
935
+ it "raises an error when called on an uninitialized object" do
936
+ expect { described_class.allocate.number_of_capturing_groups }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
937
+ end
779
938
  end
780
939
 
781
940
  describe "#named_capturing_groups" do
@@ -798,6 +957,10 @@ RSpec.describe RE2::Regexp do
798
957
  it "returns an empty hash for an invalid regexp" do
799
958
  expect(RE2::Regexp.new('???', log_errors: false).named_capturing_groups).to be_empty
800
959
  end
960
+
961
+ it "raises an error when called on an uninitialized object" do
962
+ expect { described_class.allocate.named_capturing_groups }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
963
+ end
801
964
  end
802
965
 
803
966
  describe "#scan" do
@@ -813,6 +976,10 @@ RSpec.describe RE2::Regexp do
813
976
 
814
977
  expect { r.scan(nil) }.to raise_error(TypeError)
815
978
  end
979
+
980
+ it "raises an error when called on an uninitialized object" do
981
+ expect { described_class.allocate.scan("test") }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
982
+ end
816
983
  end
817
984
 
818
985
  describe "#partial_match" do
@@ -868,6 +1035,10 @@ RSpec.describe RE2::Regexp do
868
1035
 
869
1036
  expect(r.partial_match('ruby:1234', anchor: :anchor_both)).to be_a(RE2::MatchData)
870
1037
  end
1038
+
1039
+ it "raises an error when called on an uninitialized object" do
1040
+ expect { described_class.allocate.partial_match('test') }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
1041
+ end
871
1042
  end
872
1043
 
873
1044
  describe "#full_match" do
@@ -924,5 +1095,9 @@ RSpec.describe RE2::Regexp do
924
1095
 
925
1096
  expect(r.full_match('ruby:1234', anchor: :unanchored)).to be_nil
926
1097
  end
1098
+
1099
+ it "raises an error when called on an uninitialized object" do
1100
+ expect { described_class.allocate.full_match('test') }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
1101
+ end
927
1102
  end
928
1103
  end
@@ -8,6 +8,56 @@ RSpec.describe RE2::Scanner do
8
8
 
9
9
  expect(scanner.regexp).to equal(re)
10
10
  end
11
+
12
+ it "raises an error when called on an uninitialized object" do
13
+ expect { described_class.allocate.regexp }.to raise_error(TypeError, /uninitialized RE2::Scanner/)
14
+ end
15
+ end
16
+
17
+ describe "#dup" do
18
+ it "returns a usable copy of the scanner at the same position" do
19
+ scanner = RE2::Regexp.new('(\w+)').scan("foo bar baz")
20
+ scanner.scan
21
+
22
+ copy = scanner.dup
23
+
24
+ expect(copy.scan).to eq(["bar"])
25
+ end
26
+
27
+ it "creates an independent copy" do
28
+ scanner = RE2::Regexp.new('(\w+)').scan("foo bar baz")
29
+ scanner.scan
30
+
31
+ copy = scanner.dup
32
+ copy.scan
33
+
34
+ expect(scanner.scan).to eq(["bar"])
35
+ end
36
+
37
+ it "copies the EOF state of the scanner" do
38
+ scanner = RE2::Regexp.new('(\w+)').scan("foo")
39
+ scanner.scan
40
+ scanner.scan
41
+
42
+ copy = scanner.dup
43
+
44
+ expect(copy).to be_eof
45
+ end
46
+
47
+ it "raises an error when called on an uninitialized object" do
48
+ expect { described_class.allocate.dup }.to raise_error(TypeError, /uninitialized RE2::Scanner/)
49
+ end
50
+ end
51
+
52
+ describe "#clone" do
53
+ it "returns a usable copy of the scanner at the same position" do
54
+ scanner = RE2::Regexp.new('(\w+)').scan("foo bar baz")
55
+ scanner.scan
56
+
57
+ copy = scanner.clone
58
+
59
+ expect(copy.scan).to eq(["bar"])
60
+ end
11
61
  end
12
62
 
13
63
  describe "#string" do
@@ -50,6 +100,10 @@ RSpec.describe RE2::Scanner do
50
100
 
51
101
  expect(scanner.string).to equal(text)
52
102
  end
103
+
104
+ it "raises an error when called on an uninitialized object" do
105
+ expect { described_class.allocate.string }.to raise_error(TypeError, /uninitialized RE2::Scanner/)
106
+ end
53
107
  end
54
108
 
55
109
  describe "#scan" do
@@ -211,6 +265,10 @@ RSpec.describe RE2::Scanner do
211
265
 
212
266
  expect(scanner.scan).to eq(["It"])
213
267
  end
268
+
269
+ it "raises an error when called on an uninitialized object" do
270
+ expect { described_class.allocate.scan }.to raise_error(TypeError, /uninitialized RE2::Scanner/)
271
+ end
214
272
  end
215
273
 
216
274
  it "is enumerable" do
@@ -272,6 +330,10 @@ RSpec.describe RE2::Scanner do
272
330
 
273
331
  expect(scanner).not_to be_eof
274
332
  end
333
+
334
+ it "raises an error when called on an uninitialized object" do
335
+ expect { described_class.allocate.rewind }.to raise_error(TypeError, /uninitialized RE2::Scanner/)
336
+ end
275
337
  end
276
338
 
277
339
  describe "#eof?" do
@@ -320,5 +382,9 @@ RSpec.describe RE2::Scanner do
320
382
 
321
383
  expect(scanner).to be_eof
322
384
  end
385
+
386
+ it "raises an error when called on an uninitialized object" do
387
+ expect { described_class.allocate.eof? }.to raise_error(TypeError, /uninitialized RE2::Scanner/)
388
+ end
323
389
  end
324
390
  end