guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] branch main updated: Add tests for warning locations.


From: Daniel Llorens
Subject: [Guile-commits] branch main updated: Add tests for warning locations.
Date: Tue, 29 Nov 2022 05:44:37 -0500

This is an automated email from the git hooks/post-receive script.

lloda pushed a commit to branch main
in repository guile.

The following commit(s) were added to refs/heads/main by this push:
     new 02f69c1d8 Add tests for warning locations.
02f69c1d8 is described below

commit 02f69c1d84126c35900c5743a712b1e7d07e449d
Author: Andrew Whatson <whatson@gmail.com>
AuthorDate: Thu Oct 13 13:12:08 2022 +1000

    Add tests for warning locations.
    
    These would have caught <https://bugs.gnu.org/56493>.
    
    * test-suite/tests/tree-il.test ("warnings")("location")["unused
    variable", "unbound variable (spaces)", "unbound variable (tabs)"]: New
    tests.
---
 test-suite/tests/tree-il.test | 48 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)

diff --git a/test-suite/tests/tree-il.test b/test-suite/tests/tree-il.test
index 686eab9d2..b296be336 100644
--- a/test-suite/tests/tree-il.test
+++ b/test-suite/tests/tree-il.test
@@ -1519,7 +1519,53 @@
                              #:to 'cps)))))
          (and (= (length w) 1)
               (number? (string-contains (car w)
-                                        "cannot be meaningfully 
compared")))))))
+                                        "cannot be meaningfully compared"))))))
+
+   (with-test-prefix "location"
+     (define (call-with-fake-input-file filename contents thunk)
+       (call-with-input-string contents
+         (lambda (port)
+           (set-port-filename! port filename)
+           (thunk port))))
+
+     (pass-if "unused variable"
+       (let ((w (call-with-warnings
+                 (lambda ()
+                   (call-with-fake-input-file
+                    "unused-variable.scm"
+                    "\
+(lambda (x)
+  (let ((y (+ x 2)))
+    x))"
+                    (lambda (port)
+                      (read-and-compile port #:opts %opts-w-unused #:to 
'cps)))))))
+         (and (= (length w) 1)
+              (number? (string-contains (car w) "unused variable `y'"))
+              (number? (string-contains (car w) "unused-variable.scm:2:2")))))
+
+     (pass-if "unbound variable (spaces)"
+       (let ((w (call-with-warnings
+                 (lambda ()
+                   (call-with-fake-input-file
+                    "unbound-spaces.scm"
+                    "  (foo)"
+                    (lambda (port)
+                      (read-and-compile port #:opts %opts-w-unbound #:to 
'cps)))))))
+         (and (= (length w) 1)
+              (number? (string-contains (car w) "unbound variable `foo'"))
+              (number? (string-contains (car w) "unbound-spaces.scm:1:3")))))
+
+     (pass-if "unbound variable (tabs)"
+       (let ((w (call-with-warnings
+                 (lambda ()
+                   (call-with-fake-input-file
+                    "unbound-tabs.scm"
+                    "\t\t(foo)"
+                    (lambda (port)
+                      (read-and-compile port #:opts %opts-w-unbound #:to 
'cps)))))))
+         (and (= (length w) 1)
+              (number? (string-contains (car w) "unbound variable `foo'"))
+              (number? (string-contains (car w) "unbound-tabs.scm:1:17")))))))
 
 ;; Local Variables:
 ;; eval: (put 'pass-if-primitives-resolved 'scheme-indent-function 1)



reply via email to

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