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
//! VB6 `UCase` Function
//!
//! The `UCase` function returns a String that has been converted to uppercase.
//!
//! ## Syntax
//! ```vb6
//! UCase(string)
//! ```
//!
//! ## Parameters
//! - `string`: Required. Any valid string expression. If `string` contains Null, Null is returned.
//!
//! ## Returns
//! Returns a `Variant (String)` containing the specified string converted to uppercase. Only lowercase letters are converted to uppercase; all uppercase letters and non-letter characters remain unchanged.
//!
//! ## Remarks
//! The `UCase` function converts lowercase letters to uppercase:
//!
//! - **Case conversion**: Converts a-z to A-Z
//! - **Non-letters unchanged**: Numbers, punctuation, spaces, and symbols are not affected
//! - **Null handling**: Returns Null if the argument is Null
//! - **Empty string**: Returns empty string if argument is empty
//! - **Locale-aware**: Conversion respects current locale settings for international characters
//! - **Unicode support**: Handles Unicode characters according to locale
//! - **Already uppercase**: Characters already uppercase are unchanged
//! - **String variant**: `UCase`$ variant returns String instead of Variant
//!
//! ### `UCase` vs `UCase`$
//! - `UCase`: Returns Variant (String) - can handle and return Null
//! - `UCase$`: Returns String - generates error if argument is Null
//! - Best practice: Use `UCase$` when you know the string is not Null for slightly better performance
//!
//! ### Locale Considerations
//! - Conversion is locale-aware for international characters
//! - Turkish İ (dotted I) and ı (dotless i) handled per locale
//! - German ß (eszett) may convert to SS in some contexts
//! - Accented characters (é, ñ, ü, etc.) convert to uppercase equivalents
//!
//! ## Typical Uses
//! 1. **Case-Insensitive Comparison**: Normalize strings before comparison
//! 2. **User Input Normalization**: Convert user input to consistent case
//! 3. **Data Validation**: Standardize data before validation or storage
//! 4. **Display Formatting**: Format text for display purposes (headings, labels)
//! 5. **String Matching**: Prepare strings for case-insensitive searches
//! 6. **Database Queries**: Normalize search terms
//! 7. **File Processing**: Standardize file names or extensions
//! 8. **Code Generation**: Create uppercase identifiers or constants
//!
//! ## Basic Examples
//!
//! ### Example 1: Simple Conversion
//! ```vb6
//! Dim result As String
//!
//! result = UCase("Hello World")
//! ' result = "HELLO WORLD"
//!
//! result = UCase("abc123xyz")
//! ' result = "ABC123XYZ"
//!
//! result = UCase("ALREADY UPPERCASE")
//! ' result = "ALREADY UPPERCASE"
//! ```
//!
//! ### Example 2: Case-Insensitive Comparison
//! ```vb6
//! Function EqualsIgnoreCase(str1 As String, str2 As String) As Boolean
//!     EqualsIgnoreCase = (UCase$(str1) = UCase$(str2))
//! End Function
//!
//! ' Usage:
//! If EqualsIgnoreCase(userInput, "YES") Then
//!     ProcessConfirmation
//! End If
//! ```
//!
//! ### Example 3: Normalize User Input
//! ```vb6
//! Sub ProcessCommand(command As String)
//!     Select Case UCase$(Trim$(command))
//!         Case "SAVE"
//!             SaveData
//!         Case "LOAD"
//!             LoadData
//!         Case "EXIT"
//!             CloseApplication
//!         Case Else
//!             MsgBox "Unknown command"
//!     End Select
//! End Sub
//! ```
//!
//! ### Example 4: File Extension Check
//! ```vb6
//! Function IsImageFile(fileName As String) As Boolean
//!     Dim ext As String
//!     ext = UCase$(Right$(fileName, 4))
//!     
//!     IsImageFile = (ext = ".JPG" Or ext = ".PNG" Or ext = ".GIF" Or ext = ".BMP")
//! End Function
//! ```
//!
//! ## Common Patterns
//!
//! ### Pattern 1: Case-Insensitive String Comparison
//! ```vb6
//! Function CompareIgnoreCase(str1 As String, str2 As String) As Boolean
//!     CompareIgnoreCase = (UCase$(str1) = UCase$(str2))
//! End Function
//! ```
//!
//! ### Pattern 2: Normalize Database Input
//! ```vb6
//! Function NormalizeForDatabase(value As String) As String
//!     NormalizeForDatabase = UCase$(Trim$(value))
//! End Function
//! ```
//!
//! ### Pattern 3: Case-Insensitive Contains
//! ```vb6
//! Function ContainsIgnoreCase(source As String, searchTerm As String) As Boolean
//!     ContainsIgnoreCase = (InStr(UCase$(source), UCase$(searchTerm)) > 0)
//! End Function
//! ```
//!
//! ### Pattern 4: Validate Yes/No Response
//! ```vb6
//! Function IsYesResponse(response As String) As Boolean
//!     Dim normalized As String
//!     normalized = UCase$(Trim$(response))
//!     IsYesResponse = (normalized = "Y" Or normalized = "YES")
//! End Function
//! ```
//!
//! ### Pattern 5: Case-Insensitive `StartsWith`
//! ```vb6
//! Function StartsWithIgnoreCase(str As String, prefix As String) As Boolean
//!     StartsWithIgnoreCase = (UCase$(Left$(str, Len(prefix))) = UCase$(prefix))
//! End Function
//! ```
//!
//! ### Pattern 6: Format Heading Text
//! ```vb6
//! Function FormatHeading(text As String) As String
//!     FormatHeading = UCase$(text)
//! End Function
//! ```
//!
//! ### Pattern 7: Normalize Array Elements
//! ```vb6
//! Sub NormalizeArray(arr() As String)
//!     Dim i As Long
//!     For i = LBound(arr) To UBound(arr)
//!         arr(i) = UCase$(arr(i))
//!     Next i
//! End Sub
//! ```
//!
//! ### Pattern 8: Case-Insensitive Search in Array
//! ```vb6
//! Function FindInArray(arr() As String, searchValue As String) As Long
//!     Dim i As Long
//!     Dim searchUpper As String
//!     
//!     searchUpper = UCase$(searchValue)
//!     
//!     For i = LBound(arr) To UBound(arr)
//!         If UCase$(arr(i)) = searchUpper Then
//!             FindInArray = i
//!             Exit Function
//!         End If
//!     Next i
//!     
//!     FindInArray = -1 ' Not found
//! End Function
//! ```
//!
//! ### Pattern 9: Create Acronym
//! ```vb6
//! Function CreateAcronym(phrase As String) As String
//!     Dim words() As String
//!     Dim i As Integer
//!     Dim result As String
//!     
//!     words = Split(phrase, " ")
//!     result = ""
//!     
//!     For i = LBound(words) To UBound(words)
//!         If Len(words(i)) > 0 Then
//!             result = result & UCase$(Left$(words(i), 1))
//!         End If
//!     Next i
//!     
//!     CreateAcronym = result
//! End Function
//! ```
//!
//! ### Pattern 10: Safe Null-Handling Comparison
//! ```vb6
//! Function SafeCompareIgnoreCase(str1 As Variant, str2 As Variant) As Boolean
//!     If IsNull(str1) Or IsNull(str2) Then
//!         SafeCompareIgnoreCase = False
//!     Else
//!         SafeCompareIgnoreCase = (UCase(str1) = UCase(str2))
//!     End If
//! End Function
//! ```
//!
//! ## Advanced Usage
//!
//! ### Example 1: Case-Insensitive Dictionary Class
//! ```vb6
//! ' Class: CaseInsensitiveDictionary
//! ' Dictionary with case-insensitive key lookup
//! Option Explicit
//!
//! Private m_Items As Collection
//!
//! Private Sub Class_Initialize()
//!     Set m_Items = New Collection
//! End Sub
//!
//! Public Sub Add(key As String, value As Variant)
//!     On Error Resume Next
//!     
//!     If IsObject(value) Then
//!         m_Items.Add value, UCase$(key)
//!     Else
//!         m_Items.Add value, UCase$(key)
//!     End If
//!     
//!     If Err.Number <> 0 Then
//!         Err.Raise 457, , "Key already exists: " & key
//!     End If
//! End Sub
//!
//! Public Function Item(key As String) As Variant
//!     On Error Resume Next
//!     
//!     If IsObject(m_Items(UCase$(key))) Then
//!         Set Item = m_Items(UCase$(key))
//!     Else
//!         Item = m_Items(UCase$(key))
//!     End If
//!     
//!     If Err.Number <> 0 Then
//!         Err.Raise 5, , "Key not found: " & key
//!     End If
//! End Function
//!
//! Public Function Exists(key As String) As Boolean
//!     On Error Resume Next
//!     Dim test As Variant
//!     test = m_Items(UCase$(key))
//!     Exists = (Err.Number = 0)
//! End Function
//!
//! Public Sub Remove(key As String)
//!     On Error Resume Next
//!     m_Items.Remove UCase$(key)
//!     If Err.Number <> 0 Then
//!         Err.Raise 5, , "Key not found: " & key
//!     End If
//! End Sub
//!
//! Public Property Get Count() As Long
//!     Count = m_Items.Count
//! End Property
//! ```
//!
//! ### Example 2: String Comparison Utilities Module
//! ```vb6
//! ' Module: StringComparisonUtils
//! ' Case-insensitive string comparison utilities
//! Option Explicit
//!
//! Public Function EqualsIgnoreCase(str1 As String, str2 As String) As Boolean
//!     EqualsIgnoreCase = (UCase$(str1) = UCase$(str2))
//! End Function
//!
//! Public Function StartsWithIgnoreCase(str As String, prefix As String) As Boolean
//!     If Len(prefix) > Len(str) Then
//!         StartsWithIgnoreCase = False
//!     Else
//!         StartsWithIgnoreCase = (UCase$(Left$(str, Len(prefix))) = UCase$(prefix))
//!     End If
//! End Function
//!
//! Public Function EndsWithIgnoreCase(str As String, suffix As String) As Boolean
//!     If Len(suffix) > Len(str) Then
//!         EndsWithIgnoreCase = False
//!     Else
//!         EndsWithIgnoreCase = (UCase$(Right$(str, Len(suffix))) = UCase$(suffix))
//!     End If
//! End Function
//!
//! Public Function ContainsIgnoreCase(source As String, searchTerm As String) As Boolean
//!     ContainsIgnoreCase = (InStr(1, source, searchTerm, vbTextCompare) > 0)
//! End Function
//!
//! Public Function IndexOfIgnoreCase(source As String, searchTerm As String, _
//!                                  Optional startPos As Long = 1) As Long
//!     IndexOfIgnoreCase = InStr(startPos, source, searchTerm, vbTextCompare)
//! End Function
//!
//! Public Function ReplaceIgnoreCase(source As String, findText As String, _
//!                                  replaceText As String) As String
//!     ReplaceIgnoreCase = Replace(source, findText, replaceText, 1, -1, vbTextCompare)
//! End Function
//!
//! Public Function CompareIgnoreCase(str1 As String, str2 As String) As Integer
//!     If UCase$(str1) < UCase$(str2) Then
//!         CompareIgnoreCase = -1
//!     ElseIf UCase$(str1) > UCase$(str2) Then
//!         CompareIgnoreCase = 1
//!     Else
//!         CompareIgnoreCase = 0
//!     End If
//! End Function
//! ```
//!
//! ### Example 3: Text Normalizer Class
//! ```vb6
//! ' Class: TextNormalizer
//! ' Normalizes text for consistent processing
//! Option Explicit
//!
//! Public Enum NormalizationMode
//!     nmUpperCase = 0
//!     nmLowerCase = 1
//!     nmTrimmed = 2
//!     nmUpperCaseTrimmed = 3
//!     nmLowerCaseTrimmed = 4
//! End Enum
//!
//! Public Function Normalize(text As String, mode As NormalizationMode) As String
//!     Select Case mode
//!         Case nmUpperCase
//!             Normalize = UCase$(text)
//!         Case nmLowerCase
//!             Normalize = LCase$(text)
//!         Case nmTrimmed
//!             Normalize = Trim$(text)
//!         Case nmUpperCaseTrimmed
//!             Normalize = UCase$(Trim$(text))
//!         Case nmLowerCaseTrimmed
//!             Normalize = LCase$(Trim$(text))
//!         Case Else
//!             Normalize = text
//!     End Select
//! End Function
//!
//! Public Function NormalizeArray(arr() As String, mode As NormalizationMode) As String()
//!     Dim result() As String
//!     Dim i As Long
//!     
//!     ReDim result(LBound(arr) To UBound(arr))
//!     
//!     For i = LBound(arr) To UBound(arr)
//!         result(i) = Normalize(arr(i), mode)
//!     Next i
//!     
//!     NormalizeArray = result
//! End Function
//!
//! Public Function NormalizeForComparison(text As String) As String
//!     ' Remove extra spaces and convert to uppercase
//!     Dim temp As String
//!     temp = Trim$(text)
//!     
//!     ' Replace multiple spaces with single space
//!     Do While InStr(temp, "  ") > 0
//!         temp = Replace(temp, "  ", " ")
//!     Loop
//!     
//!     NormalizeForComparison = UCase$(temp)
//! End Function
//! ```
//!
//! ### Example 4: Command Parser Module
//! ```vb6
//! ' Module: CommandParser
//! ' Parses and processes user commands
//! Option Explicit
//!
//! Public Function ParseCommand(commandLine As String, command As String, _
//!                             arguments() As String) As Boolean
//!     Dim parts() As String
//!     Dim i As Integer
//!     
//!     commandLine = Trim$(commandLine)
//!     If Len(commandLine) = 0 Then
//!         ParseCommand = False
//!         Exit Function
//!     End If
//!     
//!     parts = Split(commandLine, " ")
//!     command = UCase$(parts(0))
//!     
//!     If UBound(parts) > 0 Then
//!         ReDim arguments(0 To UBound(parts) - 1)
//!         For i = 1 To UBound(parts)
//!             arguments(i - 1) = parts(i)
//!         Next i
//!     Else
//!         ReDim arguments(0 To -1) ' Empty array
//!     End If
//!     
//!     ParseCommand = True
//! End Function
//!
//! Public Function IsValidCommand(command As String, validCommands() As String) As Boolean
//!     Dim i As Long
//!     Dim cmdUpper As String
//!     
//!     cmdUpper = UCase$(command)
//!     
//!     For i = LBound(validCommands) To UBound(validCommands)
//!         If UCase$(validCommands(i)) = cmdUpper Then
//!             IsValidCommand = True
//!             Exit Function
//!         End If
//!     Next i
//!     
//!     IsValidCommand = False
//! End Function
//!
//! Public Function GetCommandHelp(command As String) As String
//!     Select Case UCase$(Trim$(command))
//!         Case "HELP"
//!             GetCommandHelp = "Displays help information"
//!         Case "SAVE"
//!             GetCommandHelp = "Saves the current document"
//!         Case "LOAD"
//!             GetCommandHelp = "Loads a document"
//!         Case "EXIT", "QUIT"
//!             GetCommandHelp = "Exits the application"
//!         Case Else
//!             GetCommandHelp = "Unknown command"
//!     End Select
//! End Function
//! ```
//!
//! ## Error Handling
//! The `UCase` function can raise the following errors:
//!
//! - **Error 13 (Type mismatch)**: If argument cannot be converted to a string
//! - **Error 94 (Invalid use of Null)**: When using `UCase$` (not `UCase`) with Null argument
//!
//! Note: `UCase` (without $) returns Null if passed Null, while `UCase$` raises an error.
//!
//! ## Performance Notes
//! - Very fast string operation
//! - Performance is linear O(n) with string length
//! - `UCase$` is slightly faster than `UCase` (returns String vs Variant)
//! - Consider caching result if used multiple times with same value
//! - No significant difference for short strings (< 100 characters)
//! - For large-scale comparisons, convert once and cache
//!
//! ## Best Practices
//! 1. **Use `UCase`$ when possible** for better performance and type safety
//! 2. **Cache conversions** when comparing the same string multiple times
//! 3. **Combine with Trim$** when normalizing user input
//! 4. **Handle Null explicitly** when using `UCase` (not `UCase`$)
//! 5. **Use `StrComp` for locale-aware comparison** instead of manual `UCase` conversion
//! 6. **Consider Option Compare Text** for case-insensitive operations in entire module
//! 7. **Document case-sensitivity** in function comments
//! 8. **Normalize early** in data processing pipeline
//! 9. **Use for display formatting** when uppercase is needed for UI
//! 10. **Avoid repeated conversion** in tight loops
//!
//! ## Comparison Table
//!
//! | Function | Conversion | Returns | Null Handling |
//! |----------|------------|---------|---------------|
//! | `UCase` | To uppercase | Variant (String) | Returns Null |
//! | `UCase$` | To uppercase | String | Error on Null |
//! | `LCase` | To lowercase | Variant (String) | Returns Null |
//! | `LCase$` | To lowercase | String | Error on Null |
//! | `StrConv` | Various | Variant | Configurable |
//!
//! ## Platform Notes
//! - Available in VB6, VBA, and `VBScript`
//! - Behavior consistent across platforms
//! - Locale-aware conversion for international characters
//! - Unicode support in VBA/VB6
//! - String length unchanged by conversion
//!
//! ## Limitations
//! - Cannot selectively convert parts of string (use Mid$ if needed)
//! - No way to specify locale explicitly (uses system locale)
//! - Cannot preserve original case information (one-way conversion)
//! - Does not handle special Unicode cases (e.g., title case)
//! - No built-in toggle case functionality
//! - Cannot convert specific character ranges

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

    #[test]
    fn ucase_basic() {
        let source = r#"
Sub Test()
    result = UCase("hello")
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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_variable_assignment() {
        let source = r"
Sub Test()
    Dim upper As String
    upper = UCase(text)
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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_dollar_sign() {
        let source = r"
Sub Test()
    result = UCase$(input)
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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_function_return() {
        let source = r"
Function NormalizeString(text As String) As String
    NormalizeString = UCase$(text)
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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_comparison() {
        let source = r"
Sub Test()
    If UCase$(str1) = UCase$(str2) Then
        Match
    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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_select_case() {
        let source = r#"
Sub Test()
    Select Case UCase$(command)
        Case "SAVE"
            SaveFile
        Case "LOAD"
            LoadFile
    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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_for_loop() {
        let source = r"
Sub Test()
    For i = 1 To 10
        items(i) = UCase$(items(i))
    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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_msgbox() {
        let source = r#"
Sub Test()
    MsgBox UCase("hello world")
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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_concatenation() {
        let source = r#"
Sub Test()
    message = "Name: " & UCase$(name)
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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_function_argument() {
        let source = r"
Sub Test()
    Call ProcessText(UCase$(input))
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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_array_assignment() {
        let source = r"
Sub Test()
    normalized(i) = UCase$(original(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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_debug_print() {
        let source = r#"
Sub Test()
    Debug.Print UCase$("testing")
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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_with_trim() {
        let source = r"
Sub Test()
    cleaned = UCase$(Trim$(rawInput))
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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_do_while() {
        let source = r#"
Sub Test()
    Do While UCase$(response) <> "QUIT"
        response = InputBox("Command:")
    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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_do_until() {
        let source = r#"
Sub Test()
    Do Until UCase$(answer) = "YES"
        answer = InputBox("Continue?")
    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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_while_wend() {
        let source = r#"
Sub Test()
    While UCase$(status) = "ACTIVE"
        Process
    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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_iif() {
        let source = r#"
Sub Test()
    category = IIf(UCase$(type) = "ADMIN", "Administrator", "User")
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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_with_statement() {
        let source = r"
Sub Test()
    With user
        .Name = UCase$(.Name)
    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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_parentheses() {
        let source = r"
Sub Test()
    result = (UCase$(text))
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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_error_handling() {
        let source = r#"
Sub Test()
    On Error Resume Next
    normalized = UCase(value)
    If Err.Number <> 0 Then
        normalized = ""
    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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_property_assignment() {
        let source = r"
Sub Test()
    obj.DisplayName = UCase$(obj.Name)
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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_instr() {
        let source = r"
Sub Test()
    pos = InStr(UCase$(text), UCase$(search))
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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_print_statement() {
        let source = r"
Sub Test()
    Print #1, UCase$(data)
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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_class_usage() {
        let source = r"
Sub Test()
    Set formatter = New TextFormatter
    formatter.Text = UCase$(inputText)
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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_elseif() {
        let source = r#"
Sub Test()
    If mode = 1 Then
        x = 1
    ElseIf UCase$(status) = "READY" Then
        x = 2
    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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_left_function() {
        let source = r"
Sub Test()
    initial = UCase$(Left$(name, 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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_right_function() {
        let source = r"
Sub Test()
    extension = UCase$(Right$(fileName, 4))
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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn ucase_switch() {
        let source = r#"
Sub Test()
    result = Switch(UCase$(type) = "A", 1, UCase$(type) = "B", 2, True, 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/ucase");
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }
}