#!./tt++ -G

#0   1: #math
#0   2: #line
#0   3: #return
#0   4: #buffer
#0   5: #switch
#0   6: #class


#line sub arg #var arg {%0}

#if {"$arg" == "draw"}
{
	#screen clear all;
	#draw convert scroll Red Blue box 1 1 5 40 convert\nx\ny;
	#draw Red box 1 1 2 2;
	#draw rounded Red box 3 1 4 2;
	#draw tubed Red box 5 1 6 2;
	#draw crossed Red box 8 1 9 2;

	#draw Green line 1 4 1 14;
	#draw Green teed line 2 4 2 14;
	#draw Green jeweled line 3 4 3 14;
	#draw Green circled line 4 4 4 14;
	#draw Green left circled line 5 4 5 14;
	#draw Green right circled line 6 4 6 14;
	#draw Green bot vertical teed line 7 4 7 14;
	#draw Green top vertical teed line 8 4 8 14;

	#draw Yellow left horizontal teed line  1 16 10 16;
	#draw Yellow right horizontal teed line 1 18 10 18;
	#draw Yellow top circled line 1 20 10 20;
	#draw Yellow bottom circled line 1 22 10 22;
	#draw Yellow pruned circled line 1 24 10 24;
	#draw Yellow filled circled line 1 26 10 26;
	#draw Yellow filled jeweled line 1 28 10 28;

	#draw Cyan box 1 40 10 60;
	#draw Jade rounded box 2 41  9 59;
	#draw Azure pruned box 2 41 9 59;
	#draw Violet numbered box 3 42 8 58;
	#draw White rounded tubed box 4 43 7 57;

	#draw Magenta Green round table 12  1 20 38 {{a}{b}{c}{d}}{{e}{f}{g}{h}}{{i}{j}{k}{l}};
	#draw Magenta Green grid table 12 42 21 78 {{a}{b}{c}{d}}{{e}{f}{g}{h}}{{i}{j}{k}{l}};

	#draw White Red talign box 22  1 27 19 talign;
	#draw White Red balign box 22 21 27 39 balign;
	#draw White Red lalign box 22 41 27 59 lalign;
	#draw White Red ralign box 22 61 27 79 ralign;
	#draw White Red calign talign balign box 22 81 26 99 calign;

	#draw Lime Azure cursive box 28  1 31 19 cursive;
	#draw Lime Azure     fat box 28 21 31 39 fat;
	#draw Lime Azure sansser box 28 41 31 59 sansserif;
	#draw Lime Azure ualign  box 28 61 31 79 { u\na\nl\ni\ng\nn};
	#draw Lime Azure scaled  box 28 81 31 99 scaled;

	#draw Violet Jade box 32  1 37 19 test of a test of a test;
	#draw Violet Jade box 32 21 37 39 {test} {of a test} {of a test};
	#draw Violet Jade box 32 41 37 59 test\nof a test\nof a test;
	#draw Violet Jade box 32 61 37 79 color<118>test<128>test<138>test<148>test;
	#draw Violet Jade box 32 81 37 99 {  offset test};



	#end \
}

#draw Yellow Green scroll box 1 1 3 -1 Running Validator

#format start %U

#math error 0

#alias error
{
	#math error $error + 1;
	#line ignore #showme <118>Failed test %0
}

#0 )=-=( ERROR 1 )=-=( 0#

#math tmp 1 + 1
#if {$tmp != 2}{error 1: math failure}

#math tmp 7 / 11 * 100.00
#if {"$tmp" != "63.64"} {error 1.1: math failure}

#math tmp (1 + 1) % 10
#if {$tmp != 2} {error 1.2: math failure}

#0 )=-=( ERROR 2 )=-=( 0#

#alias {test} {#math tmp $tmp + 1}
#line oneshot #alias {test%*} {#nop} {4}
#math tmp 0
#2 test
#if {$tmp != 1}
{
	error 2: oneshot or math or alias failure
}

#0 )=-=( ERROR 3 )=-=( 0#

