test-ein-node.el 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. (eval-when-compile (require 'cl))
  2. (require 'ert)
  3. (require 'ein-node)
  4. (defun ein:testing-node-dummy-ewco-node (data)
  5. `[nil nil ,data])
  6. (defun ein:testing-node-ewoc-data (ewoc-node)
  7. (ein:$node-data (ewoc-data ewoc-node)))
  8. (ert-deftest ein:testing-node-dummy-ewco-node ()
  9. (let* ((obj "some-object")
  10. (ewoc-node (ein:testing-node-dummy-ewco-node obj)))
  11. (should (eq (ewoc-data ewoc-node) obj))))
  12. (ert-deftest ein:node-filter-is ()
  13. (let ((en-list (mapcar
  14. #'ein:testing-node-dummy-ewco-node
  15. (list (ein:node-new nil "s" '(spam sag))
  16. (ein:node-new nil "p" '(spam))
  17. (ein:node-new nil "e" '(egg))
  18. (ein:node-new nil "a" '(spam sag))
  19. (ein:node-new nil "g" '(egg sag))
  20. (ein:node-new nil "m" '(spam))
  21. (ein:node-new nil "g" '(egg))))))
  22. (should (equal (mapcar #'ein:testing-node-ewoc-data
  23. (ein:node-filter en-list :is 'spam))
  24. '("s" "p" "a" "m")))
  25. (should (equal (mapcar #'ein:testing-node-ewoc-data
  26. (ein:node-filter en-list :is 'egg))
  27. '("e" "g" "g")))
  28. (should (equal (mapcar #'ein:testing-node-ewoc-data
  29. (ein:node-filter en-list :is 'sag))
  30. '("s" "a" "g")))))
  31. (ert-deftest ein:node-filter-not ()
  32. (let ((en-list (mapcar
  33. #'ein:testing-node-dummy-ewco-node
  34. (list (ein:node-new nil "s" '(spam sag))
  35. (ein:node-new nil "p" '(spam))
  36. (ein:node-new nil "e" '(egg))
  37. (ein:node-new nil "a" '(spam sag))
  38. (ein:node-new nil "g" '(egg sag))
  39. (ein:node-new nil "m" '(spam))
  40. (ein:node-new nil "g" '(egg))))))
  41. (should (equal (mapcar #'ein:testing-node-ewoc-data
  42. (ein:node-filter en-list :not 'spam))
  43. '("e" "g" "g")))
  44. (should (equal (mapcar #'ein:testing-node-ewoc-data
  45. (ein:node-filter en-list :not 'egg))
  46. '("s" "p" "a" "m")))
  47. (should (equal (mapcar #'ein:testing-node-ewoc-data
  48. (ein:node-filter en-list :not 'sag))
  49. '("p" "e" "m" "g")))))
  50. (ert-deftest ein:node-filter-is-and-not ()
  51. (let ((en-list (mapcar
  52. #'ein:testing-node-dummy-ewco-node
  53. (list (ein:node-new nil "s" '(spam sag))
  54. (ein:node-new nil "p" '(spam))
  55. (ein:node-new nil "e" '(egg))
  56. (ein:node-new nil "a" '(spam sag))
  57. (ein:node-new nil "g" '(egg sag))
  58. (ein:node-new nil "m" '(spam))
  59. (ein:node-new nil "g" '(egg))))))
  60. (should (equal (mapcar #'ein:testing-node-ewoc-data
  61. (ein:node-filter en-list :not 'spam :is 'sag))
  62. '("g")))
  63. (should (equal (mapcar #'ein:testing-node-ewoc-data
  64. (ein:node-filter en-list :is 'sag :not 'spam))
  65. '("g")))
  66. (should (equal (mapcar #'ein:testing-node-ewoc-data
  67. (ein:node-filter en-list :is 'spam :is 'sag))
  68. '("s" "a")))
  69. (should (equal (mapcar #'ein:testing-node-ewoc-data
  70. (ein:node-filter en-list :is 'sag :not 'spam
  71. :not 'not-existing))
  72. '("g")))
  73. (should (equal (mapcar #'ein:testing-node-ewoc-data
  74. (ein:node-filter en-list :is 'sag :is 'spam))
  75. '("s" "a")))))