๐Ÿงช VBScript Syntax Variations Test Suite

Testing all the quirky ways VBScript allows you to write code...

Test 1: Colon Separator (:) - Multiple Statements on One Line

Dim v : v = "I am a string" & " " & "!"
Result: I am a string ! Expected: "I am a string !"

Test 2: Standard Two-Line Format

Dim v2
v2 = "I am a string" & " " & "!"
Result: I am a string ! Expected: "I am a string !"

Test 3: Tight Spacing Around Operators

Dim v3 : v3 = "I am a string"&" "&"!"
Result: I am a string ! Expected: "I am a string !"

Test 4: Plus (+) Operator for String Concatenation

Dim v4 : v4 = "I am a string" + " " + "!"
Result: I am a string ! Expected: "I am a string !"

Test 5: Plus (+) Without Spaces

Dim v5 : v5 = "Hello"+"World"
Result: HelloWorld Expected: "HelloWorld"

Test 6: Line Continuation with Underscore (_)

Dim v6
v6 = "I am a string" & _
    " " & _
    "!"
Result: I am a string ! Expected: "I am a string !"

Test 7: Mixed Case Keywords (DIM keyword works with any case)

dIm mixedVar
mixedVar = "Mixed Case Works!"
Result: Mixed Case Works! Expected: "Mixed Case Works!"

Test 8: Multiple Statements with Multiple Colons

Dim a, b, c : a = "Hello" : b = "World" : c = a & " " & b
Result: Hello World Expected: "Hello World"

Test 9: The Ultimate Combo (Colon + Plus + Continuation)

Dim result : result = _
    "Part1" + _
    " Part2" + _
    " Part3"
Result: Part1 Part2 Part3 Expected: "Part1 Part2 Part3"

Test 10: Response.Write on Same Line with Colon

Dim msg : msg = "Quick Message" : Response.Write("<p>" & msg & "</p>")

Quick Message

Expected: A paragraph with "Quick Message"

Test 11: Plus (+) for Numeric Addition

Dim num1, num2, sum : num1 = 10 : num2 = 20 : sum = num1 + num2
Result: 30 Expected: 30

Test 12: For Loop with Inline Counter Declaration

Dim i, loopResult : loopResult = ""
For i = 1 To 5 : loopResult = loopResult & i & " " : Next
Result: 1 2 3 4 5 Expected: "1 2 3 4 5 "

Test 13: Mixing & and + Operators

Dim mixed : mixed = "Start" & " Middle" + " End"
Result: Start Middle End Expected: "Start Middle End"

Test 14: Complex Expression with Line Continuation

Dim complexExpr
complexExpr = ("Hello" & _
    " Beautiful" & _
    " World")
Result: Hello Beautiful World Expected: "Hello Beautiful World"

Test 15: The Kitchen Sink (All Features Combined)

dIm X, Y, Z
X = "First" : Y = "Second" + _
    " Part" : Z = X & _
    " " + Y
Result: First Second Part Expected: "First Second Part"

Test 16: If Statement (Colon Should Not Split Control Structure)

Dim testVal : testVal = 5
If testVal > 3 Then
    testVal = "Greater"
Else
    testVal = "Lesser"
End If
Result: Greater Expected: "Greater"

โœ… Test Suite Complete

All VBScript syntax variations tested:

Note: Variable names are case-sensitive (Python limitation), but VBScript keywords work with any case.