;Chapter 4, Bryan Test 2, Page 69-70 ;Structure to help test-structure. (defstruct (callrecord2 (:print-function print-callrecord2));creates a structure with 3 members, and will call print-callrecord2 when tostring is called (number nil) (durration 0) (status "just beginning")) (defun print-callrecord2 (stream obj depth) ;takes the stream, object, and depth, and calls format to print. (format stream "The call to ~A lasted for ~A minute(s), and is now ~A." (callrecord2-number obj) (callrecord2-durration obj) (callrecord2-status obj))) (deftest test-structure-2 () (let ((num 13) (mycall (make-callrecord2)) ;create empty instance (thatcall (make-callrecord2)) ;create another empty instance (yourcall (make-callrecord2 :number "+13302940684" :status "complete" :durration 10.5))) ; create populated instance (setf mycall (copy-callrecord2 yourcall)) ;copies the data member wise from yourcall to mycall (setf (callrecord2-number thatcall) "+13046585755") ;sets number in thatcall to ... (check (equal (callrecord2-number thatcall) "+13046585755") ;Checks the value stored in thatcall->number two lines above (equal (print-callrecord2 nil mycall 0) "The call to +13302940684 lasted for 10.5 minute(s), and is now complete."); tests the print function (not (callrecord2-p num)) ;checks to make sure that the predicate works. (callrecord2-p mycall) ;same as above (typep mycall 'callrecord2) ;uses typep to show that callrecord2 is now an official type (equal (callrecord2-status thatcall) "just beginning"); checks the status of a call. (not (equal mycall yourcall))))) ;shows that two instances of a class are not equal even though the values are the same.