From 1856fe44a8f7fe3802e6c3e5e6369f2c7e8e5699 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Fri, 5 Aug 2022 19:32:09 -0300 Subject: tests/heredoc.scm: Add test for (enable-syntax) macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test both compiled and non-compiled variants of the test in order to stress the scenarios of *when* the read-macro is set. Also change the (eval-when ...) case used: - "compile": for when the code is being compiled only, and before its execution; - "eval": for the the code is being evaluated only, during its execution. Also from the Guile manual (via 'info (guile)Loading'): Changing ‘current-reader’ is typically useful to introduce local syntactic changes, such that code following the ‘fluid-set!’ call is read using the newly installed reader. The ‘current-reader’ change should take place at evaluation time when the code is evaluated, or at compilation time when the code is compiled: (eval-when (compile eval) (fluid-set! current-reader my-own-reader)) The ‘eval-when’ form above ensures that the ‘current-reader’ change occurs at the right time. --- tests/heredoc.scm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tests/heredoc.scm') diff --git a/tests/heredoc.scm b/tests/heredoc.scm index e368119..931b7a2 100644 --- a/tests/heredoc.scm +++ b/tests/heredoc.scm @@ -1,5 +1,6 @@ (use-modules ((xyz euandreh heredoc) #:prefix heredoc:) + ((language tree-il) #:prefix tree-il:) ((srfi srfi-64) #:prefix t:)) (heredoc:enable-syntax) @@ -315,6 +316,16 @@ fi fi """#))) +(define (test-enable-syntax) + (t:test-group "enable-syntax" + (t:test-equal '(read-hash-extend #\" + (@ (xyz euandreh heredoc) + reader)) + (tree-il:tree-il->scheme + (macroexpand + '(heredoc:enable-syntax)))))) + + (define test-fns (list test-extract-single-line-indentation @@ -322,7 +333,8 @@ fi test-maximum-indentation test-trim-indentation test-non-quote-chars? - test-reader)) + test-reader + test-enable-syntax)) (define (main) (t:test-begin "heredoc") -- cgit v1.2.3