forked from CopilotC-Nvim/CopilotChat.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass_spec.lua
More file actions
33 lines (30 loc) · 783 Bytes
/
class_spec.lua
File metadata and controls
33 lines (30 loc) · 783 Bytes
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
local class = require('CopilotChat.utils.class')
describe('CopilotChat.utils.class', function()
it('creates a simple class', function()
local Foo = class(function(self, x)
self.x = x
end)
local obj = Foo(42)
assert.equals(42, obj.x)
end)
it('supports init method', function()
local Bar = class(function(self, y)
self.y = y
end)
local obj = Bar.new(7)
assert.equals(7, obj.y)
obj:init(8)
assert.equals(8, obj.y)
end)
it('supports inheritance', function()
local Parent = class(function(self)
self.val = 1
end)
local Child = class(function(self)
self.val = 2
end, Parent)
local obj = Child()
assert.equals(2, obj.val)
assert.equals(Parent, getmetatable(Child).__index)
end)
end)