vb6parse 1.0.1

vb6parse is a library for parsing and analyzing VB6 code, from projects, to controls, to modules, and forms.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
//! VB6 `StrComp` Function
//!
//! The `StrComp` function compares two strings and returns a value indicating their relationship.
//!
//! ## Syntax
//! ```vb6
//! StrComp(string1, string2[, compare])
//! ```
//!
//! ## Parameters
//! - `string1`: Required. Any valid string expression.
//! - `string2`: Required. Any valid string expression.
//! - `compare`: Optional. Specifies the type of string comparison. Can be one of the following constants:
//!   - `vbBinaryCompare` (0): Performs a binary comparison (case-sensitive, based on character codes)
//!   - `vbTextCompare` (1): Performs a textual comparison (case-insensitive)
//!   - `vbDatabaseCompare` (2): Performs a comparison based on database information (Microsoft Access only)
//!
//! ## Returns
//! Returns an `Integer` indicating the result of the comparison:
//! - `-1` if `string1` is less than `string2`
//! - `0` if `string1` equals `string2`
//! - `1` if `string1` is greater than `string2`
//! - `Null` if either `string1` or `string2` is `Null`
//!
//! ## Remarks
//! The `StrComp` function provides flexible string comparison with control over case sensitivity:
//!
//! - **Binary comparison (vbBinaryCompare = 0)**: Compares strings based on internal binary representation (character codes). This is case-sensitive and faster. "A" < "a" because uppercase letters have lower ASCII values than lowercase letters.
//! - **Text comparison (vbTextCompare = 1)**: Compares strings in a case-insensitive manner. "A" = "a" in text comparison.
//! - **Default behavior**: If `compare` argument is omitted, the comparison mode is determined by the `Option Compare` statement at the module level. If no `Option Compare` is specified, binary comparison is used.
//! - **Null handling**: If either string is `Null`, the function returns `Null` (not an error).
//! - **Empty strings**: Empty strings ("") are less than any non-empty string.
//! - **Comparison logic**: Uses lexicographic ordering based on character codes (binary) or case-folded characters (text).
//! - **Performance**: Binary comparison is faster than text comparison.
//! - **Unicode support**: VB6 uses Unicode internally, so comparisons work correctly with international characters.
//!
//! ### Option Compare Statement
//! The module-level `Option Compare` statement affects default comparison behavior:
//! ```vb6
//! Option Compare Binary   ' Default: case-sensitive comparisons
//! Option Compare Text     ' Case-insensitive comparisons
//! Option Compare Database ' Database-based comparisons (Access only)
//! ```
//!
//! ### Comparison with Operators
//! - **`StrComp` vs = operator**: The `=` operator returns Boolean (True/False), while `StrComp` returns Integer (-1, 0, 1) providing ordering information.
//! - **`StrComp` vs `InStr`**: `InStr` finds substring position, while `StrComp` compares entire strings.
//! - **`StrComp` vs Like**: `Like` supports pattern matching with wildcards, while `StrComp` is exact comparison.
//!
//! ## Typical Uses
//! 1. **Sorting Algorithms**: Implement custom sorting routines for string arrays
//! 2. **Case-Insensitive Comparisons**: Compare strings without regard to case
//! 3. **Data Validation**: Verify string equality with specific comparison rules
//! 4. **Search Operations**: Find matching strings in collections with case control
//! 5. **Alphabetical Ordering**: Determine alphabetical order for display or reports
//! 6. **User Input Validation**: Compare user input against expected values case-insensitively
//! 7. **Database Queries**: Build comparison logic for filtering and searching
//! 8. **File Comparisons**: Compare filenames or paths with case sensitivity control
//!
//! ## Basic Examples
//!
//! ### Example 1: Basic String Comparison
//! ```vb6
//! Dim result As Integer
//!
//! ' Binary comparison (case-sensitive)
//! result = StrComp("ABC", "abc", vbBinaryCompare)   ' Returns -1 (ABC < abc)
//! result = StrComp("ABC", "ABC", vbBinaryCompare)   ' Returns 0 (equal)
//! result = StrComp("abc", "ABC", vbBinaryCompare)   ' Returns 1 (abc > ABC)
//!
//! ' Text comparison (case-insensitive)
//! result = StrComp("ABC", "abc", vbTextCompare)     ' Returns 0 (equal)
//! result = StrComp("ABC", "ABD", vbTextCompare)     ' Returns -1 (ABC < ABD)
//! result = StrComp("XYZ", "ABC", vbTextCompare)     ' Returns 1 (XYZ > ABC)
//! ```
//!
//! ### Example 2: Using Return Value
//! ```vb6
//! Dim str1 As String
//! Dim str2 As String
//! Dim compareResult As Integer
//!
//! str1 = "Apple"
//! str2 = "apple"
//!
//! compareResult = StrComp(str1, str2, vbTextCompare)
//!
//! Select Case compareResult
//!     Case -1
//!         MsgBox str1 & " comes before " & str2
//!     Case 0
//!         MsgBox str1 & " equals " & str2
//!     Case 1
//!         MsgBox str1 & " comes after " & str2
//! End Select
//! ```
//!
//! ### Example 3: Case-Insensitive Search
//! ```vb6
//! Function FindInArray(arr() As String, searchValue As String) As Integer
//!     Dim i As Integer
//!     
//!     For i = LBound(arr) To UBound(arr)
//!         If StrComp(arr(i), searchValue, vbTextCompare) = 0 Then
//!             FindInArray = i
//!             Exit Function
//!         End If
//!     Next i
//!     
//!     FindInArray = -1  ' Not found
//! End Function
//! ```
//!
//! ### Example 4: Null Handling
//! ```vb6
//! Dim result As Variant
//! Dim str1 As Variant
//! Dim str2 As Variant
//!
//! str1 = "Hello"
//! str2 = Null
//!
//! result = StrComp(str1, str2)  ' Returns Null
//!
//! If IsNull(result) Then
//!     MsgBox "One of the strings is Null"
//! End If
//! ```
//!
//! ## Common Patterns
//!
//! ### Pattern 1: Bubble Sort with `StrComp`
//! ```vb6
//! Sub SortStrings(arr() As String, caseInsensitive As Boolean)
//!     Dim i As Integer
//!     Dim j As Integer
//!     Dim temp As String
//!     Dim compareMode As Integer
//!     
//!     compareMode = IIf(caseInsensitive, vbTextCompare, vbBinaryCompare)
//!     
//!     For i = LBound(arr) To UBound(arr) - 1
//!         For j = i + 1 To UBound(arr)
//!             If StrComp(arr(i), arr(j), compareMode) > 0 Then
//!                 temp = arr(i)
//!                 arr(i) = arr(j)
//!                 arr(j) = temp
//!             End If
//!         Next j
//!     Next i
//! End Sub
//! ```
//!
//! ### Pattern 2: Case-Insensitive Equality Check
//! ```vb6
//! Function EqualsIgnoreCase(str1 As String, str2 As String) As Boolean
//!     EqualsIgnoreCase = (StrComp(str1, str2, vbTextCompare) = 0)
//! End Function
//! ```
//!
//! ### Pattern 3: Find Minimum String
//! ```vb6
//! Function FindMinString(arr() As String) As String
//!     Dim i As Integer
//!     Dim minStr As String
//!     
//!     If UBound(arr) < LBound(arr) Then Exit Function
//!     
//!     minStr = arr(LBound(arr))
//!     For i = LBound(arr) + 1 To UBound(arr)
//!         If StrComp(arr(i), minStr, vbTextCompare) < 0 Then
//!             minStr = arr(i)
//!         End If
//!     Next i
//!     
//!     FindMinString = minStr
//! End Function
//! ```
//!
//! ### Pattern 4: Binary Search (Sorted Array)
//! ```vb6
//! Function BinarySearch(arr() As String, searchValue As String) As Integer
//!     Dim low As Integer
//!     Dim high As Integer
//!     Dim mid As Integer
//!     Dim compareResult As Integer
//!     
//!     low = LBound(arr)
//!     high = UBound(arr)
//!     
//!     Do While low <= high
//!         mid = (low + high) \ 2
//!         compareResult = StrComp(arr(mid), searchValue, vbTextCompare)
//!         
//!         If compareResult = 0 Then
//!             BinarySearch = mid
//!             Exit Function
//!         ElseIf compareResult < 0 Then
//!             low = mid + 1
//!         Else
//!             high = mid - 1
//!         End If
//!     Loop
//!     
//!     BinarySearch = -1  ' Not found
//! End Function
//! ```
//!
//! ### Pattern 5: Validate Against List
//! ```vb6
//! Function IsValidValue(value As String, validValues() As String) As Boolean
//!     Dim i As Integer
//!     
//!     For i = LBound(validValues) To UBound(validValues)
//!         If StrComp(value, validValues(i), vbTextCompare) = 0 Then
//!             IsValidValue = True
//!             Exit Function
//!         End If
//!     Next i
//!     
//!     IsValidValue = False
//! End Function
//! ```
//!
//! ### Pattern 6: Remove Duplicates (Case-Insensitive)
//! ```vb6
//! Function RemoveDuplicates(arr() As String) As String()
//!     Dim result() As String
//!     Dim count As Integer
//!     Dim i As Integer
//!     Dim j As Integer
//!     Dim isDuplicate As Boolean
//!     
//!     count = 0
//!     For i = LBound(arr) To UBound(arr)
//!         isDuplicate = False
//!         For j = 0 To count - 1
//!             If StrComp(arr(i), result(j), vbTextCompare) = 0 Then
//!                 isDuplicate = True
//!                 Exit For
//!             End If
//!         Next j
//!         
//!         If Not isDuplicate Then
//!             ReDim Preserve result(0 To count)
//!             result(count) = arr(i)
//!             count = count + 1
//!         End If
//!     Next i
//!     
//!     RemoveDuplicates = result
//! End Function
//! ```
//!
//! ### Pattern 7: Group By First Letter
//! ```vb6
//! Function GroupByFirstLetter(arr() As String) As Collection
//!     Dim groups As New Collection
//!     Dim i As Integer
//!     Dim firstLetter As String
//!     Dim group As Collection
//!     
//!     For i = LBound(arr) To UBound(arr)
//!         firstLetter = UCase$(Left$(arr(i), 1))
//!         
//!         On Error Resume Next
//!         Set group = groups(firstLetter)
//!         On Error GoTo 0
//!         
//!         If group Is Nothing Then
//!             Set group = New Collection
//!             groups.Add group, firstLetter
//!         End If
//!         
//!         group.Add arr(i)
//!         Set group = Nothing
//!     Next i
//!     
//!     Set GroupByFirstLetter = groups
//! End Function
//! ```
//!
//! ### Pattern 8: Natural Sort Helper
//! ```vb6
//! Function CompareNatural(str1 As String, str2 As String) As Integer
//!     ' Simple natural sort: compare non-numeric parts with StrComp
//!     ' This is a simplified version
//!     
//!     If IsNumeric(str1) And IsNumeric(str2) Then
//!         If CDbl(str1) < CDbl(str2) Then
//!             CompareNatural = -1
//!         ElseIf CDbl(str1) > CDbl(str2) Then
//!             CompareNatural = 1
//!         Else
//!             CompareNatural = 0
//!         End If
//!     Else
//!         CompareNatural = StrComp(str1, str2, vbTextCompare)
//!     End If
//! End Function
//! ```
//!
//! ### Pattern 9: Case-Sensitive Contains
//! ```vb6
//! Function ContainsCaseSensitive(arr() As String, value As String) As Boolean
//!     Dim i As Integer
//!     
//!     For i = LBound(arr) To UBound(arr)
//!         If StrComp(arr(i), value, vbBinaryCompare) = 0 Then
//!             ContainsCaseSensitive = True
//!             Exit Function
//!         End If
//!     Next i
//!     
//!     ContainsCaseSensitive = False
//! End Function
//! ```
//!
//! ### Pattern 10: Compare File Extensions
//! ```vb6
//! Function HasExtension(filename As String, extension As String) As Boolean
//!     Dim fileExt As String
//!     Dim dotPos As Integer
//!     
//!     dotPos = InStrRev(filename, ".")
//!     If dotPos = 0 Then
//!         HasExtension = False
//!         Exit Function
//!     End If
//!     
//!     fileExt = Mid$(filename, dotPos + 1)
//!     HasExtension = (StrComp(fileExt, extension, vbTextCompare) = 0)
//! End Function
//! ```
//!
//! ## Advanced Usage
//!
//! ### Example 1: String Sorter Class
//! ```vb6
//! ' Class: StringSorter
//! ' Provides sorting capabilities with various comparison modes
//! Option Explicit
//!
//! Public Enum SortOrder
//!     Ascending = 1
//!     Descending = -1
//! End Enum
//!
//! Private m_CompareMode As VbCompareMethod
//! Private m_SortOrder As SortOrder
//!
//! Public Sub Initialize(Optional compareMode As VbCompareMethod = vbBinaryCompare, _
//!                       Optional sortOrder As SortOrder = Ascending)
//!     m_CompareMode = compareMode
//!     m_SortOrder = sortOrder
//! End Sub
//!
//! Public Sub QuickSort(arr() As String, Optional leftIndex As Long = -1, _
//!                                       Optional rightIndex As Long = -1)
//!     Dim i As Long
//!     Dim j As Long
//!     Dim pivot As String
//!     Dim temp As String
//!     
//!     ' Initialize indices on first call
//!     If leftIndex = -1 Then leftIndex = LBound(arr)
//!     If rightIndex = -1 Then rightIndex = UBound(arr)
//!     
//!     If leftIndex >= rightIndex Then Exit Sub
//!     
//!     ' Choose pivot
//!     pivot = arr((leftIndex + rightIndex) \ 2)
//!     i = leftIndex
//!     j = rightIndex
//!     
//!     ' Partition
//!     Do While i <= j
//!         Do While CompareValues(arr(i), pivot) < 0
//!             i = i + 1
//!         Loop
//!         
//!         Do While CompareValues(arr(j), pivot) > 0
//!             j = j - 1
//!         Loop
//!         
//!         If i <= j Then
//!             temp = arr(i)
//!             arr(i) = arr(j)
//!             arr(j) = temp
//!             i = i + 1
//!             j = j - 1
//!         End If
//!     Loop
//!     
//!     ' Recursive calls
//!     If leftIndex < j Then QuickSort arr, leftIndex, j
//!     If i < rightIndex Then QuickSort arr, i, rightIndex
//! End Sub
//!
//! Private Function CompareValues(str1 As String, str2 As String) As Integer
//!     CompareValues = StrComp(str1, str2, m_CompareMode) * m_SortOrder
//! End Function
//!
//! Public Function IsSorted(arr() As String) As Boolean
//!     Dim i As Long
//!     
//!     For i = LBound(arr) To UBound(arr) - 1
//!         If CompareValues(arr(i), arr(i + 1)) > 0 Then
//!             IsSorted = False
//!             Exit Function
//!         End If
//!     Next i
//!     
//!     IsSorted = True
//! End Function
//! ```
//!
//! ### Example 2: Dictionary with Case-Insensitive Keys
//! ```vb6
//! ' Class: CaseInsensitiveDictionary
//! ' Dictionary that treats keys as case-insensitive
//! Option Explicit
//!
//! Private m_Keys() As String
//! Private m_Values() As Variant
//! Private m_Count As Long
//!
//! Public Sub Initialize()
//!     m_Count = 0
//!     ReDim m_Keys(0 To 9)
//!     ReDim m_Values(0 To 9)
//! End Sub
//!
//! Public Sub Add(key As String, value As Variant)
//!     Dim index As Long
//!     
//!     ' Check if key already exists
//!     index = FindKey(key)
//!     If index >= 0 Then
//!         Err.Raise 457, , "Key already exists"
//!     End If
//!     
//!     ' Resize if necessary
//!     If m_Count > UBound(m_Keys) Then
//!         ReDim Preserve m_Keys(0 To UBound(m_Keys) * 2 + 1)
//!         ReDim Preserve m_Values(0 To UBound(m_Values) * 2 + 1)
//!     End If
//!     
//!     ' Add new item
//!     m_Keys(m_Count) = key
//!     If IsObject(value) Then
//!         Set m_Values(m_Count) = value
//!     Else
//!         m_Values(m_Count) = value
//!     End If
//!     m_Count = m_Count + 1
//! End Sub
//!
//! Public Function Item(key As String) As Variant
//!     Dim index As Long
//!     index = FindKey(key)
//!     
//!     If index < 0 Then
//!         Err.Raise 5, , "Key not found"
//!     End If
//!     
//!     If IsObject(m_Values(index)) Then
//!         Set Item = m_Values(index)
//!     Else
//!         Item = m_Values(index)
//!     End If
//! End Function
//!
//! Public Function Exists(key As String) As Boolean
//!     Exists = (FindKey(key) >= 0)
//! End Function
//!
//! Private Function FindKey(key As String) As Long
//!     Dim i As Long
//!     
//!     For i = 0 To m_Count - 1
//!         If StrComp(m_Keys(i), key, vbTextCompare) = 0 Then
//!             FindKey = i
//!             Exit Function
//!         End If
//!     Next i
//!     
//!     FindKey = -1
//! End Function
//!
//! Public Property Get Count() As Long
//!     Count = m_Count
//! End Property
//! ```
//!
//! ### Example 3: String Matcher Module
//! ```vb6
//! ' Module: StringMatcher
//! ' Advanced string matching and searching utilities
//! Option Explicit
//!
//! Public Function FindAllMatches(arr() As String, searchValue As String, _
//!                                caseInsensitive As Boolean) As Long()
//!     Dim matches() As Long
//!     Dim matchCount As Long
//!     Dim i As Long
//!     Dim compareMode As VbCompareMethod
//!     
//!     compareMode = IIf(caseInsensitive, vbTextCompare, vbBinaryCompare)
//!     matchCount = 0
//!     ReDim matches(0 To UBound(arr) - LBound(arr))
//!     
//!     For i = LBound(arr) To UBound(arr)
//!         If StrComp(arr(i), searchValue, compareMode) = 0 Then
//!             matches(matchCount) = i
//!             matchCount = matchCount + 1
//!         End If
//!     Next i
//!     
//!     ' Resize to actual count
//!     If matchCount > 0 Then
//!         ReDim Preserve matches(0 To matchCount - 1)
//!     Else
//!         ReDim matches(0 To -1)  ' Empty array
//!     End If
//!     
//!     FindAllMatches = matches
//! End Function
//!
//! Public Function GetUniqueValues(arr() As String, caseInsensitive As Boolean) As String()
//!     Dim unique() As String
//!     Dim uniqueCount As Long
//!     Dim i As Long
//!     Dim j As Long
//!     Dim found As Boolean
//!     Dim compareMode As VbCompareMethod
//!     
//!     compareMode = IIf(caseInsensitive, vbTextCompare, vbBinaryCompare)
//!     uniqueCount = 0
//!     ReDim unique(0 To UBound(arr) - LBound(arr))
//!     
//!     For i = LBound(arr) To UBound(arr)
//!         found = False
//!         For j = 0 To uniqueCount - 1
//!             If StrComp(arr(i), unique(j), compareMode) = 0 Then
//!                 found = True
//!                 Exit For
//!             End If
//!         Next j
//!         
//!         If Not found Then
//!             unique(uniqueCount) = arr(i)
//!             uniqueCount = uniqueCount + 1
//!         End If
//!     Next i
//!     
//!     ' Resize to actual count
//!     If uniqueCount > 0 Then
//!         ReDim Preserve unique(0 To uniqueCount - 1)
//!     Else
//!         ReDim unique(0 To -1)
//!     End If
//!     
//!     GetUniqueValues = unique
//! End Function
//!
//! Public Function CompareArrays(arr1() As String, arr2() As String, _
//!                               caseInsensitive As Boolean) As Boolean
//!     Dim i As Long
//!     Dim compareMode As VbCompareMethod
//!     
//!     ' Check bounds
//!     If UBound(arr1) - LBound(arr1) <> UBound(arr2) - LBound(arr2) Then
//!         CompareArrays = False
//!         Exit Function
//!     End If
//!     
//!     compareMode = IIf(caseInsensitive, vbTextCompare, vbBinaryCompare)
//!     
//!     ' Compare elements
//!     For i = 0 To UBound(arr1) - LBound(arr1)
//!         If StrComp(arr1(LBound(arr1) + i), arr2(LBound(arr2) + i), compareMode) <> 0 Then
//!             CompareArrays = False
//!             Exit Function
//!         End If
//!     Next i
//!     
//!     CompareArrays = True
//! End Function
//!
//! Public Function CountOccurrences(arr() As String, searchValue As String, _
//!                                  caseInsensitive As Boolean) As Long
//!     Dim i As Long
//!     Dim count As Long
//!     Dim compareMode As VbCompareMethod
//!     
//!     compareMode = IIf(caseInsensitive, vbTextCompare, vbBinaryCompare)
//!     count = 0
//!     
//!     For i = LBound(arr) To UBound(arr)
//!         If StrComp(arr(i), searchValue, compareMode) = 0 Then
//!             count = count + 1
//!         End If
//!     Next i
//!     
//!     CountOccurrences = count
//! End Function
//! ```
//!
//! ### Example 4: Validation Helper Class
//! ```vb6
//! ' Class: StringValidator
//! ' Provides string validation with comparison options
//! Option Explicit
//!
//! Private m_ValidValues As Collection
//! Private m_CaseInsensitive As Boolean
//!
//! Public Sub Initialize(caseInsensitive As Boolean)
//!     Set m_ValidValues = New Collection
//!     m_CaseInsensitive = caseInsensitive
//! End Sub
//!
//! Public Sub AddValidValue(value As String)
//!     ' Check for duplicates
//!     If Not IsValid(value) Then
//!         m_ValidValues.Add value
//!     End If
//! End Sub
//!
//! Public Function IsValid(value As String) As Boolean
//!     Dim item As Variant
//!     Dim compareMode As VbCompareMethod
//!     
//!     compareMode = IIf(m_CaseInsensitive, vbTextCompare, vbBinaryCompare)
//!     
//!     For Each item In m_ValidValues
//!         If StrComp(CStr(item), value, compareMode) = 0 Then
//!             IsValid = True
//!             Exit Function
//!         End If
//!     Next item
//!     
//!     IsValid = False
//! End Function
//!
//! Public Function GetClosestMatch(value As String) As String
//!     Dim item As Variant
//!     Dim minDistance As Long
//!     Dim distance As Long
//!     Dim closest As String
//!     
//!     minDistance = 999999
//!     
//!     For Each item In m_ValidValues
//!         distance = GetEditDistance(value, CStr(item))
//!         If distance < minDistance Then
//!             minDistance = distance
//!             closest = CStr(item)
//!         End If
//!     Next item
//!     
//!     GetClosestMatch = closest
//! End Function
//!
//! Private Function GetEditDistance(str1 As String, str2 As String) As Long
//!     ' Simple implementation - just return length difference
//!     GetEditDistance = Abs(Len(str1) - Len(str2))
//! End Function
//!
//! Public Sub Clear()
//!     Set m_ValidValues = New Collection
//! End Sub
//!
//! Public Property Get Count() As Long
//!     Count = m_ValidValues.Count
//! End Property
//! ```
//!
//! ## Error Handling
//! The `StrComp` function does not raise errors under normal circumstances. However:
//!
//! - Returns `Null` if either string argument is `Null` (not an error)
//! - **Error 13 (Type mismatch)**: If arguments cannot be converted to strings
//! - **Error 5 (Invalid procedure call)**: If `compare` argument is not 0, 1, or 2
//!
//! ## Performance Notes
//! - **Binary comparison** is faster than text comparison
//! - Very fast for short strings (< 100 characters)
//! - Performance scales linearly with string length
//! - Text comparison requires case folding, adding overhead
//! - Consider using `=` operator if simple equality check suffices
//! - Cache comparison mode constant if used repeatedly in loops
//!
//! ## Best Practices
//! 1. **Use vbTextCompare constants** instead of numeric values (0, 1, 2) for clarity
//! 2. **Set Option Compare** at module level for consistent default behavior
//! 3. **Handle Null values** explicitly with `IsNull` check when dealing with Variants
//! 4. **Choose appropriate mode**: Use binary for exact matching, text for user-facing comparisons
//! 5. **Cache compare mode** in variables when using the same mode repeatedly
//! 6. **Use return value properly**: Remember -1, 0, 1 (not True/False)
//! 7. **Consider = operator** for simple equality checks (may be optimized better)
//! 8. **Document comparison mode** in function signatures and comments
//! 9. **Test edge cases**: Empty strings, Null values, Unicode characters
//! 10. **Use for sorting**: `StrComp` is ideal for custom sort implementations
//!
//! ## Comparison Table
//!
//! | Function | Returns | Case-Sensitive | Ordering | Null Handling |
//! |----------|---------|----------------|----------|---------------|
//! | `StrComp` | -1/0/1 | Configurable | Yes | Returns Null |
//! | `=` operator | Boolean | Per Option Compare | No | Error if Null |
//! | `InStr` | Position | Configurable | No | Returns Null |
//! | `Like` | Boolean | Per Option Compare | No | False if Null |
//!
//! ## Platform Notes
//! - Available in VB6, VBA, and `VBScript`
//! - Behavior consistent across platforms
//! - `vbDatabaseCompare` only meaningful in Microsoft Access
//! - Unicode comparison works correctly with international characters
//! - Option Compare affects default behavior differently in VBA vs VB6
//!
//! ## Limitations
//! - No support for locale-specific collation beyond text/binary
//! - Cannot specify custom comparison rules
//! - `vbDatabaseCompare` mode rarely useful outside Access
//! - Null handling returns Null rather than error (can be unexpected)
//! - No indication of *where* strings differ, only that they do
//! - Cannot compare string arrays directly (must loop)
//! - No natural sort support (e.g., "file2.txt" vs "file10.txt")