#1 {#return;error 3: #return failure}

#0 )=-=( ERROR 4 )=-=( 0#

#buf get tmp -3 -1

#if {&tmp[] != 3} error 4.1: buffer or variable or if failure (&&tmp[] != 3)
#if {&tmp[%*] != 3} error 4.2: buffer or variable or if failure (&&tmp[%*] != 3)
#if {&{tmp[]} != 3} error 4.3: buffer or variable or if failure (&&{tmp[]} != 3)
#if {&{tmp[%*]} != 3} error 4.4: buffer or variable or if failure (&&{tmp[%*]} != 3)

#showme $arg

#0 )=-=( ERROR 5 )=-=( 0#

#switch {3}     {#case 3 #return;#default error 5.0: switch failure}
#switch {1+2}   {#case 3 #return;#default error 5.1: switch failure}
#switch {"bla"} {#case "bla" #return;#default error 5.2: switch string failure}

#0 )=-=( ERROR 6 )=-=( 0#

#class tmp open
#unvar tmp
#var tmp 1
#class tmp kill

#if {&{tmp} != 0}
{
	error 6.1: class or variable failure
}
#class tmp assign #var tmp 2
#if {$tmp != 2}
{
	error 6.2: class or variable failure
}
#class tmp save
#class tmp clear
#if {&{tmp} != 0}
{
	error 6.3: class or variable failure
}
#class tmp load
#if {$tmp != 2}
{
	error 6.4: class or variable failure
}
#class tmp kill
#if {&{tmp} != 0}
{
	error 6.5: class or variable failure
}

#0 )=-=( ERROR 7 )=-=( 0#

#loop 1 2 tmp {#continue;error 7: continue failure}

#0 )=-=( ERROR 8 )=-=( 0#

#kill variable tmp

#if {&{tmp} != 0}
{
	error 8: kill variable %* failure
}

#0 )=-=( ERROR 9 )=-=( 0#

#line strip #if {{<128>} != {}}
{
	error 9: line strip failure
}

#0 )=-=( ERROR 10 )=-=( 0#

#act {test} {error 10: line ignore failure}
#line gag;
#line ignore #showme <118>Failed test 10: line gag failure
#unact {test}

#0 )=-=( ERROR 11 )=-=( 0#

#parse {abcd} {tmp} {#var tmp ($tmp)}
#if {"$tmp" != "(d)"}
{
	error 11: parse failure
}

#0 )=-=( ERROR 12 )=-=( 0#

#path load {#var tmp 1}
#path walk
#if {$tmp != 1}
{
	error 12: path load or walk failure
}

#0 )=-=( ERROR 13 )=-=( 0#

#script tmp {echo 'test'}
#if {{$tmp[1]} != {test}}
{
	error 13: script failure
}

#0 )=-=( ERROR 14 )=-=( 0#

#regex {test} {te%?t} {#nop}
{
	error 14: regex failure
}

#0 )=-=( ERROR 15 )=-=( 0#

#regex {bla} {bli}         {error 15.1: regex failure}
#regex {$OK} {$OK}  {#nop} {error 15.2: regex failure}
#regex {OK$} {OK$}         {error 15.3: regex failure}
#regex {OK$} {OK$$}        {error 15.4: regex failure}
#regex {OK$} {OK\$} {#nop} {error 15.5: regex failure}

#0 )=-=( ERROR 16 )=-=( 0#

#0 error 16: repeat failure

#0 )=-=( ERROR 17 )=-=( 0#

#unvar tmp

#1
{
	#local tmp 1;
	#if {$tmp != 1}
	{
		error 17: local failure
	}
}

#0 )=-=( ERROR 18 )=-=( 0#

#if {${tmp} == 1}
{
	error 18: local failure
}

#0 )=-=( ERROR 19 )=-=( 0#

#1
{
	#local tmp 2;

	#regex {a} {a}
	{
		#if {$tmp != 2}
		{
			error 19: local failure
		}
	}
}

#0 )=-=( ERROR 20 )=-=( 0#

