re2 2.23.0-aarch64-linux-gnu → 2.25.0-aarch64-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.
@@ -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
@@ -596,7 +723,6 @@ RSpec.describe RE2::Regexp do
596
723
 
597
724
  it "raises an exception if given too large a number of submatches instead of options" do
598
725
  re = RE2::Regexp.new('(\w+) (\w+) (\w+)')
599
- md = re.match("one two three", 2)
600
726
 
601
727
  expect { re.match("one two three", INT_MAX) }.to raise_error(RangeError, "number of matches should be < #{INT_MAX}")
602
728
  end
@@ -612,6 +738,10 @@ RSpec.describe RE2::Regexp do
612
738
 
613
739
  expect(re.match("one two three", nil)).to be_a(RE2::MatchData)
614
740
  end
741
+
742
+ it "raises an error when called on an uninitialized object" do
743
+ expect { described_class.allocate.match("test") }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
744
+ end
615
745
  end
616
746
 
617
747
  describe "#match?" do
@@ -633,6 +763,10 @@ RSpec.describe RE2::Regexp do
633
763
 
634
764
  expect { re.match?(0) }.to raise_error(TypeError)
635
765
  end
766
+
767
+ it "raises an error when called on an uninitialized object" do
768
+ expect { described_class.allocate.match?("test") }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
769
+ end
636
770
  end
637
771
 
638
772
  describe "#partial_match?" do
@@ -661,6 +795,10 @@ RSpec.describe RE2::Regexp do
661
795
 
662
796
  expect { re.partial_match?(0) }.to raise_error(TypeError)
663
797
  end
798
+
799
+ it "raises an error when called on an uninitialized object" do
800
+ expect { described_class.allocate.partial_match?("test") }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
801
+ end
664
802
  end
665
803
 
666
804
  describe "#=~" do
@@ -689,6 +827,10 @@ RSpec.describe RE2::Regexp do
689
827
 
690
828
  expect { re =~ 0 }.to raise_error(TypeError)
691
829
  end
830
+
831
+ it "raises an error when called on an uninitialized object" do
832
+ expect { described_class.allocate =~ "test" }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
833
+ end
692
834
  end
693
835
 
694
836
  describe "#===" do
@@ -710,6 +852,10 @@ RSpec.describe RE2::Regexp do
710
852
 
711
853
  expect { re === 0 }.to raise_error(TypeError)
712
854
  end
855
+
856
+ it "raises an error when called on an uninitialized object" do
857
+ expect { described_class.allocate === "test" }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
858
+ end
713
859
  end
714
860
 
715
861
  describe "#full_match?" do
@@ -738,6 +884,10 @@ RSpec.describe RE2::Regexp do
738
884
 
739
885
  expect { re.full_match?(0) }.to raise_error(TypeError)
740
886
  end
887
+
888
+ it "raises an error when called on an uninitialized object" do
889
+ expect { described_class.allocate.full_match?("test") }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
890
+ end
741
891
  end
742
892
 
743
893
  describe "#ok?" do
@@ -752,6 +902,10 @@ RSpec.describe RE2::Regexp do
752
902
  expect(RE2::Regexp.new('wo[o', log_errors: false)).to_not be_ok
753
903
  expect(RE2::Regexp.new('*', log_errors: false)).to_not be_ok
754
904
  end
905
+
906
+ it "raises an error when called on an uninitialized object" do
907
+ expect { described_class.allocate.ok? }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
908
+ end
755
909
  end
756
910
 
757
911
  describe ".escape" do
@@ -776,6 +930,10 @@ RSpec.describe RE2::Regexp do
776
930
  it "returns -1 for an invalid pattern" do
777
931
  expect(RE2::Regexp.new('???', log_errors: false).number_of_capturing_groups).to eq(-1)
778
932
  end
933
+
934
+ it "raises an error when called on an uninitialized object" do
935
+ expect { described_class.allocate.number_of_capturing_groups }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
936
+ end
779
937
  end
