UnitTest( dump )

Output

(String) "nagaozen"
(Integer) 28
(Double) 3.1415
(Boolean) True
(Date) 12/14/2017 2:11:24 AM
(Array) [(String) "nagaozen",(Integer) 28,(Boolean) True]
(Array) [(Array) [(String) "nagaozen",(Integer) 28,(Boolean) True],(Array) [(String) "nagaozen",(Integer) 28,(Boolean) True]]
(RegExp) /[A-Za-z0-9]/gim
(Dictionary) {"firstname": (String) "Fabio","lastname": (String) "Nagao","age": (Integer) 28,"male": (Boolean) True}
(Recorset) [(Record) {"name": (String) "Fabio Zendhi Nagao","age": (Long) 28},(Record) {"name": (String) "Manoela Suzane de Alencar Rodrigues","age": (Long) 27}]
(Stream) "ADODB.Stream text content"

Sources

/axe-ut/dump.unit.test.asp

<!--#include virtual="/lib/unit-tests.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:lang="en">
    <head>
        <title>AXE - Unit Test - dump</title>
        <!--// meta tags //-->
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <!--// link tags //-->
        <link rel="stylesheet" type="text/css" media="screen" href="/lib/unit-tests.css" />
    </head>
    <body>
        <div id="container">
            <div id="container-hd">
                <h1>UnitTest( dump )</h1>
            </div>
            <div id="container-bd">
 
<h2>Output</h2>
<div class="code"><pre><%
 
function iif(assert, ret_true, ret_false)
    if(assert) then
        iif = ret_true
    else
        iif = ret_false
    end if
end function
 
function dump(mixed)
    select case lcase(typename(mixed))
        case "string":
            dump = "(" & typename(mixed) & ") """ & mixed & """"
        case "iregexp2":
            dump = "(RegExp) /" & mixed.pattern & "/" & iif(mixed.global, "g", "") & iif(mixed.ignoreCase, "i", "") & iif(mixed.multiline, "m", "")
        case "variant()":
            dump = dump_hdlArray(mixed)
        case "dictionary":
            dump = dump_hdlDictionary(mixed)
        case "recordset":
            dump = dump_hdlRecordset(mixed)
        case "stream":
            dump = dump_hdlStream(mixed)
        case else:
            on error resume next
            dump = "(" & typename(mixed) & ") " & mixed
            if(Err.number <> 0) then
                dump = "(" & typename(mixed) & ")"
                Err.clear()
            end if
            on error goto 0
    end select
end function
 
function dump_hdlArray(arr)
    dim entry : dump_hdlArray = ""
    for each entry in arr
        dump_hdlArray = dump_hdlArray & "," & dump(entry)
    next
    dump_hdlArray = "(Array) [" & mid(dump_hdlArray, 2) & "]"
end function
 
function dump_hdlDictionary(Dic)
    dim key : dump_hdlDictionary = ""
    for each key in Dic.keys()
        dump_hdlDictionary = dump_hdlDictionary & ",""" & key & """: " & dump(Dic(key))
    next
    dump_hdlDictionary = "(Dictionary) {" & mid(dump_hdlDictionary, 2) & "}"
end function
 
function dump_hdlRecordset(Rs)
    dim i, row : dump_hdlRecordset = ""
    while( not Rs.eof )
        row = ""
        for i = 0 to Rs.Fields.count - 1
            row = row & ",""" & Rs(i).name & """: " & dump(Rs(i).value)
        next
        dump_hdlRecordset = dump_hdlRecordset & ",(Record) {" & mid(row, 2) & "}"
        Rs.moveNext()
    wend
    dump_hdlRecordset = "(Recorset) [" & mid(dump_hdlRecordset, 2) & "]"
end function
 
function dump_hdlStream(St)
    if(St.type = 1) then
        dump_hdlStream = "(Stream) adTypeBinary"
    else
        St.position = 0
        dump_hdlStream = "(Stream) """ & St.readText() & """"
    end if
end function
 
 
 
dim str, num, flo, bol, dat, arr, mat, Re, Dic, Rs, St
 
str = "nagaozen"
num = 28
flo = 3.1415
bol = true
dat = now
arr = array(str, num, bol)
mat = array(arr, arr)
 
 
 
set Re = new RegExp
Re.pattern = "[A-Za-z0-9]"
Re.global = true
Re.ignoreCase = true
Re.multiline = true
 
 
 
set Dic = Server.createObject("Scripting.Dictionary")
Dic.add "firstname", "Fabio"
Dic.add "lastname", "Nagao"
Dic.add "age", 28
Dic.add "male", true
 
 
 
set Rs = Server.createObject("ADODB.Recordset")
Rs.Fields.append "name", 200, 64
Rs.Fields.append "age", 3
Rs.open()
 
Rs.addNew()
Rs("name") = "Fabio Zendhi Nagao"
Rs("age") = 28
Rs.update()
 
Rs.addNew()
Rs("name") = "Manoela Suzane de Alencar Rodrigues"
Rs("age") = 27
Rs.update()
 
Rs.moveFirst()
 
 
 
set St = Server.createObject("ADODB.Stream")
St.type = 2' adTypeText
St.mode = 3' adModeReadWrite
St.open()
St.position = 0
St.writeText("ADODB.Stream text content")
 
 
 
Response.write( dump( str ) & vbNewline )
Response.write( dump( num ) & vbNewline )
Response.write( dump( flo ) & vbNewline )
Response.write( dump( bol ) & vbNewline )
Response.write( dump( dat ) & vbNewline )
Response.write( dump( arr ) & vbNewline )
Response.write( dump( mat ) & vbNewline )
Response.write( dump( Re ) & vbNewline )
Response.write( dump( Dic ) & vbNewline )
Response.write( dump( Rs ) & vbNewline )
Response.write( dump( St ) & vbNewline )
 
%></pre></div>
 
            </div>
            <div id="container-ft">
                <h2>Sources</h2>
                <h3><%= Request.ServerVariables("SCRIPT_NAME") %></h3>
                <div class="code"><%= geshify( loadTextFile( Server.mapPath( Request.ServerVariables("SCRIPT_NAME") ) ), "asp" ) %></div>
            </div>
        </div>
        <!--// javascript tags //-->
    </body>
</html>