diff options
author | Subbu Dantu <subbudantu@Subbus-MacBook-Pro.local> | 2017-04-13 18:22:58 +0530 |
---|---|---|
committer | Roman Ivanov <romani@users.noreply.github.com> | 2017-04-15 17:09:37 -0700 |
commit | 888f258e2b14637cd7447dc4dbecc1c96d711109 (patch) | |
tree | 757c353fedb8f793169e932537d166151a61f1a6 /src/test/resources/com/puppycrawl/tools/checkstyle/checks | |
parent | 92c43f0a4fed1166fc840e1e427e385a5993b12f (diff) | |
download | checkstyle-888f258e2b14637cd7447dc4dbecc1c96d711109.tar.gz |
Issue #3048: ParenPad now correctly evaluates precedence parens
Diffstat (limited to 'src/test/resources/com/puppycrawl/tools/checkstyle/checks')
-rw-r--r-- | src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputParenPad.java | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputParenPad.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputParenPad.java index b3c08ea8b..52c8bea46 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputParenPad.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputParenPad.java @@ -131,4 +131,84 @@ enum MyEnum { int i = (int) (2 * (4 / 2) ); }; + + public void myMethod() { + String s = "test"; + Object o = s; + ((String)o).length(); + ( (String)o ).length(); + } + + public void crisRon() { + Object leo = "messi"; + Object ibra = leo; + ((String)leo).compareTo( (String)ibra ); + Math.random(); + } + + public void intStringConv() { + Object a = 5; + Object b = "string"; + int w = Integer.parseInt((String)a); + int x = Integer.parseInt( (String)a); + double y = Double.parseDouble((String)a ); + float z = Float.parseFloat( (String)a ); + String d = ((String)b); + } + + public int something( Object o ) { + if ( o == null || !( o instanceof Float ) ) { + return -1; + } + return Integer.valueOf( 22 ).compareTo( (Integer) o ); + } + + private void launch(Integer number ) { + String myInt = ( number.toString() + '\0' ); + boolean result = false; + if (number == 123) + result = true; + } + + private static String getterName( Exception t) { + if (t instanceof ClassNotFoundException ) { + return ( (ClassNotFoundException) t ).getMessage(); + } + else { + return "?"; + } + } + + private Object exam; + + public String testing() { + return ( this.exam != null ) + ? ( ( Enum )this.exam ).name() + : null; + } + + Object stringReturnValue( Object result ) { + if ( result instanceof String ) { + result = ( (String) result ).length(); + } + return result; + } + + + + private void except() { + java.util.ArrayList<Integer> arrlist = new java.util.ArrayList<Integer>( 5 ); + arrlist.add( 20); + arrlist.add(15 ); + arrlist.add( 30 ); + arrlist.add(45); + try { + ( arrlist ).remove( 2); + } catch ( IndexOutOfBoundsException x ) { + x.getMessage(); + } + org.junit.Assert.assertThat( "123", org.hamcrest.CoreMatchers.is( "123" ) ); + org.junit.Assert.assertThat( "Help! Integers don't work", + 0, org.hamcrest.CoreMatchers.is( 1 ) ); + } } |