groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 12/21: [mdoc]: Add tests for `Nm` macro.


From: G. Branden Robinson
Subject: [groff] 12/21: [mdoc]: Add tests for `Nm` macro.
Date: Fri, 18 Nov 2022 13:47:53 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit 0089d2e5a2d6096b6c31d06305ff1fea33ef0292
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Thu Nov 17 16:04:56 2022 -0600

    [mdoc]: Add tests for `Nm` macro.
    
    * tmac/tests/doc_Nm-works.sh: Do it.  Test regression reported in
      Savannah #63377.  Also ensure that we handle the case where multiple
      `Nm` items are declared in the "Name" section (as might happen in
      library man pages).
    
    * tmac/tmac.am (tmac_TESTS): Run test.
    
    Test fails at this commit.
---
 ChangeLog                  | 10 +++++++
 tmac/tests/doc_Nm-works.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++++
 tmac/tmac.am               |  1 +
 3 files changed, 79 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index b365a70b2..8232b2e1d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2022-11-17  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [mdoc]: Add tests for `Nm` macro.
+
+       * tmac/tests/doc_Nm-works.sh: Do it.  Test regression reported
+       in Savannah #63377.  Also ensure that we handle the case where
+       multiple `Nm` items are declared in the "Name" section (as might
+       happen in library man pages).
+       * tmac/tmac.am (tmac_TESTS): Run test.
+
 2022-11-17  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * tmac/papersize.tmac: Improve integration with mm(7) macro
diff --git a/tmac/tests/doc_Nm-works.sh b/tmac/tests/doc_Nm-works.sh
new file mode 100755
index 000000000..7a07833d0
--- /dev/null
+++ b/tmac/tests/doc_Nm-works.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+groff="${abs_top_builddir:-.}/test-groff"
+
+fail=
+
+wail () {
+    echo "...FAILED" >&2
+    fail=yes
+}
+
+# Unit test `Nm` macro (and regression-test Savannah #63377).
+
+input='.Dd 2022-11-17
+.Dt foo 1
+.Os "groff test suite"
+.Sh Name
+.Nm foo
+.Nd frobnicate a bar
+.Sh Description
+.Nm
+is a program.'
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -mdoc)
+echo "$output"
+echo "$output" | grep 'foo is a program\.' || wail
+
+# Handle multiple declarations in "Name" section.
+
+input='.Dd 2022-11-17
+.Dt trig.h 3
+.Os "groff test suite"
+.Sh Name
+.Nm sin ,
+.Nm cos ,
+.Nm tan
+.Nd trigonometric functions
+.Sh Description
+.Nm
+returns the sine of its argument,
+an angle
+.Ms theta .'
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -mdoc)
+echo "$output"
+echo "$output" | grep 'sin returns the sine' || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tmac.am b/tmac/tmac.am
index 195844c65..e37c55380 100644
--- a/tmac/tmac.am
+++ b/tmac/tmac.am
@@ -187,6 +187,7 @@ tmac_TESTS = \
   tmac/tests/doc_D-places-page-numbers-correctly.sh \
   tmac/tests/doc_Lk-respect-sentence-ending-punctuation.sh \
   tmac/tests/doc_Mt-works.sh \
+  tmac/tests/doc_Nm-works.sh \
   tmac/tests/doc_accept-mixed-case-section-headings.sh \
   tmac/tests/doc_do-not-loop-infinitely-when-shortening-headers.sh \
   tmac/tests/doc_indents-correctly.sh \



reply via email to

[Prev in Thread] Current Thread [Next in Thread]