diff options
author | Andrei Selkin <andreyselkin@gmail.com> | 2016-06-12 16:27:46 +0300 |
---|---|---|
committer | Roman Ivanov <romani@users.noreply.github.com> | 2016-06-12 06:27:46 -0700 |
commit | 490128302232d627388fc5f0023e00ec18b7939c (patch) | |
tree | f3918e9b2c8490d9f03d0fede6d9f45758e92f95 /src/test/resources/com/puppycrawl/tools/checkstyle/checks | |
parent | c7834c28ce1c55e053062dd7a21785d9e161414a (diff) | |
download | checkstyle-490128302232d627388fc5f0023e00ec18b7939c.tar.gz |
Issue #3090: Fix wrong enforcement of same brace policy for LITERAL_DO in RightCurlyCheck (#3267)
Diffstat (limited to 'src/test/resources/com/puppycrawl/tools/checkstyle/checks')
-rw-r--r-- | src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyDoWhile.java | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyDoWhile.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyDoWhile.java new file mode 100644 index 000000000..b9019a775 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyDoWhile.java @@ -0,0 +1,94 @@ +package com.puppycrawl.tools.checkstyle.checks.blocks; + +import java.util.Scanner; + +/** + * Test input for GitHub issue #3090. + * https://github.com/checkstyle/checkstyle/issues/3090 + */ +public class InputRightCurlyDoWhile { + + public void foo1() { + do { + } while (true); + } + + public void foo2() { + int i = 1; + while (i < 5) { + System.out.print(i + " "); + i++; + } + } + + public void foo3() { + int i = 1; + do { + i++; + System.out.print(i + " "); + } while (i < 5); + } + + public void foo4() { + int prog, user; + prog = (int)(Math.random() * 10) + 1; + Scanner input = new Scanner(System.in); + if( input.hasNextInt() ) { + do { + user = input.nextInt(); + if(user == prog) { + System.out.println("Good!"); + } else { + if (user > 0 && user <= 10) { + System.out.print("Bad! "); + if( prog < user ) { + System.out.println("My number is less than yours."); + } else { + System.out.println("My number is greater than yours."); + } + } else { + System.out.println("Error!"); + } + } + } while( user != prog ); + } else { + System.out.println("Error!"); + } + System.out.println("Goodbye!"); + } + + public void foo5() { + do { + } // violation + while (true); + } + + public void foo6() { + do {} // violation + while (true); + } + + public void foo7() { + do + { + + } while (true); + } + + public void foo8() { + do + + { + + } // violation + + while + + (true); + } + + public void foo9() { + do {} while (true); + } +} + |