Skip to content

Commit 5ac63b1

Browse files
committed
Improve tests for VB family
1 parent 6b83788 commit 5ac63b1

File tree

13 files changed

+221
-36
lines changed

13 files changed

+221
-36
lines changed

Unix/t/00_C.t

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,9 +1433,14 @@ my @Tests = (
14331433
'args' => '../tests/inputs/gnureadline.vala',
14341434
},
14351435
{
1436-
'name' => 'VB.Net',
1437-
'ref' => '../tests/outputs/VisualBasic.Net.vba.yaml',
1438-
'args' => '../tests/inputs/VisualBasic.Net.vba',
1436+
'name' => 'VBA',
1437+
'ref' => '../tests/outputs/vba_test.vba.yaml',
1438+
'args' => '../tests/inputs/vba_test.vba',
1439+
},
1440+
{
1441+
'name' => 'VB.NET',
1442+
'ref' => '../tests/outputs/vbnet_test.vb.yaml',
1443+
'args' => '../tests/inputs/vbnet_test.vb',
14391444
},
14401445
{
14411446
'name' => 'Velocity Template Language',
@@ -1452,6 +1457,21 @@ my @Tests = (
14521457
'ref' => '../tests/outputs/JetCar.cls.yaml',
14531458
'args' => '../tests/inputs/JetCar.cls',
14541459
},
1460+
{
1461+
'name' => 'Visual Basic (Dsr)',
1462+
'ref' => '../tests/outputs/test.Dsr.yaml',
1463+
'args' => '../tests/inputs/test.Dsr',
1464+
},
1465+
{
1466+
'name' => 'Visual Basic .NET (vbhtml)',
1467+
'ref' => '../tests/outputs/test.vbhtml.yaml',
1468+
'args' => '../tests/inputs/test.vbhtml',
1469+
},
1470+
{
1471+
'name' => 'VBScript',
1472+
'ref' => '../tests/outputs/test.vbs.yaml',
1473+
'args' => '../tests/inputs/test.vbs',
1474+
},
14551475
{
14561476
'name' => 'Visual Studio Solution',
14571477
'ref' => '../tests/outputs/vs_solution.sln.yaml',

tests/inputs/VisualBasic.Net.vba

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/inputs/test.Dsr

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
VERSION 1.0 CLASS
2+
BEGIN
3+
MultiUse = -1 'True
4+
Persistable = 0 'NotPersistable
5+
DataBindingBehavior = 0 'vbNone
6+
DataSourceBehavior = 0 'vbNone
7+
MTSTransactionMode = 0 'NotAnMTSObject
8+
END
9+
Attribute VB_Name = "TestClass"
10+
Attribute VB_GlobalNameSpace = False
11+
12+
' This is a comment in a Dsr file
13+
Option Explicit
14+
15+
Public Sub TestMethod()
16+
' Method implementation
17+
Dim x As Integer
18+
x = 42
19+
Debug.Print "Value: " & x
20+
End Sub

tests/inputs/test.vbhtml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@{
2+
' VB.NET code in a vbhtml file
3+
ViewBag.Title = "Test Page"
4+
Dim message As String = "Hello from VB.NET"
5+
}
6+
7+
<!DOCTYPE html>
8+
<html>
9+
<head>
10+
<title>@ViewBag.Title</title>
11+
</head>
12+
<body>
13+
<h1>@message</h1>
14+
@If True Then
15+
@<p>This is a VB.NET HTML template</p>
16+
End If
17+
</body>
18+
</html>

tests/inputs/test.vbs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
' VBScript test file
2+
' This is a comment
3+
Dim greeting
4+
greeting = "Hello, World!"
5+
WScript.Echo greeting
6+
7+
' Another comment
8+
If 1 = 1 Then
9+
WScript.Echo "True"
10+
End If

tests/inputs/vba_test.vba

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Attribute VB_Name = "Module1"
2+
' VBA (Visual Basic for Applications) example
3+
' This would typically be found in Excel, Word, or Access
4+
5+
Option Explicit
6+
7+
Sub HelloWorld()
8+
' This is a VBA subroutine
9+
MsgBox "Hello from VBA!"
10+
End Sub
11+
12+
Function AddNumbers(x As Integer, y As Integer) As Integer
13+
' VBA function to add two numbers
14+
AddNumbers = x + y
15+
End Function
16+
17+
Private Sub Worksheet_Change(ByVal Target As Range)
18+
' Event handler - typical in VBA
19+
If Target.Address = "$A$1" Then
20+
Range("B1").Value = "Cell A1 was changed"
21+
End If
22+
End Sub

tests/inputs/vbnet_test.vb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Imports System
2+
Imports System.Collections.Generic
3+
4+
' VB.NET example
5+
Namespace HelloWorldApp
6+
Public Class Program
7+
Public Shared Sub Main(args As String())
8+
Console.WriteLine("Hello from VB.NET!")
9+
10+
Dim numbers As New List(Of Integer)
11+
numbers.Add(1)
12+
numbers.Add(2)
13+
numbers.Add(3)
14+
15+
For Each num As Integer In numbers
16+
Console.WriteLine($"Number: {num}")
17+
Next
18+
End Sub
19+
20+
' VB.NET method with modern syntax
21+
Public Function CalculateSum(values As List(Of Integer)) As Integer
22+
Return values.Sum()
23+
End Function
24+
End Class
25+
End Namespace

tests/outputs/VisualBasic.Net.vba.yaml

Lines changed: 0 additions & 21 deletions
This file was deleted.

tests/outputs/test.Dsr.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
# github.com/AlDanial/cloc
3+
header :
4+
cloc_url : github.com/AlDanial/cloc
5+
cloc_version : 2.07
6+
elapsed_seconds : 0.00898003578186035
7+
n_files : 1
8+
n_lines : 20
9+
files_per_second : 111.358130890747
10+
lines_per_second : 2227.16261781495
11+
report_file : tests/outputs/test.Dsr.yaml
12+
'Visual Basic' :
13+
nFiles: 1
14+
blank: 2
15+
comment: 12
16+
code: 6
17+
SUM:
18+
blank: 2
19+
comment: 12
20+
code: 6
21+
nFiles: 1

tests/outputs/test.vbhtml.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
# github.com/AlDanial/cloc
3+
header :
4+
cloc_url : github.com/AlDanial/cloc
5+
cloc_version : 2.07
6+
elapsed_seconds : 0.0128321647644043
7+
n_files : 1
8+
n_lines : 18
9+
files_per_second : 77.9291739437405
10+
lines_per_second : 1402.72513098733
11+
report_file : tests/outputs/test.vbhtml.yaml
12+
'Visual Basic .NET' :
13+
nFiles: 1
14+
blank: 1
15+
comment: 1
16+
code: 16
17+
SUM:
18+
blank: 1
19+
comment: 1
20+
code: 16
21+
nFiles: 1

0 commit comments

Comments
 (0)