source: trunk/source/tests/ansi-tests/stream-element-type.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 12 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 2.7 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Tue Jan 13 20:09:50 2004
4;;;; Contains: Tests for STREAM-ELEMENT-TYPE
5
6(in-package :cl-test)
7
8(deftest stream-element-type.1
9  (loop for s in (list *debug-io* *error-output* *query-io*
10                       *standard-input* *standard-output*
11                       *trace-output* *terminal-io*)
12        for results = (multiple-value-list (stream-element-type s))
13        unless (and (eql (length results) 1)
14                    (car results))
15        collect s)
16  nil)
17
18(deftest stream-element-type.2
19  (let ((pn "foo.txt"))
20    (loop for i from 1 to 100
21          for etype = `(unsigned-byte ,i)
22          for s = (progn (delete-all-versions pn)
23                         (open pn :direction :output
24                               :element-type etype))
25          unless
26          (multiple-value-bind (sub good)
27              (subtypep etype (stream-element-type s))
28            (close s)
29            (or sub (not good)))
30          collect i))
31  nil)
32
33(deftest stream-element-type.3
34  (let ((pn "foo.txt"))
35    (loop for i from 1 to 100
36          for etype = `(signed-byte ,i)
37          for s = (progn (delete-all-versions pn)
38                         (open pn :direction :output
39                               :element-type etype))
40          unless
41          (multiple-value-bind (sub good)
42              (subtypep etype (stream-element-type s))
43            (close s)
44            (or sub (not good)))
45          collect i))
46  nil)
47
48(deftest stream-element-type.4
49  (let ((pn "foo.txt"))
50    (loop for i from 1 to 100
51          for etype = `(integer 0 ,i)
52          for s = (progn (delete-all-versions pn)
53                         (open pn :direction :output
54                               :element-type etype))
55          unless
56          (multiple-value-bind (sub good)
57              (subtypep etype (stream-element-type s))
58            (close s)
59            (or sub (not good)))
60          collect i))
61  nil)
62
63
64(deftest stream-element-type.5
65  :notes (:assume-no-simple-streams)
66  (let ((pn "foo.txt"))
67    (delete-all-versions pn)
68    (let ((s (open pn :direction :output)))
69      (let ((etype (stream-element-type s)))
70        (unwind-protect
71            (equalt (multiple-value-list (subtypep* 'character etype))
72                    '(nil t))
73          (close s)))))
74  nil)
75
76(deftest stream-element-type.6
77  :notes (:assume-no-simple-streams)
78  (let ((pn "foo.txt"))
79    (delete-all-versions pn)
80    (let ((s (open pn :direction :output
81                   :element-type :default)))
82      (let ((etype (stream-element-type s)))
83        (unwind-protect
84            (multiple-value-bind (sub1 good1) (subtypep* etype 'integer)
85              (multiple-value-bind (sub2 good2) (subtypep* etype 'character)
86                (or (not good1)
87                    (not good2)
88                    sub1 sub2)))
89          (close s)))))
90  t)
91
92(deftest stream-element-type.error.1
93  (signals-error (stream-element-type) program-error)
94  t)
95
96(deftest stream-element-type.error.2
97  (signals-error (stream-element-type *standard-input* nil) program-error)
98  t)
99
100(deftest stream-element-type.error.3
101  (check-type-error #'stream-element-type #'streamp)
102  nil)
Note: See TracBrowser for help on using the repository browser.