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
//! # `Oct$` Function
//!
//! The `Oct$` function in Visual Basic 6 returns a string representing the octal (base-8) value
//! of a number. The function name stands for "Octal String".
//!
//! ## Syntax
//!
//! ```vb6
//! Oct$(number)
//! ```
//!
//! ## Parameters
//!
//! - `number` - Required. Any valid numeric expression. If `number` is not a whole number, it is
//!   rounded to the nearest whole number before being evaluated.
//!
//! ## Return Value
//!
//! Returns a `String` representing the octal value of the number. The returned string contains
//! only the digits 0-7, without a leading "0" or "&O" prefix.
//!
//! ## Behavior and Characteristics
//!
//! ### Data Type Handling
//!
//! - Accepts any numeric type: `Byte`, `Integer`, `Long`, `Single`, `Double`, `Currency`
//! - Floating-point values are rounded to the nearest integer before conversion
//! - Negative numbers are represented using two's complement notation
//! - Returns unsigned octal representation for the underlying bit pattern
//!
//! ### Range Considerations
//!
//! - `Integer` values: Returns 1-6 octal digits (range: 0 to 177777 for positive, 100000-177777 for negative)
//! - `Long` values: Returns 1-11 octal digits (range: 0 to 17777777777 for positive)
//! - `Byte` values: Returns 1-3 octal digits (range: 0 to 377)
//!
//! ## Common Usage Patterns
//!
//! ### 1. Basic Octal Conversion
//!
//! ```vb6
//! Dim octStr As String
//! octStr = Oct$(64)  ' Returns "100"
//! octStr = Oct$(8)   ' Returns "10"
//! octStr = Oct$(511) ' Returns "777"
//! ```
//!
//! ### 2. Converting Negative Numbers
//!
//! ```vb6
//! Dim octStr As String
//! octStr = Oct$(-1)  ' Returns "177777" (Integer range, two's complement)
//! ```
//!
//! ### 3. File Permission Representation
//!
//! ```vb6
//! Function FormatPermissions(permissions As Integer) As String
//!     ' Unix-style file permissions (e.g., 755, 644)
//!     FormatPermissions = Oct$(permissions)
//! End Function
//!
//! Dim perms As String
//! perms = FormatPermissions(&H1ED)  ' Returns "755"
//! ```
//!
//! ### 4. Bit Mask Display
//!
//! ```vb6
//! Dim flags As Integer
//! Dim octDisplay As String
//! flags = &H1FF
//! octDisplay = "Flags: " & Oct$(flags)  ' "Flags: 777"
//! ```
//!
//! ### 5. Color Component Extraction (Octal)
//!
//! ```vb6
//! Dim colorValue As Long
//! Dim component As Integer
//! colorValue = &HFF8040
//! component = (colorValue And &HFF)
//! Debug.Print Oct$(component)  ' Shows octal representation
//! ```
//!
//! ### 6. Data Structure Field Values
//!
//! ```vb6
//! Type SystemFlags
//!     ReadWrite As Integer
//!     Execute As Integer
//! End Type
//!
//! Dim sysFlags As SystemFlags
//! sysFlags.ReadWrite = &O644  ' Octal literal
//! Debug.Print "RW: " & Oct$(sysFlags.ReadWrite)
//! ```
//!
//! ### 7. Debugging Bit Patterns
//!
//! ```vb6
//! Sub ShowBitPattern(value As Integer)
//!     Debug.Print "Decimal: " & value
//!     Debug.Print "Octal: " & Oct$(value)
//!     Debug.Print "Hex: " & Hex$(value)
//! End Sub
//! ```
//!
//! ### 8. Network Protocol Values
//!
//! ```vb6
//! Dim socketMode As Integer
//! socketMode = &O666  ' Read/write for all
//! Debug.Print "Mode: " & Oct$(socketMode)
//! ```
//!
//! ### 9. Conversion Table Generation
//!
//! ```vb6
//! Sub GenerateOctalTable()
//!     Dim i As Integer
//!     For i = 0 To 64
//!         Debug.Print i & " = " & Oct$(i)
//!     Next i
//! End Sub
//! ```
//!
//! ### 10. Configuration Value Formatting
//!
//! ```vb6
//! Function SaveConfigValue(value As Integer) As String
//!     ' Store configuration as octal string
//!     SaveConfigValue = "CONFIG=" & Oct$(value)
//! End Function
//! ```
//!
//! ## Related Functions
//!
//! - `Hex$()` - Converts a number to hexadecimal (base-16) string representation
//! - `Str$()` - Converts a number to decimal string representation
//! - `Val()` - Converts a string to a numeric value (doesn't parse octal)
//! - `CLng()` - Converts an expression to a `Long` integer
//! - `CInt()` - Converts an expression to an `Integer`
//! - `Format$()` - Provides custom number formatting options
//!
//! ## Best Practices
//!
//! ### When to Use `Oct$`
//!
//! 1. **Unix-style Permissions**: Representing file or directory permissions (e.g., 755, 644)
//! 2. **Bit Pattern Analysis**: When examining data in groups of 3 bits
//! 3. **Legacy System Integration**: Working with systems that use octal notation
//! 4. **Debugging**: Displaying bit patterns in a more compact form than binary
//! 5. **Configuration Files**: Storing numeric values in octal format
//!
//! ### Formatting Output
//!
//! ```vb6
//! ' Add prefix for clarity
//! Debug.Print "Octal: &O" & Oct$(value)
//!
//! ' Pad with leading zeros
//! Debug.Print Right$("000" & Oct$(value), 3)
//! ```
//!
//! ### Type Safety
//!
//! ```vb6
//! ' Explicitly convert to ensure correct range
//! Dim longValue As Long
//! longValue = 1000000
//! Debug.Print Oct$(longValue)  ' Uses Long range
//! ```
//!
//! ## Performance Considerations
//!
//! - `Oct$` is a lightweight function with minimal overhead
//! - String concatenation in loops should use a `String` buffer or array for better performance
//! - For frequent conversions, consider caching results if the same values are converted repeatedly
//!
//! ## Octal Literals in VB6
//!
//! VB6 supports octal literals using the `&O` prefix:
//!
//! ```vb6
//! Dim octValue As Integer
//! octValue = &O777  ' Octal literal (equals 511 decimal)
//! Debug.Print Oct$(octValue)  ' Returns "777"
//! ```
//!
//! ## Common Pitfalls
//!
//! ### 1. No Direct Reverse Function
//!
//! VB6's `Val()` function does not parse octal strings. You need a custom function:
//!
//! ```vb6
//! Function OctVal(octStr As String) As Long
//!     Dim i As Integer
//!     Dim result As Long
//!     For i = 1 To Len(octStr)
//!         result = result * 8 + Val(Mid$(octStr, i, 1))
//!     Next i
//!     OctVal = result
//! End Function
//! ```
//!
//! ### 2. Two's Complement Representation
//!
//! Negative numbers produce two's complement octal strings:
//!
//! ```vb6
//! Debug.Print Oct$(-1)   ' "177777" (for Integer)
//! Debug.Print Oct$(-100) ' Not intuitive without understanding two's complement
//! ```
//!
//! ### 3. Floating-Point Rounding
//!
//! ```vb6
//! Debug.Print Oct$(8.5)  ' "10" (rounds to 8)
//! Debug.Print Oct$(8.6)  ' "11" (rounds to 9)
//! ```
//!
//! ### 4. Leading Zeros Not Included
//!
//! ```vb6
//! Debug.Print Oct$(8)  ' "10", not "010"
//! ' Pad manually if needed
//! Debug.Print Right$("000" & Oct$(8), 3)  ' "010"
//! ```
//!
//! ### 5. No Prefix in Output
//!
//! Unlike some languages, VB6's `Oct$` doesn't include the `&O` prefix:
//!
//! ```vb6
//! Debug.Print Oct$(64)  ' "100", not "&O100"
//! ```
//!
//! ## Limitations
//!
//! - No built-in function to convert octal strings back to numbers (must implement manually)
//! - Cannot specify minimum width or padding (must format manually)
//! - Limited usefulness in modern applications (hexadecimal is more common)
//! - No validation that a string contains valid octal digits
//! - Returns unsigned representation for negative numbers (two's complement)

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

    #[test]
    fn oct_dollar_simple() {
        let source = r"
Sub Main()
    result = Oct$(64)
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/conversion/oct_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn oct_dollar_assignment() {
        let source = r"
Sub Main()
    Dim octStr As String
    octStr = Oct$(511)
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/conversion/oct_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn oct_dollar_variable() {
        let source = r"
Sub Main()
    Dim num As Integer
    Dim octStr As String
    num = 255
    octStr = Oct$(num)
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/conversion/oct_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn oct_dollar_negative() {
        let source = r"
Sub Main()
    Dim result As String
    result = Oct$(-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/conversion/oct_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn oct_dollar_permissions() {
        let source = r"
Function FormatPermissions(permissions As Integer) As String
    FormatPermissions = Oct$(permissions)
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/conversion/oct_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn oct_dollar_in_condition() {
        let source = r#"
Sub Main()
    If Oct$(value) = "100" Then
        Debug.Print "Is 64"
    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/conversion/oct_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn oct_dollar_bit_mask() {
        let source = r#"
Sub Main()
    Dim flags As Integer
    Dim display As String
    flags = &H1FF
    display = "Flags: " & Oct$(flags)
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/conversion/oct_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn oct_dollar_loop_table() {
        let source = r#"
Sub GenerateTable()
    Dim i As Integer
    For i = 0 To 64
        Debug.Print i & " = " & Oct$(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/conversion/oct_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn oct_dollar_in_function() {
        let source = r"
Function GetOctalString(value As Long) As String
    GetOctalString = Oct$(value)
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/conversion/oct_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn oct_dollar_multiple_calls() {
        let source = r"
Sub ShowConversions()
    Debug.Print Oct$(8)
    Debug.Print Oct$(64)
    Debug.Print Oct$(511)
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/conversion/oct_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn oct_dollar_select_case() {
        let source = r#"
Sub Main()
    Select Case Oct$(value)
        Case "10"
            Debug.Print "Eight"
        Case "100"
            Debug.Print "Sixty-four"
    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/conversion/oct_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn oct_dollar_color_component() {
        let source = r"
Sub ExtractComponent()
    Dim colorValue As Long
    Dim component As Integer
    colorValue = &HFF8040
    component = (colorValue And &HFF)
    Debug.Print Oct$(component)
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/conversion/oct_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn oct_dollar_expression_arg() {
        let source = r"
Sub Main()
    Dim result As String
    result = Oct$(value * 8 + offset)
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/conversion/oct_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn oct_dollar_concatenation() {
        let source = r#"
Sub Main()
    Dim output As String
    output = "Octal: &O" & Oct$(value)
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/conversion/oct_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn oct_dollar_padded_output() {
        let source = r#"
Sub Main()
    Dim padded As String
    padded = Right$("000" & Oct$(value), 3)
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/conversion/oct_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn oct_dollar_debug_pattern() {
        let source = r#"
Sub ShowBitPattern(value As Integer)
    Debug.Print "Decimal: " & value
    Debug.Print "Octal: " & Oct$(value)
    Debug.Print "Hex: " & Hex$(value)
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/conversion/oct_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn oct_dollar_config_value() {
        let source = r#"
Function SaveConfig(value As Integer) As String
    SaveConfig = "CONFIG=" & Oct$(value)
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/conversion/oct_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn oct_dollar_floating_point() {
        let source = r"
Sub Main()
    Dim result As String
    result = Oct$(8.6)
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/conversion/oct_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn oct_dollar_octal_literal() {
        let source = r"
Sub Main()
    Dim octValue As Integer
    Dim result As String
    octValue = &O777
    result = Oct$(octValue)
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/conversion/oct_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn oct_dollar_socket_mode() {
        let source = r#"
Sub Main()
    Dim socketMode As Integer
    socketMode = &O666
    Debug.Print "Mode: " & Oct$(socketMode)
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/conversion/oct_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }
}