1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-24 12:20:20 +02:00

SRFI-1 'length+' raises an error unless passed a proper or circular list.

Fixes <http://bugs.gnu.org/17296>.

* libguile/srfi-1.c (scm_srfi1_length_plus): Rewrite to raise an error
  unless passed a proper or circular list, based on code from
  'scm_ilength'.

* test-suite/tests/srfi-1.test (length+): Add tests.
This commit is contained in:
Mark H Weaver 2014-04-18 15:04:12 -04:00
parent 12c6a47773
commit a5186f506f
2 changed files with 33 additions and 5 deletions

View file

@ -1,6 +1,6 @@
;;;; srfi-1.test --- Test suite for Guile's SRFI-1 functions. -*- scheme -*-
;;;;
;;;; Copyright 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
;;;; Copyright 2003-2006, 2008-2011, 2014 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
@ -1329,6 +1329,10 @@
(length+))
(pass-if-exception "too many args" exception:wrong-num-args
(length+ 123 456))
(pass-if-exception "not a pair" exception:wrong-type-arg
(length+ 'x))
(pass-if-exception "improper list" exception:wrong-type-arg
(length+ '(x y . z)))
(pass-if (= 0 (length+ '())))
(pass-if (= 1 (length+ '(x))))
(pass-if (= 2 (length+ '(x y))))