guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.3-125-g017eb


From: Andy Wingo
Subject: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.3-125-g017eb4a
Date: Mon, 09 Jan 2012 15:15:10 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=017eb4a6be938c50df7fe6a27ca38486e75e02d5

The branch, stable-2.0 has been updated
       via  017eb4a6be938c50df7fe6a27ca38486e75e02d5 (commit)
      from  9858e529621193222a28b7ee0e53a428aa007363 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 017eb4a6be938c50df7fe6a27ca38486e75e02d5
Author: Andy Wingo <address@hidden>
Date:   Mon Jan 9 16:07:46 2012 +0100

    primitive-load returns the value(s) of the last expression
    
    * libguile/load.c (scm_primitive_load): Return the values yielded from
      evaluating the last expression in the file.
    
    * test-suite/tests/load.test ("return value of `load'"): Add tests.

-----------------------------------------------------------------------

Summary of changes:
 libguile/load.c            |   12 ++++++++----
 test-suite/tests/load.test |   20 +++++++++++++++++---
 2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/libguile/load.c b/libguile/load.c
index a400318..0076218 100644
--- a/libguile/load.c
+++ b/libguile/load.c
@@ -87,7 +87,9 @@ SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0,
 #define FUNC_NAME s_scm_primitive_load
 {
   SCM hook = *scm_loc_load_hook;
+  SCM ret = SCM_UNSPECIFIED;
   char *encoding;
+
   SCM_VALIDATE_STRING (1, filename);
   if (scm_is_true (hook) && scm_is_false (scm_procedure_p (hook)))
     SCM_MISC_ERROR ("value of %load-hook is neither a procedure nor #f",
@@ -96,8 +98,10 @@ SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0,
   if (!scm_is_false (hook))
     scm_call_1 (hook, filename);
 
-  { /* scope */
-    SCM port = scm_open_file (filename, scm_from_locale_string ("r"));
+  {
+    SCM port;
+
+    port = scm_open_file (filename, scm_from_locale_string ("r"));
     scm_dynwind_begin (SCM_F_DYNWIND_REWINDABLE);
     scm_i_dynwind_current_load_port (port);
 
@@ -124,13 +128,13 @@ SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0,
        if (SCM_EOF_OBJECT_P (form))
          break;
 
-       scm_primitive_eval_x (form);
+       ret = scm_primitive_eval_x (form);
       }
 
     scm_dynwind_end ();
     scm_close_port (port);
   }
-  return SCM_UNSPECIFIED;
+  return ret;
 }
 #undef FUNC_NAME
 
diff --git a/test-suite/tests/load.test b/test-suite/tests/load.test
index 50e5fa7..1cf8d65 100644
--- a/test-suite/tests/load.test
+++ b/test-suite/tests/load.test
@@ -1,7 +1,7 @@
 ;;;; load.test --- test LOAD and path searching functions  -*- scheme -*-
 ;;;; Jim Blandy <address@hidden> --- September 1999
 ;;;;
-;;;;   Copyright (C) 1999, 2001, 2006, 2010 Free Software Foundation, Inc.
+;;;;   Copyright (C) 1999, 2001, 2006, 2010, 2012 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
@@ -18,8 +18,9 @@
 ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
USA
 
 (define-module (test-suite test-load)
-  :use-module (test-suite lib)
-  :use-module (test-suite guile-test))
+  #:use-module (test-suite lib)
+  #:use-module (test-suite guile-test)
+  #:use-module (system base compile))
 
 (define temp-dir (data-file-name "load-test.dir"))
 
@@ -124,4 +125,17 @@
   (try-search-with-extensions path "ugly.scm" extensions "dir3/ugly.scm")
   (try-search-with-extensions path "ugly.ss"  extensions #f))
       
+(with-test-prefix "return value of `load'"
+  (let ((temp-file (in-vicinity temp-dir "foo.scm")))
+    (call-with-output-file temp-file
+      (lambda (port)
+        (write '(+ 2 3) port)
+        (newline port)))
+    (pass-if "primitive-load"
+      (equal? 5 (primitive-load temp-file)))
+    (let ((temp-compiled-file (in-vicinity temp-dir "foo.go")))
+      (compile-file temp-file #:output-file temp-compiled-file)
+      (pass-if "load-compiled"
+        (equal? 5 (load-compiled temp-compiled-file))))))
+
 (delete-tree temp-dir)


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]