#if {"$arglebargle" != "\$arglebargle"}
{
	error 20: unassigned variable
}

#0 )=-=( ERROR 21 )=-=( 0#

#alias {bla} {error 21: unalias malfunction}
#alias {bla%*} {#nop}
#unalias {bla}
bla
#unalias {bla%*}

#0 )=-=( ERROR 22 )=-=( 0#

#class bla open
#var bla 2
#var bli 2
#alias haha hihi
#fun bla blo
#class bla close
#class bla save
#class bla clear
#if {&{bla} != 0} {error 22: #class clear malfunction}
#class bla load
#if {&{bla} == 0} {error 23: #class load malfunction}
#class bla clear
#class bla load
#class bla kill


#0 )=-=( ERROR 24 )=-=( 0#

#if {(513 & ~1) != 512} {error 24.01: #math error}
#if {1 << 1 != 2}	   {error 24.02: #math error}
#if {1 < 2} {#nop} {error 24.03: #math error}
#if {2 > 1} {#nop} {error 24.04: #math error}
#if {2 % 2} {error 24.05: #math error}

#0 )=-=( ERROR 25 )=-=( 0#

#var tmp 0;
#var bla var
#{$bla} tmp 1
#if {$tmp != 1} {error 25.1: variable command}
#$bla tmp 2
#if {$tmp != 2} {error 25.2: variable command}

#var bla gts
#{$bla} #var tmp 3
#if {$tmp != 3} {error 25.3: variable session}
#$bla #var tmp 4
#if {$tmp != 4} {error 25.4: variable session}

#var bla #math tmp 5
$bla
#if {$tmp != 5} {error 25.5: variable input}
$bla + 1
#if {$tmp != 6} {error 25.6: variable input}

#0 )=-=( ERROR 26 )=-=( 0#

#format bla %X ─
#if {$bla != 2500}     {error 26.1: format unicode handling}
#format bla %x 2500
#line sub esc #var bli \u2500
#if {{$bla} != {$bli}} {error 26.2: unicode handling}
#var {bla} {<128>A<138>BC<148>DE<158>FG}
#format tmp %L {$bla}
#if {$tmp != 7}        {error 26.6: format L handling}
#format bli {%.5s} {$bla}
#format tmp %L {$bli}
#if {$tmp != 5}        {error 26.7: format .+s handling}
#format bli {%.-5s} {$bla}
#format tmp %L {$bli}
#if {$tmp != 5}        {error 26.8: format .-s handling}
#format bli {%-20s} {$bla}
#format tmp %L {$bli}
#if {$tmp != 20}       {error 26.9: format -s handling}
#format bli {%+20s} {$bla}
#format tmp %L {$bli}
#if {$tmp != 20}       {error 26.10: format +s handling}
#format bli {%+20.-3s} {$bla}
#format tmp %L {$bli}
#if {$tmp != 20}       {error 26.11: format +.-s handling}
#format tmp %+10s {\e]68;1;SEND;bow\a\e[4mbow\e[24m}
#format tmp %L {$tmp}
#if {$tmp != 10} {error 26.12: format escape code handling}
#line sub esc #format tmp %+10s {\e]68;1;SEND;bow\a\e[4mbow\e[24m}
#format tmp %L {$tmp}
#if {$tmp != 10} {error 26.13: format escape code handling}

#0 )=-=( ERROR 27 )=-=( 0#

#line sub esc #var bla {x\nx}
#if {"$bla" === "x\nx"} {error 27.1: escape handling}
#if {"$bla" != "x\nx"}  {error 27.2: escape handling}

#0 )=-=( ERROR 28 )=-=( 0#

#var bla[1] {{bli}{2}}
#var bla[2] {{bli}{3}}

