intersection.spec.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // ██████╗ ████████╗████████╗ ██████╗ ███████╗██████╗ ███████╗ ██████╗
  2. // ██╔══██╗╚══██╔══╝╚══██╔══╝██╔════╝ ██╔════╝██╔══██╗██╔════╝██╔════╝ ██╗██╗
  3. // ██████╔╝ ██║ ██║ ██║ ███████╗██████╔╝█████╗ ██║ ╚═╝╚═╝
  4. // ██╔══██╗ ██║ ██║ ██║ ╚════██║██╔═══╝ ██╔══╝ ██║ ██╗██╗
  5. // ██║ ██║ ██║ ██║ ╚██████╗ ███████║██║ ███████╗╚██████╗ ╚═╝╚═╝
  6. // ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚══════╝ ╚═════╝
  7. //
  8. // ██╗███╗ ██╗████████╗███████╗██████╗ ███████╗███████╗ ██████╗████████╗██╗ ██████╗ ███╗ ██╗
  9. // ██║████╗ ██║╚══██╔══╝██╔════╝██╔══██╗██╔════╝██╔════╝██╔════╝╚══██╔══╝██║██╔═══██╗████╗ ██║
  10. // ██║██╔██╗ ██║ ██║ █████╗ ██████╔╝███████╗█████╗ ██║ ██║ ██║██║ ██║██╔██╗ ██║
  11. // ██║██║╚██╗██║ ██║ ██╔══╝ ██╔══██╗╚════██║██╔══╝ ██║ ██║ ██║██║ ██║██║╚██╗██║
  12. // ██║██║ ╚████║ ██║ ███████╗██║ ██║███████║███████╗╚██████╗ ██║ ██║╚██████╔╝██║ ╚████║
  13. // ╚═╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚══════╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝
  14. //
  15. // > NOTE:
  16. // > All tests below assume `rttc.intersection()` is being called with
  17. // > exemplars (rather than type schemas), and with `strict` mode disabled.
  18. module.exports = [
  19. ////////////////////////////////////////////////////
  20. // null ∩ ...
  21. //
  22. // > `null` is not actually a valid exemplar,
  23. // > rather it's a special value used for
  24. // > indicating that the set of values that
  25. // > validate against this is Ø (the empty set).
  26. ////////////////////////////////////////////////////
  27. { e0: null, e1: null, result: null },
  28. { e0: null, e1: 'bar', result: null },
  29. { e0: null, e1: 'foo', result: null },
  30. { e0: null, e1: '', result: null },
  31. { e0: null, e1: 0, result: null },
  32. { e0: null, e1: 1, result: null },
  33. { e0: null, e1: -1.1, result: null },
  34. { e0: null, e1: true, result: null },
  35. { e0: null, e1: false, result: null },
  36. { e0: null, e1: '->', result: null },
  37. { e0: null, e1: '*', result: null },
  38. { e0: null, e1: '===', result: null },
  39. { e0: null, e1: {}, result: null },
  40. { e0: null, e1: [], result: null },
  41. { e0: null, e1: {foo:'bar'}, result: null },
  42. { e0: null, e1: {foo:{bar:{baz:{}}}}, result: null },
  43. { e0: null, e1: {foo:['bar']}, result: null },
  44. { e0: null, e1: {foo:{bar:{baz:[{}]}}}, result: null },
  45. { e0: null, e1: ['asdf'], result: null },
  46. { e0: null, e1: [''], result: null },
  47. { e0: null, e1: [235], result: null },
  48. { e0: null, e1: [false],   result: null },
  49. { e0: null, e1: [{}], result: null },
  50. { e0: null, e1: [{foo:'bar'}], result: null },
  51. ////////////////////////////////////////////
  52. // "some string" ∩ ...
  53. ////////////////////////////////////////////
  54. { e0: 'foo', e1: 'bar', result: 'bar' },
  55. { e0: 'bar', e1: 'foo', result: 'foo' },
  56. { e0: 'foo', e1: '', result: '' },
  57. { e0: 'foo', e1: 0, result: 0 },
  58. { e0: 'foo', e1: 1, result: 1 },
  59. { e0: 'foo', e1: -1.1, result: -1.1 },
  60. { e0: 'foo', e1: true, result: true },
  61. { e0: 'foo', e1: false, result: false },
  62. { e0: 'foo', e1: '->', result: null },
  63. { e0: 'foo', e1: '*', result: 'foo' },
  64. { e0: 'foo', e1: '===', result: 'foo' },
  65. { e0: 'foo', e1: {}, result: null },
  66. { e0: 'foo', e1: [], result: null },
  67. { e0: 'foo', e1: {foo:'bar'}, result: null },
  68. { e0: 'foo', e1: {foo:{bar:{baz:{}}}}, result: null },
  69. { e0: 'foo', e1: {foo:['bar']}, result: null },
  70. { e0: 'foo', e1: {foo:{bar:{baz:[{}]}}}, result: null },
  71. { e0: 'foo', e1: ['asdf'], result: null },
  72. { e0: 'foo', e1: [''], result: null },
  73. { e0: 'foo', e1: [235], result: null },
  74. { e0: 'foo', e1: [false],   result: null },
  75. { e0: 'foo', e1: [{}], result: null },
  76. { e0: 'foo', e1: [{foo:'bar'}], result: null },
  77. // Add more tests.
  78. // TODO
  79. ];