;;; .EnTete "Le-Lisp (c) version 15.2" " " "Test des modules Le-Lisp" ;;; .EnPied "testmodule.ll" "%" " " ;;; ;;; .SuperTitre "Test des modules Le-Lisp" ;;; ;;; ;;; .Centre "*****************************************************************" ;;; .Centre " Ce fichier est en lecture seule hors du projet ALE de l'INRIA. " ;;; .Centre " Il est maintenu par ILOG SA, 2 Avenue Gallie'ni, 94250 Gentilly " ;;; .Centre " (c) Le-Lisp est une marque de'pose'e de l'INRIA " ;;; .Centre "*****************************************************************" ;;; ;;; .Centre "$Header: testmodule.ll,v 1.2 88/12/14 13:18:40 nuyens Exp $" (unless (>= (version) 15.2) (error 'load 'erricf 'testmodule)) (unless (featurep 'testcomm) (libload testcomm)) (setq #:sys-package:colon 'testmodule) (defvar testmodule1 '(defmodule testmodule1 files (testmodule1.ll) export (testmodulefn))) (de :similar-module (mod1 mod2) ;; an incomplete test for the similarity of two modules. (every #'(lambda (key) (equal (getdefmodule mod1 key) (getdefmodule mod2 key))) '(defmodule files import export))) (defun :simple-module () ;; return a NEW simple module `((defmodule . testmod) (files foofile barfile zeefile) (import noomodule) (export thisfun thatfun theotherfun))) (testfn ()) (test-serie "Tests d'acce`s au clefs des modules" ()) ;;; This series counts on the representation of modules, but ;;; Complice counts on the fact that setdefmodule returns the modified ;;; module as its value, so we test it here. (setq :mod ()) () (setq :mod (setdefmodule :mod 'defmodule 'testm1) :fu ()) () (getdefmodule :mod 'defmodule) testm1 (setdefmodule :mod 'files '(testm1 testm2)) ((defmodule . testm1) (files testm1 testm2)) (getdefmodule :mod 'files) (testm1 testm2) (test-serie "Tests d'e'criture/lecture des modules" ()) (setq :fname "/tmp/testmodule1.lm") "/tmp/testmodule1.lm" (with ((outchan (openo :fname))) (print "foo")()) () ;;; test that :simple-module still creates a valid module (getdefmodule (:simple-module) 'files) (foofile barfile zeefile) (setq :def (:simple-module) :fu ()) () (car (newl #:system:path "/tmp/")) "/tmp/" (printdefmodule :def :fname) "/tmp/testmodule1.lm" (setq :lu (readdefmodule :fname) :fu ()) () (:similar-module :def :lu) t ;;; The same thing but with #:system:print-for-read set to T (setq :new (:simple-module) :fu ()) () (let ((#:system:print-for-read t)) (printdefmodule :new :fname)) "/tmp/testmodule1.lm" (setq :lu (readdefmodule :fname) :fu ()) () (:similar-module :new :lu) t ;;; but this time having modified the module. (setq :fname "/tmp/testmodule2.lm") "/tmp/testmodule2.lm" (setq :new (:simple-module) :fu ()) () (with ((outchan (openo :fname))) (print "foo")()) () (printdefmodule :new :fname) "/tmp/testmodule2.lm" (setq :lu (readdefmodule 'testmodule2) :fu ()) () (:similar-module :new :lu) t (progn (setdefmodule :lu 'cpexport '(this that)) ())() (let ((#:system:print-for-read t)) (printdefmodule :lu :fname)) "/tmp/testmodule2.lm" (setq :lu2 (readdefmodule :fname) :fu ()) () (:similar-module :lu :lu2) t ;;; clean up ;(deletefile :fname) t (setq #:system:path (cdr #:system:path) :fu ()) () (test-serie "Fin des tests des modules")