From e03dc18930c7f8e92b2f685ff39271698903dae5 Mon Sep 17 00:00:00 2001 From: fesily Date: Mon, 26 Feb 2024 12:46:41 +0800 Subject: [PATCH] update test --- test/diagnostics/await-in-sync.lua | 2 +- test/diagnostics/redundant-parameter.lua | 2 +- test/hover/init.lua | 4 +-- test/signature/init.lua | 41 ++++++++++++++++++++---- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/test/diagnostics/await-in-sync.lua b/test/diagnostics/await-in-sync.lua index 7647f2eb2..323c11137 100644 --- a/test/diagnostics/await-in-sync.lua +++ b/test/diagnostics/await-in-sync.lua @@ -119,7 +119,7 @@ end TEST [[ local function f(cb) - () + cb() end local function af() diff --git a/test/diagnostics/redundant-parameter.lua b/test/diagnostics/redundant-parameter.lua index 520a63812..fabe33403 100644 --- a/test/diagnostics/redundant-parameter.lua +++ b/test/diagnostics/redundant-parameter.lua @@ -94,7 +94,7 @@ print(1, 2, 3, 4, 5) TEST [[ local function f(callback) - callback(, , ) + callback(1, 2, 3) end f(function () end) ]] diff --git a/test/hover/init.lua b/test/hover/init.lua index bed5828ae..0cfce3a42 100644 --- a/test/hover/init.lua +++ b/test/hover/init.lua @@ -276,7 +276,7 @@ function string.lower(s: string|number) -> string ]] --- 根据传入值推测参数类型 +-- 不根据传入值推测参数类型 TEST [[ local function x(a, ...) end @@ -284,7 +284,7 @@ end (1, 2, 3, 4, 5, 6, 7) ]] [[ -function x(a: integer, ...any) +function x(a: any, ...any) ]] TEST [[ diff --git a/test/signature/init.lua b/test/signature/init.lua index 2bf4b8241..bd4d40cd4 100644 --- a/test/signature/init.lua +++ b/test/signature/init.lua @@ -88,7 +88,7 @@ end x(1, 2, 3, ]] -{'function x(a: integer, )'} +{'function x(a: any, )'} TEST [[ (''):sub( @@ -106,7 +106,7 @@ end f(1, 'string') ]] -{'function f(a: integer, , c: any)'} +{'function f(a: any, , c: any)'} TEST [[ pcall(function () end) @@ -156,7 +156,7 @@ end f({},) ]] -{'function f(a: table, , c: any)'} +{'function f(a: any, , c: any)'} TEST [[ for _ in pairs() do @@ -188,7 +188,7 @@ end x( aaaa , 2) ]] -{"function x(, b: integer)"} +{"function x(, b: any)"} TEST [[ local function x(a, b) @@ -196,7 +196,7 @@ end x( aaaa , 2) ]] -{'function x(, b: integer)'} +{'function x(, b: any)'} TEST [[ local function x(a, b) @@ -204,7 +204,7 @@ end x(aaaa , 2) ]] -{'function x(a: any, )'} +{'function x(a: any, )'} TEST [[ local function x(a, b) @@ -212,7 +212,7 @@ end x(aaaa , 2 ) ]] -{'function x(a: any, )'} +{'function x(a: any, )'} TEST [[ local fooC @@ -372,3 +372,30 @@ t:event("onTimer", ) { '(method) (ev: "onTimer", )', } + +local config = require 'config' +config.set(nil, "Lua.type.inferParamType", true) + +TEST [[ +local function x(a, b) +end + +x("1", ) +]] +{ +'function x(a: string, )' +} + +TEST [[ +local function x(a) + +end +x('str') +x(1) +x() +]] +{ +'function x()', +} + +config.set(nil, "Lua.type.inferParamType", false)