-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_framework.lua
More file actions
131 lines (110 loc) · 3.56 KB
/
test_framework.lua
File metadata and controls
131 lines (110 loc) · 3.56 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
--[[
Quick Framework Test
Simple test to verify the framework loads and runs without errors.
Run with: love . --test
--]]
-- Test basic module loading
local function testModuleLoading()
print("Testing module loading...")
local modules = {
"lib.utils",
"lib.animation",
"lib.layout",
"lib.input",
"lib.scene_manager",
"lib.card_renderer",
"lib.audio_manager",
"data.cards",
"data.atlas_config"
}
for _, module_name in ipairs(modules) do
local success, module = pcall(require, module_name)
if success then
print("✓ " .. module_name .. " loaded successfully")
else
print("✗ " .. module_name .. " failed to load: " .. tostring(module))
return false
end
end
return true
end
-- Test basic functionality
local function testBasicFunctionality()
print("\nTesting basic functionality...")
-- Test Utils
local Utils = require('lib.utils')
Utils.setSeed(12345)
local random_val = Utils.random()
assert(random_val >= 0 and random_val < 1, "Random value should be in [0,1)")
print("✓ Utils RNG working")
-- Test Cards
local Cards = require('data.cards')
local all_cards = Cards.getAllCards()
assert(#all_cards > 0, "Should have cards loaded")
print("✓ Cards loaded: " .. #all_cards .. " cards")
-- Test Animation
local Animation = require('lib.animation')
local test_obj = {x = 0, y = 0}
local tween = Animation.Tween:new(test_obj, 1.0, {x = 100}, Animation.Easing.linear)
assert(tween ~= nil, "Should create tween")
print("✓ Animation system working")
-- Test Layout
local Layout = require('lib.layout')
local container = Layout.Container:new(0, 0, 100, 100)
assert(container ~= nil, "Should create container")
print("✓ Layout system working")
return true
end
-- Main test function
local function runTests()
-- Check if we have the full test suite
local has_full_suite = love.filesystem.getInfo("tests/test_runner.lua") ~= nil
if has_full_suite then
-- Run comprehensive test suite
local TestRunner = require('tests.test_runner')
return TestRunner.runAll()
else
-- Fall back to basic tests
print("=== Love2D Card Game Framework Basic Test ===\n")
local success = true
success = success and testModuleLoading()
success = success and testBasicFunctionality()
print("\n=== Test Results ===")
if success then
print("✓ Basic tests passed! Framework core is working.")
print("Run 'love .' to start the game.")
print("Note: Install full test suite in tests/ directory for comprehensive testing.")
else
print("✗ Some basic tests failed. Check the errors above.")
end
return success
end
end
-- Check if running as test
local function shouldRunTests()
-- Check command line arguments
if arg then
for i, argument in ipairs(arg) do
if argument == "--test" then
return true
end
end
end
-- Check Love2D arguments
if love.arg then
for i, argument in ipairs(love.arg) do
if argument == "--test" then
return true
end
end
end
return false
end
if shouldRunTests() then
local success = runTests()
love.event.quit(success and 0 or 1)
else
return {
runTests = runTests
}
end