;;; srfi-9.scm --- define-record-type
-;; Copyright (C) 2001, 2002, 2006, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2002, 2006, 2009, 2010 Free Software Foundation, Inc.
;;
;; This library is free software; you can redistribute it and/or
;; modify it under the terms of the GNU Lesser General Public
(ctor-args (map (lambda (field)
(cons (syntax->datum field) field))
#'(field ...))))
- #`(define #,constructor-spec
+ #`(define-inlinable #,constructor-spec
(make-struct #,type-name 0
#,@(unfold
(lambda (field-num)
:export (
;; Exceptions which are commonly being tested for.
+ exception:syntax-pattern-unmatched
exception:bad-variable
exception:missing-expression
exception:out-of-range exception:unbound-var
;;;;
;;; Define some exceptions which are commonly being tested for.
+(define exception:syntax-pattern-unmatched
+ (cons 'syntax-error "source expression failed to match any pattern"))
(define exception:bad-variable
(cons 'syntax-error "Bad variable"))
(define exception:missing-expression
;;;; srfi-9.test --- Test suite for Guile's SRFI-9 functions. -*- scheme -*-
;;;; Martin Grabmueller, 2001-05-10
;;;;
-;;;; Copyright (C) 2001, 2006, 2007 Free Software Foundation, Inc.
+;;;; Copyright (C) 2001, 2006, 2007, 2010 Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
(define-module (test-suite test-numbers)
#:use-module (test-suite lib)
+ #:use-module ((system base compile) #:select (compile))
#:use-module (srfi srfi-9))
(with-test-prefix "constructor"
+ ;; Constructors are defined using `define-integrable', meaning that direct
+ ;; calls as in `(make-foo)' lead to a compile-time psyntax error, hence the
+ ;; distinction below.
+
+ (pass-if-exception "foo 0 args (inline)" exception:syntax-pattern-unmatched
+ (compile '(make-foo) #:env (current-module)))
+ (pass-if-exception "foo 2 args (inline)" exception:syntax-pattern-unmatched
+ (compile '(make-foo 1 2) #:env (current-module)))
+
(pass-if-exception "foo 0 args" exception:wrong-num-args
- (make-foo))
+ (let ((make-foo make-foo))
+ (make-foo)))
(pass-if-exception "foo 2 args" exception:wrong-num-args
- (make-foo 1 2)))
+ (let ((make-foo make-foo))
+ (make-foo 1 2))))
(with-test-prefix "predicate"