Conversation
Add comprehensive edge case tests across all components: Bayes: - Empty string training/classification - Unicode and emoji handling - Special characters, whitespace-only input - Very long text, mixed case, numbers in text LSI: - Empty/single item index behavior - remove_item and items methods - categories_for edge cases - Unicode mixed with ASCII Extensions: - without_punctuation method coverage - Vector magnitude/normalize (including zero vector) - Matrix diag, trans alias, element assignment - Array sum_with_identity with blocks Coverage improved to 93% line, 76% branch. Fixes #52
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive edge case tests to improve test coverage for the Bayes, LSI, and Extensions components. The additions focus on boundary conditions, Unicode handling, and error cases to document expected behavior and increase overall test coverage from 91.39% to 92.78% for line coverage and from 72.64% to 76.42% for branch coverage.
Key Changes:
- Added 10 edge case tests for Bayesian classifier covering empty strings, Unicode, emojis, special characters, and very long text
- Added 8 edge case tests for LSI covering index operations, item management, and category lookups
- Added 18 tests for Extensions covering string punctuation handling, vector operations, and matrix utilities
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/bayes/bayesian_test.rb | Added 10 edge case tests for empty strings, Unicode text, emojis, special characters, very long text, single words, whitespace-only input, mixed case, and numbers in text |
| test/lsi/lsi_test.rb | Added 8 edge case tests for empty/single item indexes, item removal, related item finding, Unicode handling, auto-rebuild behavior, and category lookups |
| test/extensions/word_hash_test.rb | Added 18 tests covering array sum methods with blocks and custom identities, string punctuation removal, vector magnitude and normalization, and matrix operations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add comprehensive edge case tests across all components to improve test coverage and document expected behavior.
Tests Added
Bayes (10 tests)
LSI (8 tests)
remove_itemfunctionalityremove_itemon nonexistent itemitemsmethodfind_relatedexcludes selfneeds_rebuild?with auto_rebuildcategories_fornonexistent itemExtensions (18 tests)
without_punctuationmethod (5 tests)sum_with_identitywith block and custom identitymagnitude(basic, zero vector, single element, negative values)normalize(basic, unit vector, preserves direction)diag,transalias, element assignmentCoverage
Fixes #52