SMOLNET PORTAL home about changes
(fiasco:define-test-package #:st-buchberger-test
  (:use #:st-buchberger)
  (:import-from #:st-buchberger #:element->string))

(in-package #:st-buchberger-test)

(deftest test-make-polynomial ()
  (flet ((is-string= (sexp string)
           "Assert that the polynomial given by SEXP is represented as STRING."
           (is (string= (element->string (make-polynomial sexp))
                        string))))
    (signals error (make-polynomial nil))
    (is (ring-zero-p (make-polynomial 0)))
    (is (ring-zero-p (make-polynomial '(+))))
    (is (ring-zero-p (make-polynomial '(-))))
    (is-string= 1 "1")
    (is-string= 'x "x")
    (signals error (make-polynomial 'w))
    (is-string= '(+ x y z) "x + y + z")
    (is-string= '(* (expt x 2) y (expt z 3)) "x^2yz^3")
    (signals error (make-polynomial '(* 1.0d0 x)))
    (signals error (make-polynomial '(* -1 0)))
    (signals error (make-polynomial '(expt 3 2)))
    (signals error (make-polynomial '(expt 3 2)))
    (signals error (make-polynomial '(expt x -1)))
    (is-string= '(- (expt x 2) (* 2 x y) (- (expt y 2)))
                "x^2 - 2xy + y^2")))

(deftest test-member-p ()
  (with-polynomial-ring
      (make-instance 'polynomial-ring :variables '(x y))
    (let* ((f (make-polynomial 'x))
           (g (make-polynomial '(+ x y)))
           (h (make-polynomial 1))
           (ideal (make-ideal f g)))
      (is (member-p (ring* f g) ideal))
      (is (not (member-p h ideal))))))
Response: text/plain
Original URLgopher://tilde.institute/0/~screwtape/st-buchberger/tests...
Content-Typetext/plain; charset=utf-8