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
//! # `LCase$` Function
//!
//! Returns a `String` that has been converted to lowercase.
//! The "$" suffix indicates this function returns a `String` type.
//!
//! ## Syntax
//!
//! ```vb
//! LCase$(string)
//! ```
//!
//! ## Parameters
//!
//! - **string**: Required. Any valid string expression. If `string` contains `Null`, `Null` is returned.
//!
//! ## Returns
//!
//! Returns a `String` with all uppercase letters converted to lowercase. Numbers and punctuation
//! are unchanged.
//!
//! ## Remarks
//!
//! - `LCase$` converts all uppercase letters in a string to lowercase.
//! - The "$" suffix explicitly indicates the function returns a `String` type rather than a `Variant`.
//! - Only uppercase letters (A-Z) are affected; lowercase letters and non-alphabetic characters remain unchanged.
//! - `LCase$` is functionally equivalent to `LCase`, but `LCase$` returns a `String` while `LCase` can return a `Variant`.
//! - For better performance when you know the result is a string, use `LCase$`.
//! - If the argument is `Null`, the function returns `Null`.
//! - The conversion is based on the system locale settings.
//! - For international characters, the behavior depends on the current code page.
//! - The inverse function is `UCase$`, which converts strings to uppercase.
//! - Common use cases include case-insensitive comparisons and normalizing user input.
//!
//! ## Typical Uses
//!
//! 1. **Case-insensitive comparisons** - Compare strings without regard to case
//! 2. **User input normalization** - Convert user input to a consistent case
//! 3. **Email address handling** - Normalize email addresses to lowercase
//! 4. **File path comparisons** - Compare file paths on case-insensitive file systems
//! 5. **Username validation** - Normalize usernames to lowercase
//! 6. **Search operations** - Perform case-insensitive searches
//! 7. **Data standardization** - Ensure consistent casing in databases
//!
//! ## Basic Examples
//!
//! ```vb
//! ' Example 1: Simple conversion
//! Dim result As String
//! result = LCase$("HELLO")  ' Returns "hello"
//! ```
//!
//! ```vb
//! ' Example 2: Mixed case
//! Dim text As String
//! text = LCase$("Hello World")  ' Returns "hello world"
//! ```
//!
//! ```vb
//! ' Example 3: With numbers and punctuation
//! Dim mixed As String
//! mixed = LCase$("ABC123!@#")  ' Returns "abc123!@#"
//! ```
//!
//! ```vb
//! ' Example 4: Already lowercase
//! Dim lower As String
//! lower = LCase$("already lowercase")  ' Returns "already lowercase"
//! ```
//!
//! ## Common Patterns
//!
//! ### Case-Insensitive Comparison
//! ```vb
//! Function CompareIgnoreCase(str1 As String, str2 As String) As Boolean
//!     CompareIgnoreCase = (LCase$(str1) = LCase$(str2))
//! End Function
//! ```
//!
//! ### Normalize User Input
//! ```vb
//! Function NormalizeInput(userInput As String) As String
//!     NormalizeInput = Trim$(LCase$(userInput))
//! End Function
//! ```
//!
//! ### Email Address Normalization
//! ```vb
//! Function NormalizeEmail(email As String) As String
//!     NormalizeEmail = LCase$(Trim$(email))
//! End Function
//! ```
//!
//! ### Case-Insensitive Search
//! ```vb
//! Function ContainsIgnoreCase(text As String, searchFor As String) As Boolean
//!     ContainsIgnoreCase = (InStr(LCase$(text), LCase$(searchFor)) > 0)
//! End Function
//! ```
//!
//! ### Username Validation
//! ```vb
//! Function ValidateUsername(username As String) As String
//!     ' Normalize to lowercase
//!     ValidateUsername = LCase$(Trim$(username))
//! End Function
//! ```
//!
//! ### File Extension Check
//! ```vb
//! Function HasExtension(filename As String, ext As String) As Boolean
//!     Dim fileExt As String
//!     fileExt = LCase$(Right$(filename, Len(ext)))
//!     HasExtension = (fileExt = LCase$(ext))
//! End Function
//! ```
//!
//! ### Dictionary Key Normalization
//! ```vb
//! Sub AddToDictionary(dict As Object, key As String, value As Variant)
//!     dict.Add LCase$(key), value
//! End Sub
//! ```
//!
//! ### Case-Insensitive Replace
//! ```vb
//! Function ReplaceIgnoreCase(text As String, findText As String, replaceWith As String) As String
//!     Dim lowerText As String
//!     Dim lowerFind As String
//!     Dim pos As Long
//!     
//!     lowerText = LCase$(text)
//!     lowerFind = LCase$(findText)
//!     pos = InStr(lowerText, lowerFind)
//!     
//!     If pos > 0 Then
//!         ReplaceIgnoreCase = Left$(text, pos - 1) & replaceWith & Mid$(text, pos + Len(findText))
//!     Else
//!         ReplaceIgnoreCase = text
//!     End If
//! End Function
//! ```
//!
//! ### Sort Key Generation
//! ```vb
//! Function GenerateSortKey(text As String) As String
//!     GenerateSortKey = LCase$(Trim$(text))
//! End Function
//! ```
//!
//! ### Command Parser
//! ```vb
//! Function ParseCommand(input As String) As String
//!     Dim cmd As String
//!     cmd = LCase$(Trim$(input))
//!     
//!     Select Case cmd
//!         Case "help"
//!             ParseCommand = "ShowHelp"
//!         Case "exit", "quit"
//!             ParseCommand = "Exit"
//!         Case Else
//!             ParseCommand = "Unknown"
//!     End Select
//! End Function
//! ```
//!
//! ## Advanced Examples
//!
//! ### Case-Insensitive Collection Lookup
//! ```vb
//! Function FindInCollection(col As Collection, key As String) As Variant
//!     On Error Resume Next
//!     Dim lowerKey As String
//!     Dim item As Variant
//!     Dim i As Long
//!     
//!     lowerKey = LCase$(key)
//!     
//!     ' Try direct lookup first
//!     FindInCollection = col(lowerKey)
//!     
//!     If Err.Number <> 0 Then
//!         ' Not found, search manually
//!         Err.Clear
//!         For i = 1 To col.Count
//!             If LCase$(col(i)) = lowerKey Then
//!                 FindInCollection = col(i)
//!                 Exit Function
//!             End If
//!         Next i
//!     End If
//! End Function
//! ```
//!
//! ### SQL Query Builder
//! ```vb
//! Function BuildWhereClause(fieldName As String, operator As String, value As String) As String
//!     Dim op As String
//!     op = LCase$(Trim$(operator))
//!     
//!     Select Case op
//!         Case "equals", "="
//!             BuildWhereClause = fieldName & " = '" & value & "'"
//!         Case "contains", "like"
//!             BuildWhereClause = fieldName & " LIKE '%" & value & "%'"
//!         Case "startswith"
//!             BuildWhereClause = fieldName & " LIKE '" & value & "%'"
//!         Case Else
//!             BuildWhereClause = ""
//!     End Select
//! End Function
//! ```
//!
//! ### Configuration File Parser
//! ```vb
//! Function ParseConfigLine(line As String, ByRef key As String, ByRef value As String) As Boolean
//!     Dim pos As Long
//!     Dim trimmedLine As String
//!     
//!     trimmedLine = Trim$(line)
//!     
//!     ' Skip comments and empty lines
//!     If Len(trimmedLine) = 0 Or Left$(trimmedLine, 1) = "#" Then
//!         ParseConfigLine = False
//!         Exit Function
//!     End If
//!     
//!     pos = InStr(trimmedLine, "=")
//!     If pos > 0 Then
//!         key = LCase$(Trim$(Left$(trimmedLine, pos - 1)))
//!         value = Trim$(Mid$(trimmedLine, pos + 1))
//!         ParseConfigLine = True
//!     Else
//!         ParseConfigLine = False
//!     End If
//! End Function
//! ```
//!
//! ### Smart String Comparison
//! ```vb
//! Function SmartCompare(str1 As String, str2 As String, caseSensitive As Boolean) As Boolean
//!     If caseSensitive Then
//!         SmartCompare = (str1 = str2)
//!     Else
//!         SmartCompare = (LCase$(str1) = LCase$(str2))
//!     End If
//! End Function
//! ```
//!
//! ## Error Handling
//!
//! ```vb
//! Function SafeLCase(text As String) As String
//!     On Error GoTo ErrorHandler
//!     
//!     If IsNull(text) Then
//!         SafeLCase = ""
//!         Exit Function
//!     End If
//!     
//!     SafeLCase = LCase$(text)
//!     Exit Function
//!     
//! ErrorHandler:
//!     SafeLCase = ""
//! End Function
//! ```
//!
//! ## Performance Notes
//!
//! - `LCase$` is a fast operation with minimal overhead
//! - For large strings, the performance is linear with string length
//! - `LCase$` (returns `String`) is slightly faster than `LCase` (returns `Variant`)
//! - When comparing strings, convert both once rather than repeatedly
//! - Consider caching lowercase versions of frequently compared strings
//! - For very large datasets, consider using database-level case-insensitive comparisons
//!
//! ## Best Practices
//!
//! 1. **Use for comparisons** - Always normalize case when doing case-insensitive comparisons
//! 2. **Prefer `LCase$` over `LCase`** - Use `LCase$` when you know the result is a string
//! 3. **Cache results** - Store lowercase versions rather than converting repeatedly
//! 4. **Handle Null** - Check for `Null` values before calling `LCase$`
//! 5. **Combine with Trim** - Often useful to combine `LCase$` with `Trim$` for user input
//! 6. **Document intent** - Make it clear when lowercase conversion is for comparison vs. display
//! 7. **Consider locale** - Be aware that conversion may vary by system locale
//!
//! ## Comparison with Related Functions
//!
//! | Function | Return Type | Conversion | Use Case |
//! |----------|-------------|------------|----------|
//! | `LCase` | `Variant` | To lowercase | When working with `Variant` types |
//! | `LCase$` | `String` | To lowercase | When result is definitely a string |
//! | `UCase` | `Variant` | To uppercase | Convert to uppercase (`Variant`) |
//! | `UCase$` | `String` | To uppercase | Convert to uppercase (`String`) |
//! | `StrConv` | `String` | Various conversions | Complex case conversions |
//!
//! ## Common Use Cases
//!
//! ### Case-Insensitive String Arrays
//!
//! ```vb
//! Function ArrayContains(arr() As String, value As String) As Boolean
//!     Dim i As Long
//!     Dim lowerValue As String
//!     
//!     lowerValue = LCase$(value)
//!     
//!     For i = LBound(arr) To UBound(arr)
//!         If LCase$(arr(i)) = lowerValue Then
//!             ArrayContains = True
//!             Exit Function
//!         End If
//!     Next i
//!     
//!     ArrayContains = False
//! End Function
//! ```
//!
//! ### URL Parameter Parsing
//!
//! ```vb
//! Function GetURLParameter(url As String, paramName As String) As String
//!     Dim lowerURL As String
//!     Dim lowerParam As String
//!     Dim startPos As Long
//!     Dim endPos As Long
//!     
//!     lowerURL = LCase$(url)
//!     lowerParam = LCase$(paramName) & "="
//!     
//!     startPos = InStr(lowerURL, lowerParam)
//!     If startPos > 0 Then
//!         startPos = startPos + Len(lowerParam)
//!         endPos = InStr(startPos, url, "&")
//!         If endPos = 0 Then endPos = Len(url) + 1
//!         GetURLParameter = Mid$(url, startPos, endPos - startPos)
//!     End If
//! End Function
//! ```
//!
//! ## Platform Notes
//!
//! - On Windows, `LCase$` respects the system locale for character conversion
//! - Behavior may vary for extended ASCII and international characters
//! - For ASCII characters (A-Z), behavior is consistent across all platforms
//! - Some characters may convert differently depending on the active code page
//! - Modern Windows systems handle Unicode characters in `LCase$` operations
//!
//! ## Limitations
//!
//! - Conversion is based on system locale; may not work as expected for all Unicode characters
//! - Returns `Null` if the input is `Null` (unlike some other string functions that error)
//! - Does not handle advanced Unicode normalization or case folding
//! - For true Unicode case folding, more sophisticated methods may be needed
//! - Some special characters (like German ß) may not convert in all locales

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

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

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

    #[test]
    fn lcase_dollar_with_numbers() {
        let source = r#"
Sub Test()
    mixed = LCase$("ABC123")
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/lcase_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn lcase_dollar_compare_function() {
        let source = r"
Function CompareIgnoreCase(str1 As String, str2 As String) As Boolean
    CompareIgnoreCase = (LCase$(str1) = LCase$(str2))
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/lcase_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn lcase_dollar_normalize_input() {
        let source = r"
Function NormalizeInput(userInput As String) As String
    NormalizeInput = Trim$(LCase$(userInput))
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/lcase_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn lcase_dollar_email_normalization() {
        let source = r"
Function NormalizeEmail(email As String) As String
    NormalizeEmail = LCase$(Trim$(email))
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/lcase_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn lcase_dollar_search() {
        let source = r"
Function ContainsIgnoreCase(text As String, searchFor As String) As Boolean
    ContainsIgnoreCase = (InStr(LCase$(text), LCase$(searchFor)) > 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/lcase_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn lcase_dollar_username_validation() {
        let source = r"
Function ValidateUsername(username As String) As String
    ValidateUsername = LCase$(Trim$(username))
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/lcase_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn lcase_dollar_file_extension() {
        let source = r"
Function HasExtension(filename As String, ext As String) As Boolean
    Dim fileExt As String
    fileExt = LCase$(Right$(filename, Len(ext)))
    HasExtension = (fileExt = LCase$(ext))
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/lcase_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn lcase_dollar_dictionary_key() {
        let source = r"
Sub AddToDictionary(dict As Object, key As String, value As Variant)
    lowercaseKey = LCase$(key)
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/lcase_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn lcase_dollar_command_parser() {
        let source = r"
Function ParseCommand(input As String) As String
    Dim cmd As String
    cmd = LCase$(Trim$(input))
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/lcase_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn lcase_dollar_collection_lookup() {
        let source = r"
Function FindInCollection(col As Collection, key As String) As Variant
    Dim lowerKey As String
    lowerKey = LCase$(key)
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/lcase_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn lcase_dollar_sql_builder() {
        let source = r"
Function BuildWhereClause(fieldName As String, operator As String) As String
    Dim op As String
    op = LCase$(Trim$(operator))
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/lcase_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn lcase_dollar_config_parser() {
        let source = r"
Function ParseConfigLine(line As String, key As String) As Boolean
    key = LCase$(Trim$(Left$(line, 10)))
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/lcase_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn lcase_dollar_smart_compare() {
        let source = r"
Function SmartCompare(str1 As String, str2 As String, caseSensitive As Boolean) As Boolean
    If Not caseSensitive Then
        SmartCompare = (LCase$(str1) = LCase$(str2))
    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/lcase_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

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

    #[test]
    fn lcase_dollar_array_contains() {
        let source = r"
Function ArrayContains(arr() As String, value As String) As Boolean
    Dim lowerValue As String
    lowerValue = LCase$(value)
    If LCase$(arr(0)) = lowerValue Then
        ArrayContains = True
    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/lcase_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn lcase_dollar_url_parameter() {
        let source = r"
Function GetURLParameter(url As String, paramName As String) As String
    Dim lowerURL As String
    lowerURL = LCase$(url)
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/lcase_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn lcase_dollar_in_select() {
        let source = r#"
Sub Test()
    Select Case LCase$(command)
        Case "help"
            ShowHelp
        Case "exit"
            ExitApp
    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/lcase_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

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