1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-01 04:10:18 +02:00
guile/testsuite/t-match.scm
Andy Wingo 9806a548fe Fix a bug in the (ice-9 match) test
* testsuite/t-match.scm (matches?): Fix match invocation. As far as I can
  tell, although (ice-9 match) does advertise a => form of clauses, it
  requires that the end of the => be a symbol. For some reason this
  works in the interpreter:

    ((lambda () (begin => #t)))

  It's part of the expansion of matches?. It also worked in the old
  compiler. Thinking that maybe toplevel references could cause side
  effects, I made the new compiler actually ref =>, which brought this to
  light.
2009-05-20 17:28:59 +02:00

26 lines
558 B
Scheme
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;;; Pattern matching with `(ice-9 match)'.
;;;
(use-modules (ice-9 match)
(srfi srfi-9)) ;; record type (FIXME: See `t-records.scm')
(define-record-type <stuff>
(%make-stuff chbouib)
stuff?
(chbouib stuff:chbouib stuff:set-chbouib!))
(define (matches? obj)
; (format #t "matches? ~a~%" obj)
(match obj
(($ stuff) #t)
; (blurps #t)
("hello" #t)
(else #f)))
;(format #t "go!~%")
(and (matches? (%make-stuff 12))
(matches? (%make-stuff 7))
(matches? "hello")
; (matches? 'blurps)
(not (matches? 66)))