From 9f960a74cefb64fd188365405072234ce8eefffa Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Wed, 27 Aug 2025 23:07:33 -0400 Subject: [PATCH 1/9] Add FIXME --- src/word-list-misc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/word-list-misc.c b/src/word-list-misc.c index 17215ca6..124c552d 100644 --- a/src/word-list-misc.c +++ b/src/word-list-misc.c @@ -433,6 +433,7 @@ static gboolean word_not_in_set (gpointer key, return !g_hash_table_contains (word_set, word_index); } +/* FIXME(lookahead): Attempt the optimization again. */ void word_set_remove_unique (WordSet *word_set1, WordSet *word_set2) { -- GitLab From 4f730367316a4c1b8628b416f8d0a8d4b27daffb Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Wed, 27 Aug 2025 23:09:54 -0400 Subject: [PATCH 2/9] Rename FIXMEs --- src/clue-matches.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/clue-matches.c b/src/clue-matches.c index 0d30f0ce..4a156a3b 100644 --- a/src/clue-matches.c +++ b/src/clue-matches.c @@ -33,8 +33,8 @@ filter_is_unconstrained (const gchar *filter) return TRUE; } -/* FIXME(clue-matches): Caching. */ -/* Combine get filter and get offset +/* FIXME(lookahead): Caching. */ +/* FIXME(lookahead): Combine get filter and get offset * into a single loop function? */ static guint get_filter_offset (const IpuzClue *clue, @@ -86,7 +86,7 @@ word_list_find_clue_matches (WordList *word_list, g_assert (current_clue_n_coords > 1); current_filter = clue_get_filter (current_clue, grid); - /* FIXME(editor): Add support for other directions. */ + /* FIXME(lookahead): Add support for other directions. */ current_clue_direction = ipuz_clue_get_direction (current_clue); intersecting_clue_direction = ipuz_clue_direction_switch (current_clue_direction); -- GitLab From eedf2355a527a8fac2289250987bdc72b88e60f3 Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Thu, 28 Aug 2025 05:07:50 -0400 Subject: [PATCH 3/9] Add word-list-tests-utils --- src/word-list-tests-utils.c | 19 +++++++++++++++++++ src/word-list-tests-utils.h | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 src/word-list-tests-utils.c create mode 100644 src/word-list-tests-utils.h diff --git a/src/word-list-tests-utils.c b/src/word-list-tests-utils.c new file mode 100644 index 00000000..dd75b38a --- /dev/null +++ b/src/word-list-tests-utils.c @@ -0,0 +1,19 @@ +/* word-list-tests-utils.c + * + * Copyright 2025 Victor Ma + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ \ No newline at end of file diff --git a/src/word-list-tests-utils.h b/src/word-list-tests-utils.h new file mode 100644 index 00000000..e207f497 --- /dev/null +++ b/src/word-list-tests-utils.h @@ -0,0 +1,19 @@ +/* word-list-tests-utils.h + * + * Copyright 2025 Victor Ma + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ \ No newline at end of file -- GitLab From 93650b14633cfc979cc44172f9bc44481b3ec05f Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Thu, 28 Aug 2025 05:31:20 -0400 Subject: [PATCH 4/9] Move common code to utils file --- src/clue-matches-tests.c | 36 ------------------------------------ src/clue-matches.h | 2 ++ src/word-list-tests-utils.c | 37 ++++++++++++++++++++++++++++++++++++- src/word-list-tests-utils.h | 9 ++++++++- src/word-list-tests.c | 36 ------------------------------------ 5 files changed, 46 insertions(+), 74 deletions(-) diff --git a/src/clue-matches-tests.c b/src/clue-matches-tests.c index 74964215..5068f01d 100644 --- a/src/clue-matches-tests.c +++ b/src/clue-matches-tests.c @@ -26,42 +26,6 @@ // #define _TEST_FILE "tests/clue-matches/.ipuz" -#define BRODA_RESOURCE "../word-lists/broda.gresource" -#define EGG_IPUZ_FILE_PATH "tests/clue-matches/egg.ipuz" -#define VALID_INTERSECTION_IPUZ_FILE_PATH "tests/clue-matches/valid-intersection.ipuz" -#define INVALID_INTERSECTION_IPUZ_FILE_PATH "tests/clue-matches/invalid-intersection.ipuz" - -/* FIXME(tests): Duplicate code in word-list-tests.c. */ -static WordList * -get_word_list (const gchar *resource_path) -{ - g_autofree gchar *path = NULL; - g_autoptr (WordListResource) resource = NULL; - WordList *word_list = NULL; - - path = g_test_build_filename (G_TEST_BUILT, resource_path, NULL); - resource = word_list_resource_new_from_file (path); - - word_list = g_object_new (WORD_TYPE_LIST, - "resource", resource, - NULL); - - return word_list; -} - -static WordList * -get_broda_word_list (void) -{ - return get_word_list (BRODA_RESOURCE); -} - -static IpuzGrid* -create_grid (const gchar* filename) -{ - GridState *state = (load_state (filename, GRID_STATE_EDIT)); - return IPUZ_GRID (state->xword); -} - static IpuzClue* get_clue (IpuzGrid* grid, IpuzClueDirection direction, guint index) { diff --git a/src/clue-matches.h b/src/clue-matches.h index ecacefb3..d090d396 100644 --- a/src/clue-matches.h +++ b/src/clue-matches.h @@ -18,6 +18,8 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ +#pragma once + #include "word-list.h" /* This function is in a separate file from word-list.c, diff --git a/src/word-list-tests-utils.c b/src/word-list-tests-utils.c index dd75b38a..8e4081f1 100644 --- a/src/word-list-tests-utils.c +++ b/src/word-list-tests-utils.c @@ -16,4 +16,39 @@ * along with this program. If not, see . * * SPDX-License-Identifier: GPL-3.0-or-later - */ \ No newline at end of file + */ + +#include "word-list-tests-utils.h" + +#define TEST_RESOURCE "../word-lists/test.gresource" +#define BRODA_RESOURCE "../word-lists/broda.gresource" + +/* FIXME(test): Intersection function generates bad results with TEST_RESOURCE. */ +static WordList * +get_word_list (const gchar *resource_path) +{ + g_autofree gchar *path = NULL; + g_autoptr (WordListResource) resource = NULL; + WordList *word_list = NULL; + + path = g_test_build_filename (G_TEST_BUILT, resource_path, NULL); + resource = word_list_resource_new_from_file (path); + + word_list = g_object_new (WORD_TYPE_LIST, + "resource", resource, + NULL); + + return word_list; +} + +WordList * +get_test_word_list (void) +{ + return get_word_list (TEST_RESOURCE); +} + +WordList * +get_broda_word_list (void) +{ + return get_word_list (BRODA_RESOURCE); +} \ No newline at end of file diff --git a/src/word-list-tests-utils.h b/src/word-list-tests-utils.h index e207f497..34eb1eda 100644 --- a/src/word-list-tests-utils.h +++ b/src/word-list-tests-utils.h @@ -16,4 +16,11 @@ * along with this program. If not, see . * * SPDX-License-Identifier: GPL-3.0-or-later - */ \ No newline at end of file + */ + +#pragma once + +#include "word-list.h" + +WordList *get_test_word_list (void); +WordList *get_broda_word_list (void); \ No newline at end of file diff --git a/src/word-list-tests.c b/src/word-list-tests.c index 10731194..c4a474f9 100644 --- a/src/word-list-tests.c +++ b/src/word-list-tests.c @@ -24,11 +24,6 @@ #include "gen-word-list.h" #include "word-list.h" - -#define TEST_RESOURCE "../word-lists/test.gresource" -#define BRODA_RESOURCE "../word-lists/broda.gresource" - - /* Uncommenting this will enable the profile test. This test will run * word-list matches in an infinite loop and never complete. That can * be used along with a profiler to profile the word-list MATCH @@ -44,37 +39,6 @@ */ //#define PROFILE_TEST - -/* FIXME(test): Intersection function generates bad results with TEST_RESOURCE. */ -static WordList * -get_word_list (const gchar *resource_path) -{ - g_autofree gchar *path = NULL; - g_autoptr (WordListResource) resource = NULL; - WordList *word_list = NULL; - - path = g_test_build_filename (G_TEST_BUILT, resource_path, NULL); - resource = word_list_resource_new_from_file (path); - - word_list = g_object_new (WORD_TYPE_LIST, - "resource", resource, - NULL); - - return word_list; -} - -static WordList * -get_test_word_list (void) -{ - return get_word_list (TEST_RESOURCE); -} - -static WordList * -get_broda_word_list (void) -{ - return get_word_list (BRODA_RESOURCE); -} - #if 0 static void dump_bytes (GBytes *bytes) -- GitLab From 38947615141e0e13d8753641ef34f4e221039848 Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Thu, 28 Aug 2025 05:53:10 -0400 Subject: [PATCH 5/9] Update meson.build --- src/clue-matches-tests.c | 13 +++++++++++++ src/meson.build | 8 +++++++- src/word-list-tests.c | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/clue-matches-tests.c b/src/clue-matches-tests.c index 5068f01d..7e31c576 100644 --- a/src/clue-matches-tests.c +++ b/src/clue-matches-tests.c @@ -22,10 +22,23 @@ #include #include "crosswords-misc.h" #include "clue-matches.h" +#include "word-list-tests-utils.h" #include "test-utils.h" // #define _TEST_FILE "tests/clue-matches/.ipuz" +#define BRODA_RESOURCE "../word-lists/broda.gresource" +#define EGG_IPUZ_FILE_PATH "tests/clue-matches/egg.ipuz" +#define VALID_INTERSECTION_IPUZ_FILE_PATH "tests/clue-matches/valid-intersection.ipuz" +#define INVALID_INTERSECTION_IPUZ_FILE_PATH "tests/clue-matches/invalid-intersection.ipuz" + +static IpuzGrid* +create_grid (const gchar* filename) +{ + GridState *state = (load_state (filename, GRID_STATE_EDIT)); + return IPUZ_GRID (state->xword); +} + static IpuzClue* get_clue (IpuzGrid* grid, IpuzClueDirection direction, guint index) { diff --git a/src/meson.build b/src/meson.build index 73fbff81..d87735a5 100644 --- a/src/meson.build +++ b/src/meson.build @@ -422,9 +422,14 @@ test( # Tests with wordlist +clue_matches_tests_sources = [ + 'word-list-tests.c', + 'word-list-tests-utils.c' +] + word_list_tests = executable( 'word-list-tests', - [ 'word-list-tests.c' ], + clue_matches_tests_sources, dependencies: crosswords_deps, install: false ) @@ -441,6 +446,7 @@ test( clue_matches_tests_sources = [ 'clue-matches-tests.c', + 'word-list-tests-utils.c', 'test-utils.c', 'clue-matches.c' ] + common_sources diff --git a/src/word-list-tests.c b/src/word-list-tests.c index c4a474f9..fbae2e9f 100644 --- a/src/word-list-tests.c +++ b/src/word-list-tests.c @@ -23,6 +23,7 @@ #include "crosswords-stats.h" #include "gen-word-list.h" #include "word-list.h" +#include "word-list-tests-utils.h" /* Uncommenting this will enable the profile test. This test will run * word-list matches in an infinite loop and never complete. That can -- GitLab From d237e5db645cc3d5bef57d1548a27dc6c3e57f4d Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Thu, 28 Aug 2025 06:02:55 -0400 Subject: [PATCH 6/9] Rename ...tests-utils to ...test-utils --- src/clue-matches-tests.c | 2 +- src/meson.build | 4 ++-- src/{word-list-tests-utils.c => word-list-test-utils.c} | 4 ++-- src/{word-list-tests-utils.h => word-list-test-utils.h} | 2 +- src/word-list-tests.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) rename src/{word-list-tests-utils.c => word-list-test-utils.c} (96%) rename src/{word-list-tests-utils.h => word-list-test-utils.h} (96%) diff --git a/src/clue-matches-tests.c b/src/clue-matches-tests.c index 7e31c576..8d2ca27e 100644 --- a/src/clue-matches-tests.c +++ b/src/clue-matches-tests.c @@ -22,7 +22,7 @@ #include #include "crosswords-misc.h" #include "clue-matches.h" -#include "word-list-tests-utils.h" +#include "word-list-test-utils.h" #include "test-utils.h" // #define _TEST_FILE "tests/clue-matches/.ipuz" diff --git a/src/meson.build b/src/meson.build index d87735a5..ea540d27 100644 --- a/src/meson.build +++ b/src/meson.build @@ -424,7 +424,7 @@ test( clue_matches_tests_sources = [ 'word-list-tests.c', - 'word-list-tests-utils.c' + 'word-list-test-utils.c' ] word_list_tests = executable( @@ -446,7 +446,7 @@ test( clue_matches_tests_sources = [ 'clue-matches-tests.c', - 'word-list-tests-utils.c', + 'word-list-test-utils.c', 'test-utils.c', 'clue-matches.c' ] + common_sources diff --git a/src/word-list-tests-utils.c b/src/word-list-test-utils.c similarity index 96% rename from src/word-list-tests-utils.c rename to src/word-list-test-utils.c index 8e4081f1..7e496b50 100644 --- a/src/word-list-tests-utils.c +++ b/src/word-list-test-utils.c @@ -1,4 +1,4 @@ -/* word-list-tests-utils.c +/* word-list-test-utils.c * * Copyright 2025 Victor Ma * @@ -18,7 +18,7 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -#include "word-list-tests-utils.h" +#include "word-list-test-utils.h" #define TEST_RESOURCE "../word-lists/test.gresource" #define BRODA_RESOURCE "../word-lists/broda.gresource" diff --git a/src/word-list-tests-utils.h b/src/word-list-test-utils.h similarity index 96% rename from src/word-list-tests-utils.h rename to src/word-list-test-utils.h index 34eb1eda..705aed9b 100644 --- a/src/word-list-tests-utils.h +++ b/src/word-list-test-utils.h @@ -1,4 +1,4 @@ -/* word-list-tests-utils.h +/* word-list-test-utils.h * * Copyright 2025 Victor Ma * diff --git a/src/word-list-tests.c b/src/word-list-tests.c index fbae2e9f..59c45fd5 100644 --- a/src/word-list-tests.c +++ b/src/word-list-tests.c @@ -23,7 +23,7 @@ #include "crosswords-stats.h" #include "gen-word-list.h" #include "word-list.h" -#include "word-list-tests-utils.h" +#include "word-list-test-utils.h" /* Uncommenting this will enable the profile test. This test will run * word-list matches in an infinite loop and never complete. That can -- GitLab From 1be4ded2d204cbce17007381aedf5c370724d9cd Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Fri, 29 Aug 2025 01:01:27 -0400 Subject: [PATCH 7/9] Remove unused macro --- src/clue-matches-tests.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/clue-matches-tests.c b/src/clue-matches-tests.c index 8d2ca27e..4ac58731 100644 --- a/src/clue-matches-tests.c +++ b/src/clue-matches-tests.c @@ -27,7 +27,6 @@ // #define _TEST_FILE "tests/clue-matches/.ipuz" -#define BRODA_RESOURCE "../word-lists/broda.gresource" #define EGG_IPUZ_FILE_PATH "tests/clue-matches/egg.ipuz" #define VALID_INTERSECTION_IPUZ_FILE_PATH "tests/clue-matches/valid-intersection.ipuz" #define INVALID_INTERSECTION_IPUZ_FILE_PATH "tests/clue-matches/invalid-intersection.ipuz" -- GitLab From 79628add26d19ee854db52b570bc10c5b0cd3dd0 Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Fri, 29 Aug 2025 01:13:28 -0400 Subject: [PATCH 8/9] Use get_broda_word_list() --- src/word-list-tests.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/word-list-tests.c b/src/word-list-tests.c index 59c45fd5..fe920be8 100644 --- a/src/word-list-tests.c +++ b/src/word-list-tests.c @@ -442,16 +442,9 @@ frequency_test (void) static void profile_test (void) { - g_autofree gchar *path = NULL; - g_autoptr (WordListResource) resource = NULL; - WordList *word_list = NULL; + g_autoptr (WordList) word_list = NULL; - path = g_test_build_filename (G_TEST_BUILT, BRODA_RESOURCE, NULL); - resource = word_list_resource_new_from_file (path); - - word_list = g_object_new (WORD_TYPE_LIST, - "resource", resource, - NULL); + word_list = get_broda_word_list (); while (TRUE) { -- GitLab From 19a99b5d3707efa400f4497ff98de2fa7ccf1723 Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Fri, 29 Aug 2025 12:25:28 -0400 Subject: [PATCH 9/9] Remove pragma once --- src/clue-matches.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/clue-matches.h b/src/clue-matches.h index d090d396..ecacefb3 100644 --- a/src/clue-matches.h +++ b/src/clue-matches.h @@ -18,8 +18,6 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -#pragma once - #include "word-list.h" /* This function is in a separate file from word-list.c, -- GitLab