summaryrefslogtreecommitdiff
path: root/test/diagnostics/invisible.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/diagnostics/invisible.lua')
-rw-r--r--test/diagnostics/invisible.lua145
1 files changed, 145 insertions, 0 deletions
diff --git a/test/diagnostics/invisible.lua b/test/diagnostics/invisible.lua
new file mode 100644
index 00000000..2fc6791e
--- /dev/null
+++ b/test/diagnostics/invisible.lua
@@ -0,0 +1,145 @@
+local config = require 'config'
+
+TEST [[
+---@class A
+---@field private x number
+---@field protected y number
+---@field public z number
+local t
+print(t.x)
+]]
+
+TEST [[
+---@class A
+---@field private x number
+---@field protected y number
+---@field public z number
+
+---@type A
+local t
+
+print(t.<!x!>)
+]]
+
+TEST [[
+---@class A
+---@field private x number
+---@field protected y number
+---@field public z number
+
+---@class B: A
+local t
+
+print(t.y)
+]]
+
+TEST [[
+---@class A
+---@field private x number
+---@field protected y number
+---@field public z number
+
+---@class B: A
+
+---@type B
+local t
+
+print(t.<!y!>)
+]]
+
+TEST [[
+---@class A
+---@field private x number
+---@field protected y number
+---@field public z number
+
+---@class B: A
+
+---@type B
+local t
+
+print(t.z)
+]]
+TEST [[
+---@class A
+---@field _id number
+
+---@type A
+local t
+
+print(t._id)
+]]
+
+config.set(nil, 'Lua.doc.privateName', { '_*' })
+TEST [[
+---@class A
+---@field _id number
+
+---@type A
+local t
+
+print(t.<!_id!>)
+
+---@class B: A
+local t2
+
+print(t2.<!_id!>)
+]]
+config.set(nil, 'Lua.doc.privateName', nil)
+
+config.set(nil, 'Lua.doc.protectedName', { '_*' })
+TEST [[
+---@class A
+---@field _id number
+
+---@type A
+local t
+
+print(t.<!_id!>)
+
+---@class B: A
+local t2
+
+print(t2._id)
+]]
+config.set(nil, 'Lua.doc.protectedName', nil)
+
+TEST [[
+---@class A
+---@field private x number
+local mt = {}
+
+function mt:init()
+ print(self.x)
+end
+]]
+
+TEST [[
+---@diagnostic disable: unused-local
+---@diagnostic disable: missing-fields
+---@class A
+---@field private x number
+local mt = {}
+
+function mt:init()
+ ---@type A
+ local obj = {}
+
+ obj.x = 1
+end
+]]
+
+TEST [[
+---@diagnostic disable: unused-local
+---@diagnostic disable: missing-fields
+---@class A
+---@field private x number
+local mt = {}
+
+mt.init = function ()
+ ---@type A
+ local obj = {}
+
+ obj.x = 1
+end
+]]