From b7c5809d6c5b08f295e60c5e53ee8d8e1074667c Mon Sep 17 00:00:00 2001 From: NeOzay Date: Sun, 28 Jul 2024 22:29:32 +0200 Subject: add test --- test/diagnostics/cast-local-type.lua | 66 ++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'test/diagnostics/cast-local-type.lua') diff --git a/test/diagnostics/cast-local-type.lua b/test/diagnostics/cast-local-type.lua index f79bf48d..93452a92 100644 --- a/test/diagnostics/cast-local-type.lua +++ b/test/diagnostics/cast-local-type.lua @@ -332,3 +332,69 @@ local x - 类型 `nil` 无法匹配 `'B'` - 类型 `nil` 无法匹配 `'A'`]]) end) + +TEST [[ +---@class A +---@field x string +---@field y number + +local a = {x = "", y = 0} + +---@type A +local v +v = a +]] + +TEST [[ +---@class A +---@field x string +---@field y number + +local a = {x = ""} + +---@type A +local v + = a +]] + +TEST [[ +---@class A +---@field x string +---@field y number + +local a = {x = "", y = ""} + +---@type A +local v + = a +]] + +TEST [[ +---@class A +---@field x string +---@field y? B + +---@class B +---@field x string + +local a = {x = "b", y = {x = "c"}} + +---@type A +local v +v = a +]] + +TEST [[ +---@class A +---@field x string +---@field y B + +---@class B +---@field x string + +local a = {x = "b", y = {}} + +---@type A +local v + = a +]] -- cgit v1.2.3