#list bla index bli
#list bla order
#if {$bla[1][bli] != 2} {error 28.01: 2D list handling}
#list bla reverse
#if {$bla[1][bli] != 3} {error 28.02: 2D list handling}
#var bla[1][blo] 4
#list bla[1] get 1 tmp
#if {$tmp != 3} {error 28.03: 2D list handling: $tmp}
#list bla[1] get -1 tmp
#if {$tmp != 4} {error 28.04: 2D list handling: $tmp}
#list bla[1] find {4} tmp
#if {$tmp != 2} {error 28.05: 2D list handling: $tmp}
#list bla[1] set 2 5
#list bla[1] find {5} tmp
#if {$tmp != 2} {error 28.06: 2D list handling: $tmp}
#list bla[1] insert 2 9
#list bla[1] get 2 tmp
#if {$tmp != 9} {error 28.07: 2D list handling: $tmp}

#list bla tokenize 123456789
#list bli create $bla[+2..+4]
#if {&bli[] != 3} {error 28.08: list range handling: &bli[]}
#list bli create $bla[-3..-1]
#if {&bli[] != 3} {error 28.09: list range handling: &bli[]}

#list bla tokenize abcdefghi
#list bla filter {} {d}
#if {"$bla[+4]" != "e"} {error 28.10: list filter handling: "$bla[+4]" != "e"}
#list bla filter {f}
#if {"$bla[+1]" != "f"} {error 28.11: list filter handling: "$bla[+1]" != "f"}

#0 )=-=( ERROR 29 )=-=( 0#

#alias {bla}
{
	#var bla 1;
	#return;
	#var bla 2
}
bla
#if {$bla != 1} {error 29.1: return handling}

#function {bla}
{
	#return 1;
	#return 2;
}
#if {@bla{} != 1} {error 29.2: return handling}

#function {bla}
{
	#if {1} #return 1;
	#return 2
}
#if {@bla{} != 1} {error 29.3: return handling}

#function {bla}
{
	#regex {1} {1} {#return 1};
	#return 2
}
#if {@bla{} != 2} {error 29.4: regex return handling}

#function {bla}
{
	#var blo 5;
	#return $blo
}

#function {bli}
{
	#return @bla{}
}

#if {@bli{} != 5} {error 29.5: regex return handling (@bli{})}

#0 )=-=( ERROR 30 )=-=( 0#

#history insert {#var bla 33}
!
#if {$bla != 33} {error 30.1: history handling}

#0 )=-=( ERROR 30 )=-=( 0#

#var bla {{d}{4}{b}{2}{a}{1}{c}{3}}

#if {$bla[+3] != 3} {error 30.1: table handling ($bla[+3] != 3)}
#if {$bla[-2] != 3} {error 30.2: table handling ($bla[-2] != 3)}
#if {&bla[0] != 0}  {error 30.3: table handling (&bla[0] != 0)}
#unvar bla[=d]
#if {&bla[] != 3}   {error 30.4: table handling (#unvar bla[=d])}
#if {$bla[=d] != 4} {error 30.5: table handling (\$bla[=d])}

#0 )=-=( ERROR 31 )=-=( 0#

#tab bliblablo
#cursor clear
#cursor set bli
#cursor tab list forward
#cursor get bla
#cursor clear
#if {"$bla" != "bliblablo"} {error 31.1: tab list handling ("$bla" != "bliblablo")}
#untab bliblablo
#cursor set bli
#cursor tab dict forward
#cursor get bla
#cursor clear
#if {"$bla" != "bliaut"} {error 31.2: tab dict handling ("$bla" != "bliaut")}

#0 )=-=( ERROR 32 )=-=( 0#
#map create
#map goto 1
#map move {nw;ne;s;s}
#map exit n weight 0.9
#map find 3
#path save forward bla
#if {"$bla" != "n;n"} {error 32.1: #map find failing exit weight reduction}
#map exit n weight 1.0
#map find 3
#path save forward bla
#if {"$bla" != "nw;ne"} {error 32.2: #map find failing exit weight increase}

#0 )=-=( ERROR 33 )=-=( 0#

#alias {sethash}
{
       #format hash %H %1;
       #math hash1 $hash % 100;
       #math hash2 $hash / 100 % 100;
       #var hashtable[$hash1][$hash2][%1] %2
}

