Title: Stavan Somaiya — R50-T004: Test an invariant of swap (OddEvenSort.js) [Sorts/OddEvenSort.js] · Issue #4 · S-AI-Projects/TheAlgorithms-JavaScript · GitHub
Open Graph Title: Stavan Somaiya — R50-T004: Test an invariant of swap (OddEvenSort.js) [Sorts/OddEvenSort.js] · Issue #4 · S-AI-Projects/TheAlgorithms-JavaScript
X Title: Stavan Somaiya — R50-T004: Test an invariant of swap (OddEvenSort.js) [Sorts/OddEvenSort.js] · Issue #4 · S-AI-Projects/TheAlgorithms-JavaScript
Description: Student: Stavan Somaiya Task: R50-T004 · 4 of 10 Repository: https://github.com/S-AI-Projects/TheAlgorithms-JavaScript Assigned working branch: student/e26b07f1064 Goal Work on Sorts/OddEvenSort.js. Add a property test around swap: Outpu...
Open Graph Description: Student: Stavan Somaiya Task: R50-T004 · 4 of 10 Repository: https://github.com/S-AI-Projects/TheAlgorithms-JavaScript Assigned working branch: student/e26b07f1064 Goal Work on Sorts/OddEvenSort.js...
X Description: Student: Stavan Somaiya Task: R50-T004 · 4 of 10 Repository: https://github.com/S-AI-Projects/TheAlgorithms-JavaScript Assigned working branch: student/e26b07f1064 Goal Work on Sorts/OddEvenSort.js...
Opengraph URL: https://github.com/S-AI-Projects/TheAlgorithms-JavaScript/issues/4
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Stavan Somaiya — R50-T004: Test an invariant of swap (OddEvenSort.js) [Sorts/OddEvenSort.js]","articleBody":"\u003c!-- sai-task-v1:R50-T004 -->\n\n## Student: Stavan Somaiya\n\n**Task:** R50-T004 · 4 of 10\n**Repository:** https://github.com/S-AI-Projects/TheAlgorithms-JavaScript\n**Assigned working branch:** `student/e26b07f1064`\n\n## Goal\n\nWork on Sorts/OddEvenSort.js. Add a property test around `swap`: Output is ordered and preserves input multiplicities; also check the source mutation/return contract. Fixture: Use [3, 1, 2], [2, 2, 1], already ordered [1, 2, 3], reversed [3, 2, 1], and the smallest supported collection. Expected ascending outputs are [1, 2, 3] and [1, 2, 2]; honor a descending interface if that is what the source defines.\n\n## Steps\n\n1. Read Sorts/OddEvenSort.js, especially `swap` near line 10. Record its public inputs, result, mutation behavior and any external dependencies before changing it.\n2. Use the fixture to establish the invariant on understandable examples. Use [3, 1, 2], [2, 2, 1], already ordered [1, 2, 3], reversed [3, 2, 1], and the smallest supported collection. Expected ascending outputs are [1, 2, 3] and [1, 2, 2]; honor a descending interface if that is what the source defines.\n3. Generate at least 100 bounded valid cases with a fixed seed; restrict the generator to the actual input domain and retain a readable small case.\n4. Implement work/R50-T004/check.py as a focused runner that executes the new checks and propagates failures. Native check to incorporate: run the repository test script in non-watch mode after installing from its lockfile; for browser-only code use a browser test instead of plain Node. Record the actual command and nonzero test count.\n5. Create the checks specified below and run `python3 work/R50-T004/check.py`. Save inputs, expected versus actual results and tool versions in work/R50-T004/; a check must exit non-zero when an assertion fails.\n6. Commit the repository change on branch R50-T004; prepare a PR to the organisation fork explaining the result and linking the checks. Keep each task independently reviewable. Remove work/R50-T004/ from a later upstream branch.\n\n## Done when\n\n☐ The checked behavior is tied to `swap` in Sorts/OddEvenSort.js; every assertion has an explicit expected value.\n☐ Use [3, 1, 2], [2, 2, 1], already ordered [1, 2, 3], reversed [3, 2, 1], and the smallest supported collection. Expected ascending outputs are [1, 2, 3] and [1, 2, 2]; honor a descending interface if that is what the source defines.\n☐ Existing supported behavior and the public interface are preserved unless a failing regression demonstrates and documents a defect.\n☐ The generator never relies on undefined input behavior; the invariant is justified in the PR.\n☐ The checks fail when the relevant invariant is deliberately broken in a temporary copy.\n\n\u003cdetails>\n\u003csummary>Additional task guidance\u003c/summary>\n\n\nAdditional curated task guidance\n\nItem:\nSorts/OddEvenSort.js\n\nTask type:\nInvariant/property checks\n\nCode change (goes into the PR):\nAdd invariant-based tests for Sorts/OddEvenSort.js, with a deterministic seed and the smallest failing example; document the invariant next to the implementation.\n\nAutomated check:\npython3 work/R50-T004/check.py\n\nPrerequisites:\nNode matching the project engines/CI, package manager selected by its lockfile, and Python 3.\n\nUpstream PR rules:\nPreserve the repository JavaScript style, use its test framework, and include JSDoc for changed public behavior. Submit coursework to the organisation fork first; keep work/ evidence out of any later upstream PR. Upstream acceptance is not a grading requirement. Policy: https://github.com/TheAlgorithms/JavaScript/blob/5c39e87a9a31f279c60f830ad74a845e4788a517/CONTRIBUTING.md\n\nSource (pinned):\nhttps://github.com/TheAlgorithms/JavaScript/blob/5c39e87a9a31f279c60f830ad74a845e4788a517/Sorts/OddEvenSort.js#L10\n\nChange:\nReplaces the shared task template with an item-specific contribution brief.\n\nPR destination:\nUpstream candidate after review\n\n\n\u003c/details>\n\n## Submission checklist\n\n- [ ] Complete this task and its checks.\n- [ ] Add the required evidence and link your pull request here.\n- [ ] Select this **S-AI-Projects fork** as the PR base repository.\n- [ ] Request instructor review.\n\nKeep this PR focused on this task. Do not submit assignment PRs to the upstream repository.","author":{"url":"https://github.com/ankushbisht01","@type":"Person","name":"ankushbisht01"},"datePublished":"2026-11-03T23:29:58Z","url":"https://github.com/S-AI-Projects/TheAlgorithms-JavaScript/issues/4"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2a5cded0-c406-f03d-f1d6-10284b6d45fc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B07C:161654:2CE50A2:3C6C94C:6B06DAC1 |
| html-safe-nonce | ae138868c96465a363bd46fe24803cb0f61874bd4b222e202478428ecc4d4daf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMDdDOjE2MTY1NDoyQ0U1MEEyOjNDNkM5NEM6NkIwNkRBQzEiLCJ2aXNpdG9yX2lkIjoiMjg5NzY1ODA5MTAwNzMwMjMzNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f0c14db4084dc749aabbe726193b3b8367231ce1cb63a88a24723d9c3ba360ce |
| hovercard-subject-tag | issue:6193062832 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/S-AI-Projects/TheAlgorithms-JavaScript/4/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d67b13467a61ca1c1ca3d7dbda2cd102bcab5b2f80db869f509eb9e293d23464/S-AI-Projects/TheAlgorithms-JavaScript/issues/4 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d67b13467a61ca1c1ca3d7dbda2cd102bcab5b2f80db869f509eb9e293d23464/S-AI-Projects/TheAlgorithms-JavaScript/issues/4 |
| og:image:alt | Student: Stavan Somaiya Task: R50-T004 · 4 of 10 Repository: https://github.com/S-AI-Projects/TheAlgorithms-JavaScript Assigned working branch: student/e26b07f1064 Goal Work on Sorts/OddEvenSort.js... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ankushbisht01 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 06cadd0061c549662a50be90eb5baba7608f00f521574931eec01db0deb9e636 |
| turbo-cache-control | no-preview |
| go-import | github.com/S-AI-Projects/TheAlgorithms-JavaScript git https://github.com/S-AI-Projects/TheAlgorithms-JavaScript.git |
| octolytics-dimension-user_id | 351892385 |
| octolytics-dimension-user_login | S-AI-Projects |
| octolytics-dimension-repository_id | 1444142713 |
| octolytics-dimension-repository_nwo | S-AI-Projects/TheAlgorithms-JavaScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | true |
| octolytics-dimension-repository_parent_id | 97086543 |
| octolytics-dimension-repository_parent_nwo | TheAlgorithms/JavaScript |
| octolytics-dimension-repository_network_root_id | 97086543 |
| octolytics-dimension-repository_network_root_nwo | TheAlgorithms/JavaScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 6953c712585a8d7406b7695e48fffcb670fd241d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width