;;; -*- Mode: Lisp -*- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (C) 1999, 2002, 2009, 2015 Marek Rychlik ;;; ;;; This program is free software; you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 2 of the License, or ;;; (at your option) any later version. ;;; ;;; This program is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with this program; if not, write to the Free Software ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Run tests using 5am unit testing framework ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; We assume that QuickLisp package manager is installed. ;; See : ;; https://www.quicklisp.org/beta/ ;; ;; The following is unnecessary after running: ;; * (ql:add-to-init-file) ;; at lisp prompt: ;;(load "~/quicklisp/setup") (ql:quickload :fiveam) (require :ring "ring") (require :monom "monom") (require :term "term") (require :order "order") (require :polynomial "polynomial") (defpackage #:5am-poly (:use :cl :it.bese.fiveam :ring :monom :term :order :polynomial)) (in-package :5am-poly) (def-suite poly-suite :description "Monom package suite") (in-suite poly-suite) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; POLY class tests ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (def-fixture poly-context () (let ((p (make-instance 'poly)) (q (make-instance 'poly :order #'grlex>)) (p+q (make-instance 'poly)) (p-q (make-instance 'poly))) (dolist (x '( (2 . 22) (4 . 44) (5 . 55) )) (insert-item p (make-instance 'term :exponents (list (car x)) :coeff (cdr x)))) (dolist (x '( (0 . 11) (3 . 33) (4 . -44) (7 . 77) )) (insert-item q (make-instance 'term :exponents (list (car x)) :coeff (cdr x)))) (dolist (x '((0 . 11) (2 . 22) (3 . 33) (5 . 55) (7 . 77) )) (insert-item p+q (make-instance 'term :exponents (list (car x)) :coeff (cdr x)))) (&body))) (test poly "Polynomial addition" (with-fixture poly-context () (is (r-equalp (add-to p q) p+q))) (with-fixture poly-context () (is (r-equalp (subtract-from p q) p-q)))) (run! 'poly-suite) (format t "All tests done!~%")