Fix bug in test SIMPLE-LOCAL-SOCKETS.
[iolib.git] / tests / misc.lisp
blob606a77948d8a0fd9b9f39ccb2d0544fc40dfb654
1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Indent-tabs-mode: NIL -*-
2 ;;;
3 ;;; misc.lisp --- test suite for miscellaneous routines.
4 ;;;
5 ;;; Copyright (C) 2008, Stelian Ionescu <sionescu@common-lisp.net>
6 ;;;
7 ;;; Permission is hereby granted, free of charge, to any person
8 ;;; obtaining a copy of this software and associated documentation
9 ;;; files (the "Software"), to deal in the Software without
10 ;;; restriction, including without limitation the rights to use, copy,
11 ;;; modify, merge, publish, distribute, sublicense, and/or sell copies
12 ;;; of the Software, and to permit persons to whom the Software is
13 ;;; furnished to do so, subject to the following conditions:
14 ;;;
15 ;;; The above copyright notice and this permission notice shall be
16 ;;; included in all copies or substantial portions of the Software.
17 ;;;
18 ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 ;;; DEALINGS IN THE SOFTWARE.
27 (in-package :iolib-tests)
29 (in-suite* :iolib.misc :in :iolib)
31 (test literal-hash-tables.creation.empty-hash-table-default-test
32 (finishes
33 (read-from-string "#h{}")))
35 (test (literal-hash-tables.type.empty-hash-table-default-test
36 :depends-on literal-hash-tables.creation.empty-hash-table-default-test)
37 (is-true
38 (let ((ht (read-from-string "#h{}")))
39 (and (zerop (hash-table-count ht))
40 (eq (hash-table-test ht) #-clisp 'eql
41 #+clisp 'ext:fasthash-eql)))))
43 (test literal-hash-tables.creation.empty-hash-table-test-eq
44 (finishes
45 (read-from-string "#h:eq{}")))
47 (test (literal-hash-tables.type.empty-hash-table-test-eq
48 :depends-on literal-hash-tables.creation.empty-hash-table-test-eq)
49 (is-true
50 (let ((ht (read-from-string "#h:eq{}")))
51 (and (zerop (hash-table-count ht))
52 (eq (hash-table-test ht) #-clisp 'eq
53 #+clisp 'ext:fasthash-eq)))))
55 (test literal-hash-tables.creation.one-element-hash-table-default-test
56 (finishes
57 (read-from-string "#h{1 => 3}")))
59 (test (literal-hash-tables.type.one-element-hash-table-default-test
60 :depends-on literal-hash-tables.creation.one-element-hash-table-default-test)
61 (is-true
62 (let ((ht (read-from-string "#h{1 => 3}")))
63 (and (= 1 (hash-table-count ht))
64 (eq (hash-table-test ht) #-clisp 'eql
65 #+clisp 'ext:fasthash-eql)
66 (= 3 (gethash 1 ht))))))
68 (test literal-hash-tables.creation.one-element-hash-table-test-eq
69 (finishes
70 (read-from-string "#h:eq{:a => :test}")))
72 (test (literal-hash-tables.type.one-element-hash-table-test-eq
73 :depends-on literal-hash-tables.creation.one-element-hash-table-test-eq)
74 (is-true
75 (let ((ht (read-from-string "#h:eq{:a => :test}")))
76 (and (= 1 (hash-table-count ht))
77 (eq (hash-table-test ht) #-clisp 'eq
78 #+clisp 'ext:fasthash-eq)
79 (eq :test (gethash :a ht))))))
81 (test literal-hash-tables.error.only-key
82 (signals reader-error
83 (read-from-string "#h{2}")))
85 (test literal-hash-tables.error.only-key-and-arrow
86 (signals reader-error
87 (read-from-string "#h{2 =>}")))
89 (test literal-hash-tables.error.only-separator
90 (signals reader-error
91 (read-from-string "#h{,}")))
93 (test literal-hash-tables.error.mismatched-separator
94 (signals reader-error
95 (read-from-string "#h{2 => 3 ,}")))
97 (test literal-hash-tables.error.wrong-test
98 (signals error
99 (read-from-string "#h:nologo{2 => 3}")))