- Types on every parameter, return value and variable, and snake_case names (the player name limit is the constant MAX_NAME_LENGTH). - Spelling fixes: *_triggered, character_selected, separator, caught_errors. The server's catched_errors key stays as the server sends it. - Signals are connected with signal.connect() instead of by name. - Code is ordered signals, constants, exported vars, vars, @onready vars, functions, with @onready on one line and two blank lines between functions. - Every script starts with a ## description. Template comments, old LOC notes and commented-out code are gone, apart from the local play code. - Lines are at most 100 characters, apart from the local play path. - The screenshot tour turns off the blinking text cursor so pictures match.
62 lines
1.7 KiB
GDScript
62 lines
1.7 KiB
GDScript
extends GdUnitTestSuite
|
|
## SongObject: what it shows before and after the answer, and its points.
|
|
|
|
var _is_debug: bool
|
|
var _song: SongObject
|
|
|
|
|
|
func before_test() -> void:
|
|
_is_debug = Settings.is_debug
|
|
Settings.is_debug = false
|
|
_song = SongObject.new()
|
|
_song.song_number = 4
|
|
_song.soundtrack_title = "Final Fantasy VI"
|
|
_song.song_title = "Dancing Mad"
|
|
|
|
|
|
func after_test() -> void:
|
|
Settings.is_debug = _is_debug
|
|
|
|
|
|
func test_titles_are_hidden_until_answered() -> void:
|
|
assert_str(_song.get_soundtrack_title()).is_equal("????????")
|
|
assert_str(_song.get_song_title()).is_equal("??????")
|
|
assert_str(_song.get_song_info()).is_equal("??? - ???")
|
|
|
|
|
|
func test_titles_are_shown_once_answered() -> void:
|
|
_song.is_answered = true
|
|
|
|
assert_str(_song.get_soundtrack_title()).is_equal("Final Fantasy VI")
|
|
assert_str(_song.get_song_title()).is_equal("Dancing Mad")
|
|
assert_str(_song.get_song_info()).is_equal("5. Final Fantasy VI - Dancing Mad")
|
|
|
|
|
|
func test_debug_info_shows_unanswered_songs() -> void:
|
|
Settings.is_debug = true
|
|
|
|
assert_str(_song.get_song_info()).is_equal(
|
|
"5. Final Fantasy VI - Dancing Mad | played: false | answered: false")
|
|
|
|
|
|
func test_points_are_kept_in_the_order_given() -> void:
|
|
_song.add_point("marle-id")
|
|
_song.add_point("crono-id")
|
|
|
|
assert_array(_song.players_given_point).contains_exactly(["marle-id", "crono-id"])
|
|
|
|
|
|
func test_player_gets_at_most_one_point_per_song() -> void:
|
|
_song.add_point("crono-id")
|
|
_song.add_point("crono-id")
|
|
|
|
assert_array(_song.players_given_point).contains_exactly(["crono-id"])
|
|
|
|
|
|
func test_removing_point_of_player_without_point_changes_nothing() -> void:
|
|
_song.add_point("crono-id")
|
|
|
|
_song.remove_point("marle-id")
|
|
|
|
assert_array(_song.players_given_point).contains_exactly(["crono-id"])
|