From d5eafde045fbadd94ec10dc98a2983b036dd9f20 Mon Sep 17 00:00:00 2001 From: Moritz Petersen Date: Wed, 22 Apr 2020 22:03:14 +0200 Subject: [PATCH] Add a regression test for the bug described in #576 Merge a test for with-output-to-string with the one for with-input-input-from-string to ensure both close their streams. Remove check for stream-var being a stream outside of w-i-f-s & w-o-t-s. According to the specification, the streams' extent ends with the respective providing form. If the stream was indeed not acccessible anymore, the test would not pass. In that case open-stream-p should signal a type-error, causing the test to crash. However in ECL we can assume that the stream is still intact. --- src/tests/normal-tests/mixed.lsp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/tests/normal-tests/mixed.lsp b/src/tests/normal-tests/mixed.lsp index 455201185..b1e9cd262 100644 --- a/src/tests/normal-tests/mixed.lsp +++ b/src/tests/normal-tests/mixed.lsp @@ -374,16 +374,20 @@ (signals ext:stack-overflow (labels ((f (x) (f (1+ x)))) (f 1)))) -;;; Date 2020-04-18 +;;; Date 2020-04-22 ;;; URL: https://gitlab.com/embeddable-common-lisp/ecl/-/merge_requests/197 +;;; URL: https://gitlab.com/embeddable-common-lisp/ecl/-/issues/576 ;;; Description: ;;; -;;; Ensure that with-input-from-string closes the input stream -;;; that it creates. -(test mix.0019.close-with-input-from-string-stream +;;; Ensure that with-input-from-string and with-output-to-string +;;; close the streams that they provide. +(test mix.0019.with-string-io-close-streams (let (stream-var) (with-input-from-string (inner-stream-var "test") (setf stream-var inner-stream-var) (is (open-stream-p stream-var))) - (is (streamp stream-var)) + (is (not (open-stream-p stream-var))) + (with-output-to-string (inner-stream-var) + (setf stream-var inner-stream-var) + (is (open-stream-p stream-var))) (is (not (open-stream-p stream-var)))))