File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ public void arraysDoNotConsiderElementsWhenEvaluatingEquality(){
1414 // arrays utilize default object equality (A == {1} B == {1}, though A
1515 // and B contain the same thing, the container is not the same
1616 // referenced array instance...
17- assertEquals (new int [] { 1 }.equals (new int [] { 1 }), __ );
17+ assertEquals (new int [] {1 }.equals (new int [] {1 }), __ );
1818 }
1919
2020 @ Koan
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ public void basicIfWithoutCurly(){
1414 int x = 1 ;
1515 if (true )
1616 x ++;
17- assertEquals (x ,__ );
17+ assertEquals (x , __ );
1818 }
1919
2020 @ Koan
@@ -26,7 +26,7 @@ public void basicIfElseWithoutCurly(){
2626 x ++;
2727 else
2828 x --;
29- assertEquals (x ,__ );
29+ assertEquals (x , __ );
3030 }
3131
3232 @ Koan
@@ -41,7 +41,7 @@ else if (otherBooleanCondition)
4141 x = 10 ;
4242 else
4343 x --;
44- assertEquals (x ,__ );
44+ assertEquals (x , __ );
4545 }
4646
4747 @ Koan
@@ -55,21 +55,21 @@ public void nestedIfsWithoutCurlysAreReallyMisleading() {
5555 if (otherBooleanCondition ) x = 10 ;
5656 else x --;
5757 // Where does this else belong to!?
58- assertEquals (x ,__ );
58+ assertEquals (x , __ );
5959 }
6060
6161 @ Koan
6262 public void ifAsIntended () {
6363 boolean secretBoolean = true ;
6464 int x = 1 ;
65- if (secretBoolean ) {
65+ if (secretBoolean ) {
6666 x ++;
6767 } else {
6868 x = 0 ;
6969 }
7070 // There are different opinions on where the curly braces go...
7171 // But as long as you put them here. You avoid problems as seen above.
72- assertEquals (x ,__ );
72+ assertEquals (x , __ );
7373 }
7474
7575 @ Koan
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ public class AboutConstructors {
99
1010 class A {
1111 String someString = "a" ;
12- public A () { someString += "x" ; }
12+ public A () { someString += "x" ; }
1313
1414 }
1515
@@ -24,7 +24,7 @@ public void simpleConstructorOrder(){
2424
2525 class Aa {
2626 String someString = "a" ;
27- public Aa () { someString += "x" ; }
27+ public Aa () { someString += "x" ; }
2828 public Aa (String s ) {
2929 someString += s ;
3030 }
Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ private void throwIt() throws ParentException {
114114
115115 @ Koan
116116 public void catchOrder () {
117- String s = "" ;
117+ String s = "" ;
118118 try {
119119 throwIt ();
120120 } catch (ChildException e ) {
Original file line number Diff line number Diff line change @@ -21,9 +21,9 @@ class Child extends Parent {
2121
2222 @ Koan
2323 public void differenceBetweenOverloadingAndOverriding () {
24- assertEquals (new Parent ().doStuff (),__ );
25- assertEquals (new Child ().doStuff (),__ );
26- assertEquals (new Child ().doStuff ("oh no" ),__ );
24+ assertEquals (new Parent ().doStuff (), __ );
25+ assertEquals (new Child ().doStuff (), __ );
26+ assertEquals (new Child ().doStuff ("oh no" ), __ );
2727 }
2828
2929 abstract class ParentTwo {
@@ -38,7 +38,7 @@ class ChildTwo extends ParentTwo {
3838 public void overriddenMethodsMayReturnSubtype () {
3939 // What do you need to change in order to get rid of the type cast?
4040 // Why does this work?
41- List <?> list = (List <?>)new ChildTwo ().doStuff ();
41+ List <?> list = (List <?>) new ChildTwo ().doStuff ();
4242 assertEquals (list instanceof List , __ );
4343 }
4444}
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ public void doLoop() {
5656
5757 @ Koan
5858 public void extendedForLoopBreak () {
59- String [] sa = {"Dog" , "Cat" , "Tiger" };
59+ String [] sa = {"Dog" , "Cat" , "Tiger" };
6060 int count = 0 ;
6161 for (String current : sa ) {
6262 if ("Cat" .equals (current )) {
@@ -69,7 +69,7 @@ public void extendedForLoopBreak() {
6969
7070 @ Koan
7171 public void extendedForLoopContinue () {
72- String [] sa = {"Dog" , "Cat" , "Tiger" };
72+ String [] sa = {"Dog" , "Cat" , "Tiger" };
7373 int count = 0 ;
7474 for (String current : sa ) {
7575 if ("Dog" .equals (current )) {
@@ -81,7 +81,6 @@ public void extendedForLoopContinue() {
8181 assertEquals (count , __ );
8282 }
8383
84-
8584 @ Koan
8685 public void forLoopContinueLabel () {
8786 int count = 0 ;
Original file line number Diff line number Diff line change @@ -46,6 +46,6 @@ public void methodPreferenceMore() {
4646 // What happens if you change 'Integer' to 'Double'
4747 // Does this explain 'methodPreferenceDouble'?
4848 // Think about why this happens?
49- assertEquals (new A ().doStuff (1 ,Integer .valueOf (2 )), __ );
49+ assertEquals (new A ().doStuff (1 , Integer .valueOf (2 )), __ );
5050 }
5151}
Original file line number Diff line number Diff line change @@ -34,20 +34,20 @@ public void objectToString() {
3434 }
3535
3636 @ Koan
37- public void toStringConcatenates (){
37+ public void toStringConcatenates () {
3838 final String string = "ha" ;
39- Object object = new Object (){
40- @ Override public String toString (){
39+ Object object = new Object () {
40+ @ Override public String toString () {
4141 return string ;
4242 }
4343 };
4444 assertEquals (string + object , __ );
4545 }
4646
4747 @ Koan
48- public void toStringIsTestedForNullWhenInvokedImplicitly (){
48+ public void toStringIsTestedForNullWhenInvokedImplicitly () {
4949 String string = "string" ;
50- assertEquals (string + null , __ );
50+ assertEquals (string + null , __ );
5151 }
5252
5353 private Class <?>[] getAncestors (Object object ) {
Original file line number Diff line number Diff line change @@ -9,10 +9,10 @@ public class AboutOperators {
99 @ Koan
1010 public void plusPlusVariablePlusPlus (){
1111 int i = 1 ;
12- assertEquals (++i ,__ );
13- assertEquals (i ,__ );
14- assertEquals (i ++,__ );
15- assertEquals (i ,__ );
12+ assertEquals (++i , __ );
13+ assertEquals (i , __ );
14+ assertEquals (i ++, __ );
15+ assertEquals (i , __ );
1616 }
1717
1818 @ Koan
@@ -21,39 +21,39 @@ public void shortCircuit() {
2121 int a = 6 ; // Why did we use a variable here?
2222 // What happens if you replace 'a' with '6' below?
2323 // Try this with an IDE like Eclipse...
24- if ( (a < 9 ) || (++i < 8 ) ) i = i + 1 ;
25- assertEquals (i ,__ );
24+ if ( (a < 9 ) || (++i < 8 ) ) i = i + 1 ;
25+ assertEquals (i , __ );
2626 }
2727
2828 @ Koan
2929 public void fullAnd (){
3030 int i = 1 ;
31- if ( true & (++i < 8 ) ) i = i + 1 ;
32- assertEquals (i ,__ );
31+ if ( true & (++i < 8 ) ) i = i + 1 ;
32+ assertEquals (i , __ );
3333 }
3434
3535 @ Koan
3636 public void shortCircuitAnd (){
3737 int i = 1 ;
38- if ( true && (i < -28 ) ) i = i + 1 ;
39- assertEquals (i ,__ );
38+ if ( true && (i < -28 ) ) i = i + 1 ;
39+ assertEquals (i , __ );
4040 }
4141
4242 @ Koan
4343 public void aboutXOR () {
4444 int i = 1 ;
4545 int a = 6 ;
4646 if ( (a < 9 ) ^ false ) i = i + 1 ;
47- assertEquals (i ,__ );
47+ assertEquals (i , __ );
4848 }
4949
5050 @ Koan
5151 public void dontMistakeEqualsForEqualsEquals () {
5252 int i = 1 ;
5353 boolean a = false ;
54- if (a = true ) i ++;
54+ if (a = true ) i ++;
5555 assertEquals (a , __ );
56- assertEquals (i ,__ );
56+ assertEquals (i , __ );
5757 // How could you write the condition 'with a twist' to avoid this trap?
5858 }
5959
Original file line number Diff line number Diff line change 22
33import com .sandwich .koan .Koan ;
44
5+ import java .util .*;
56import java .text .MessageFormat ;
67
78import static com .sandwich .koan .constant .KoanConstants .*;
You can’t perform that action at this time.
0 commit comments