mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-03-11 23:40:36 -07:00
tests: add regression tests for define-method-combination
This commit is contained in:
parent
8ba1bb888a
commit
3064bac62b
2 changed files with 53 additions and 0 deletions
|
|
@ -13,6 +13,7 @@
|
|||
:default-component-class asdf:cl-source-file.lsp
|
||||
:components
|
||||
((:file "ansi")
|
||||
(:file "clos")
|
||||
(:file "mixed")
|
||||
(:file "compiler")
|
||||
(:file "executable-cli")
|
||||
|
|
|
|||
52
src/tests/normal-tests/clos.lsp
Normal file
52
src/tests/normal-tests/clos.lsp
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
;;;; -*- Mode: Lisp; Syntax: Common-Lisp; indent-tabs-mode: nil -*-
|
||||
;;;; vim: set filetype=lisp tabstop=8 shiftwidth=2 expandtab:
|
||||
|
||||
;;;; Author: Daniel Kochmański
|
||||
;;;; Created: 2023-01-19
|
||||
;;;; Contains: CLOS tests
|
||||
|
||||
(in-package #:cl-test)
|
||||
|
||||
(suite 'clos)
|
||||
|
||||
|
||||
;;; Method combination long form
|
||||
|
||||
;;; Check whether different types of wildcard patterns are correctly handled.
|
||||
;;; Most notably the symbol * in a pattern matches any method qualifier on
|
||||
;;; that position.
|
||||
(ext:with-clean-symbols (combin gf)
|
||||
(test clos.0001.combin/wildcard
|
||||
(define-method-combination combin ()
|
||||
((p1 (:wild :no))
|
||||
(p2 (:wild * *))
|
||||
(p3 (:wild . *))
|
||||
(pr *))
|
||||
`(list ,(length p1)
|
||||
,(length p2)
|
||||
,(length p3)
|
||||
,(length pr)))
|
||||
(defgeneric gf ()
|
||||
(:method-combination combin))
|
||||
(finishes (defmethod gf :wild :no ())) ; p1
|
||||
(finishes (defmethod gf :wild :x :y ())) ; p2
|
||||
(finishes (defmethod gf :wild ())) ; p3
|
||||
(finishes (defmethod gf :wild :foobar ())) ; p3
|
||||
(finishes (defmethod gf :wild :no :a :b ())) ; p3
|
||||
(finishes (defmethod gf :xxx :yyy 34 23 ())) ; p4
|
||||
(is-equal '(1 1 3 1) (gf))))
|
||||
|
||||
;;; This test checks whether define-method-combination handles arguments
|
||||
;;; :GENERIC-FUNCTION and :ARGUMENTS &WHOLE ARGS.
|
||||
(ext:with-clean-symbols (combin f1 f2)
|
||||
(test clos.0002.combin/arguments
|
||||
(define-method-combination combin ()
|
||||
((method-list *))
|
||||
(:arguments &whole args)
|
||||
(:generic-function gf)
|
||||
`(list ,gf ,args))
|
||||
(defgeneric f1 (a &key key-1)
|
||||
(:method-combination combin)
|
||||
(:method (a &key key-1 key-2)
|
||||
(declare (ignore a key-1 key-2))))
|
||||
(is-equal (list #'f1 1 :key-1 2) (f1 1 :key-1 2))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue