list.test 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. ;;;; list.test --- tests guile's lists -*- scheme -*-
  2. ;;;; Copyright (C) 2000, 2001, 2006, 2011 Free Software Foundation, Inc.
  3. ;;;;
  4. ;;;; This library is free software; you can redistribute it and/or
  5. ;;;; modify it under the terms of the GNU Lesser General Public
  6. ;;;; License as published by the Free Software Foundation; either
  7. ;;;; version 3 of the License, or (at your option) any later version.
  8. ;;;;
  9. ;;;; This library is distributed in the hope that it will be useful,
  10. ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. ;;;; Lesser General Public License for more details.
  13. ;;;;
  14. ;;;; You should have received a copy of the GNU Lesser General Public
  15. ;;;; License along with this library; if not, write to the Free Software
  16. ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. (use-modules (test-suite lib)
  18. (ice-9 documentation))
  19. ;;;
  20. ;;; miscellaneous
  21. ;;;
  22. (define (documented? object)
  23. (not (not (object-documentation object))))
  24. ;;
  25. ;; This unique tag is reserved for the unroll and diff-unrolled functions.
  26. ;;
  27. (define circle-indicator
  28. (cons 'circle 'indicator))
  29. ;;
  30. ;; Extract every single scheme object that is contained within OBJ into a new
  31. ;; data structure. That means, if OBJ somewhere contains a pair, the newly
  32. ;; created structure holds a reference to the pair as well as references to
  33. ;; the car and cdr of that pair. For vectors, the newly created structure
  34. ;; holds a reference to that vector as well as references to every element of
  35. ;; that vector. Since this is done recursively, the original data structure
  36. ;; is deeply unrolled. If there are circles within the original data
  37. ;; structures, every reference that points backwards into the data structure
  38. ;; is denoted by storing the circle-indicator tag as well as the object the
  39. ;; circular reference points to.
  40. ;;
  41. (define (unroll obj)
  42. (let unroll* ((objct obj)
  43. (hist '()))
  44. (reverse!
  45. (let loop ((object objct)
  46. (histry hist)
  47. (result '()))
  48. (if (memq object histry)
  49. (cons (cons circle-indicator object) result)
  50. (let ((history (cons object histry)))
  51. (cond ((pair? object)
  52. (loop (cdr object) history
  53. (cons (cons object (unroll* (car object) history))
  54. result)))
  55. ((vector? object)
  56. (cons (cons object
  57. (map (lambda (x)
  58. (unroll* x history))
  59. (vector->list object)))
  60. result))
  61. (else (cons object result)))))))))
  62. ;;
  63. ;; Compare two data-structures that were generated with unroll. If any of the
  64. ;; elements found not to be eq?, return a pair that holds the position of the
  65. ;; first found differences of the two data structures. If all elements are
  66. ;; found to be eq?, #f is returned.
  67. ;;
  68. (define (diff-unrolled a b)
  69. (cond ;; has everything been compared already?
  70. ((and (null? a) (null? b))
  71. #f)
  72. ;; do both structures still contain elements?
  73. ((and (pair? a) (pair? b))
  74. (cond ;; are the next elements both plain objects?
  75. ((and (not (pair? (car a))) (not (pair? (car b))))
  76. (if (eq? (car a) (car b))
  77. (diff-unrolled (cdr a) (cdr b))
  78. (cons a b)))
  79. ;; are the next elements both container objects?
  80. ((and (pair? (car a)) (pair? (car b)))
  81. (if (eq? (caar a) (caar b))
  82. (cond ;; do both objects close a circular structure?
  83. ((eq? circle-indicator (caar a))
  84. (if (eq? (cdar a) (cdar b))
  85. (diff-unrolled (cdr a) (cdr b))
  86. (cons a b)))
  87. ;; do both objects hold a vector?
  88. ((vector? (caar a))
  89. (or (let loop ((a1 (cdar a)) (b1 (cdar b)))
  90. (cond
  91. ((and (null? a1) (null? b1))
  92. #f)
  93. ((and (pair? a1) (pair? b1))
  94. (or (diff-unrolled (car a1) (car b1))
  95. (loop (cdr a1) (cdr b1))))
  96. (else
  97. (cons a1 b1))))
  98. (diff-unrolled (cdr a) (cdr b))))
  99. ;; do both objects hold a pair?
  100. (else
  101. (or (diff-unrolled (cdar a) (cdar b))
  102. (diff-unrolled (cdr a) (cdr b)))))
  103. (cons a b)))
  104. (else
  105. (cons a b))))
  106. (else
  107. (cons a b))))
  108. ;;; list
  109. (with-test-prefix "list"
  110. (pass-if "documented?"
  111. (documented? list))
  112. ;; in guile 1.6.7 and earlier `list' called using `apply' didn't make a
  113. ;; new list, it just returned the given list
  114. (pass-if "apply gets fresh list"
  115. (let* ((x '(1 2 3))
  116. (y (apply list x)))
  117. (not (eq? x y)))))
  118. ;;; make-list
  119. (with-test-prefix "make-list"
  120. (pass-if "documented?"
  121. (documented? make-list))
  122. (with-test-prefix "no init"
  123. (pass-if "0"
  124. (equal? '() (make-list 0)))
  125. (pass-if "1"
  126. (equal? '(()) (make-list 1)))
  127. (pass-if "2"
  128. (equal? '(() ()) (make-list 2)))
  129. (pass-if "3"
  130. (equal? '(() () ()) (make-list 3))))
  131. (with-test-prefix "with init"
  132. (pass-if "0"
  133. (equal? '() (make-list 0 'foo)))
  134. (pass-if "1"
  135. (equal? '(foo) (make-list 1 'foo)))
  136. (pass-if "2"
  137. (equal? '(foo foo) (make-list 2 'foo)))
  138. (pass-if "3"
  139. (equal? '(foo foo foo) (make-list 3 'foo)))))
  140. ;;; cons*
  141. (with-test-prefix "cons*"
  142. (pass-if "documented?"
  143. (documented? list))
  144. (with-test-prefix "one arg"
  145. (pass-if "empty list"
  146. (eq? '() (cons* '())))
  147. (pass-if "one elem list"
  148. (let* ((lst '(1)))
  149. (eq? lst (cons* lst))))
  150. (pass-if "two elem list"
  151. (let* ((lst '(1 2)))
  152. (eq? lst (cons* lst)))))
  153. (with-test-prefix "two args"
  154. (pass-if "empty list"
  155. (equal? '(1) (cons* 1 '())))
  156. (pass-if "one elem list"
  157. (let* ((lst '(1))
  158. (ret (cons* 2 lst)))
  159. (and (equal? '(2 1) ret)
  160. (eq? lst (cdr ret)))))
  161. (pass-if "two elem list"
  162. (let* ((lst '(1 2))
  163. (ret (cons* 3 lst)))
  164. (and (equal? '(3 1 2) ret)
  165. (eq? lst (cdr ret))))))
  166. (with-test-prefix "three args"
  167. (pass-if "empty list"
  168. (equal? '(1 2) (cons* 1 2 '())))
  169. (pass-if "one elem list"
  170. (let* ((lst '(1))
  171. (ret (cons* 2 3 lst)))
  172. (and (equal? '(2 3 1) ret)
  173. (eq? lst (cddr ret)))))
  174. (pass-if "two elem list"
  175. (let* ((lst '(1 2))
  176. (ret (cons* 3 4 lst)))
  177. (and (equal? '(3 4 1 2) ret)
  178. (eq? lst (cddr ret))))))
  179. ;; in guile 1.6.7 and earlier `cons*' called using `apply' modified its
  180. ;; list argument
  181. (pass-if "apply list unchanged"
  182. (let* ((lst '(1 2 (3 4)))
  183. (ret (apply cons* lst)))
  184. (and (equal? lst '(1 2 (3 4)))
  185. (equal? ret '(1 2 3 4))))))
  186. ;;; null?
  187. ;;; list?
  188. ;;; length
  189. ;;; append
  190. ;;;
  191. ;;; append!
  192. ;;;
  193. (with-test-prefix "append!"
  194. (pass-if "documented?"
  195. (documented? append!))
  196. ;; Is the handling of empty lists as arguments correct?
  197. (pass-if "no arguments"
  198. (eq? (append!)
  199. '()))
  200. (pass-if "empty list argument"
  201. (eq? (append! '())
  202. '()))
  203. (pass-if "some empty list arguments"
  204. (eq? (append! '() '() '())
  205. '()))
  206. ;; Does the last non-empty-list argument remain unchanged?
  207. (pass-if "some empty lists with non-empty list"
  208. (let* ((foo (list 1 2))
  209. (foo-unrolled (unroll foo))
  210. (tst (append! '() '() '() foo))
  211. (tst-unrolled (unroll tst)))
  212. (and (eq? tst foo)
  213. (not (diff-unrolled foo-unrolled tst-unrolled)))))
  214. (pass-if "some empty lists with improper list"
  215. (let* ((foo (cons 1 2))
  216. (foo-unrolled (unroll foo))
  217. (tst (append! '() '() '() foo))
  218. (tst-unrolled (unroll tst)))
  219. (and (eq? tst foo)
  220. (not (diff-unrolled foo-unrolled tst-unrolled)))))
  221. (pass-if "some empty lists with circular list"
  222. (let ((foo (list 1 2)))
  223. (set-cdr! (cdr foo) (cdr foo))
  224. (let* ((foo-unrolled (unroll foo))
  225. (tst (append! '() '() '() foo))
  226. (tst-unrolled (unroll tst)))
  227. (and (eq? tst foo)
  228. (not (diff-unrolled foo-unrolled tst-unrolled))))))
  229. (pass-if "some empty lists with non list object"
  230. (let* ((foo (vector 1 2 3))
  231. (foo-unrolled (unroll foo))
  232. (tst (append! '() '() '() foo))
  233. (tst-unrolled (unroll tst)))
  234. (and (eq? tst foo)
  235. (not (diff-unrolled foo-unrolled tst-unrolled)))))
  236. (pass-if "non-empty list between empty lists"
  237. (let* ((foo (list 1 2))
  238. (foo-unrolled (unroll foo))
  239. (tst (append! '() '() '() foo '() '() '()))
  240. (tst-unrolled (unroll tst)))
  241. (and (eq? tst foo)
  242. (not (diff-unrolled foo-unrolled tst-unrolled)))))
  243. ;; Are arbitrary lists append!ed correctly?
  244. (pass-if "two one-element lists"
  245. (let* ((foo (list 1))
  246. (foo-unrolled (unroll foo))
  247. (bar (list 2))
  248. (bar-unrolled (unroll bar))
  249. (tst (append! foo bar))
  250. (tst-unrolled (unroll tst))
  251. (diff-foo-tst (diff-unrolled foo-unrolled tst-unrolled)))
  252. (and (equal? tst '(1 2))
  253. (not (diff-unrolled (car diff-foo-tst) (unroll '())))
  254. (not (diff-unrolled bar-unrolled (cdr diff-foo-tst))))))
  255. (pass-if "three one-element lists"
  256. (let* ((foo (list 1))
  257. (foo-unrolled (unroll foo))
  258. (bar (list 2))
  259. (bar-unrolled (unroll bar))
  260. (baz (list 3))
  261. (baz-unrolled (unroll baz))
  262. (tst (append! foo bar baz))
  263. (tst-unrolled (unroll tst))
  264. (diff-foo-tst (diff-unrolled foo-unrolled tst-unrolled)))
  265. (and (equal? tst '(1 2 3))
  266. (not (diff-unrolled (car diff-foo-tst) (unroll '())))
  267. (let* ((tst-unrolled-2 (cdr diff-foo-tst))
  268. (diff-foo-bar (diff-unrolled bar-unrolled tst-unrolled-2)))
  269. (and (not (diff-unrolled (car diff-foo-bar) (unroll '())))
  270. (not (diff-unrolled baz-unrolled (cdr diff-foo-bar))))))))
  271. (pass-if "two two-element lists"
  272. (let* ((foo (list 1 2))
  273. (foo-unrolled (unroll foo))
  274. (bar (list 3 4))
  275. (bar-unrolled (unroll bar))
  276. (tst (append! foo bar))
  277. (tst-unrolled (unroll tst))
  278. (diff-foo-tst (diff-unrolled foo-unrolled tst-unrolled)))
  279. (and (equal? tst '(1 2 3 4))
  280. (not (diff-unrolled (car diff-foo-tst) (unroll '())))
  281. (not (diff-unrolled bar-unrolled (cdr diff-foo-tst))))))
  282. (pass-if "three two-element lists"
  283. (let* ((foo (list 1 2))
  284. (foo-unrolled (unroll foo))
  285. (bar (list 3 4))
  286. (bar-unrolled (unroll bar))
  287. (baz (list 5 6))
  288. (baz-unrolled (unroll baz))
  289. (tst (append! foo bar baz))
  290. (tst-unrolled (unroll tst))
  291. (diff-foo-tst (diff-unrolled foo-unrolled tst-unrolled)))
  292. (and (equal? tst '(1 2 3 4 5 6))
  293. (not (diff-unrolled (car diff-foo-tst) (unroll '())))
  294. (let* ((tst-unrolled-2 (cdr diff-foo-tst))
  295. (diff-foo-bar (diff-unrolled bar-unrolled tst-unrolled-2)))
  296. (and (not (diff-unrolled (car diff-foo-bar) (unroll '())))
  297. (not (diff-unrolled baz-unrolled (cdr diff-foo-bar))))))))
  298. (pass-if "empty list between non-empty lists"
  299. (let* ((foo (list 1 2))
  300. (foo-unrolled (unroll foo))
  301. (bar (list 3 4))
  302. (bar-unrolled (unroll bar))
  303. (baz (list 5 6))
  304. (baz-unrolled (unroll baz))
  305. (tst (append! foo '() bar '() '() baz '() '() '()))
  306. (tst-unrolled (unroll tst))
  307. (diff-foo-tst (diff-unrolled foo-unrolled tst-unrolled)))
  308. (and (equal? tst '(1 2 3 4 5 6))
  309. (not (diff-unrolled (car diff-foo-tst) (unroll '())))
  310. (let* ((tst-unrolled-2 (cdr diff-foo-tst))
  311. (diff-foo-bar (diff-unrolled bar-unrolled tst-unrolled-2)))
  312. (and (not (diff-unrolled (car diff-foo-bar) (unroll '())))
  313. (not (diff-unrolled baz-unrolled (cdr diff-foo-bar))))))))
  314. (pass-if "list and improper list"
  315. (let* ((foo (list 1 2))
  316. (foo-unrolled (unroll foo))
  317. (bar (cons 3 4))
  318. (bar-unrolled (unroll bar))
  319. (tst (append! foo bar))
  320. (tst-unrolled (unroll tst))
  321. (diff-foo-tst (diff-unrolled foo-unrolled tst-unrolled)))
  322. (and (equal? tst '(1 2 3 . 4))
  323. (not (diff-unrolled (car diff-foo-tst) (unroll '())))
  324. (not (diff-unrolled bar-unrolled (cdr diff-foo-tst))))))
  325. (pass-if "list and circular list"
  326. (let* ((foo (list 1 2))
  327. (foo-unrolled (unroll foo))
  328. (bar (list 3 4 5)))
  329. (set-cdr! (cddr bar) (cdr bar))
  330. (let* ((bar-unrolled (unroll bar))
  331. (tst (append! foo bar))
  332. (tst-unrolled (unroll tst))
  333. (diff-foo-tst (diff-unrolled foo-unrolled tst-unrolled)))
  334. (and (equal? (map (lambda (n x) (eqv? (list-ref tst n) x))
  335. (iota 9)
  336. '(1 2 3 4 5 4 5 4 5))
  337. '(#t #t #t #t #t #t #t #t #t))
  338. (not (diff-unrolled (car diff-foo-tst) (unroll '())))
  339. (not (diff-unrolled bar-unrolled (cdr diff-foo-tst)))))))
  340. (pass-if "list and non list object"
  341. (let* ((foo (list 1 2))
  342. (foo-unrolled (unroll foo))
  343. (bar (vector 3 4))
  344. (bar-unrolled (unroll bar))
  345. (tst (append! foo bar))
  346. (tst-unrolled (unroll tst))
  347. (diff-foo-tst (diff-unrolled foo-unrolled tst-unrolled)))
  348. (and (equal? tst '(1 2 . #(3 4)))
  349. (not (diff-unrolled (car diff-foo-tst) (unroll '())))
  350. (not (diff-unrolled bar-unrolled (cdr diff-foo-tst))))))
  351. (pass-if "several arbitrary lists"
  352. (equal? (append! (list 1 2)
  353. (list (list 3) 4)
  354. (list (list 5) (list 6))
  355. (list 7 (cons 8 9))
  356. (list 10 11)
  357. (list (cons 12 13) 14)
  358. (list (list)))
  359. (list 1 2
  360. (list 3) 4
  361. (list 5) (list 6)
  362. 7 (cons 8 9)
  363. 10 11
  364. (cons 12 13)
  365. 14 (list))))
  366. (pass-if "list to itself"
  367. (let* ((foo (list 1 2))
  368. (foo-unrolled (unroll foo))
  369. (tst (append! foo foo))
  370. (tst-unrolled (unroll tst))
  371. (diff-foo-tst (diff-unrolled foo-unrolled tst-unrolled)))
  372. (and (equal? (map (lambda (n x) (eqv? (list-ref tst n) x))
  373. (iota 6)
  374. '(1 2 1 2 1 2))
  375. '(#t #t #t #t #t #t))
  376. (not (diff-unrolled (car diff-foo-tst) (unroll '())))
  377. (eq? (caar (cdr diff-foo-tst)) circle-indicator)
  378. (eq? (cdar (cdr diff-foo-tst)) foo))))
  379. ;; Are wrong type arguments detected correctly?
  380. (with-test-prefix "wrong argument"
  381. (pass-if-exception "improper list and empty list"
  382. exception:wrong-type-arg
  383. (append! (cons 1 2) '()))
  384. (pass-if-exception "improper list and list"
  385. exception:wrong-type-arg
  386. (append! (cons 1 2) (list 3 4)))
  387. (pass-if-exception "list, improper list and list"
  388. exception:wrong-type-arg
  389. (append! (list 1 2) (cons 3 4) (list 5 6)))
  390. (expect-fail "circular list and empty list"
  391. (let ((foo (list 1 2 3)))
  392. (set-cdr! (cddr foo) (cdr foo))
  393. (catch #t
  394. (lambda ()
  395. (catch 'wrong-type-arg
  396. (lambda ()
  397. (append! foo '())
  398. #f)
  399. (lambda (key . args)
  400. #t)))
  401. (lambda (key . args)
  402. #f))))
  403. (expect-fail "circular list and list"
  404. (let ((foo (list 1 2 3)))
  405. (set-cdr! (cddr foo) (cdr foo))
  406. (catch #t
  407. (lambda ()
  408. (catch 'wrong-type-arg
  409. (lambda ()
  410. (append! foo (list 4 5))
  411. #f)
  412. (lambda (key . args)
  413. #t)))
  414. (lambda (key . args)
  415. #f))))
  416. (expect-fail "list, circular list and list"
  417. (let ((foo (list 3 4 5)))
  418. (set-cdr! (cddr foo) (cdr foo))
  419. (catch #t
  420. (lambda ()
  421. (catch 'wrong-type-arg
  422. (lambda ()
  423. (append! (list 1 2) foo (list 6 7))
  424. #f)
  425. (lambda (key . args)
  426. #t)))
  427. (lambda (key . args)
  428. #f))))))
  429. ;;; last-pair
  430. ;;; reverse
  431. ;;; reverse!
  432. ;;; list-ref
  433. (with-test-prefix "list-ref"
  434. (pass-if "documented?"
  435. (documented? list-ref))
  436. (with-test-prefix "argument error"
  437. (with-test-prefix "non list argument"
  438. #t)
  439. (with-test-prefix "improper list argument"
  440. #t)
  441. (with-test-prefix "non integer index"
  442. #t)
  443. (with-test-prefix "index out of range"
  444. (with-test-prefix "empty list"
  445. (pass-if-exception "index 0"
  446. exception:out-of-range
  447. (list-ref '() 0))
  448. (pass-if-exception "index > 0"
  449. exception:out-of-range
  450. (list-ref '() 1))
  451. (pass-if-exception "index < 0"
  452. exception:out-of-range
  453. (list-ref '() -1)))
  454. (with-test-prefix "non-empty list"
  455. (pass-if-exception "index > length"
  456. exception:out-of-range
  457. (list-ref '(1) 1))
  458. (pass-if-exception "index < 0"
  459. exception:out-of-range
  460. (list-ref '(1) -1))))))
  461. ;;; list-set!
  462. (with-test-prefix "list-set!"
  463. (pass-if "documented?"
  464. (documented? list-set!))
  465. (with-test-prefix "argument error"
  466. (with-test-prefix "non list argument"
  467. #t)
  468. (with-test-prefix "improper list argument"
  469. #t)
  470. (with-test-prefix "read-only list argument"
  471. #t)
  472. (with-test-prefix "non integer index"
  473. #t)
  474. (with-test-prefix "index out of range"
  475. (with-test-prefix "empty list"
  476. (pass-if-exception "index 0"
  477. exception:out-of-range
  478. (list-set! (list) 0 #t))
  479. (pass-if-exception "index > 0"
  480. exception:out-of-range
  481. (list-set! (list) 1 #t))
  482. (pass-if-exception "index < 0"
  483. exception:out-of-range
  484. (list-set! (list) -1 #t)))
  485. (with-test-prefix "non-empty list"
  486. (pass-if-exception "index > length"
  487. exception:out-of-range
  488. (list-set! (list 1) 1 #t))
  489. (pass-if-exception "index < 0"
  490. exception:out-of-range
  491. (list-set! (list 1) -1 #t))))))
  492. ;;; list-cdr-ref
  493. ;;; list-tail
  494. ;;; list-cdr-set!
  495. (with-test-prefix "list-cdr-set!"
  496. (pass-if "documented?"
  497. (documented? list-cdr-set!))
  498. (with-test-prefix "argument error"
  499. (with-test-prefix "non list argument"
  500. #t)
  501. (with-test-prefix "improper list argument"
  502. #t)
  503. (with-test-prefix "read-only list argument"
  504. #t)
  505. (with-test-prefix "non integer index"
  506. #t)
  507. (with-test-prefix "index out of range"
  508. (with-test-prefix "empty list"
  509. (pass-if-exception "index 0"
  510. exception:out-of-range
  511. (list-cdr-set! (list) 0 #t))
  512. (pass-if-exception "index > 0"
  513. exception:out-of-range
  514. (list-cdr-set! (list) 1 #t))
  515. (pass-if-exception "index < 0"
  516. exception:out-of-range
  517. (list-cdr-set! (list) -1 #t)))
  518. (with-test-prefix "non-empty list"
  519. (pass-if-exception "index > length"
  520. exception:out-of-range
  521. (list-cdr-set! (list 1) 1 #t))
  522. (pass-if-exception "index < 0"
  523. exception:out-of-range
  524. (list-cdr-set! (list 1) -1 #t))))))
  525. ;;; list-head
  526. ;;; list-copy
  527. ;;; memq
  528. (with-test-prefix/c&e "memq"
  529. (pass-if "inline"
  530. ;; In this case `memq' is inlined and the loop is unrolled.
  531. (equal? '(b c d) (memq 'b '(a b c d))))
  532. (pass-if "non inline"
  533. ;; In this case a real function call is generated.
  534. (equal? '(b c d) (memq 'b (list 'a 'b 'c 'd)))))
  535. ;;; memv
  536. (with-test-prefix/c&e "memv"
  537. (pass-if "inline"
  538. ;; In this case `memv' is inlined and the loop is unrolled.
  539. (equal? '(b c d) (memv 'b '(a b c d))))
  540. (pass-if "non inline"
  541. ;; In this case a real function call is generated.
  542. (equal? '(b c d) (memv 'b (list 'a 'b 'c 'd)))))
  543. ;;; member
  544. ;;; delq!
  545. ;;; delv!
  546. ;;; delete!
  547. ;;; delq
  548. ;;; delv
  549. ;;; delete
  550. ;;; delq1!
  551. ;;; delv1!
  552. ;;; delete1!