gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit2f986ca32f986ca3Log: RT50 passmre2f986ca3/tests/catalog-entries.hl

2.8 KB

  1. // Representation-independent regression: stable ties, refresh placement, paging and day rollover.
  2. import { index, beginIndex, noteIndexShow, noteIndexEpisode, finishIndex, placeIn, takeOut, rollDay, catalogCounts, pageNumberOf } from '../lib/catalog.hl'
  3. import { todayStr } from '../lib/util.hl'
  4. static idsOf = (&list) => {
  5. out = []
  6. if (list.length == 0) { return out }
  7. if (hlTypeName(list[0]) == 'String') {
  8. for (let i = 0; i < list.length; i = i + 2) { out.push(list[i]) }
  9. } else { for (row of list) { out.push(row.id) } }
  10. return out.join(',')
  11. }
  12. static check = (Boolean ok, String label) => {
  13. if (!ok) { hlError('catalog regression: ' + label) }
  14. console.log('ok ' + label)
  15. }
  16. static place = (&list, String id, String key, Boolean absent) => {
  17. // The old implementation accepts a row; the new implementation accepts separate slots.
  18. if (list.length > 0 && hlTypeName(list[0]) != 'String') { placeIn(&list, { id = id key = key }, absent) }
  19. else { placeIn(&list, &id, &key, absent) }
  20. return null
  21. }
  22. static probe = () => {
  23. beginIndex()
  24. noteIndexShow({ id = 'a' type = 'movie' adult = false release = '2020-01-01' genres = ['g'] })
  25. noteIndexShow({ id = 'b' type = 'movie' adult = false release = '2020-01-01' genres = ['g'] })
  26. noteIndexShow({ id = 'c' type = 'movie' adult = false release = '' genres = ['g'] })
  27. noteIndexShow({ id = 'hidden' type = 'movie' adult = true release = '2030-01-01' genres = ['g'] })
  28. noteIndexShow({ id = 'tv' type = 'series' adult = false release = '1999-01-01' genres = ['g'] })
  29. noteIndexShow({ id = 'tv2' type = 'series' adult = false release = '1999-01-01' genres = ['g'] })
  30. noteIndexEpisode({ show = 'tv' release = '2022-01-01' })
  31. finishIndex()
  32. check(idsOf(&index.movies) == 'a,b,c', 'stable movie ties and missing release')
  33. check(idsOf(&index.series) == 'tv,tv2', 'released TV before unreleased TV')
  34. check(idsOf(&index.genres.g) == 'tv,a,b,tv2,c', 'genre dates and adult filter')
  35. check(catalogCounts().movies == 3 && catalogCounts().series == 2, 'counts are rows')
  36. place(&index.movies, 'a', '2020-01-01', false)
  37. check(idsOf(&index.movies) == 'b,a,c', 'refresh moves equal key after existing ties')
  38. place(&index.movies, 'new', '2030-01-01', true)
  39. takeOut(&index.movies, 'b')
  40. takeOut(&index.movies, 'missing')
  41. check(idsOf(&index.movies) == 'new,a,c', 'new insertion and removal keep id/key alignment')
  42. index.upcoming.tv2 = [todayStr(), '9999-01-01']
  43. index.day = '2000-01-01'
  44. rollDay()
  45. check(idsOf(&index.series) == 'tv2,tv', 'day rollover reorders TV')
  46. check(idsOf(&index.genres.g) == 'tv2,tv,a,b,c', 'day rollover reorders genres')
  47. check(index.upcoming.tv2.length == 1 && index.upcoming.tv2[0] == '9999-01-01', 'day rollover keeps future episodes')
  48. check(pageNumberOf('999999', 3) == 3 && pageNumberOf('nope', 3) == 1 && pageNumberOf('0', 3) == 1, 'page boundaries')
  49. console.log('catalog-entries: passed')
  50. return true
  51. }
  52. probe()

Branches

Latest commits

  • 2f986ca3Log: RT50 passmre
  • 1c4715a4RT50 mission: day50 repro retestmre
  • 57d1c0dcLog: day50 retest requestmre
  • 60b1f419Log: Anton #336 result, wake checkmre
  • 919a18aalog: scratchmre
  • 6b504440status tidymre
  • 9332bd10log: DP70 livemre
  • be11daa0DP70 brief fixmre
  • 886a7028DP70 brief, HM67 mergedmre
  • b41cdd6dMerge hm67-searchids: packed search IDsmre
  • 385904eaReport HM67 matched heap measurements and gate proofmre
  • e5c9b659Pack retained search IDs into UTF-8 bytesmre
  • 62a5f6c7HM67 brief, HM66 mergedmre
  • b32b8440Merge hm66-catalogindex: packed catalog indexmre
  • 2db0f7adReport HM66 heap measurements and validationmre
  • 6ce15623Pack catalog lists and membership maps in UTF-8 bytesmre
  • 71134e21HM66 briefmre
  • ed4cbab2status timemre
  • e982c26dlog: HM65 mergedmre
  • 6e72f9d1Merge hm65-fields: episode boot scan reads three fieldsmre