gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Main branchmaind2e6d26bMerge branch 'records-park55' into mainTrackermain/tests/boot-sort.hl

2.1 KB

  1. // BS2: a paused sort preserves descending order and the input order of equal keys.
  2. import { now } from 'hl:time'
  3. import SortRows from '../lib/sort-rows.hl'
  4. import CatalogSort from '../lib/catalog-sort.hl'
  5. import CatalogList from '../lib/catalog-list.hl'
  6. import { sortEntries } from '../lib/catalog-entries.hl'
  7. import { sortDesc } from '../lib/util.hl'
  8. static check = (Number count) => {
  9. rows = []
  10. list = new CatalogList()
  11. sorter = new SortRows()
  12. for (let i = 0; i < count; i = i + 1) {
  13. row = { id = '' + i key = '' + (i * 17 % 53) }
  14. rows.push(row)
  15. list.insert(list.length, row.id, row.key)
  16. sorter.add(row)
  17. }
  18. let calls = 0
  19. while (!sorter.step(now())) { calls = calls + 1 }
  20. expected = []
  21. // Independent fixture oracle: descending string keys, original order for ties.
  22. keys = ['9', '8', '7', '6', '52', '51', '50', '5', '49', '48', '47', '46', '45', '44', '43', '42', '41', '40', '4', '39', '38', '37', '36', '35', '34', '33', '32', '31', '30', '3', '29', '28', '27', '26', '25', '24', '23', '22', '21', '20', '2', '19', '18', '17', '16', '15', '14', '13', '12', '11', '10', '1', '0']
  23. for (key of keys) {
  24. for (row of rows) { if (row.key == key) { expected.push(row) } }
  25. }
  26. sync = sortDesc(&rows)
  27. if (sync.length != expected.length) { hlError('sync count') }
  28. for (let i = 0; i < expected.length; i = i + 1) {
  29. if (sync[i].id != expected[i].id || sync[i].key != expected[i].key) { hlError('sync stable order at ' + i) }
  30. }
  31. if (sorter.count() != expected.length) { hlError('row count') }
  32. for (let i = 0; i < expected.length; i = i + 1) {
  33. got = sorter.row(i)
  34. if (got.id != expected[i].id || got.key != expected[i].key) { hlError('stable row order at ' + i) }
  35. }
  36. packed = new CatalogSort(source = list)
  37. while (!packed.step(now())) { calls = calls + 1 }
  38. old = sortEntries(&list)
  39. if (packed.out.length != old.length) { hlError('packed count') }
  40. for (let i = 0; i < old.length; i = i + 1) {
  41. if (packed.out.fetch(i) != old.fetch(i)) { hlError('packed order at ' + i) }
  42. }
  43. if (count > 100 && calls == 0) { hlError('sort did not yield') }
  44. console.log('boot sort: ' + count + ' rows identical; yielded ' + calls + ' times')
  45. return null
  46. }
  47. check(0)
  48. check(1)
  49. check(3)
  50. check(33)
  51. check(4096)

Branches

Latest commits

  • d2e6d26bMerge branch 'records-park55' into mainTracker
  • f567f025|||PR records: park #55, no Claude workers ruleTracker
  • c21aff6bMerge branch 'records-hm55c' into mainTracker
  • 9ba258d3|||PR records: HM55b resultTracker
  • 64f2d300Merge branch 'records-hm55b2' into mainTracker
  • ae3b80dc|||PR records: HM55b briefTracker
  • 7ef3cb3bMerge branch 'records-st55' into mainTracker
  • fec2e080|||PR records: STATUS HM55Tracker
  • 8e174918Merge branch 'records-hm55b' into mainTracker
  • b1ecee57|||PR records: HM55 stateTracker
  • 28eab08cMerge branch 'records-hm55' into mainTracker
  • d3edaa05|||PR records: HM55 start, PROCEDURES.mdTracker
  • 3059f86cMerge branch 'records-design-rule' into mainTracker
  • 421a4809|||PR records: his-design rule (Apollo 2026-11-13)Tracker
  • d1390692Merge branch 'records-dp75b' into mainTracker
  • a4d1a7d2|||PR records: later steps checked, branch auditTracker
  • e070e16fMerge branch 'records-dp75' into mainTracker
  • 642b4fa8|||PR records: DP75 day62 live, AP62 briefTracker
  • bfc4ea4dMerge branch 'ap62' into mainTracker
  • 2c95ac46|||PR AP62: re-vendor Hybriel set day62 (source 70341ad2, bin a54f5f08)Tracker