summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Benkard <code@mail.matthias.benkard.de>2008-03-06 22:09:36 +0100
committerMatthias Benkard <code@mail.matthias.benkard.de>2008-03-06 22:09:36 +0100
commitf9c6f26037c09495bd6c5791c85717b013a4492f (patch)
treefa1842614e105d1838eabad3759479b1e50b9b25
parent6ffe476ad4c840a00f0c2e72c6020091e3ce801d (diff)
Add tests for SUPER calls.
darcs-hash:ba79356bb11de7346137e998a4e2db696d325e51
-rw-r--r--Lisp/tests.lisp35
1 files changed, 30 insertions, 5 deletions
diff --git a/Lisp/tests.lisp b/Lisp/tests.lisp
index cd138e5..94a20b0 100644
--- a/Lisp/tests.lisp
+++ b/Lisp/tests.lisp
@@ -430,8 +430,19 @@
(let ((class-name (intern (format nil "~A~D"
'#:mlk-test-string
(incf *class-counter*))))
+ (numclass-name (intern (format nil "~A~D"
+ '#:mlk-test-number
+ (incf *class-counter*))
+ '#:objective-c-classes))
+ (subnumclass-name (intern (format nil "~A~D"
+ '#:mlk-test-sub-number
+ (incf *class-counter*))
+ '#:objective-c-classes))
(class nil)
- (instance nil))
+ (instance nil)
+ (numinstance nil)
+ (subnuminstance nil))
+ (is (find-objc-class "NSNumber"))
(setq class
(is (c2mop:ensure-class class-name
:direct-superclasses
@@ -448,11 +459,21 @@
;; Method definition.
#.(enable-method-syntax)
+ (is (eval `(define-objective-c-generic-function #/prettifyNumber:
+ (self number))))
+
+ (is (eval `(define-objective-c-class ,numclass-name (ns::ns-object) ())))
+ (is (eval `(define-objective-c-method #/prettifyNumber: :int
+ ((self ,numclass-name) (number ns::ns-number))
+ (- (#/intValue number)))))
+
+ (is (eval `(define-objective-c-class ,subnumclass-name (,numclass-name) ())))
+ (is (eval `(define-objective-c-method #/prettifyNumber: :int
+ ((self ,subnumclass-name) (number ns::ns-number))
+ (* 2 (super)))))
+
(is (eval `(define-objective-c-generic-function #/foo:bar:stuff:do:
- (a b c d e &rest f)
- (:generic-function-class objective-c-generic-function)
- (:method-class objective-c-method))))
- (is (find-objc-class "NSNumber"))
+ (a b c d e &rest f))))
(is (eval `(define-objective-c-method #/foo:bar:stuff:do: :int
((x ,class-name)
(y :int)
@@ -467,6 +488,8 @@
;; Sanity checks.
(is (typep class 'objective-c-class))
(setq instance (is (invoke (invoke class 'alloc) 'init)))
+ (setq numinstance (is (invoke (find-objc-class numclass-name) 'new)))
+ (setq subnuminstance (is (invoke (find-objc-class subnumclass-name) 'new)))
;; Class finalisation. (Should be automatic upon instance
;; creation.)
@@ -474,6 +497,8 @@
;; Method calls.
(is (= 170 (invoke instance :foo 150 :bar nil :stuff nil :do 100)))
+ (is (= -30 (invoke numinstance :prettify-number 30)))
+ (is (= -60 (invoke subnuminstance :prettify-number 30)))
;; Object identity preservation.
(is (eql instance