#! /usr/bin/sbcl --script
; ******************************************************
; THE TEST CASES/CALLS BELOW ARE MERELY A STARTING POINT
; FOR TESTING YOUR CODE, THEY ARE NOT ADEQUATE TO ENSURE
; YOUR CODE IS ANYWHERE CLOSE TO SUFFICIENT
; ******************************************************
; define a constant identifying all the valid departments/areas for the
; purposes of the test (this is used by the validGrade function)
(defconstant VALIDAREAS '("BIOL" "CSCI" "MATH" "ENGL"))
; ensure the lab2 functions are correctly loaded
(load "lab2.cl")
(format t "---~%")
(format t "lab2.cl functions loading complete~%")
(format t "---~%")
; some basic lists for use in testing
(defvar okCS1 '("CSCI" 159 4 "C"))
(defvar okCS2 '("CSCI" 159 4 "C+"))
(defvar badGrade '("CSCI" 4 "C+"))
(defvar okMath '("MATH" 123 3 "C-"))
; try building dispatchers from the lists above
(format t "building dispatchers~%")
(defvar okReqDisp (buildGrade okCS1 t))
(defvar okGradeDisp (buildGrade okCS2 nil))
(defvar badGradeDisp (buildGrade badGrade nil))
(defvar okMathReqDisp (buildGrade okMath t))
(defvar okMathGrDisp (buildGrade okMath nil))
(format t "dispatchers built~%")
(format t "---~%")
; test various get commands on dispatchers
(format t "trying out a mix of get commands on the various dispatchers~%")
(format t "isReq on okReqDisp:~%")
(format t " ... ~A~%" (funcall okReqDisp 'isReq))
(format t "isReq on okGradeDisp:~%")
(format t " ... ~A~%" (funcall okGradeDisp 'isReq))
(format t "getArea on okGradeDisp:~%")
(format t " ... ~A~%" (funcall okGradeDisp 'getArea))
(format t "getCnum on okGradeDisp:~%")
(format t " ... ~A~%" (funcall okGradeDisp 'getCnum))
(format t "getCred on okGradeDisp:~%")
(format t " ... ~A~%" (funcall okGradeDisp 'getCred))
(format t "getLetG on okGradeDisp:~%")
(format t " ... ~A~%" (funcall okGradeDisp 'getLetG))
(format t "getGPA on okGradeDisp:~%")
(format t " ... ~A~%" (funcall okGradeDisp 'getGPA))
(format t "getWGPA on okGradeDisp:~%")
(format t " ... ~A~%" (funcall okGradeDisp 'getWGPA))
(format t "isValid on okGradeDisp:~%")
(format t " ... ~A~%" (funcall okGradeDisp 'isValid))
(format t "getAsList on okGradeDisp, which came from ~A:~%" okCS2)
(format t " ... ~A~%" (funcall okGradeDisp 'getAsList))
(format t "isValid on badGradeDisp:~%")
(format t " ... ~A~%" (funcall badGradeDisp 'isValid))
(format t "---~%")
; test the meets requirements command on dispatchers
(format t "trying out the meetsReq command on dispatchers~%")
(format t "using okReqDisp, does okCS1 pass (should)~%")
(format t " ... ~A~%" (funcall okReqDisp 'meetsReq okCS1))
(format t "using okGradeDisp, does it meet req okCS1 (should)~%")
(format t " ... ~A~%" (funcall okGradeDisp 'meetsReq okCS1))
(format t "using okMathGrDisp, does it meet req okCS1 (should not)~%")
(format t " ... ~A~%" (funcall okMathGrDisp 'meetsReq okCS1))
(format t "---~%")
; build lists of actual/required courses for use in testing gpaCalc and meetsAll
(defvar reqsList (list okReqDisp okMathReqDisp))
(defvar actualList (list okGradeDisp okMathGrDisp))
(defvar oneCourseReq (list okMathReqDisp))
(defvar oneCourseAct (list okMathGrDisp))
(defvar actWithBad (list okGradeDisp badGradeDisp okMathGrDisp))
; test if all the requirements are met
(format t "trying out the meetsAllReqs function on lists of dispatchers~%")
(format t "(meetsAllReqs reqsList actualList) should pass~%")
(format t " ... result: ~A~%" (meetsAllReqs reqsList actualList))
(format t "(meetsAllReqs reqsList oneCourseAct) should fail~%")
(format t " ... result: ~A~%" (meetsAllReqs reqsList oneCourseAct))
(format t "---~%")
; simple check of gpaCalc
(format t "trying out the gpaCalcs on actualList, should give about 2.05~%")
(format t " ... result: ~A~%" (gpaCalc actualList))
(format t "trying out the gpaCalcs on actWithBad, should still give about 2.05~%")
(format t " ... result: ~A~%" (gpaCalc actWithBad))
(format t "---~%")
---
lab2.cl functions loading complete
---
building dispatchers
Error: (CSCI 4 C+) does not have four elements, cannot represent a grade
dispatchers built
---
trying out a mix of get commands on the various dispatchers
isReq on okReqDisp:
... T
isReq on okGradeDisp:
... NIL
getArea on okGradeDisp:
... CSCI
getCnum on okGradeDisp:
... 159
getCred on okGradeDisp:
... 4
getLetG on okGradeDisp:
... C+
getGPA on okGradeDisp:
... 2.33
getWGPA on okGradeDisp:
... 9.32
isValid on okGradeDisp:
... T
getAsList on okGradeDisp, which came from (CSCI 159 4 C+):
... (CSCI 159 4 C+)
isValid on badGradeDisp:
... NIL
---
trying out the meetsReq command on dispatchers
using okReqDisp, does okCS1 pass (should)
... T
using okGradeDisp, does it meet req okCS1 (should)
... T
using okMathGrDisp, does it meet req okCS1 (should not)
... NIL
---
trying out the meetsAllReqs function on lists of dispatchers
(meetsAllReqs reqsList actualList) should pass
... result: T
(meetsAllReqs reqsList oneCourseAct) should fail
UNMET Requirement: (CSCI 159 4 C)
... result: NIL
---
trying out the gpaCalcs on actualList, should give about 2.05
... result: 2.0471427
trying out the gpaCalcs on actWithBad, should still give about 2.05
... result: 2.0471427
---
|