mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-19 06:15:34 +00:00
Diagnostics, implementation and definition tools (WIP)
This commit is contained in:
1 parent
df0f476614
commit
c55e0c900e
66 files changed
+3928
-38
No files matched your search
@@ -3,6 +3,7 @@
|
||||
-- main.lua: Entry point for the test application
|
||||
|
||||
local calculator = require("src.calculator")
|
||||
local animals = require("src.animals")
|
||||
local utils = require("src.utils")
|
||||
|
||||
local function print_banner()
|
||||
@@ -50,6 +51,12 @@ local function test_utils()
|
||||
logger:warn("This is a warning")
|
||||
end
|
||||
|
||||
local function test_animals()
|
||||
print("\nTesting Animal Module:")
|
||||
local dog = animals.Dog:new("Rex")
|
||||
print(dog:speak())
|
||||
end
|
||||
|
||||
local function interactive_calculator()
|
||||
print("\nInteractive Calculator (type 'quit' to exit):")
|
||||
while true do
|
||||
@@ -99,11 +106,13 @@ local function main(args)
|
||||
if #args == 0 then
|
||||
test_calculator()
|
||||
test_utils()
|
||||
test_animals()
|
||||
elseif args[1] == "interactive" then
|
||||
interactive_calculator()
|
||||
elseif args[1] == "test" then
|
||||
test_calculator()
|
||||
test_utils()
|
||||
test_animals()
|
||||
print("\nAll tests completed!")
|
||||
else
|
||||
print("Usage: lua main.lua [interactive|test]")
|
||||
@@ -111,4 +120,4 @@ local function main(args)
|
||||
end
|
||||
|
||||
-- Run main function
|
||||
main(arg or {})
|
||||
main(arg or {})
|
||||
@@ -0,0 +1,37 @@
|
||||
---@class Animal
|
||||
local Animal = {}
|
||||
Animal.__index = Animal
|
||||
|
||||
---@param name string
|
||||
---@return Animal
|
||||
function Animal:new(name)
|
||||
local self = setmetatable({}, Animal)
|
||||
self.name = name
|
||||
return self
|
||||
end
|
||||
|
||||
---@return string
|
||||
function Animal:speak()
|
||||
return self.name .. " makes a sound"
|
||||
end
|
||||
|
||||
---@class Dog: Animal
|
||||
local Dog = setmetatable({}, { __index = Animal })
|
||||
Dog.__index = Dog
|
||||
|
||||
---@param name string
|
||||
---@return Dog
|
||||
function Dog:new(name)
|
||||
local self = Animal.new(self, name)
|
||||
return setmetatable(self, Dog)
|
||||
end
|
||||
|
||||
---@return string
|
||||
function Dog:speak()
|
||||
return self.name .. " says woof"
|
||||
end
|
||||
|
||||
return {
|
||||
Animal = Animal,
|
||||
Dog = Dog,
|
||||
}
|
||||
Reference in new issue
Block a user