X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=tests%2Ftype.pure.lisp;h=bac6d51169cce9ba6c4b8d85e4ce6b44c7645f52;hb=9943ee511c2e114876b2c6f52876984ad7087354;hp=5e4b98d2ca7e52d24ce6f6fb6a28e6f29dfd46ea;hpb=4898ef32c639b1c7f4ee13a5ba566ce6debd03e6;p=sbcl.git diff --git a/tests/type.pure.lisp b/tests/type.pure.lisp index 5e4b98d..bac6d51 100644 --- a/tests/type.pure.lisp +++ b/tests/type.pure.lisp @@ -237,6 +237,10 @@ ;;; Test derivation of LOG{AND,IOR,XOR} bounds for unsigned arguments. ;;; ;;; Fear the Loop of Doom! +;;; +;;; (In fact, this is such a fearsome loop that executing it with the +;;; evaluator would take ages... Disable it under those circumstances.) +#+#.(cl:if (cl:eq sb-ext:*evaluator-mode* :compile) '(and) '(or)) (let* ((bits 5) (size (ash 1 bits))) (flet ((brute-force (a b c d op minimize) @@ -266,3 +270,79 @@ ACTUAL ~D DERIVED ~D~%" op a b c d minimize brute derived) (assert (= brute derived))))))))))))) + +;;; subtypep on CONS types wasn't taking account of the fact that a +;;; CONS type could be the empty type (but no other non-CONS type) in +;;; disguise. +(multiple-value-bind (yes win) + (subtypep '(and function stream) 'nil) + (multiple-value-bind (cyes cwin) + (subtypep '(cons (and function stream) t) + '(cons nil t)) + (assert (eq yes cyes)) + (assert (eq win cwin)))) + +;;; CONS type subtypep could be too enthusiastic about thinking it was +;;; certain +(multiple-value-bind (yes win) + (subtypep '(satisfies foo) '(satisfies bar)) + (assert (null yes)) + (assert (null win)) + (multiple-value-bind (cyes cwin) + (subtypep '(cons (satisfies foo) t) + '(cons (satisfies bar) t)) + (assert (null cyes)) + (assert (null cwin)))) + +(multiple-value-bind (yes win) + (subtypep 'generic-function 'function) + (assert yes) + (assert win)) +;;; this would be in some internal test suite like type.before-xc.lisp +;;; except that generic functions don't exist at that stage. +(multiple-value-bind (yes win) + (subtypep 'generic-function 'sb-kernel:funcallable-instance) + (assert yes) + (assert win)) + +;;; all sorts of answers are right for this one, but it used to +;;; trigger an AVER instead. +(subtypep '(function ()) '(and (function ()) (satisfies identity))) + +(assert (sb-kernel:unknown-type-p (sb-kernel:specifier-type 'an-unkown-type))) + +(assert + (sb-kernel:type= + (sb-kernel:specifier-type '(or (simple-array an-unkown-type (*)) + (simple-array an-unkown-type))) + (sb-kernel:specifier-type '(or (simple-array an-unkown-type (*)) + (simple-array an-unkown-type))))) + +(assert + (sb-kernel:type= + (sb-kernel:specifier-type '(simple-array an-unkown-type (*))) + (sb-kernel:specifier-type '(simple-array an-unkown-type (*))))) + +(assert + (not + (sb-kernel:type= + (sb-kernel:specifier-type '(simple-array an-unkown-type (*))) + (sb-kernel:specifier-type '(array an-unkown-type (*)))))) + +(assert + (not + (sb-kernel:type= + (sb-kernel:specifier-type '(simple-array an-unkown-type (7))) + (sb-kernel:specifier-type '(simple-array an-unkown-type (8)))))) + +(assert + (sb-kernel:type/= (sb-kernel:specifier-type 'cons) + (sb-kernel:specifier-type '(cons single-float single-float)))) + +(multiple-value-bind (match win) + (sb-kernel:type= (sb-kernel:specifier-type '(cons integer)) + (sb-kernel:specifier-type '(cons))) + (assert (and (not match) win))) + +(assert (typep #p"" 'sb-kernel:instance)) +(assert (subtypep '(member #p"") 'sb-kernel:instance))