@@ -295,3 +295,63 @@ no-change-test:
295295 (define sum (hash-ref! h1 (cadr term) 0 ))
296296 (hash-set! h2 (cadr term) (+ (car term) sum)))
297297------------------------------
298+
299+
300+ test: "make-immutable-hash with quasiquoted pairs can be simplified to hash "
301+ ------------------------------
302+ (define body 'test-body )
303+ (define event 'test-event )
304+ (define comments '(c1 c2))
305+ (make-immutable-hash
306+ `((body . ,body)
307+ (event . ,event)
308+ (comments . ,(map values comments))))
309+ ==============================
310+ (define body 'test-body )
311+ (define event 'test-event )
312+ (define comments '(c1 c2))
313+ (hash 'body body 'event event 'comments (map values comments))
314+ ------------------------------
315+
316+
317+ test: "make-immutable-hash with simple quasiquoted pairs can be simplified to hash "
318+ ------------------------------
319+ (define x 1 )
320+ (define y 2 )
321+ (make-immutable-hash `((a . ,x) (b . ,y)))
322+ ==============================
323+ (define x 1 )
324+ (define y 2 )
325+ (hash 'a x 'b y)
326+ ------------------------------
327+
328+
329+ test: "make-immutable-hash with single pair can be simplified to hash "
330+ ------------------------------
331+ (define value 42 )
332+ (make-immutable-hash `((key . ,value)))
333+ ==============================
334+ (define value 42 )
335+ (hash 'key value)
336+ ------------------------------
337+
338+
339+ no-change-test: "make-immutable-hash without quasiquote should not be changed "
340+ ------------------------------
341+ (make-immutable-hash '((a . 1 ) (b . 2 )))
342+ ------------------------------
343+
344+
345+ no-change-test: "make-immutable-hash with variable keys should not be changed "
346+ ------------------------------
347+ (define k 'key )
348+ (define v 'value )
349+ (make-immutable-hash `((,k . ,v)))
350+ ------------------------------
351+
352+
353+ no-change-test: "make-immutable-hash with list literal should not be changed "
354+ ------------------------------
355+ (define pairs '((a . 1 ) (b . 2 )))
356+ (make-immutable-hash pairs)
357+ ------------------------------
0 commit comments