git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brandon Casey <casey@nrlssc.navy.mil>
To: peff@peff.net
Cc: git@vger.kernel.org, j6t@kdbg.org, gitster@pobox.com,
	jrnieder@gmail.com, trast@student.ethz.ch,
	Brandon Casey <drafnel@gmail.com>
Subject: [PATCH] t4018: add a few more test cases for cpp hunk header matching
Date: Mon, 19 Dec 2011 15:53:13 -0600	[thread overview]
Message-ID: <6fUozvAFiZtWtB8fYx2kUeUq8VtDgI4bzcA55hMiHJgT_Ag96PM120NEGB5HdtvbJQHJWjAksX6bgea_pMM2jpV6mCwiLKQ9EacSnIUmJ8llgHHqU2I0v9oMj8mYKTJxdIZXJFnBtYA@cipher.nrlssc.navy.mil> (raw)
In-Reply-To: <31E9klcRboMV0wSJY5WO-N7nIBOUOa_wr6MVfWY9AInImxJIqC0flahvpDrVGMIuZ9e7Ouha1HDuesbwTGaNQA4dgN-FShNJKkfMG_cHLUJAT2rE539shnQxzM0dQyZIb5661As6Tvs@cipher.nrlssc.navy.mil>

From: Brandon Casey <drafnel@gmail.com>

Add one case for matching a function returning a pointer.

Plus add examples of things we explicitly do not match:

   labels
   function declarations
   global variable declarations

Signed-off-by: Brandon Casey <drafnel@gmail.com>
---


This can be squashed into the original patch with the other test cases.
This just introduces a few more cases pointed out by Thomas Rast in the
email Johannes referenced.

   http://thread.gmane.org/gmane.comp.version-control.git/186355/focus=186439

Also, note that all of the tests pass except for ignore_global.cpp with
Johannes's pattern:

   "!^[ \\t]*[a-zA-Z_][a-zA-Z_0-9]*[^()]*:[[:space:]]*$\n^[a-zA-Z_][a-zA-Z_0-9]*.*"

-Brandon


 t/t4018/ignore_declaration.cpp |   35 +++++++++++++++++++++++++++++++++++
 t/t4018/ignore_global.cpp      |   36 ++++++++++++++++++++++++++++++++++++
 t/t4018/ignore_label.cpp       |   35 +++++++++++++++++++++++++++++++++++
 t/t4018/pointer_return.cpp     |   34 ++++++++++++++++++++++++++++++++++
 4 files changed, 140 insertions(+), 0 deletions(-)
 create mode 100644 t/t4018/ignore_declaration.cpp
 create mode 100644 t/t4018/ignore_global.cpp
 create mode 100644 t/t4018/ignore_label.cpp
 create mode 100644 t/t4018/pointer_return.cpp