#function {gethash}
{
       #format hash %H %1;
       #math hash1 $hash % 100;
       #math hash2 $hash / 100 % 100;
       #return $hashtable[$hash1][$hash2][%1]
}

sethash bli hey
sethash bla hi
sethash blo hello
#if {"@gethash{bla}" !== "hi"} {error 33.1: variable hashing support}

#0 )=-=( ERROR 34 )=-=( 0#

#regex {blibla} {%10bli%+3..3a} {#if {"&11" !== "bla"} {error 34.1: regex argument indexing (&11)}}
#regex {blibla} {%.%+%.%*}      {#if {"&4" !== "bla"}  {error 34.2: regex argument indexing (&4)}}
#regex {blibla} {%99bli%+3..3*} {#if {"&99" !== "bla"} {error 34.3: regex argument indexing (&99)}}
#regex {blibla} {bli%!+}        {#if {"&1" !== ""}     {error 34.4: regex argument indexing (&1)}}
#regex {blibla} {%+2*%+3*}      {#if {"&2" !== "ibl"}  {error 34.5: regex argument indexing (&2)}}
#regex {blibla} {%+1..2*}       {#if {"&1" !== "bl"}   {error 34.6: regex argument indexing (&1)}}
#regex {blibla} {%!+5*%*}       {#if {"&1" !== "a"}    {error 34.7: regex argument indexing (&1)}}
#regex {blibla} {%+%*}          {#if {"&1" !== "b"}    {error 34.8: regex argument indexing (&1)}}

#0 )=-=( ERROR 35 )=-=( 0#

#var bla {}
#cat bla bli
#if {{$bla} !== {bli}} {error 35.1: #cat simple}
#cat bla bli
#if {{$bla} !== {blibli}} {error 35.2: #cat simple ($bla) != (blibli)}
#cat bla {{bli}{blo}}
#if {{$bla[bli]} !== {blo}} {error 35.3: #cat table}
#cat bla {{bla}{blu}}
#if {{$bla[bla]} !== {blu}} {error 35.4: #cat table}
#cat bla[bli] {{a}{b}}
#if {{$bla[bli][a]} !== {b}} {error 35.5: #cat table}
#var bla {}
#foreach {bli;bla;blo} {add} #cat bla $add
#if {"$bla" != "bliblablo"} {error 35.6: #foreach cat bliblablo}
#var bla {}
#while {&bla[] < 10}
{
	#cat bla {{&bla[]} {x}}
}
#if {&bla[] != 10} {error 35.7: #while bla (&bla[] != 10)}

#0 )=-=( ERROR 36 )=-=( 0#

#var match 0
#line oneshot #act {^^^bla$$$} {#var match 1;#line gag}
#showme bla
#if {$match == 0} {error 36.1: regex ^^^$$$} {#var match 0}
#line oneshot #act {^%.l%.$} {#var match 1;#line gag}
#showme bla
#if {$match == 0} {error 36.2: regex ^%.l%.$} {#var match 0}
#line oneshot #act {^%+1Dl%+1S$} {#var match 1;#line gag}
#showme bla
#if {$match == 0} {error 36.3: regex ^%+1Dl%+1S$} {#var match 0}
#line oneshot #act {^%iBLA$} {#var match 1;#line gag}
#showme bla
#if {$match == 0} {error 36.4: regex ^%iBLA$} {#var match 0}
#line oneshot #act {^%+2wa$} {#var match 1}
#line gag
#showme bla
#if {$match == 0} {error 36.5: regex ^%+2wa$} {#var match 0}
#line oneshot #act {^%+2*a$} {#if {"%1" == "bl"} {#var match 1}}
#line gag
#showme bla
#if {$match == 0} {error 36.6: regex ^%+2*a$} {#var match 0}

#0 )=-=( ERROR 37 )=-=( 0#

#var bla {{dzp}{{id}{dzp}{level}{18}}{xgg}{{id}{xgg}{level}{33}}}