780
938
 
781
939
  describe "#named_capturing_groups" do
@@ -798,6 +956,68 @@ RSpec.describe RE2::Regexp do
798
956
  it "returns an empty hash for an invalid regexp" do
799
957
  expect(RE2::Regexp.new('???', log_errors: false).named_capturing_groups).to be_empty
800
958
  end
959
+
960
+ it "raises an error when called on an uninitialized object" do
961
+ expect { described_class.allocate.named_capturing_groups }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
962
+ end
963
+ end
964
+
965
+ describe "#names" do
966
+ it "returns an array of names of named capturing groups" do
967
+ expect(RE2::Regexp.new('(?P<bob>a)(?P<rob>b)').names).to eq(["bob", "rob"])
968
+ end
969
+
970
+ it "returns an empty array if there are no named capturing groups" do
971
+ expect(RE2::Regexp.new('(a)(b)').names).to be_empty
972
+ end
973
+
974
+ it "returns an empty array for a pattern with no capturing groups" do
975
+ expect(RE2::Regexp.new('ab').names).to be_empty
976
+ end
977
+
978
+ it "returns an empty array for an invalid regexp" do
979
+ expect(RE2::Regexp.new('???', log_errors: false).names).to be_empty
980
+ end
981
+
982
+ it "returns UTF-8 strings if the pattern is UTF-8" do
983
+ names = RE2::Regexp.new('(?P<bob>a)').names
984
+
985
+ expect(names.first.encoding).to eq(Encoding::UTF_8)
986
+ end
987
+
988
+ it "returns ISO-8859-1 strings if the pattern is not UTF-8" do
989
+ names = RE2::Regexp.new('(?P<bob>a)', utf8: false).names
990
+
991
+ expect(names.first.encoding).to eq(Encoding::ISO_8859_1)
992
+ end
993
+
994
+ it "raises an error when called on an uninitialized object" do
995
+ expect { described_class.allocate.names }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
996
+ end
997
+ end
998
+
999
+ describe "#named_captures" do
1000
+ it "returns a hash of names to indices" do
1001
+ expect(RE2::Regexp.new('(?P<bob>a)').named_captures).to eq("bob" => 1)
1002
+ end
1003
+
1004
+ it "maps names to indices with several groups" do
1005
+ groups = RE2::Regexp.new('(?P<bob>a)(o)(?P<rob>e)').named_captures
1006
+
1007
+ expect(groups).to eq("bob" => 1, "rob" => 3)
1008
+ end
1009
+
1010
+ it "returns an empty hash for a pattern with no named groups" do
1011
+ expect(RE2::Regexp.new('(a)(b)').named_captures).to be_empty
1012
+ end
1013
+
1014
+ it "returns an empty hash for an invalid regexp" do
1015
+ expect(RE2::Regexp.new('???', log_errors: false).named_captures).to be_empty
1016
+ end
1017
+
1018
+ it "raises an error when called on an uninitialized object" do
1019
+ expect { described_class.allocate.named_captures }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
1020
+ end
801
1021
  end
802
1022
 
803
1023
  describe "#scan" do
@@ -813,6 +1033,10 @@ RSpec.describe RE2::Regexp do
813
1033
 
814
1034
  expect { r.scan(nil) }.to raise_error(TypeError)
815
1035
  end
1036
+
1037
+ it "raises an error when called on an uninitialized object" do
1038
+ expect { described_class.allocate.scan("test") }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
1039
+ end
816
1040
  end
817
1041
 
818
1042
  describe "#partial_match" do
@@ -868,6 +1092,10 @@ RSpec.describe RE2::Regexp do
868
1092
 
869
1093
  expect(r.partial_match('ruby:1234', anchor: :anchor_both)).to be_a(RE2::MatchData)
870
1094
  end
