-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest.lua
114 lines (83 loc) · 2.96 KB
/
Test.lua
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
require "Compare"
require "Run"
-- Common Type Variables
TNumber = "number"
TInt = "integer"
TFloat = "float"
TString = "string"
TBool = "boolean"
TUnknown = "unknown"
TNil = "nil"
TEmptyTable = "emptyTable"
TArrayNumber = {tag = "table", tableType = {arrayType = TNumber}}
TArrayInt = {tag = "table", tableType = {arrayType = TInt}}
TArrayFloat = {tag = "table", tableType = {arrayType = TFloat}}
TArrayString = {tag = "table", tableType = {arrayType = TString}}
TArrayBool = {tag = "table", tableType = {arrayType = TBool}}
TArrayUnknown = {tag = "table", tableType = {arrayType = TUnknown}}
TOptInt = {tag = "optional", optType = TInt}
TOptFloat = {tag = "optional", optType = TFloat}
TOptNumber = {tag = "optional", optType = TNumber}
TOptString = {tag = "optional", optType = TString}
TOptBool = {tag = "optional", optType = TBool}
local function clear()
Functions = {}
end
-- #1
run("Test/temp.lua")
local _,fType = next(Functions)
assert(compareFunction({paramType = {{Type = TInt}},resultType = {{Type = TInt}}}, fType))
-- #2
clear()
run("Test/temp2.lua")
_,fType = next(Functions)
assert(compareFunction({paramType = {{Type = TString}}, resultType = {{Type = TString}}}, fType))
-- #3
clear()
run("Test/temp3.lua")
_,fType = next(Functions)
assert(compareFunction({paramType = {{Type = TBool}}, resultType = {{Type = TBool}}}, fType))
-- #4
clear()
run("Test/temp4.lua")
_,fType = next(Functions)
assert(compareFunction({paramType = {{Type = TFloat}}, resultType = {{Type = TFloat}}}, fType))
-- #5
clear()
run("Test/temp5.lua")
_,fType = next(Functions)
assert(compareFunction({paramType = {{Type = TNumber}}, resultType = {{Type = TNumber}}}, fType))
--#6
clear()
run("Test/temp6.lua")
_,fType = next(Functions)
assert(compareFunction({paramType = {{Type = TNil}}, resultType = {{Type = TNil}}}, fType))
-- #7
clear()
run("Test/temp7.lua")
_,fType = next(Functions)
assert(compareFunction({paramType = {},resultType = {}}, fType))
-- #8
clear()
run("Test/temp8.lua")
_,fType = next(Functions)
assert(compareFunction({paramType = {{Type = {tag = "table", tableType = {arrayType = TInt}}}},
resultType = {{Type = {tag = "table", tableType = {arrayType = TInt}}}}}, fType))
-- #9
clear()
run("Test/temp9.lua")
_,fType = next(Functions)
assert(compareFunction({paramType = {{Type = {tag = "table", tableType = {structType = {a = TInt}}}}},
resultType = {{Type = {tag = "table", tableType = {structType = {a = TInt}}}}}}, fType))
-- #10
clear()
run("Test/temp10.lua")
_,fType = next(Functions)
assert(compareFunction({paramType = {{Type = {tag = "table", tableType = {arrayType = TInt, structType = {a = TInt}}}}},
resultType = {{Type = {tag = "table", tableType = {arrayType = TInt, structType = {a = TInt}}}}}}
, fType))
-- #11
clear()
run("Test/temp11.lua")
_,fType = next(Functions)
assert(compareFunction({paramType = {{Type = TOptInt}}, resultType = {{Type = TOptInt}}}, fType))