| 1 |
;; Tests for class `rst-Ado' -*- lexical-binding: t -*- |
| 2 |
|
| 3 |
(add-to-list 'load-path ".") |
| 4 |
(load "init" nil t) |
| 5 |
(init-rst-ert nil) |
| 6 |
|
| 7 |
(ert-deftest rst-Ado-new-transition () |
| 8 |
"Test `rst-Ado-new-transition'." |
| 9 |
(should (rst-Ado-p (rst-Ado-new-transition))) |
| 10 |
) |
| 11 |
|
| 12 |
(ert-deftest rst-Ado-new-simple () |
| 13 |
"Test `rst-Ado-new-simple'." |
| 14 |
(should-error (rst-Ado-new-simple nil) |
| 15 |
:type 'wrong-type-argument) |
| 16 |
(should-error (rst-Ado-new-simple "=") |
| 17 |
:type 'wrong-type-argument) |
| 18 |
|
| 19 |
(should-error (rst-Ado-new-simple ?a) |
| 20 |
:type 'wrong-type-argument) |
| 21 |
|
| 22 |
(should (rst-Ado-p (rst-Ado-new-simple ?=))) |
| 23 |
) |
| 24 |
|
| 25 |
(ert-deftest rst-Ado-new-over-and-under () |
| 26 |
"Test `rst-Ado-new-over-and-under'." |
| 27 |
(should-error (rst-Ado-new-over-and-under nil) |
| 28 |
:type 'wrong-type-argument) |
| 29 |
(should-error (rst-Ado-new-over-and-under "=") |
| 30 |
:type 'wrong-type-argument) |
| 31 |
|
| 32 |
(should-error (rst-Ado-new-over-and-under ?a) |
| 33 |
:type 'wrong-type-argument) |
| 34 |
|
| 35 |
(should (rst-Ado-p (rst-Ado-new-over-and-under ?=))) |
| 36 |
) |
| 37 |
|
| 38 |
(ert-deftest rst-Ado-new-invert () |
| 39 |
"Test `rst-Ado-new-invert'." |
| 40 |
(let ((dbl-eq (rst-Ado-new-over-and-under ?=)) |
| 41 |
(spl-eq (rst-Ado-new-simple ?=)) |
| 42 |
(tsn (rst-Ado-new-transition))) |
| 43 |
(should (rst-Ado-equal (rst-Ado-new-invert dbl-eq) spl-eq)) |
| 44 |
(should (rst-Ado-equal (rst-Ado-new-invert spl-eq) dbl-eq)) |
| 45 |
(should (rst-Ado-equal (rst-Ado-new-invert tsn) tsn)) |
| 46 |
)) |
| 47 |
|
| 48 |
(ert-deftest rst-Ado-is-transition () |
| 49 |
"Test `rst-Ado-is-transition'." |
| 50 |
(should-error (rst-Ado-is-transition nil) |
| 51 |
:type 'wrong-type-argument) |
| 52 |
(should-error (rst-Ado-is-transition 3) |
| 53 |
:type 'wrong-type-argument) |
| 54 |
|
| 55 |
(should (rst-Ado-is-transition (rst-Ado-new-transition))) |
| 56 |
|
| 57 |
(should-not (rst-Ado-is-transition (rst-Ado-new-simple ?=))) |
| 58 |
) |
| 59 |
|
| 60 |
(ert-deftest rst-Ado-is-section () |
| 61 |
"Test `rst-Ado-is-section'." |
| 62 |
(should-error (rst-Ado-is-section nil) |
| 63 |
:type 'wrong-type-argument) |
| 64 |
(should-error (rst-Ado-is-section 3) |
| 65 |
:type 'wrong-type-argument) |
| 66 |
|
| 67 |
(should (rst-Ado-is-section (rst-Ado-new-simple ?=))) |
| 68 |
|
| 69 |
(should-not (rst-Ado-is-section (rst-Ado-new-transition))) |
| 70 |
) |
| 71 |
|
| 72 |
(ert-deftest rst-Ado-is-simple () |
| 73 |
"Test `rst-Ado-is-simple'." |
| 74 |
(should-error (rst-Ado-is-simple nil) |
| 75 |
:type 'wrong-type-argument) |
| 76 |
(should-error (rst-Ado-is-simple 3) |
| 77 |
:type 'wrong-type-argument) |
| 78 |
|
| 79 |
(should (rst-Ado-is-simple (rst-Ado-new-simple ?=))) |
| 80 |
|
| 81 |
(should-not (rst-Ado-is-simple (rst-Ado-new-transition))) |
| 82 |
(should-not (rst-Ado-is-simple (rst-Ado-new-over-and-under ?=))) |
| 83 |
) |
| 84 |
|
| 85 |
(ert-deftest rst-Ado-is-over-and-under () |
| 86 |
"Test `rst-Ado-is-over-and-under'." |
| 87 |
(should-error (rst-Ado-is-over-and-under nil) |
| 88 |
:type 'wrong-type-argument) |
| 89 |
(should-error (rst-Ado-is-over-and-under 3) |
| 90 |
:type 'wrong-type-argument) |
| 91 |
|
| 92 |
(should (rst-Ado-is-over-and-under (rst-Ado-new-over-and-under ?=))) |
| 93 |
|
| 94 |
(should-not (rst-Ado-is-over-and-under (rst-Ado-new-transition))) |
| 95 |
(should-not (rst-Ado-is-over-and-under (rst-Ado-new-simple ?=))) |
| 96 |
) |
| 97 |
|
| 98 |
(ert-deftest rst-Ado-equal () |
| 99 |
"Test `rst-Ado-equal'." |
| 100 |
(let ((dbl-eq (rst-Ado-new-over-and-under ?=)) |
| 101 |
(dbl-pl (rst-Ado-new-over-and-under ?+)) |
| 102 |
(spl-eq (rst-Ado-new-simple ?=)) |
| 103 |
(spl-pl (rst-Ado-new-simple ?+)) |
| 104 |
(tsn (rst-Ado-new-transition))) |
| 105 |
(should-error (rst-Ado-equal nil dbl-eq) |
| 106 |
:type 'wrong-type-argument) |
| 107 |
(should-error (rst-Ado-equal dbl-eq nil) |
| 108 |
:type 'wrong-type-argument) |
| 109 |
(should-error (rst-Ado-equal dbl-eq 3) |
| 110 |
:type 'wrong-type-argument) |
| 111 |
(should-error (rst-Ado-equal 'some-sym dbl-eq) |
| 112 |
:type 'wrong-type-argument) |
| 113 |
|
| 114 |
(should (rst-Ado-equal dbl-eq dbl-eq)) |
| 115 |
(should (rst-Ado-equal spl-eq spl-eq)) |
| 116 |
(should (rst-Ado-equal spl-pl spl-pl)) |
| 117 |
|
| 118 |
(should-not (rst-Ado-equal dbl-eq dbl-pl)) |
| 119 |
(should-not (rst-Ado-equal dbl-eq spl-eq)) |
| 120 |
(should-not (rst-Ado-equal dbl-eq spl-pl)) |
| 121 |
(should-not (rst-Ado-equal dbl-eq tsn)) |
| 122 |
(should-not (rst-Ado-equal spl-eq spl-pl)) |
| 123 |
(should-not (rst-Ado-equal spl-eq tsn)) |
| 124 |
)) |
| 125 |
|
| 126 |
(ert-deftest rst-Ado-position () |
| 127 |
"Test `rst-Ado-position'." |
| 128 |
(let ((dbl-eq (rst-Ado-new-over-and-under ?=)) |
| 129 |
(dbl-pl (rst-Ado-new-over-and-under ?+)) |
| 130 |
(spl-eq (rst-Ado-new-simple ?=)) |
| 131 |
(spl-pl (rst-Ado-new-simple ?+)) |
| 132 |
(tsn- (rst-Ado-new-transition))) |
| 133 |
(let* ((tsn (list tsn-)) |
| 134 |
(spl_tsn (cons spl-eq tsn)) |
| 135 |
(dbl_spl_tsn (cons dbl-eq spl_tsn))) |
| 136 |
(should-error (rst-Ado-position nil nil) |
| 137 |
:type 'wrong-type-argument) |
| 138 |
(should-error (rst-Ado-position 3 nil) |
| 139 |
:type 'wrong-type-argument) |
| 140 |
(should-error (rst-Ado-position dbl-eq '(3)) |
| 141 |
:type 'wrong-type-argument) |
| 142 |
|
| 143 |
(should (equal (rst-Ado-position tsn- dbl_spl_tsn) 2)) |
| 144 |
(should (equal (rst-Ado-position tsn- tsn) 0)) |
| 145 |
(should (equal (rst-Ado-position spl-eq dbl_spl_tsn) 1)) |
| 146 |
(should (equal (rst-Ado-position dbl-eq dbl_spl_tsn) 0)) |
| 147 |
|
| 148 |
(should-not (rst-Ado-position dbl-pl dbl_spl_tsn)) |
| 149 |
(should-not (rst-Ado-position spl-pl dbl_spl_tsn)) |
| 150 |
))) |