diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2021-03-14 10:19:21 +0700 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2021-03-14 10:19:21 +0700 |
commit | 052bd66fb22b11cc53f4379f53dc4f894257470b (patch) | |
tree | d32b6d5d02b975e9d3ac8961bf067570830b51f2 /tests | |
parent | 2fd6804db8aebfe6634e4df7d5e5c71fe856d4f6 (diff) | |
download | aspectj-052bd66fb22b11cc53f4379f53dc4f894257470b.tar.gz aspectj-052bd66fb22b11cc53f4379f53dc4f894257470b.zip |
Improve text matching in OutputSpec, fixing some failing Windows tests
Some Java 14 text block tests failed on Windows because a
StringTokenizer was used to split by LF, but the Windows line
separator is CR+LF. Because a multi-line string ending with CR+LF is
printed via 'System.out.println' in the test code, another CR+LF is
added to the output, resulting in trailing CR+LF+CR+LF. Hence, between
the two LFs, the tokenizer actually found an additional line consisting
of CR (only on Windows, of course). Despite each line token actually
containing a trailing CR token, that did not matter much because
'String.trim' was used everywhere before comparing values.
Anyway, the improved OutputSpec uses text.trim().split("\\s*\n\\s*"),
which takes care of leading/trailing whitespace both around the whole
output and for each separate line.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/features195/textblock/Code.java | 2 | ||||
-rw-r--r-- | tests/features195/textblock/Code2.java | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/tests/features195/textblock/Code.java b/tests/features195/textblock/Code.java index 89df1e537..5dc430872 100644 --- a/tests/features195/textblock/Code.java +++ b/tests/features195/textblock/Code.java @@ -1,9 +1,9 @@ public class Code { public static void main(String[] argv) { + // Caveat: Putting the closing '"""' on a separate line adds a line break and 'println' (not 'print'!) adds another. System.out.println(""" this is a text block """); } } - diff --git a/tests/features195/textblock/Code2.java b/tests/features195/textblock/Code2.java index f0b39e08b..7020b67a5 100644 --- a/tests/features195/textblock/Code2.java +++ b/tests/features195/textblock/Code2.java @@ -6,10 +6,10 @@ public class Code2 { aspect X { before(): execution(* Code2.main(..)) { + // Caveat: Putting the closing '"""' on a separate line adds a line break and 'println' (not 'print'!) adds another. System.out.println(""" this is a text block in advice """); } } - |