summaryrefslogtreecommitdiff
path: root/tests/test-lorem-optimum.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-11 17:17:54 -0500
committerCraig Jennings <c@cjennings.net>2026-05-11 17:17:54 -0500
commit7f353e925b7dbd6d0c16962e0e822aea0093308b (patch)
treecc4a86ada9d06050b3176a2da664646c44b16242 /tests/test-lorem-optimum.el
parent96d5d6a7454f4e35860dc3d93cb3a447263859d7 (diff)
downloaddotemacs-7f353e925b7dbd6d0c16962e0e822aea0093308b.tar.gz
dotemacs-7f353e925b7dbd6d0c16962e0e822aea0093308b.zip
perf(lorem-optimum): speed up the Markov generation path
`cj/markov-join-tokens' collects tokens in a list and `mapconcat's once instead of repeated string concatenation. `cj/markov-generate' uses `push'/`nreverse' instead of repeated `append'. The Markov keys are cached as a vector so random key selection is O(1). Re-enabled the benchmark tests (the `:slow' tags were stale) and added a `cj/lipsum-title' test after byte-compilation flagged a malformed form there. `assets/liber-primus.txt' is left as-is (36 KB / 5,374 words, small enough not to need trimming). 100K-word learning now measures about 196 ms.
Diffstat (limited to 'tests/test-lorem-optimum.el')
-rw-r--r--tests/test-lorem-optimum.el9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/test-lorem-optimum.el b/tests/test-lorem-optimum.el
index ca2e52f4..40bdc684 100644
--- a/tests/test-lorem-optimum.el
+++ b/tests/test-lorem-optimum.el
@@ -238,5 +238,14 @@
(let ((result (cj/markov-generate chain 2)))
(should (stringp result)))))
+(ert-deftest test-title-generation-produces-title ()
+ "Should generate a non-empty title from the global chain."
+ (let ((cj/lipsum-chain
+ (test-learn "lorem ipsum dolor sit amet consectetur adipiscing elit")))
+ (let ((result (cj/lipsum-title)))
+ (should (stringp result))
+ (should (> (length result) 0))
+ (should (string-match-p "^[[:upper:]]" result)))))
+
(provide 'test-lorem-optimum)
;;; test-lorem-optimum.el ends here