diff options
| author | Andrea Corallo | 2020-12-29 13:29:02 +0100 |
|---|---|---|
| committer | Andrea Corallo | 2020-12-29 17:49:30 +0100 |
| commit | c4efb49a27f05284d28eac7f60b28495c68f63fb (patch) | |
| tree | 0d80e074e33c9cbfbbbdca07dbfe27da861f89bc /test/src | |
| parent | e83c6994e1f2553634e0877e86a8ebaa19fbc5d1 (diff) | |
| download | emacs-c4efb49a27f05284d28eac7f60b28495c68f63fb.tar.gz emacs-c4efb49a27f05284d28eac7f60b28495c68f63fb.zip | |
Constrain mvars under compare and branch with built-in predicates
* lisp/emacs-lisp/comp.el (comp-emit-assume): Update.
(comp-known-predicate-p): New function.
(comp-add-cond-cstrs): Extend to pattern match predicate calls.
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-null-p)
(comp-pred-to-cstr): New function.
* test/src/comp-tests.el (comp-tests-type-spec-tests): Add a
number of tests and fix comments.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/comp-tests.el | 69 |
1 files changed, 52 insertions, 17 deletions
diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el index c79190e2967..240af102ec4 100644 --- a/test/src/comp-tests.el +++ b/test/src/comp-tests.el | |||
| @@ -837,7 +837,6 @@ Return a list of results." | |||
| 837 | y)) | 837 | y)) |
| 838 | (or (integer 1 1) (integer 3 3))) | 838 | (or (integer 1 1) (integer 3 3))) |
| 839 | 839 | ||
| 840 | |||
| 841 | ;; 6 | 840 | ;; 6 |
| 842 | ((defun comp-tests-ret-type-spec-f (x) | 841 | ((defun comp-tests-ret-type-spec-f (x) |
| 843 | (if x | 842 | (if x |
| @@ -1035,8 +1034,6 @@ Return a list of results." | |||
| 1035 | (or null marker number)) | 1034 | (or null marker number)) |
| 1036 | 1035 | ||
| 1037 | ;; 36 | 1036 | ;; 36 |
| 1038 | ;; SBCL: (OR (RATIONAL (5)) (SINGLE-FLOAT 5.0) | ||
| 1039 | ;; (DOUBLE-FLOAT 5.0d0) NULL) !? | ||
| 1040 | ((defun comp-tests-ret-type-spec-f (x y) | 1037 | ((defun comp-tests-ret-type-spec-f (x y) |
| 1041 | (when (and (> x 3) | 1038 | (when (and (> x 3) |
| 1042 | (> y 2)) | 1039 | (> y 2)) |
| @@ -1051,15 +1048,14 @@ Return a list of results." | |||
| 1051 | (+ x y))) | 1048 | (+ x y))) |
| 1052 | (or null float (integer * 5))) | 1049 | (or null float (integer * 5))) |
| 1053 | 1050 | ||
| 1054 | ;; 38 SBCL gives: (OR (RATIONAL (2) (10)) (SINGLE-FLOAT 2.0 10.0) | 1051 | ;; 38 |
| 1055 | ;; (DOUBLE-FLOAT 2.0d0 10.0d0) NULL)!? | ||
| 1056 | ((defun comp-tests-ret-type-spec-f (x y) | 1052 | ((defun comp-tests-ret-type-spec-f (x y) |
| 1057 | (when (and (< 1 x 5) | 1053 | (when (and (< 1 x 5) |
| 1058 | (< 1 y 5)) | 1054 | (< 1 y 5)) |
| 1059 | (+ x y))) | 1055 | (+ x y))) |
| 1060 | (or null float (integer 4 8))) | 1056 | (or null float (integer 4 8))) |
| 1061 | 1057 | ||
| 1062 | ;; 37 | 1058 | ;; 39 |
| 1063 | ;; SBCL gives: (OR REAL NULL) | 1059 | ;; SBCL gives: (OR REAL NULL) |
| 1064 | ((defun comp-tests-ret-type-spec-f (x y) | 1060 | ((defun comp-tests-ret-type-spec-f (x y) |
| 1065 | (when (and (<= 1 x 10) | 1061 | (when (and (<= 1 x 10) |
| @@ -1067,7 +1063,7 @@ Return a list of results." | |||
| 1067 | (+ x y))) | 1063 | (+ x y))) |
| 1068 | (or null float (integer 3 13))) | 1064 | (or null float (integer 3 13))) |
| 1069 | 1065 | ||
| 1070 | ;; 38 | 1066 | ;; 40 |
| 1071 | ;; SBCL: (OR REAL NULL) | 1067 | ;; SBCL: (OR REAL NULL) |
| 1072 | ((defun comp-tests-ret-type-spec-f (x y) | 1068 | ((defun comp-tests-ret-type-spec-f (x y) |
| 1073 | (when (and (<= 1 x 10) | 1069 | (when (and (<= 1 x 10) |
| @@ -1075,42 +1071,42 @@ Return a list of results." | |||
| 1075 | (- x y))) | 1071 | (- x y))) |
| 1076 | (or null float (integer -2 8))) | 1072 | (or null float (integer -2 8))) |
| 1077 | 1073 | ||
| 1078 | ;; 39 | 1074 | ;; 41 |
| 1079 | ((defun comp-tests-ret-type-spec-f (x y) | 1075 | ((defun comp-tests-ret-type-spec-f (x y) |
| 1080 | (when (and (<= 1 x) | 1076 | (when (and (<= 1 x) |
| 1081 | (<= 2 y 3)) | 1077 | (<= 2 y 3)) |
| 1082 | (- x y))) | 1078 | (- x y))) |
| 1083 | (or null float (integer -2 *))) | 1079 | (or null float (integer -2 *))) |
| 1084 | 1080 | ||
| 1085 | ;; 40 | 1081 | ;; 42 |
| 1086 | ((defun comp-tests-ret-type-spec-f (x y) | 1082 | ((defun comp-tests-ret-type-spec-f (x y) |
| 1087 | (when (and (<= 1 x 10) | 1083 | (when (and (<= 1 x 10) |
| 1088 | (<= 2 y)) | 1084 | (<= 2 y)) |
| 1089 | (- x y))) | 1085 | (- x y))) |
| 1090 | (or null float (integer * 8))) | 1086 | (or null float (integer * 8))) |
| 1091 | 1087 | ||
| 1092 | ;; 41 | 1088 | ;; 43 |
| 1093 | ((defun comp-tests-ret-type-spec-f (x y) | 1089 | ((defun comp-tests-ret-type-spec-f (x y) |
| 1094 | (when (and (<= x 10) | 1090 | (when (and (<= x 10) |
| 1095 | (<= 2 y)) | 1091 | (<= 2 y)) |
| 1096 | (- x y))) | 1092 | (- x y))) |
| 1097 | (or null float (integer * 8))) | 1093 | (or null float (integer * 8))) |
| 1098 | 1094 | ||
| 1099 | ;; 42 | 1095 | ;; 44 |
| 1100 | ((defun comp-tests-ret-type-spec-f (x y) | 1096 | ((defun comp-tests-ret-type-spec-f (x y) |
| 1101 | (when (and (<= x 10) | 1097 | (when (and (<= x 10) |
| 1102 | (<= y 3)) | 1098 | (<= y 3)) |
| 1103 | (- x y))) | 1099 | (- x y))) |
| 1104 | (or null float integer)) | 1100 | (or null float integer)) |
| 1105 | 1101 | ||
| 1106 | ;; 43 | 1102 | ;; 45 |
| 1107 | ((defun comp-tests-ret-type-spec-f (x y) | 1103 | ((defun comp-tests-ret-type-spec-f (x y) |
| 1108 | (when (and (<= 2 x) | 1104 | (when (and (<= 2 x) |
| 1109 | (<= 3 y)) | 1105 | (<= 3 y)) |
| 1110 | (- x y))) | 1106 | (- x y))) |
| 1111 | (or null float integer)) | 1107 | (or null float integer)) |
| 1112 | 1108 | ||
| 1113 | ;; 44 | 1109 | ;; 46 |
| 1114 | ;; SBCL: (OR (RATIONAL (6) (30)) (SINGLE-FLOAT 6.0 30.0) | 1110 | ;; SBCL: (OR (RATIONAL (6) (30)) (SINGLE-FLOAT 6.0 30.0) |
| 1115 | ;; (DOUBLE-FLOAT 6.0d0 30.0d0) NULL) | 1111 | ;; (DOUBLE-FLOAT 6.0d0 30.0d0) NULL) |
| 1116 | ((defun comp-tests-ret-type-spec-f (x y z i j k) | 1112 | ((defun comp-tests-ret-type-spec-f (x y z i j k) |
| @@ -1123,22 +1119,61 @@ Return a list of results." | |||
| 1123 | (+ x y z i j k))) | 1119 | (+ x y z i j k))) |
| 1124 | (or null float (integer 12 24))) | 1120 | (or null float (integer 12 24))) |
| 1125 | 1121 | ||
| 1126 | ;; 45 | 1122 | ;; 47 |
| 1127 | ((defun comp-tests-ret-type-spec-f (x) | 1123 | ((defun comp-tests-ret-type-spec-f (x) |
| 1128 | (when (<= 1 x 5) | 1124 | (when (<= 1 x 5) |
| 1129 | (1+ x))) | 1125 | (1+ x))) |
| 1130 | (or null float (integer 2 6))) | 1126 | (or null float (integer 2 6))) |
| 1131 | 1127 | ||
| 1132 | ;;46 | 1128 | ;;48 |
| 1133 | ((defun comp-tests-ret-type-spec-f (x) | 1129 | ((defun comp-tests-ret-type-spec-f (x) |
| 1134 | (when (<= 1 x 5) | 1130 | (when (<= 1 x 5) |
| 1135 | (1- x))) | 1131 | (1- x))) |
| 1136 | (or null float (integer 0 4))) | 1132 | (or null float (integer 0 4))) |
| 1137 | 1133 | ||
| 1138 | ;; 47 | 1134 | ;; 49 |
| 1139 | ((defun comp-tests-ret-type-spec-f () | 1135 | ((defun comp-tests-ret-type-spec-f () |
| 1140 | (error "foo")) | 1136 | (error "foo")) |
| 1141 | nil))) | 1137 | nil) |
| 1138 | |||
| 1139 | ;; 50 | ||
| 1140 | ((defun comp-tests-ret-type-spec-f (x) | ||
| 1141 | (if (stringp x) | ||
| 1142 | x | ||
| 1143 | 'bar)) | ||
| 1144 | (or (member bar) string)) | ||
| 1145 | |||
| 1146 | ;; 51 | ||
| 1147 | ((defun comp-tests-ret-type-spec-f (x) | ||
| 1148 | (if (stringp x) | ||
| 1149 | 'bar | ||
| 1150 | x)) | ||
| 1151 | (not string)) | ||
| 1152 | |||
| 1153 | ;; 52 | ||
| 1154 | ((defun comp-tests-ret-type-spec-f (x) | ||
| 1155 | (if (integerp x) | ||
| 1156 | x | ||
| 1157 | 'bar)) | ||
| 1158 | (or (member bar) integer)) | ||
| 1159 | |||
| 1160 | ;; 53 | ||
| 1161 | ((defun comp-tests-ret-type-spec-f (x) | ||
| 1162 | (when (integerp x) | ||
| 1163 | x)) | ||
| 1164 | (or null integer)) | ||
| 1165 | |||
| 1166 | ;; 54 | ||
| 1167 | ((defun comp-tests-ret-type-spec-f (x) | ||
| 1168 | (unless (symbolp x) | ||
| 1169 | x)) | ||
| 1170 | (not symbol)) | ||
| 1171 | |||
| 1172 | ;; 55 | ||
| 1173 | ((defun comp-tests-ret-type-spec-f (x) | ||
| 1174 | (unless (integerp x) | ||
| 1175 | x)) | ||
| 1176 | (not integer)))) | ||
| 1142 | 1177 | ||
| 1143 | (defun comp-tests-define-type-spec-test (number x) | 1178 | (defun comp-tests-define-type-spec-test (number x) |
| 1144 | `(comp-deftest ,(intern (format "ret-type-spec-%d" number)) () | 1179 | `(comp-deftest ,(intern (format "ret-type-spec-%d" number)) () |