diff options
| author | Przemyslaw Wojnowski | 2015-03-09 23:14:36 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2015-03-09 23:14:36 -0400 |
| commit | 778de7270b92fcaabd515816f118b28838318ca2 (patch) | |
| tree | 914c0ded2f614007024c1b7669453aec09941af1 | |
| parent | ff032662775fb3faa7eaa99947fc40e18c948e82 (diff) | |
| download | emacs-778de7270b92fcaabd515816f118b28838318ca2.tar.gz emacs-778de7270b92fcaabd515816f118b28838318ca2.zip | |
* test/automated/cl-lib-tests.el: Add tests for plusp, second, ...
(cl-lib-test-plusp, cl-lib-test-minusp)
(cl-lib-test-oddp, cl-lib-test-evenp, cl-lib-test-first)
(cl-lib-test-second, cl-lib-test-third, cl-lib-test-fourth)
(cl-lib-test-fifth, cl-lib-test-sixth, cl-lib-test-seventh)
(cl-lib-test-eighth, cl-lib-test-ninth, cl-lib-test-tenth)
(cl-lib-test-endp, cl-lib-test-nth-value)
(cl-lib-nth-value-test-multiple-values, cl-test-caaar, cl-test-caadr)
(cl-test-ldiff): New tests.
(cl-digit-char-p): Tighten the test.
| -rw-r--r-- | test/ChangeLog | 13 | ||||
| -rw-r--r-- | test/automated/cl-lib-tests.el | 189 |
2 files changed, 197 insertions, 5 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index e51dddc05f1..03cc2818478 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2015-03-10 Przemyslaw Wojnowski <esperanto@cumego.com> | ||
| 2 | |||
| 3 | * automated/cl-lib-tests.el: Add tests for plusp, second, ... | ||
| 4 | (cl-lib-test-plusp, cl-lib-test-minusp) | ||
| 5 | (cl-lib-test-oddp, cl-lib-test-evenp, cl-lib-test-first) | ||
| 6 | (cl-lib-test-second, cl-lib-test-third, cl-lib-test-fourth) | ||
| 7 | (cl-lib-test-fifth, cl-lib-test-sixth, cl-lib-test-seventh) | ||
| 8 | (cl-lib-test-eighth, cl-lib-test-ninth, cl-lib-test-tenth) | ||
| 9 | (cl-lib-test-endp, cl-lib-test-nth-value) | ||
| 10 | (cl-lib-nth-value-test-multiple-values, cl-test-caaar, cl-test-caadr) | ||
| 11 | (cl-test-ldiff): New tests. | ||
| 12 | (cl-digit-char-p): Tighten the test. | ||
| 13 | |||
| 1 | 2015-03-09 Dmitry Gutov <dgutov@yandex.ru> | 14 | 2015-03-09 Dmitry Gutov <dgutov@yandex.ru> |
| 2 | 15 | ||
| 3 | * indent/Makefile: Call 'rm' with '-f'. Default EMACS to | 16 | * indent/Makefile: Call 'rm' with '-f'. Default EMACS to |
diff --git a/test/automated/cl-lib-tests.el b/test/automated/cl-lib-tests.el index c83391b1cc5..1c36e7d7abf 100644 --- a/test/automated/cl-lib-tests.el +++ b/test/automated/cl-lib-tests.el | |||
| @@ -223,13 +223,192 @@ | |||
| 223 | (should (= (cl-the integer (cl-incf side-effect)) 1)) | 223 | (should (= (cl-the integer (cl-incf side-effect)) 1)) |
| 224 | (should (= side-effect 1)))) | 224 | (should (= side-effect 1)))) |
| 225 | 225 | ||
| 226 | (ert-deftest cl-lib-test-plusp () | ||
| 227 | (should-not (cl-plusp -1.0e+INF)) | ||
| 228 | (should-not (cl-plusp -1.5e2)) | ||
| 229 | (should-not (cl-plusp -3.14)) | ||
| 230 | (should-not (cl-plusp -1)) | ||
| 231 | (should-not (cl-plusp -0.0)) | ||
| 232 | (should-not (cl-plusp 0)) | ||
| 233 | (should-not (cl-plusp 0.0)) | ||
| 234 | (should-not (cl-plusp -0.0e+NaN)) | ||
| 235 | (should-not (cl-plusp 0.0e+NaN)) | ||
| 236 | (should (cl-plusp 1)) | ||
| 237 | (should (cl-plusp 3.14)) | ||
| 238 | (should (cl-plusp 1.5e2)) | ||
| 239 | (should (cl-plusp 1.0e+INF)) | ||
| 240 | (should-error (cl-plusp "42") :type 'wrong-type-argument)) | ||
| 241 | |||
| 242 | (ert-deftest cl-lib-test-minusp () | ||
| 243 | (should (cl-minusp -1.0e+INF)) | ||
| 244 | (should (cl-minusp -1.5e2)) | ||
| 245 | (should (cl-minusp -3.14)) | ||
| 246 | (should (cl-minusp -1)) | ||
| 247 | (should-not (cl-minusp -0.0)) | ||
| 248 | (should-not (cl-minusp 0)) | ||
| 249 | (should-not (cl-minusp 0.0)) | ||
| 250 | (should-not (cl-minusp -0.0e+NaN)) | ||
| 251 | (should-not (cl-minusp 0.0e+NaN)) | ||
| 252 | (should-not (cl-minusp 1)) | ||
| 253 | (should-not (cl-minusp 3.14)) | ||
| 254 | (should-not (cl-minusp 1.5e2)) | ||
| 255 | (should-not (cl-minusp 1.0e+INF)) | ||
| 256 | (should-error (cl-minusp "-42") :type 'wrong-type-argument)) | ||
| 257 | |||
| 258 | (ert-deftest cl-lib-test-oddp () | ||
| 259 | (should (cl-oddp -3)) | ||
| 260 | (should (cl-oddp 3)) | ||
| 261 | (should-not (cl-oddp -2)) | ||
| 262 | (should-not (cl-oddp 0)) | ||
| 263 | (should-not (cl-oddp 2)) | ||
| 264 | (should-error (cl-oddp 3.0e+NaN) :type 'wrong-type-argument) | ||
| 265 | (should-error (cl-oddp 3.0) :type 'wrong-type-argument) | ||
| 266 | (should-error (cl-oddp "3") :type 'wrong-type-argument)) | ||
| 267 | |||
| 268 | (ert-deftest cl-lib-test-evenp () | ||
| 269 | (should (cl-evenp -2)) | ||
| 270 | (should (cl-evenp 0)) | ||
| 271 | (should (cl-evenp 2)) | ||
| 272 | (should-not (cl-evenp -3)) | ||
| 273 | (should-not (cl-evenp 3)) | ||
| 274 | (should-error (cl-evenp 2.0e+NaN) :type 'wrong-type-argument) | ||
| 275 | (should-error (cl-evenp 2.0) :type 'wrong-type-argument) | ||
| 276 | (should-error (cl-evenp "2") :type 'wrong-type-argument)) | ||
| 277 | |||
| 226 | (ert-deftest cl-digit-char-p () | 278 | (ert-deftest cl-digit-char-p () |
| 227 | (should (cl-digit-char-p ?3)) | 279 | (should (eql 3 (cl-digit-char-p ?3))) |
| 228 | (should (cl-digit-char-p ?a 11)) | 280 | (should (eql 10 (cl-digit-char-p ?a 11))) |
| 281 | (should (eql 10 (cl-digit-char-p ?A 11))) | ||
| 229 | (should-not (cl-digit-char-p ?a)) | 282 | (should-not (cl-digit-char-p ?a)) |
| 230 | (should (cl-digit-char-p ?w 36)) | 283 | (should (eql 32 (cl-digit-char-p ?w 36))) |
| 231 | (should-error (cl-digit-char-p ?a 37)) | 284 | (should-error (cl-digit-char-p ?a 37) :type 'args-out-of-range) |
| 232 | (should-error (cl-digit-char-p ?a 1))) | 285 | (should-error (cl-digit-char-p ?a 1) :type 'args-out-of-range)) |
| 286 | |||
| 287 | (ert-deftest cl-lib-test-first () | ||
| 288 | (should (null (cl-first '()))) | ||
| 289 | (should (= 4 (cl-first '(4)))) | ||
| 290 | (should (= 4 (cl-first '(4 2)))) | ||
| 291 | (should-error (cl-first "42") :type 'wrong-type-argument)) | ||
| 292 | |||
| 293 | (ert-deftest cl-lib-test-second () | ||
| 294 | (should (null (cl-second '()))) | ||
| 295 | (should (null (cl-second '(4)))) | ||
| 296 | (should (= 2 (cl-second '(1 2)))) | ||
| 297 | (should (= 2 (cl-second '(1 2 3)))) | ||
| 298 | (should-error (cl-second "1 2 3") :type 'wrong-type-argument)) | ||
| 299 | |||
| 300 | (ert-deftest cl-lib-test-third () | ||
| 301 | (should (null (cl-third '()))) | ||
| 302 | (should (null (cl-third '(1 2)))) | ||
| 303 | (should (= 3 (cl-third '(1 2 3)))) | ||
| 304 | (should (= 3 (cl-third '(1 2 3 4)))) | ||
| 305 | (should-error (cl-third "123") :type 'wrong-type-argument)) | ||
| 306 | |||
| 307 | (ert-deftest cl-lib-test-fourth () | ||
| 308 | (should (null (cl-fourth '()))) | ||
| 309 | (should (null (cl-fourth '(1 2 3)))) | ||
| 310 | (should (= 4 (cl-fourth '(1 2 3 4)))) | ||
| 311 | (should (= 4 (cl-fourth '(1 2 3 4 5)))) | ||
| 312 | (should-error (cl-fourth "1234") :type 'wrong-type-argument)) | ||
| 313 | |||
| 314 | (ert-deftest cl-lib-test-fifth () | ||
| 315 | (should (null (cl-fifth '()))) | ||
| 316 | (should (null (cl-fifth '(1 2 3 4)))) | ||
| 317 | (should (= 5 (cl-fifth '(1 2 3 4 5)))) | ||
| 318 | (should (= 5 (cl-fifth '(1 2 3 4 5 6)))) | ||
| 319 | (should-error (cl-fifth "12345") :type 'wrong-type-argument)) | ||
| 320 | |||
| 321 | (ert-deftest cl-lib-test-fifth () | ||
| 322 | (should (null (cl-fifth '()))) | ||
| 323 | (should (null (cl-fifth '(1 2 3 4)))) | ||
| 324 | (should (= 5 (cl-fifth '(1 2 3 4 5)))) | ||
| 325 | (should (= 5 (cl-fifth '(1 2 3 4 5 6)))) | ||
| 326 | (should-error (cl-fifth "12345") :type 'wrong-type-argument)) | ||
| 327 | |||
| 328 | (ert-deftest cl-lib-test-sixth () | ||
| 329 | (should (null (cl-sixth '()))) | ||
| 330 | (should (null (cl-sixth '(1 2 3 4 5)))) | ||
| 331 | (should (= 6 (cl-sixth '(1 2 3 4 5 6)))) | ||
| 332 | (should (= 6 (cl-sixth '(1 2 3 4 5 6 7)))) | ||
| 333 | (should-error (cl-sixth "123456") :type 'wrong-type-argument)) | ||
| 334 | |||
| 335 | (ert-deftest cl-lib-test-seventh () | ||
| 336 | (should (null (cl-seventh '()))) | ||
| 337 | (should (null (cl-seventh '(1 2 3 4 5 6)))) | ||
| 338 | (should (= 7 (cl-seventh '(1 2 3 4 5 6 7)))) | ||
| 339 | (should (= 7 (cl-seventh '(1 2 3 4 5 6 7 8)))) | ||
| 340 | (should-error (cl-seventh "1234567") :type 'wrong-type-argument)) | ||
| 341 | |||
| 342 | (ert-deftest cl-lib-test-eighth () | ||
| 343 | (should (null (cl-eighth '()))) | ||
| 344 | (should (null (cl-eighth '(1 2 3 4 5 6 7)))) | ||
| 345 | (should (= 8 (cl-eighth '(1 2 3 4 5 6 7 8)))) | ||
| 346 | (should (= 8 (cl-eighth '(1 2 3 4 5 6 7 8 9)))) | ||
| 347 | (should-error (cl-eighth "12345678") :type 'wrong-type-argument)) | ||
| 348 | |||
| 349 | (ert-deftest cl-lib-test-ninth () | ||
| 350 | (should (null (cl-ninth '()))) | ||
| 351 | (should (null (cl-ninth '(1 2 3 4 5 6 7 8)))) | ||
| 352 | (should (= 9 (cl-ninth '(1 2 3 4 5 6 7 8 9)))) | ||
| 353 | (should (= 9 (cl-ninth '(1 2 3 4 5 6 7 8 9 10)))) | ||
| 354 | (should-error (cl-ninth "123456789") :type 'wrong-type-argument)) | ||
| 355 | |||
| 356 | (ert-deftest cl-lib-test-tenth () | ||
| 357 | (should (null (cl-tenth '()))) | ||
| 358 | (should (null (cl-tenth '(1 2 3 4 5 6 7 8 9)))) | ||
| 359 | (should (= 10 (cl-tenth '(1 2 3 4 5 6 7 8 9 10)))) | ||
| 360 | (should (= 10 (cl-tenth '(1 2 3 4 5 6 7 8 9 10 11)))) | ||
| 361 | (should-error (cl-tenth "1234567890") :type 'wrong-type-argument)) | ||
| 362 | |||
| 363 | (ert-deftest cl-lib-test-endp () | ||
| 364 | (should (cl-endp '())) | ||
| 365 | (should-not (cl-endp '(1))) | ||
| 366 | (should-error (cl-endp 1) :type 'wrong-type-argument) | ||
| 367 | (should-error (cl-endp [1]) :type 'wrong-type-argument)) | ||
| 368 | |||
| 369 | (ert-deftest cl-lib-test-nth-value () | ||
| 370 | (let ((vals (cl-values 2 3))) | ||
| 371 | (should (= (cl-nth-value 0 vals) 2)) | ||
| 372 | (should (= (cl-nth-value 1 vals) 3)) | ||
| 373 | (should (null (cl-nth-value 2 vals))) | ||
| 374 | (should-error (cl-nth-value 0.0 vals) :type 'wrong-type-argument))) | ||
| 375 | |||
| 376 | (ert-deftest cl-lib-nth-value-test-multiple-values () | ||
| 377 | "While CL multiple values are an alias to list, these won't work." | ||
| 378 | :expected-result :failed | ||
| 379 | (should (eq (cl-nth-value 0 '(2 3)) '(2 3))) | ||
| 380 | (should (= (cl-nth-value 0 1) 1)) | ||
| 381 | (should (null (cl-nth-value 1 1))) | ||
| 382 | (should-error (cl-nth-value -1 (cl-values 2 3)) :type 'args-out-of-range) | ||
| 383 | (should (string= (cl-nth-value 0 "only lists") "only lists"))) | ||
| 384 | |||
| 385 | (ert-deftest cl-test-caaar () | ||
| 386 | (should (null (cl-caaar '()))) | ||
| 387 | (should (null (cl-caaar '(() (2))))) | ||
| 388 | (should (null (cl-caaar '((() (2)) (a b))))) | ||
| 389 | (should-error (cl-caaar '(1 2)) :type 'wrong-type-argument) | ||
| 390 | (should-error (cl-caaar '((1 2))) :type 'wrong-type-argument) | ||
| 391 | (should (= 1 (cl-caaar '(((1 2) (3 4)))))) | ||
| 392 | (should (null (cl-caaar '((() (3 4))))))) | ||
| 393 | |||
| 394 | (ert-deftest cl-test-caadr () | ||
| 395 | (should (null (cl-caadr '()))) | ||
| 396 | (should (null (cl-caadr '(1)))) | ||
| 397 | (should-error (cl-caadr '(1 2)) :type 'wrong-type-argument) | ||
| 398 | (should (= 2 (cl-caadr '(1 (2 3))))) | ||
| 399 | (should (equal '((2) (3)) (cl-caadr '((1) (((2) (3))) (4)))))) | ||
| 400 | |||
| 401 | (ert-deftest cl-test-ldiff () | ||
| 402 | (let ((l '(1 2 3))) | ||
| 403 | (should (null (cl-ldiff '() '()))) | ||
| 404 | (should (null (cl-ldiff '() l))) | ||
| 405 | (should (null (cl-ldiff l l))) | ||
| 406 | (should (equal l (cl-ldiff l '()))) | ||
| 407 | ;; must be part of the list | ||
| 408 | (should (equal l (cl-ldiff l '(2 3)))) | ||
| 409 | (should (equal '(1) (cl-ldiff l (nthcdr 1 l)))) | ||
| 410 | ;; should return a copy | ||
| 411 | (should-not (eq (cl-ldiff l '()) l)))) | ||
| 233 | 412 | ||
| 234 | (ert-deftest cl-parse-integer () | 413 | (ert-deftest cl-parse-integer () |
| 235 | (should-error (cl-parse-integer "abc")) | 414 | (should-error (cl-parse-integer "abc")) |