;;; -*- 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) (defpackage #:5am-poly-sugar (:use :cl :it.bese.fiveam :monom :polynomial :ring :symbolic-polynomial :polynomial-sugar)) (in-package :5am-poly-sugar) (def-suite poly-sugar-suite :description "Polynomial with sugar package suite") (in-suite poly-sugar-suite) (test sugar-basic "Add sugar to a polynomial" (let ((p (change-class (string->poly "x*y+x^3" '(x y)) 'poly-with-sugar))) (is (= (sugar-value p) 3)))) (test sugar-add "Checks sugar addition rule" (let* ((p (change-class (string->poly "x*y+x^3" '(x y)) 'poly-with-sugar)) (q (add p p))) (is (= (sugar-value q) 3)))) (test sugar-multiply "Checks sugar multiplication rule" (let* ((p (change-class (string->poly "x*y+x^3" '(x y)) 'poly-with-sugar)) (q (multiply p p))) (is (= (sugar-value q) 6)))) (test sugar-term-insert "Checks sugar multiplication rule" (let* ((p (change-class (string->poly "x*y+x^3" '(x y)) 'poly-with-sugar)) (q (poly-insert-term p (make-instance 'term-with-sugar :exponents '(3 4))))) (is (= (sugar-value q) 7)))) (test sugar-expt "Checks sugar exponentiation rule" (let* ((p (change-class (string->poly "x*y+x^3" '(x y)) 'poly-with-sugar)) (q (universal-expt p 3))) (is (= (sugar-value q) 12)))) (run! 'poly-sugar-suite) (format t "All tests done!~%")