What is a good way to use asserts in VBScript scripts?
Is there built-in functionality for it or will it have to be emulated? What is best practice?
One application is to test for objects being Nothing during development.
An operational answer (for others that may need it) is to define this function, from Rosetta Code:
    sub Assert( boolExpr, strOnFail )
        if not boolExpr then
            Err.Raise vbObjectError + 99999, , strOnFail
        end if
    end sub
Invocation:
    Set obj2 = Nothing
    Assert Not obj2 Is Nothing, "obj2 is Nothing!"
Output:
    someScript.vbs(17, 3) (null): obj2 is Nothing!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With