#if {{$bla[]} !== {$bla[%*]}} {error 37.1: {{$bla[] !== {$bla[%*]}}}}
#if {{*bla[]} !== {*bla[%*]}} {error 37.2: {{*bla[] !== {*bla[%*]}}}}
#if {{&bla[]} !== {&bla[%*]}} {error 37.3: {{&bla[] !== {&bla[%*]}}}}

#0 ┌──────────────────────────────────────────────────────────────────────────────┐
#0 │ ██████┐██████┐  █████┐ ███████┐██┐  ██┐   ████████┐███████┐███████┐████████┐ │
#0 │██┌────┘██┌──██┐██┌──██┐██┌────┘██│  ██│   └──██┌──┘██┌────┘██┌────┘└──██┌──┘ │
#0 │██│     ██████┌┘███████│███████┐███████│      ██│   █████┐  ███████┐   ██│    │
#0 │██│     ██┌──██┐██┌──██│└────██│██┌──██│      ██│   ██┌──┘  └────██│   ██│    │
#0 │└██████┐██│  ██│██│  ██│███████│██│  ██│      ██│   ███████┐███████│   ██│    │
#0 │ └─────┘└─┘  └─┘└─┘  └─┘└──────┘└─┘  └─┘      └─┘   └──────┘└──────┘   └─┘    │
#0 └──────────────────────────────────────────────────────────────────────────────┘

#class bla open
#var blabla x
#class bla kill

#action {bla} #nop
#alias {bla} #nop
#button {1;1;2;2} {#nop}
#delay 1000 #nop
#event {GAG SESSION DISCONNECTED} {#nop}
#fun bla {#nop}
#gag bla
#high bla green
#macro \e\e #nop
#pathdir bla bli
#prompt bla bli
#sub bla bli
#tab bla bli
#tick bla {#nop} 1
#var bla bli

#line quiet
{
	#act;#alias;#button;#delay;#event;#event %*;#fun;#gag;#high;#macro;#pathdir;#prompt;#sub;#tab;#tick;#var
}

#nop #line quiet #line debug #1 {#if {0} {#nop};#elseif {0} {#nop};#else #switch {1} {#case 0 #nop;#case 1 #continue}}

#unvar bla
#untab bla
#untick bla
#unsub bla
#unprompt bla
#unpathdir bla
#unmacro \e\e
#ungag hrm
#unfun bla
#unhigh bla
#unevent {GAG SESSION CONNECTED}
#undelay %*
#unbutton {1;1;2;2}
#unact bla
#unalias bla

#bell volume 8
#buffer get bla -1 -1;
#cat bla bli
#line quiet #chat init 0
#chat uninit
#cursor get bla
#line quiet #daemon list
#line quiet #dictionary bla
#line quiet #dictionary hello
#draw green tile 1 -1 1 -1
#draw blue red scaled box 1 1 4 4 hello world
#format bla {}
#line quiet #help %*
#history insert bla
#history delete
#info system save
#list bla create {a;b;c}
#kill variable bla
#loop 0 1 bla #nop
#line quiet
{
	#map create;
	#map goto 1;
	#map dig n;
	#map destroy world
}
#math bla 2+2
#message all on
#parse {abc} {bla} {#nop}
#path create
#path destroy
#line quiet #port init bla 0
#snoop bla
#bla #kill all
#line quiet #port uninit
#regex {bla} {bla} {#nop} {#nop}
#var bla x
#replace bla x y
#screen get cols bla
#line quiet #split
#unsplit

#format end %U;

#0 )=-=( ERROR 19 )=-=( 0#

#function time
{
	#math result ($end - $start) / 1000000.000
}

#if {$error}
{
	#draw White Red scroll box 1 1 3 80 End of validation with $error errors.;
	#end \
}
{
	#delay {0}
	{
		#info memory;
		#info stack;
		#draw Yellow Green scroll box 1 1 3 80 End of validation with 0 errors in @time{} seconds.;
		#line benchmark {#10000 #math tmp (2 | 1) / 2 + 5};
		#end \
	}
}
