Module Name: src
Committed By: rillig
Date: Fri Oct 29 16:43:05 UTC 2021
Modified Files:
src/tests/usr.bin/indent: t_errors.sh
Log Message:
tests/indent: provoke error messages for unbalanced parentheses
To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/indent/t_errors.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/indent/t_errors.sh
diff -u src/tests/usr.bin/indent/t_errors.sh:1.8 src/tests/usr.bin/indent/t_errors.sh:1.9
--- src/tests/usr.bin/indent/t_errors.sh:1.8 Thu Oct 28 21:35:57 2021
+++ src/tests/usr.bin/indent/t_errors.sh Fri Oct 29 16:43:05 2021
@@ -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 @@ preprocessing_unrecognized_body()
"$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_init_test_cases()
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'
}