🎨 Auto-format GDScript code

Automated formatting applied by tools/run_development.py

🤖 Generated by Gitea Actions
Workflow: Continuous Integration
Run: http://server:3000/nett00n/skelly/actions/runs/90
This commit is contained in:
Gitea Actions
2025-10-01 11:05:19 +00:00
parent 3b8da89ad5
commit 1f1c394587
28 changed files with 655 additions and 1945 deletions

View File

@@ -51,9 +51,7 @@ func setup_test_environment():
# Load Match3 scene
match3_scene = load("res://scenes/game/gameplays/Match3Gameplay.tscn")
TestHelperClass.assert_not_null(
match3_scene, "Match3 scene loads successfully"
)
TestHelperClass.assert_not_null(match3_scene, "Match3 scene loads successfully")
# Create test viewport for isolated testing
test_viewport = SubViewport.new()
@@ -64,9 +62,7 @@ func setup_test_environment():
if match3_scene:
match3_instance = match3_scene.instantiate()
test_viewport.add_child(match3_instance)
TestHelperClass.assert_not_null(
match3_instance, "Match3 instance created successfully"
)
TestHelperClass.assert_not_null(match3_instance, "Match3 instance created successfully")
# Wait for initialization
await process_frame
@@ -77,44 +73,28 @@ func test_basic_functionality():
TestHelperClass.print_step("Basic Functionality")
if not match3_instance:
TestHelperClass.assert_true(
false, "Match3 instance not available for testing"
)
TestHelperClass.assert_true(false, "Match3 instance not available for testing")
return
# Test that Match3 has expected properties
var expected_properties = [
"GRID_SIZE",
"TILE_TYPES",
"grid",
"current_state",
"selected_tile",
"cursor_position"
"GRID_SIZE", "TILE_TYPES", "grid", "current_state", "selected_tile", "cursor_position"
]
for prop in expected_properties:
TestHelperClass.assert_true(
prop in match3_instance, "Match3 has property: " + prop
)
TestHelperClass.assert_true(prop in match3_instance, "Match3 has property: " + prop)
# Test that Match3 has expected methods
var expected_methods = [
"_has_match_at",
"_check_for_matches",
"_get_match_line",
"_clear_matches"
"_has_match_at", "_check_for_matches", "_get_match_line", "_clear_matches"
]
TestHelperClass.assert_has_methods(
match3_instance, expected_methods, "Match3 gameplay methods"
)
TestHelperClass.assert_has_methods(match3_instance, expected_methods, "Match3 gameplay methods")
# Test signals
TestHelperClass.assert_true(
match3_instance.has_signal("score_changed"),
"Match3 has score_changed signal"
match3_instance.has_signal("score_changed"), "Match3 has score_changed signal"
)
TestHelperClass.assert_true(
match3_instance.has_signal("grid_state_loaded"),
"Match3 has grid_state_loaded signal"
match3_instance.has_signal("grid_state_loaded"), "Match3 has grid_state_loaded signal"
)
@@ -125,41 +105,26 @@ func test_constants_and_safety_limits():
return
# Test safety constants exist
TestHelperClass.assert_true(
"MAX_GRID_SIZE" in match3_instance, "MAX_GRID_SIZE constant exists"
)
TestHelperClass.assert_true("MAX_GRID_SIZE" in match3_instance, "MAX_GRID_SIZE constant exists")
TestHelperClass.assert_true(
"MAX_TILE_TYPES" in match3_instance, "MAX_TILE_TYPES constant exists"
)
TestHelperClass.assert_true(
"MAX_CASCADE_ITERATIONS" in match3_instance,
"MAX_CASCADE_ITERATIONS constant exists"
)
TestHelperClass.assert_true(
"MIN_GRID_SIZE" in match3_instance, "MIN_GRID_SIZE constant exists"
"MAX_CASCADE_ITERATIONS" in match3_instance, "MAX_CASCADE_ITERATIONS constant exists"
)
TestHelperClass.assert_true("MIN_GRID_SIZE" in match3_instance, "MIN_GRID_SIZE constant exists")
TestHelperClass.assert_true(
"MIN_TILE_TYPES" in match3_instance, "MIN_TILE_TYPES constant exists"
)
# Test safety limit values are reasonable
TestHelperClass.assert_equal(15, match3_instance.MAX_GRID_SIZE, "MAX_GRID_SIZE is reasonable")
TestHelperClass.assert_equal(10, match3_instance.MAX_TILE_TYPES, "MAX_TILE_TYPES is reasonable")
TestHelperClass.assert_equal(
15, match3_instance.MAX_GRID_SIZE, "MAX_GRID_SIZE is reasonable"
)
TestHelperClass.assert_equal(
10, match3_instance.MAX_TILE_TYPES, "MAX_TILE_TYPES is reasonable"
)
TestHelperClass.assert_equal(
20,
match3_instance.MAX_CASCADE_ITERATIONS,
"MAX_CASCADE_ITERATIONS prevents infinite loops"
)
TestHelperClass.assert_equal(
3, match3_instance.MIN_GRID_SIZE, "MIN_GRID_SIZE is reasonable"
)
TestHelperClass.assert_equal(
3, match3_instance.MIN_TILE_TYPES, "MIN_TILE_TYPES is reasonable"
20, match3_instance.MAX_CASCADE_ITERATIONS, "MAX_CASCADE_ITERATIONS prevents infinite loops"
)
TestHelperClass.assert_equal(3, match3_instance.MIN_GRID_SIZE, "MIN_GRID_SIZE is reasonable")
TestHelperClass.assert_equal(3, match3_instance.MIN_TILE_TYPES, "MIN_TILE_TYPES is reasonable")
# Test current values are within safety limits
TestHelperClass.assert_in_range(
@@ -183,16 +148,13 @@ func test_constants_and_safety_limits():
# Test timing constants
TestHelperClass.assert_true(
"CASCADE_WAIT_TIME" in match3_instance,
"CASCADE_WAIT_TIME constant exists"
"CASCADE_WAIT_TIME" in match3_instance, "CASCADE_WAIT_TIME constant exists"
)
TestHelperClass.assert_true(
"SWAP_ANIMATION_TIME" in match3_instance,
"SWAP_ANIMATION_TIME constant exists"
"SWAP_ANIMATION_TIME" in match3_instance, "SWAP_ANIMATION_TIME constant exists"
)
TestHelperClass.assert_true(
"TILE_DROP_WAIT_TIME" in match3_instance,
"TILE_DROP_WAIT_TIME constant exists"
"TILE_DROP_WAIT_TIME" in match3_instance, "TILE_DROP_WAIT_TIME constant exists"
)
@@ -203,12 +165,8 @@ func test_grid_initialization():
return
# Test grid structure
TestHelperClass.assert_not_null(
match3_instance.grid, "Grid array is initialized"
)
TestHelperClass.assert_true(
match3_instance.grid is Array, "Grid is Array type"
)
TestHelperClass.assert_not_null(match3_instance.grid, "Grid array is initialized")
TestHelperClass.assert_true(match3_instance.grid is Array, "Grid is Array type")
# Test grid dimensions
var expected_height = match3_instance.GRID_SIZE.y
@@ -222,9 +180,7 @@ func test_grid_initialization():
for y in range(match3_instance.grid.size()):
if y < expected_height:
TestHelperClass.assert_equal(
expected_width,
match3_instance.grid[y].size(),
"Grid row %d has correct width" % y
expected_width, match3_instance.grid[y].size(), "Grid row %d has correct width" % y
)
# Test tiles are properly instantiated
@@ -239,12 +195,10 @@ func test_grid_initialization():
if tile and is_instance_valid(tile):
valid_tile_count += 1
TestHelperClass.assert_true(
"tile_type" in tile,
"Tile at (%d,%d) has tile_type property" % [x, y]
"tile_type" in tile, "Tile at (%d,%d) has tile_type property" % [x, y]
)
TestHelperClass.assert_true(
"grid_position" in tile,
"Tile at (%d,%d) has grid_position property" % [x, y]
"grid_position" in tile, "Tile at (%d,%d) has grid_position property" % [x, y]
)
# Test tile type is within valid range
@@ -268,24 +222,15 @@ func test_grid_layout_calculation():
return
# Test tile size calculation
TestHelperClass.assert_true(match3_instance.tile_size > 0, "Tile size is positive")
TestHelperClass.assert_true(
match3_instance.tile_size > 0, "Tile size is positive"
)
TestHelperClass.assert_true(
match3_instance.tile_size <= 200,
"Tile size is reasonable (not too large)"
match3_instance.tile_size <= 200, "Tile size is reasonable (not too large)"
)
# Test grid offset
TestHelperClass.assert_not_null(
match3_instance.grid_offset, "Grid offset is set"
)
TestHelperClass.assert_true(
match3_instance.grid_offset.x >= 0, "Grid offset X is non-negative"
)
TestHelperClass.assert_true(
match3_instance.grid_offset.y >= 0, "Grid offset Y is non-negative"
)
TestHelperClass.assert_not_null(match3_instance.grid_offset, "Grid offset is set")
TestHelperClass.assert_true(match3_instance.grid_offset.x >= 0, "Grid offset X is non-negative")
TestHelperClass.assert_true(match3_instance.grid_offset.y >= 0, "Grid offset Y is non-negative")
# Test layout constants
TestHelperClass.assert_equal(
@@ -297,9 +242,7 @@ func test_grid_layout_calculation():
TestHelperClass.assert_equal(
50.0, match3_instance.GRID_LEFT_MARGIN, "Grid left margin constant"
)
TestHelperClass.assert_equal(
50.0, match3_instance.GRID_TOP_MARGIN, "Grid top margin constant"
)
TestHelperClass.assert_equal(50.0, match3_instance.GRID_TOP_MARGIN, "Grid top margin constant")
func test_state_management():
@@ -310,30 +253,23 @@ func test_state_management():
# Test GameState enum exists and has expected values
var game_state_class = match3_instance.get_script().get_global_class()
TestHelperClass.assert_true(
"GameState" in match3_instance, "GameState enum accessible"
)
TestHelperClass.assert_true("GameState" in match3_instance, "GameState enum accessible")
# Test current state is valid
TestHelperClass.assert_not_null(
match3_instance.current_state, "Current state is set"
)
TestHelperClass.assert_not_null(match3_instance.current_state, "Current state is set")
# Test initialization flags
TestHelperClass.assert_true(
"grid_initialized" in match3_instance, "Grid initialized flag exists"
)
TestHelperClass.assert_true(
match3_instance.grid_initialized, "Grid is marked as initialized"
)
TestHelperClass.assert_true(match3_instance.grid_initialized, "Grid is marked as initialized")
# Test instance ID for debugging
TestHelperClass.assert_true(
"instance_id" in match3_instance, "Instance ID exists for debugging"
)
TestHelperClass.assert_true(
match3_instance.instance_id.begins_with("Match3_"),
"Instance ID has correct format"
match3_instance.instance_id.begins_with("Match3_"), "Instance ID has correct format"
)
@@ -345,16 +281,13 @@ func test_match_detection():
# Test match detection methods exist and can be called safely
TestHelperClass.assert_true(
match3_instance.has_method("_has_match_at"),
"_has_match_at method exists"
match3_instance.has_method("_has_match_at"), "_has_match_at method exists"
)
TestHelperClass.assert_true(
match3_instance.has_method("_check_for_matches"),
"_check_for_matches method exists"
match3_instance.has_method("_check_for_matches"), "_check_for_matches method exists"
)
TestHelperClass.assert_true(
match3_instance.has_method("_get_match_line"),
"_get_match_line method exists"
match3_instance.has_method("_get_match_line"), "_get_match_line method exists"
)
# Test boundary checking with invalid positions
@@ -377,10 +310,7 @@ func test_match_detection():
)
TestHelperClass.assert_true(
is_invalid,
(
"Invalid position (%d,%d) is correctly identified as invalid"
% [pos.x, pos.y]
)
"Invalid position (%d,%d) is correctly identified as invalid" % [pos.x, pos.y]
)
# Test valid positions through public interface
@@ -394,8 +324,7 @@ func test_match_detection():
and pos.y < match3_instance.GRID_SIZE.y
)
TestHelperClass.assert_true(
is_valid,
"Valid position (%d,%d) is within grid bounds" % [x, y]
is_valid, "Valid position (%d,%d) is within grid bounds" % [x, y]
)
@@ -410,14 +339,12 @@ func test_scoring_system():
# Test that the match3 instance can handle scoring (indirectly through clearing matches)
TestHelperClass.assert_true(
match3_instance.has_method("_clear_matches"),
"Scoring system method exists"
match3_instance.has_method("_clear_matches"), "Scoring system method exists"
)
# Test that score_changed signal exists
TestHelperClass.assert_true(
match3_instance.has_signal("score_changed"),
"Score changed signal exists"
match3_instance.has_signal("score_changed"), "Score changed signal exists"
)
# Test scoring formula logic (based on the documented formula)
@@ -433,9 +360,7 @@ func test_scoring_system():
calculated_score = match_size + max(0, match_size - 2)
TestHelperClass.assert_equal(
expected_score,
calculated_score,
"Scoring formula correct for %d gems" % match_size
expected_score, calculated_score, "Scoring formula correct for %d gems" % match_size
)
@@ -450,26 +375,22 @@ func test_input_validation():
match3_instance.cursor_position, "Cursor position is initialized"
)
TestHelperClass.assert_true(
match3_instance.cursor_position is Vector2i,
"Cursor position is Vector2i type"
match3_instance.cursor_position is Vector2i, "Cursor position is Vector2i type"
)
# Test keyboard navigation flag
TestHelperClass.assert_true(
"keyboard_navigation_enabled" in match3_instance,
"Keyboard navigation flag exists"
"keyboard_navigation_enabled" in match3_instance, "Keyboard navigation flag exists"
)
TestHelperClass.assert_true(
match3_instance.keyboard_navigation_enabled is bool,
"Keyboard navigation flag is boolean"
match3_instance.keyboard_navigation_enabled is bool, "Keyboard navigation flag is boolean"
)
# Test selected tile safety
# selected_tile can be null initially, which is valid
if match3_instance.selected_tile:
TestHelperClass.assert_true(
is_instance_valid(match3_instance.selected_tile),
"Selected tile is valid if not null"
is_instance_valid(match3_instance.selected_tile), "Selected tile is valid if not null"
)
@@ -491,25 +412,20 @@ func test_memory_safety():
var tile = match3_instance.grid[y][x]
if tile:
TestHelperClass.assert_true(
is_instance_valid(tile),
"Grid tile at (%d,%d) is valid instance" % [x, y]
is_instance_valid(tile), "Grid tile at (%d,%d) is valid instance" % [x, y]
)
TestHelperClass.assert_true(
tile.get_parent() == match3_instance,
"Tile properly parented to Match3"
tile.get_parent() == match3_instance, "Tile properly parented to Match3"
)
# Test position validation
TestHelperClass.assert_true(
match3_instance.has_method("_is_valid_grid_position"),
"Position validation method exists"
match3_instance.has_method("_is_valid_grid_position"), "Position validation method exists"
)
# Test safe tile access patterns exist
# The Match3 code uses comprehensive bounds checking and null validation
TestHelperClass.assert_true(
true, "Memory safety patterns implemented in Match3 code"
)
TestHelperClass.assert_true(true, "Memory safety patterns implemented in Match3 code")
func test_performance_requirements():
@@ -533,16 +449,13 @@ func test_performance_requirements():
# Test timing constants are reasonable for 60fps gameplay
TestHelperClass.assert_true(
match3_instance.CASCADE_WAIT_TIME >= 0.05,
"Cascade wait time allows for smooth animation"
match3_instance.CASCADE_WAIT_TIME >= 0.05, "Cascade wait time allows for smooth animation"
)
TestHelperClass.assert_true(
match3_instance.SWAP_ANIMATION_TIME <= 0.5,
"Swap animation time is responsive"
match3_instance.SWAP_ANIMATION_TIME <= 0.5, "Swap animation time is responsive"
)
TestHelperClass.assert_true(
match3_instance.TILE_DROP_WAIT_TIME <= 0.3,
"Tile drop wait time is responsive"
match3_instance.TILE_DROP_WAIT_TIME <= 0.3, "Tile drop wait time is responsive"
)
# Test grid initialization performance