;; It's a matter of choice what this produces.
;; The test below confirms that we abandon processing
;; when we encounter an input loop.
;; A reasonable alternative would be to simply ignore the transgressing include.
;;
;; This file is part of Beastie <https://purl.org/nxg/dist/beastie>
;; SPDX-FileCopyrightText: 2024 Norman Gray <https://nxg.me.uk>
;; SPDX-License-Identifier: BSD-2-Clause

(check
 (assert-equal (map entry->list/debug (sort! (map cdr DB) entry<?))
               '((article a1
                          (author . #"First Alpha")
                          (note . #"s=topstring"))
                 (article a1-inc3
                          (author . #"First Delta")
                          (note . #"s=topstring and bibinc3-string"))
                 ;; (article a2
                 ;;          (author . #"Second Alpha")
                 ;;          (note . #"s=topstring and bibinc3-string"))
                 ;; (article a2-inc3
                 ;;          (author . #"Second Delta")
                 ;;          (note . #"s=topstring and bibinc3-string"))
                 )))

@string{s1="topstring"}

@article{a1,
  author =       {First Alpha},
  note =         "s=" # s1,
}

% bibinc3.bib attempts to @include this file, creating a loop
@include{bibinc3.bib}

@article{a2,
  author =       {Second Alpha},
  note =         "s=" # s1 # " and " # sc1
}
