Add keyword args WAIT and TIMEOUT to ACCEPT-CONNECTION.
[iolib.git] / tests / misc.lisp
blob817378f24e5fb28520f0346836a69a365074ac33
1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; indent-tabs-mode: nil -*-
2 ;;;
3 ;;; --- test suite for miscellaneous routines.
4 ;;;
6 (in-package :iolib-tests)
8 (in-suite* :iolib.misc :in :iolib)
10 (defmacro with-literal-hash-table-syntax (&body body)
11 `(let ((*readtable* (copy-readtable)))
12 (unwind-protect
13 (progn
14 (enable-reader-macro 'literal-hash-table)
15 ,@body)
16 (disable-reader-macro 'literal-hash-table))))
18 (test literal-hash-tables.creation.empty-hash-table-default-test
19 (finishes
20 (with-literal-hash-table-syntax
21 (read-from-string "#h()"))))
23 (test (literal-hash-tables.type.empty-hash-table-default-test
24 :depends-on literal-hash-tables.creation.empty-hash-table-default-test)
25 (is-true
26 (let ((ht (with-literal-hash-table-syntax
27 (read-from-string "#h()"))))
28 (and (zerop (hash-table-count ht))
29 (eq (hash-table-test ht) #-clisp 'eql
30 #+clisp 'ext:fasthash-eql)))))
32 (test literal-hash-tables.creation.empty-hash-table-test-eq
33 (finishes
34 (with-literal-hash-table-syntax
35 (read-from-string "#h:eq()"))))
37 (test (literal-hash-tables.type.empty-hash-table-test-eq
38 :depends-on literal-hash-tables.creation.empty-hash-table-test-eq)
39 (is-true
40 (let ((ht (with-literal-hash-table-syntax
41 (read-from-string "#h:eq()"))))
42 (and (zerop (hash-table-count ht))
43 (eq (hash-table-test ht) #-clisp 'eq
44 #+clisp 'ext:fasthash-eq)))))
46 (test literal-hash-tables.creation.one-element-hash-table-default-test
47 (finishes
48 (with-literal-hash-table-syntax
49 (read-from-string "#h((1 . 3))"))))
51 (test (literal-hash-tables.type.one-element-hash-table-default-test
52 :depends-on literal-hash-tables.creation.one-element-hash-table-default-test)
53 (is-true
54 (let ((ht (with-literal-hash-table-syntax
55 (read-from-string "#h((1 . 3))"))))
56 (and (= 1 (hash-table-count ht))
57 (eq (hash-table-test ht) #-clisp 'eql
58 #+clisp 'ext:fasthash-eql)
59 (= 3 (gethash 1 ht))))))
61 (test literal-hash-tables.creation.one-element-hash-table-test-eq
62 (finishes
63 (with-literal-hash-table-syntax
64 (read-from-string "#h:eq((:a . :test))"))))
66 (test (literal-hash-tables.type.one-element-hash-table-test-eq
67 :depends-on literal-hash-tables.creation.one-element-hash-table-test-eq)
68 (is-true
69 (let ((ht (with-literal-hash-table-syntax
70 (read-from-string "#h:eq((:a . :test))"))))
71 (and (= 1 (hash-table-count ht))
72 (eq (hash-table-test ht) #-clisp 'eq
73 #+clisp 'ext:fasthash-eq)
74 (eq :test (gethash :a ht))))))
76 (test literal-hash-tables.error.wrong-test
77 (signals error
78 (with-literal-hash-table-syntax
79 (read-from-string "#h:nologo((2 . 3))"))))
81 (test literal-hash-tables.error.wrong-element
82 (signals reader-error
83 (with-literal-hash-table-syntax
84 (read-from-string "#h(2)"))))