Source-Changes-HG archive

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

[src/trunk]: src/tests/usr.bin/indent tests/indent: provoke error messages fo...



details:   https://anonhg.NetBSD.org/src/rev/70444ab1aa64
branches:  trunk
changeset: 990507:70444ab1aa64
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Oct 29 16:43:05 2021 +0000

description:
tests/indent: provoke error messages for unbalanced parentheses

diffstat:

 tests/usr.bin/indent/t_errors.sh |  46 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 45 insertions(+), 1 deletions(-)

diffs (66 lines):

diff -r cbc32d6a7a9c -r 70444ab1aa64 tests/usr.bin/indent/t_errors.sh
--- a/tests/usr.bin/indent/t_errors.sh  Fri Oct 29 13:22:08 2021 +0000
+++ b/tests/usr.bin/indent/t_errors.sh  Fri Oct 29 16:43:05 2021 +0000
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: t_errors.sh,v 1.8 2021/10/28 21:35:57 rillig Exp $
+# $NetBSD: t_errors.sh,v 1.9 2021/10/29 16:43:05 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -347,6 +347,48 @@
            "$indent" code.c
 }
 
+atf_test_case 'unbalanced_parentheses_1'
+unbalanced_parentheses_1_body()
+{
+       cat <<-\EOF > code.c
+               int var =
+               (
+               ;
+               )
+               ;
+       EOF
+       cat <<-\EOF > stderr.exp
+               error: code.c:3: Unbalanced parens
+               warning: code.c:4: Extra )
+       EOF
+
+       atf_check -s 'exit:1' -e 'file:stderr.exp' \
+           "$indent" code.c
+}
+
+atf_test_case 'unbalanced_parentheses_2'
+unbalanced_parentheses_2_body()
+{
+       # '({...})' is the GCC extension "Statement expression".
+       cat <<-\EOF > code.c
+               int var =
+               (
+               {
+               1
+               }
+               )
+               ;
+       EOF
+       cat <<-\EOF > stderr.exp
+               error: code.c:3: Unbalanced parens
+               warning: code.c:6: Extra )
+       EOF
+
+       atf_check -s 'exit:1' -e 'file:stderr.exp' \
+           "$indent" code.c
+}
+
+
 atf_init_test_cases()
 {
        atf_add_test_case 'option_unknown'
@@ -375,4 +417,6 @@
        atf_add_test_case 'unexpected_closing_brace_decl'
        atf_add_test_case 'preprocessing_overflow'
        atf_add_test_case 'preprocessing_unrecognized'
+       atf_add_test_case 'unbalanced_parentheses_1'
+       atf_add_test_case 'unbalanced_parentheses_2'
 }



Home | Main Index | Thread Index | Old Index