Capture more syntax scenarios in the regression test, update the snapshot.

This commit is contained in:
Matt Hargett
2022-07-26 13:25:14 -07:00
parent 8aaa1302cc
commit cfb8374611
2 changed files with 89 additions and 51 deletions

View File

@ -8,17 +8,19 @@ local _notVariable = not x
local _length = #{x}
export type Function<T... = ...any> = (...any) -> T...
return function (req, ...: boolean): ({[string|number]: any}, string, Function<...any>)
return function <T>(req, ...: boolean): ({[string|number]: T}, string, Function<...any>)
local body = string.format("%s %s\n", req.method, req.path)
local res = {
code = 200,
{ "Content-Type", "text/plain" },
{ "Content-Length", #body } :: Array<any>,
} :: { [any]: number | Array<string | boolean> }
if req.keepAlive then
res[#res + 1] = { "Connection", "Keep-Alive" }
res[#res + 2] = { ... }
if (req :: any).keepAlive then
local socketType: "Connection" | "Pingback" | "" = "" :: ""
socketType = "Connection" :: "Connection"
res[#res + 1] = { socketType :: string, "Keep-Alive" }
res[#res - 2] = { ... }
end
return res, body, function(...): ...any return ... end
return (res :: any) :: { T }, body, function(...): ...any return ... end
end

View File

@ -67,27 +67,30 @@ L9
L11
[return] 1 6
[function] 8 15
[(] 17 17
[req] 18 20
[,] 21 21
[...] 23 25
[:] 26 26
[boolean] 28 34
[)] 35 35
[:] 36 36
[(] 38 38
[{] 39 39
[\[] 40 40
[string|number] 41 53
[\]] 54 54
[:] 55 55
[any] 57 59
[}] 60 60
[,] 61 61
[string] 63 68
[,] 69 69
[Function<...any>] 71 86
[)] 87 87
[<] 17 17
[T] 18 18
[>] 19 19
[(] 20 20
[req] 21 23
[,] 24 24
[...] 26 28
[:] 29 29
[boolean] 31 37
[)] 38 38
[:] 39 39
[(] 41 41
[{] 42 42
[\[] 43 43
[string|number] 44 56
[\]] 57 57
[:] 58 58
[T] 60 60
[}] 61 61
[,] 62 62
[string] 64 69
[,] 70 70
[Function<...any>] 72 87
[)] 88 88
L12
[local] 3 7
[body] 9 12
@ -152,11 +155,34 @@ L17
[}] 50 50
L18
[if] 3 4
[req] 6 8
[.] 9 9
[keepAlive] 10 18
[then] 20 23
[(] 6 6
[req] 7 9
[::] 11 12
[any] 14 16
[)] 17 17
[.] 18 18
[keepAlive] 19 27
[then] 29 32
L19
[local] 5 9
[socketType] 11 20
[:] 21 21
["Connection"] 23 34
[|] 36 36
["Pingback"] 38 47
[|] 49 49
[""] 51 52
[=] 54 54
[""] 56 57
[::] 59 60
[""] 62 63
L20
[socketType] 5 14
[=] 16 16
["Connection"] 18 29
[::] 31 32
["Connection"] 34 45
L21
[res] 5 7
[\[] 8 8
[#] 9 9
@ -166,38 +192,48 @@ L19
[\]] 17 17
[=] 19 19
[{] 21 21
["Connection"] 23 34
[,] 35 35
["Keep-Alive"] 37 48
[}] 50 50
L20
[socketType] 23 32
[::] 34 35
[string] 37 42
[,] 43 43
["Keep-Alive"] 45 56
[}] 58 58
L22
[res] 5 7
[\[] 8 8
[#] 9 9
[res] 10 12
[+] 14 14
[-] 14 14
[2] 16 16
[\]] 17 17
[=] 19 19
[{] 21 21
[...] 23 25
[}] 27 27
L21
[end] 3 5
L23
[end] 3 5
L25
[return] 3 8
[res] 10 12
[,] 13 13
[body] 15 18
[,] 19 19
[function] 21 28
[(] 29 29
[...)] 30 33
[:] 34 34
[...any] 36 41
[return] 43 48
[...] 50 52
[end] 54 56
L24
[(] 10 10
[res] 11 13
[::] 15 16
[any] 18 20
[)] 21 21
[::] 23 24
[{] 26 26
[T] 28 28
[}] 30 30
[,] 31 31
[body] 33 36
[,] 37 37
[function] 39 46
[(] 47 47
[...)] 48 51
[:] 52 52
[...any] 54 59
[return] 61 66
[...] 68 70
[end] 72 74
L26
[end] 1 3
EOF