-
Notifications
You must be signed in to change notification settings - Fork 74
Fix O(n²) strategy deduplication and tuple initialization bug #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #!/bin/bash | ||
| # Test runner for GenSON bug fixes | ||
| # Usage: | ||
| # ./test.sh base → Run existing tests (should pass) | ||
| # ./test.sh new → Run new tests only (should fail on buggy code, pass on fixed code) | ||
|
|
||
| set -e # Exit on error | ||
|
|
||
| MODE="${1:-base}" | ||
|
|
||
| case "$MODE" in | ||
| base) | ||
| echo "==========================================" | ||
| echo "Running BASE tests (existing test suite)" | ||
| echo "==========================================" | ||
| python3 -m unittest discover -s test -p "test_*.py" -v | ||
|
||
| echo "" | ||
| echo "✓ All base tests passed!" | ||
| ;; | ||
|
|
||
| new) | ||
| echo "==========================================" | ||
| echo "Running NEW tests (bug-specific tests)" | ||
| echo "==========================================" | ||
| echo "These tests FAIL on original code" | ||
| echo "These tests PASS on fixed code" | ||
| echo "==========================================" | ||
| python3 -m unittest test.test_bug_fixes -v | ||
| echo "" | ||
| echo "✓ All new tests passed!" | ||
| ;; | ||
|
|
||
| *) | ||
| echo "Usage: $0 {base|new}" | ||
| echo " base - Run existing test suite" | ||
| echo " new - Run new bug-specific tests" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that there will probably be more bug fixes in the future, I don't think this file is specifically enough named. Instead of adding a test file specific to this PR, please sort the tests into the existing files with similar tests, specifically |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,230 @@ | ||||||
| """ | ||||||
| New test cases for GenSON bug fixes. | ||||||
|
|
||||||
| These tests are designed to: | ||||||
| 1. FAIL on the original buggy code | ||||||
| 2. PASS after the bugs are fixed | ||||||
|
|
||||||
| Test Bug #1: O(n²) deduplication in builder.py | ||||||
| Test Bug #2: Tuple initialization in array.py | ||||||
|
|
||||||
| All tests are deterministic with no timers, network calls, or random values. | ||||||
|
||||||
| All tests are deterministic with no timers, network calls, or random values. | |
| All tests are deterministic and avoid network calls or random values; some tests use timers solely for performance validation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this class to test_custom.py and strip out the wall-clock checks.
Copilot
AI
Jan 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Performance tests using wall-clock time measurements can be flaky and may fail on slower CI systems or when the system is under load. Consider using a more deterministic approach, such as counting operations or verifying the algorithmic complexity through other means. Alternatively, add a note that this test may occasionally fail in resource-constrained environments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hesitant to rely on clock time since YMMV a lot with the testing environment and what machine it's running on.
I'm okay with dropping the wall-clock checks. I can see the algorithmic improvement myself, and I'm not really worried about a regression here; we just need to make sure that outputs are still correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please merge this test class and the next into the existing one, and use the existing assertResult abstraction, which will simplify the assertions significantly as well as ensuring the resulting schema is valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This testcase is already handled by an existing test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's already a standard way to run tests. You're welcome to use this file to run tests yourself, but please don't check it in.