1095
+
1096
+ it "raises an error when called on an uninitialized object" do
1097
+ expect { described_class.allocate.partial_match('test') }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
1098
+ end
871
1099
  end
872
1100
 
873
1101
  describe "#full_match" do
@@ -924,5 +1152,9 @@ RSpec.describe RE2::Regexp do
924
1152
 
925
1153
  expect(r.full_match('ruby:1234', anchor: :unanchored)).to be_nil
926
1154
  end
1155
+
1156
+ it "raises an error when called on an uninitialized object" do
1157
+ expect { described_class.allocate.full_match('test') }.to raise_error(TypeError, /uninitialized RE2::Regexp/)
1158
+ end
927
1159
  end
928
1160
  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
data/spec/re2/set_spec.rb CHANGED
@@ -51,6 +51,18 @@ RSpec.describe RE2::Set do
51
51
  end
52
52
  end
53
53
 
54
+ describe "#dup" do
55
+ it "raises a TypeError" do
56
+ expect { described_class.new.dup }.to raise_error(TypeError, /cannot copy RE2::Set/)
57
+ end
58
+ end
59
+
60
+ describe "#clone" do
61
+ it "raises a TypeError" do
62
+ expect { described_class.new.clone }.to raise_error(TypeError, /cannot copy RE2::Set/)
63
+ end
64
+ end
65
+
54
66
  describe "#add" do
55
67
  it "allows multiple patterns to be added", :aggregate_failures do
56
68
  set = RE2::Set.new
@@ -93,6 +105,10 @@ RSpec.describe RE2::Set do
93
105
 
94
106
  expect(set.add(StringLike.new("abc"))).to eq(0)
95
107
  end
108
+
109
+ it "raises an error when called on an uninitialized object" do
110
+ expect { described_class.allocate.add("foo") }.to raise_error(TypeError, /uninitialized RE2::Set/)
111
+ end
96
112
  end
97
113
 
98
114
  describe "#compile" do
@@ -104,6 +120,10 @@ RSpec.describe RE2::Set do
104
120
 
105
121
  expect(set.compile).to be_truthy
106
122
  end
123
+
124
+ it "raises an error when called on an uninitialized object" do
125
+ expect { described_class.allocate.compile }.to raise_error(TypeError, /uninitialized RE2::Set/)
126
+ end
107
127
  end
108
128
 
109
129
  describe "#match" do
@@ -202,6 +222,10 @@ RSpec.describe RE2::Set do
202
222
 
203
223
  expect(set.match(StringLike.new("abcdef"), exception: false)).to contain_exactly(0)
204
224
  end
225
+
226
+ it "raises an error when called on an uninitialized object" do
227
+ expect { described_class.allocate.match("foo") }.to raise_error(TypeError, /uninitialized RE2::Set/)
228
+ end
205
229
  end
206
230
 
207
231
  describe "#size" do
@@ -228,6 +252,12 @@ RSpec.describe RE2::Set do
228
252
 
229
253
  expect { set.size }.to raise_error(RE2::Set::UnsupportedError)
230
254
  end
255
+
256
+ it "raises an error when called on an uninitialized object" do
257
+ skip "Underlying RE2::Set has no Size method" unless RE2::Set.size?
258
+
259
+ expect { described_class.allocate.size }.to raise_error(TypeError, /uninitialized RE2::Set/)
260
+ end
231
261
  end
232
262
 
233
263
  describe "#length" do
@@ -246,6 +276,12 @@ RSpec.describe RE2::Set do
246
276
 
247
277
  expect(set.length).to eq(2)
248
278
  end
279
+
280
+ it "raises an error when called on an uninitialized object" do
281
+ skip "Underlying RE2::Set has no Size method" unless RE2::Set.size?
282
+
283
+ expect { described_class.allocate.length }.to raise_error(TypeError, /uninitialized RE2::Set/)
284
+ end
249
285
  end
250
286
 
251
287
  def silence_stderr