% This is a list of BibTeX .bst test cases, to confirm what BibTeX % does with the various tests (ie, that I'm interpreting the % documentation correctly, and to confirm that beastie does the % same thing, or that I'm aware of a difference). % % For BibTeX to run it, we need to edit this file to foo.bst, % generate an aux file foo.aux containing % % \citation{*} % \bibstyle{foo} % \bibdata{bib-t01-simple.bib} % % and then `bibtex foo`. The output appears in foo.blg. % % The results appear on stdout (since they're written with top$). % Since there's no function which can convert integer-or-string to % string, other than top$, or save such a thing to a variable, we have % to print out all of the 'actual'. % % This file is part of Beastie % SPDX-FileCopyrightText: 2023 Norman Gray % SPDX-License-Identifier: BSD-2-Clause INTEGERS{ngood nbad actual.i expected.i} STRINGS{ident actual.s expected.s t} % On the stack: expected/string actual/string ident/string FUNCTION{assert.equal.strings} { 'ident := 'actual.s := 'expected.s := "" top$ expected.s actual.s = { ngood #1 + 'ngood := "Case " ident * " matches!" * top$ } { nbad #1 + 'nbad := % The only way we can print out either string or integer is with top$, % and we can't use * to concatenate string and integer "vvv Case " ident * " failed!" * top$ "expected:" top$ expected.s top$ "actual:" top$ actual.s top$ "^^^" top$ } if$ } % On the stack: expected/int actual/int ident/string FUNCTION{assert.equal.integers} { 'ident := 'actual.i := 'expected.i := "" top$ expected.i actual.i = { ngood #1 + 'ngood := "Case " ident * " matches!" * top$ } { nbad #1 + 'nbad := % The only way we can print out either string or integer is with top$, % and we can't use * to concatenate string and integer "vvv Case " ident * " failed!" * top$ "expected:" top$ expected.i top$ "actual:" top$ actual.i top$ "^^^" top$ } if$ } % not and n.dashify from plain.bst FUNCTION {not} { { #0 } { #1 } if$ } FUNCTION {n.dashify} { 't := "t=" t * top$ "" { t empty$ not } { t #1 #1 substring$ "-" = { t #1 #2 substring$ "--" = not { "--" * t #2 global.max$ substring$ 't := } { { t #1 #1 substring$ "-" = } { "-" * t #2 global.max$ substring$ 't := } while$ } if$ } { t #1 #1 substring$ * t #2 global.max$ substring$ 't := } if$ } while$ } FUNCTION{run.test.cases}{ % the contents are generated from the output generated by extract-bst-tests.scm % (see the Makefile) } FUNCTION{summarise.results} { "Result: good " ngood int.to.str$ * top$ "Result: fail " nbad int.to.str$ * top$ } FUNCTION{article}{} FUNCTION{book}{} ENTRY{x}{}{} READ EXECUTE{run.test.cases} EXECUTE{summarise.results}