-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.aup
128 lines (107 loc) · 3.77 KB
/
tests.aup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include "plys.aup"
Opt("MustDeclareVars", 0)
plys = ReReplace(@AutoItExe, "AutoIt3\.exe$", "", 1) . "Plys\plys.aup.au3"
func import()
src = @ScriptDir . '\import.src.aup'
FileDelete(src)
FileWrite(src, ' #include "lib.aup" ;' . @ . '#import "lib.aup"' . @)
au3 = src . ".au3"
cmd = '"' . @AutoItExe . '" "' . plys . '" /Translate "' . src . '"'
RunWait(cmd)
FileDelete(src)
txt = Read(au3)
FileDelete(au3)
return ReFind(txt, _
'\R #include "lib\.aup\.au3" ;\R' _
. '; PLYS #import "lib\.aup"\R$')
func process_imports()
miscTokens = Split _
(' #include "lib.aup"|#import "lib.aup"|#include "lib.aup"', _
"|", @NoCount)
module = -1
isPlysFile = False
_ProcessImports(miscTokens, module, isPlysFile)
return _ArrayToString(miscTokens) == _
' #include "lib.aup.au3"|#import "lib.aup"|#include "lib.aup.au3"'
func if_then_one()
mainText = "if True then Echo(1)"
_CloseBlocks(mainText)
return mainText == _
"if True then Echo(1)"
func if_then_block()
mainText = "if True then" . @ . @tab . "Echo(1)"
_CloseBlocks(mainText)
return mainText == _
"if True then" . @ . " Echo(1)" . @ . "endif"
func if_then_()
mainText = "if True then _ ; xxx" . @ . @tab . "Echo(1)" . @
_CloseBlocks(mainText)
return mainText == "if True then _ ; xxx" . @ . " Echo(1)" . @
func script_line_number()
return @ScriptLineNumber = 48
func script_full_path()
return @ScriptFullPath = "c:\Users\Spray\Desktop\Plys\tests.aup"
func script_name()
return @ScriptName == "tests.aup"
func plys_path()
return @PlysPath = "c:\Program Files (x86)\AutoIt3\Plys\plys.aup.au3"
func plys_version()
return @PlysVersion == "0.4.0"
func path_part()
return PathPart("c:\dir\plys.aup.au3", "name") == "plys.aup"
func lambda()
return {x, y: 2*x + @ScriptLineNumber}(3, 42) == 72
func make_lambda_lines()
dim lambdaContent = ["a"]
return __MakeOrdinaryFunc(lambdaContent, "b", " ; #1") == @ . @ _
. "func b() ; #1" . @ _
. TabInSpaces . "return a ; #1" . @ _
. "endfunc" . @
func process_lambdas()
mainText = 'a = {x: x . "zxcv"}' . LineNumCommentPrefix . "1" . @ _
. '$a("qwdf")' . LineNumCommentPrefix . "2"
miscTokens = _SeparateMain(mainText)
_ProcessLambdas(mainText, miscTokens)
_CombineTokens(mainText, miscTokens)
return ReFind(mainText, _
"a = ([a-z]{" . LambdaNameLen . "})" . LineNumCommentPrefix . "1\R" _
. '\$a\("qwdf"\)' . LineNumCommentPrefix . "2\R\R" _
. "func \1\(x\)" . LineNumCommentPrefix . "1\R" _
. TabInSpaces . 'return x \. "zxcv"' . LineNumCommentPrefix . '1\R' _
. "endfunc\R")
func func_continuation()
src = @ScriptDir . '\func_.src.aup'
FileDelete(src)
FileWrite(src, "func a _" . @ _
. TabInSpaces . TabInSpaces . "(b, dim c)" . @ _
. TabInSpaces . "return b + c")
au3 = src . ".au3"
cmd = '"' . @AutoItExe . '" "' . plys . '" /Translate "' . src . '"'
RunWait(cmd)
FileDelete(src)
txt = Read(au3)
FileDelete(au3)
return ReFind(txt, _
"\Rfunc a _\R" _
. TabInSpaces . TabInSpaces . "\(const \$b, \$c\)\R" _
. TabInSpaces . "return \$b \+ \$c\R" _
. "endfunc$")
func tray_set_tool_tip()
RunMode = True
txt = 'TraySetToolTip("A")' . @ . "TraySetToolTip()"
_SubstituteMacros(txt)
return txt == 'TraySetToolTip("A")' . @ _
. 'TraySetToolTip("AutoIt Plys - " . @ScriptName)'
; TODO: on changed dependence
const funcs = [import, process_imports, if_then_one, if_then_block, if_then_, _
script_line_number, script_full_path, script_name, plys_path, _
plys_version, path_part, lambda, make_lambda_lines, process_lambdas, _
func_continuation, tray_set_tool_tip]
failed = 0
for f in funcs
Echo(Lower(ReReplace(FuncName(f), "_TESTS__(\w+)", "\1")))
res = $f()
Echo((res? " +" : ": FAIL") . @)
if res = False then failed += 1
Echo("total: " . UBound(funcs) . "; passed: " . (UBound(funcs) - failed) _
. "; failed: " . failed . @)