diff --git a/t/t4018/ignore_declaration.cpp b/t/t4018/ignore_declaration.cpp
new file mode 100644
index 0000000..615aea0
--- /dev/null
+++ b/t/t4018/ignore_declaration.cpp
@@ -0,0 +1,35 @@
+int WRONG_function_hunk_header_preceding_the_right_one (void)
+{
+	return 0;
+}
+
+int RIGHT_function_hunk_header (void)
+{
+	void WRONG_function_declaration_within_body (void);
+	/*
+	 * Filler
+	 * Filler
+	 * Filler
+	 * Filler
+	 * Filler
+	 * Filler
+	 */
+
+	int answer = 0;
+
+	/*
+	 * Filler
+	 * Filler
+	 * Filler
+	 * Filler
+	 * Filler
+	 * Filler
+	 */
+
+	return answer;
+}
+
+int WRONG_function_hunk_header_following_the_right_one (void)
+{
+	return 0;
+}
diff --git a/t/t4018/ignore_global.cpp b/t/t4018/ignore_global.cpp
new file mode 100644
index 0000000..df6b8aa
--- /dev/null
+++ b/t/t4018/ignore_global.cpp
@@ -0,0 +1,36 @@
+int WRONG_function_hunk_header_preceding_the_right_one (void)
+{
+	return 0;
+}
+
+int RIGHT_function_hunk_header (void)
+{
+	/*
+	 * Filler
+	 * Filler
+	 * Filler
+	 * Filler
+	 * Filler
+	 * Filler
+	 */
+
+	return answer;
+}
+
+int WRONG_global_variable;
+
+/*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+int answer = 0;
+
+int WRONG_function_hunk_header_following_the_right_one (void)
+{
+	return 0;
+}
diff --git a/t/t4018/ignore_label.cpp b/t/t4018/ignore_label.cpp
new file mode 100644
index 0000000..2e3ce10
--- /dev/null
+++ b/t/t4018/ignore_label.cpp
@@ -0,0 +1,35 @@
+int WRONG_function_hunk_header_preceding_the_right_one (void)
+{
+	return 0;
+}
+
+int RIGHT_function_hunk_header (void)
+{
+WRONG_should_not_match_label:
+	/*
+	 * Filler
+	 * Filler
+	 * Filler
+	 * Filler
+	 * Filler
+	 * Filler
+	 */
+
+	int answer = 0;
+
+	/*
+	 * Filler
+	 * Filler
+	 * Filler
+	 * Filler
+	 * Filler
+	 * Filler
+	 */
+
+	return answer;
+}
+
+int WRONG_function_hunk_header_following_the_right_one (void)
+{
+	return 0;
+}
diff --git a/t/t4018/pointer_return.cpp b/t/t4018/pointer_return.cpp
new file mode 100644
index 0000000..fd85545
--- /dev/null
+++ b/t/t4018/pointer_return.cpp
@@ -0,0 +1,34 @@
+int WRONG_function_hunk_header_preceding_the_right_one (void)
+{
+	return 0;
+}
+
+static int *RIGHT_function_hunk_header (void)
+{
+	/*
+	 * Filler
+	 * Filler
+	 * Filler
+	 * Filler
+	 * Filler
+	 * Filler
+	 */
+
+	int answer = 0;
+
+	/*
+	 * Filler
+	 * Filler
+	 * Filler
+	 * Filler
+	 * Filler
+	 * Filler
+	 */
+
+	return answer;
+}
+
+int WRONG_function_hunk_header_following_the_right_one (void)
+{
+	return 0;
+}
-- 
1.7.7.4

  reply	other threads:[~2011-12-19 21:54 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-16 11:00 [PATCH] attr: map builtin userdiff drivers to well-known extensions Jeff King
2011-12-16 14:00 ` Johannes Sixt
2011-12-16 17:01   ` Junio C Hamano
2011-12-16 19:21   ` Jeff King
2011-12-16 19:30     ` Jeff King
2011-12-16 19:33     ` Junio C Hamano
2011-12-17  1:17       ` Jeff King
2011-12-16 22:05     ` Johannes Sixt
2011-12-17  1:21       ` Jeff King
2011-12-17  3:38         ` Jonathan Nieder
2011-12-19 15:49           ` [PATCHv2 1/2] " Jeff King
2011-12-19 18:07             ` Jonathan Nieder
2011-12-19 18:55               ` Jeff King
2011-12-22  1:47             ` Ævar Arnfjörð Bjarmason
2011-12-19 15:57           ` [PATCHv2 2/2] attr: drop C/C++ default extension mapping Jeff King
2011-12-19 18:10             ` Jonathan Nieder
2011-12-19 20:51               ` Thomas Rast
2011-12-19 20:52         ` [PATCH] t4018: introduce test cases for the internal hunk header patterns Brandon Casey
2011-12-19 21:53           ` Brandon Casey [this message]
2011-12-19 22:37           ` Junio C Hamano
2011-12-19 22:57             ` Brandon Casey
2011-12-19 23:17               ` Junio C Hamano
2011-12-20  2:42                 ` [PATCH v2] " Brandon Casey
2011-12-20  8:25                   ` Jakub Narebski
2011-12-20 15:58                     ` Brandon Casey
2011-12-20  9:13                   ` Thomas Rast
2011-12-20 19:52                   ` Johannes Sixt
2011-12-20 20:08             ` [PATCH] " Junio C Hamano
2011-12-16 17:51 ` [PATCH] attr: map builtin userdiff drivers to well-known extensions Mark Levedahl
2011-12-16 19:28   ` Jeff King
2011-12-16 19:26 ` Philip Oakley
2011-12-16 19:32   ` Jeff King
2011-12-22  0:05     ` Philip Oakley
2011-12-23  5:47       ` Jeff King
2011-12-16 19:38   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6fUozvAFiZtWtB8fYx2kUeUq8VtDgI4bzcA55hMiHJgT_Ag96PM120NEGB5HdtvbJQHJWjAksX6bgea_pMM2jpV6mCwiLKQ9EacSnIUmJ8llgHHqU2I0v9oMj8mYKTJxdIZXJFnBtYA@cipher.nrlssc.navy.mil \
    --to=casey@nrlssc.navy.mil \
    --cc=drafnel@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=jrnieder@gmail.com \
    --cc=peff@peff.net \
    --cc=trast@student.ethz.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).