#[cfg(test)]
mod tests {
    use crate::*;

    #[test]
    fn strcomp_basic() {
        let source = r#"
Sub Test()
    result = StrComp("ABC", "abc", vbBinaryCompare)
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_variable_assignment() {
        let source = r"
Sub Test()
    Dim result As Integer
    result = StrComp(str1, str2)
End Sub
";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_text_compare() {
        let source = r"
Sub Test()
    result = StrComp(name1, name2, vbTextCompare)
End Sub
";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_if_statement() {
        let source = r#"
Sub Test()
    If StrComp(str1, str2, vbTextCompare) = 0 Then
        MsgBox "Equal"
    End If
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_select_case() {
        let source = r#"
Sub Test()
    Select Case StrComp(str1, str2)
        Case -1
            MsgBox "Less than"
        Case 0
            MsgBox "Equal"
        Case 1
            MsgBox "Greater than"
    End Select
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_for_loop() {
        let source = r"
Sub Test()
    For i = LBound(arr) To UBound(arr)
        If StrComp(arr(i), searchValue, vbTextCompare) = 0 Then
            Exit For
        End If
    Next i
End Sub
";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_function_return() {
        let source = r"
Function Compare(s1 As String, s2 As String) As Integer
    Compare = StrComp(s1, s2, vbTextCompare)
End Function
";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_do_while() {
        let source = r"
Sub Test()
    Do While StrComp(current, target, vbTextCompare) <> 0
        current = GetNext()
    Loop
End Sub
";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_sorting() {
        let source = r"
Sub Test()
    If StrComp(arr(i), arr(j), vbTextCompare) > 0 Then
        temp = arr(i)
        arr(i) = arr(j)
        arr(j) = temp
    End If
End Sub
";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_comparison() {
        let source = r"
Sub Test()
    Dim isLess As Boolean
    isLess = (StrComp(str1, str2) < 0)
End Sub
";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_function_argument() {
        let source = r"
Sub Test()
    Call ProcessResult(StrComp(a, b, vbTextCompare))
End Sub
";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_iif() {
        let source = r#"
Sub Test()
    result = IIf(StrComp(str1, str2, vbTextCompare) = 0, "Same", "Different")
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_array_search() {
        let source = r"
Sub Test()
    For Each item In collection
        If StrComp(item, searchTerm, vbTextCompare) = 0 Then
            found = True
        End If
    Next
End Sub
";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_binary_compare() {
        let source = r#"
Sub Test()
    result = StrComp("Test", "test", vbBinaryCompare)
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_while_wend() {
        let source = r"
Sub Test()
    While StrComp(str1, str2, vbTextCompare) <> 0
        str1 = Modify(str1)
    Wend
End Sub
";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_do_until() {
        let source = r"
Sub Test()
    Do Until StrComp(input, expected, vbTextCompare) = 0
        input = GetInput()
    Loop
End Sub
";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_with_statement() {
        let source = r"
Sub Test()
    With obj
        If StrComp(.Name, targetName, vbTextCompare) = 0 Then
            found = True
        End If
    End With
End Sub
";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_parentheses() {
        let source = r"
Sub Test()
    result = (StrComp(str1, str2, vbTextCompare) = 0)
End Sub
";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_error_handling() {
        let source = r"
Sub Test()
    On Error Resume Next
    result = StrComp(var1, var2, vbTextCompare)
    If Err.Number <> 0 Then
        result = -999
    End If
End Sub
";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_property_access() {
        let source = r#"
Sub Test()
    If StrComp(obj.Name, "Test", vbTextCompare) = 0 Then
        MsgBox "Found"
    End If
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_msgbox() {
        let source = r#"
Sub Test()
    MsgBox "Result: " & StrComp(str1, str2, vbTextCompare)
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_debug_print() {
        let source = r"
Sub Test()
    Debug.Print StrComp(value1, value2)
End Sub
";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_elseif() {
        let source = r#"
Sub Test()
    If StrComp(str1, str2, vbTextCompare) < 0 Then
        result = "Less"
    ElseIf StrComp(str1, str2, vbTextCompare) = 0 Then
        result = "Equal"
    Else
        result = "Greater"
    End If
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_class_method() {
        let source = r"
Sub Test()
    Set obj = New StringComparer
    obj.Compare str1, str2
End Sub
";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_binary_search() {
        let source = r"
Function BinarySearch() As Integer
    compareResult = StrComp(arr(mid), searchValue, vbTextCompare)
    If compareResult = 0 Then
        BinarySearch = mid
    End If
End Function
";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_case_insensitive_equals() {
        let source = r"
Function EqualsIgnoreCase(s1 As String, s2 As String) As Boolean
    EqualsIgnoreCase = (StrComp(s1, s2, vbTextCompare) = 0)
End Function
";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn strcomp_numeric_constant() {
        let source = r"
Sub Test()
    result = StrComp(str1, str2, 1)
End Sub
";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings
            .set_snapshot_path("../../../../../snapshots/syntax/library/functions/string/strcomp");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }
}