From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Jose A. Ortega Ruiz" Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] Fix for `submodules' in (ice-9 session) (closes #30062) Date: Thu, 02 Sep 2010 20:45:29 +0200 Message-ID: <874oe8yofq.fsf@newton.homeunix.net> References: <1283257143-24354-1-git-send-email-jao@gnu.org> <871v9e2u8m.fsf@newton.homeunix.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1283454524 12441 80.91.229.12 (2 Sep 2010 19:08:44 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 2 Sep 2010 19:08:44 +0000 (UTC) Cc: Andy Wingo To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Sep 02 21:08:43 2010 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OrF9M-0002UT-Mc for guile-devel@m.gmane.org; Thu, 02 Sep 2010 21:08:41 +0200 Original-Received: from localhost ([127.0.0.1]:51758 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OrF9M-0001ka-0X for guile-devel@m.gmane.org; Thu, 02 Sep 2010 15:08:40 -0400 Original-Received: from [140.186.70.92] (port=54884 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OrF98-0001hh-1E for guile-devel@gnu.org; Thu, 02 Sep 2010 15:08:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OrF96-0008HT-QL for guile-devel@gnu.org; Thu, 02 Sep 2010 15:08:25 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:34483) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OrF96-0008H6-Gg for guile-devel@gnu.org; Thu, 02 Sep 2010 15:08:24 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OrF94-0002HE-6r for guile-devel@gnu.org; Thu, 02 Sep 2010 21:08:22 +0200 Original-Received: from 83.50.71.238 ([83.50.71.238]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 02 Sep 2010 21:08:22 +0200 Original-Received: from jao by 83.50.71.238 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 02 Sep 2010 21:08:22 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 148 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 83.50.71.238 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-Attribution: jao X-URL: Cancel-Lock: sha1:whDCUrUcizwaRHT9492KGgumZhQ= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:10842 Archived-At: --=-=-= Heya again, On Wed, Sep 01 2010, Jose A. Ortega Ruiz wrote: > On Tue, Aug 31 2010, Andy Wingo wrote: > >> Hi, >> >> Can you submit a test please, also? This patch is correct, but with >> --enable-deprecated builds, it should be unnecessary. > > Okay, test added (i'm not sure if there's something to do about > --enable-deprecated builds), and patch attached. Sorry for self-following-up, but, after the conversation with Ludo, i added a new test using an anonymous module. The new version of the patch is attached: does it look OK for pushing? Thanks! jao --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Fix-for-submodules-in-ice-9-session-closes-30062.patch >From 58efa6f2f7ef6bd2d710e1b996b6752e9e4c5093 Mon Sep 17 00:00:00 2001 From: Jose A. Ortega Ruiz Date: Tue, 31 Aug 2010 14:13:43 +0200 Subject: [PATCH] Fix for `submodules' in (ice-9 session) (closes #30062) * module/ice-9/session.scm (submodules): replace implementation to use `module-submodules' instead of `module-obarray' (the latter doesn't include submodules anymore). * test-suite/tests/session.test: new test suite for session, checking the exported procedures that use `submodules'. Signed-off-by: Jose A. Ortega Ruiz --- module/ice-9/session.scm | 11 +------- test-suite/Makefile.am | 1 + test-suite/tests/session.test | 53 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 test-suite/tests/session.test diff --git a/module/ice-9/session.scm b/module/ice-9/session.scm index 10ce613..36aeb99 100644 --- a/module/ice-9/session.scm +++ b/module/ice-9/session.scm @@ -406,15 +406,8 @@ It is an image under the mapping EXTRACT." (define (root-modules) (submodules (resolve-module '() #f))) -(define (submodules m) - (hash-fold (lambda (name var data) - (let ((obj (and (variable-bound? var) (variable-ref var)))) - (if (and (module? obj) - (eq? (module-kind obj) 'directory)) - (cons obj data) - data))) - '() - (module-obarray m))) +(define (submodules mod) + (hash-map->list (lambda (k v) v) (module-submodules mod))) (define apropos-fold-exported (make-fold-modules root-modules submodules module-public-interface)) diff --git a/test-suite/Makefile.am b/test-suite/Makefile.am index eaa7512..c779eac 100644 --- a/test-suite/Makefile.am +++ b/test-suite/Makefile.am @@ -100,6 +100,7 @@ SCM_TESTS = tests/00-initial-env.test \ tests/reader.test \ tests/receive.test \ tests/regexp.test \ + tests/session.test \ tests/signals.test \ tests/socket.test \ tests/srcprop.test \ diff --git a/test-suite/tests/session.test b/test-suite/tests/session.test new file mode 100644 index 0000000..1697471 --- /dev/null +++ b/test-suite/tests/session.test @@ -0,0 +1,53 @@ +;;;; session.test --- test suite for (ice-9 session) -*- scheme -*- +;;;; Jose Antonio Ortega Ruiz -- August 2010 +;;;; +;;;; Copyright (C) 2010 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 3 of the License, or (at your option) any later version. +;;;; +;;;; This library 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 +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +;;;; 02110-1301 USA + +(define-module (test-suite session) + #:use-module (test-suite lib) + #:use-module (ice-9 session)) + +(define (find-module mod) + (call/cc (lambda (k) + (apropos-fold-all (lambda (m _) + (and (not (module? m)) (k #f)) + (and (eq? m mod) (k #t))) + #f)))) +(define (find-mod-name mod-name) + (find-module (resolve-module mod-name #f #:ensure #f))) + + +(with-test-prefix "apropos-fold-all" + (pass-if "a root module: ice-9" (find-mod-name '(ice-9))) + (pass-if "a child of test-suite" (find-mod-name '(test-suite lib))) + (pass-if "a non-module" (not (find-mod-name '(ice-999-0)))) + (pass-if "a childish non-module" (not (find-mod-name '(ice-9 ice-999-0)))) + (pass-if "an anonymous module" (find-mod-name (module-name (make-module))))) + +(define (find-interface mod-name) + (let* ((mod (resolve-module mod-name #f #:ensure #f)) + (ifc (and mod (module-public-interface mod)))) + (and ifc + (call/cc (lambda (k) + (apropos-fold-exported (lambda (i _) + (and (eq? i ifc) (k #t))) + #f)))))) + +(with-test-prefix "apropos-fold-exported" + (pass-if "a child of test-suite" (find-interface '(test-suite lib))) + (pass-if "a child of ice-9" (find-interface '(ice-9 session)))) -- 1.7.1 --=-=-=--