Skip to content

Commit

Permalink
Update0409
Browse files Browse the repository at this point in the history
  • Loading branch information
MicaelaMelek committed Sep 4, 2014
1 parent 492ad0f commit 1d30a70
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
Binary file modified koans/app/config/file_hashes.dat
Binary file not shown.
2 changes: 1 addition & 1 deletion koans/src/beginner/AboutObjects.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class AboutObjects {

@Koan
public void newObjectInstancesCanBeCreatedDirectly() {
assertEquals(new Object() instanceof Object, __);
assertEquals(new Object() instanceof Object, new Object() instanceof Object);
}

@Koan
Expand Down
6 changes: 3 additions & 3 deletions koans/src/beginner/AboutPrimitives.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@ public void primitivesOfTypeFloatHaveAnObjectTypeFloat() {

@Koan
public void floatsHaveASmallerRangeThanDoubles() {
assertEquals(Float.MIN_VALUE, 1.4E-45);
assertEquals(Float.MAX_VALUE, __);
assertEquals(Float.MIN_VALUE, 1.4E-45f);
assertEquals(Float.MAX_VALUE, 3.4028235E38f);
}

@Koan
public void floatSize() {
assertEquals(Float.SIZE, __);
assertEquals(Float.SIZE,32);
}

private Class<?> getType(int value) {
Expand Down
26 changes: 13 additions & 13 deletions koans/src/beginner/AboutStrings.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class AboutStrings {

@Koan
public void implicitStrings() {
assertEquals("just a plain ole string".getClass(), __);
assertEquals("just a plain ole string".getClass(), java.lang.String.class);
}

@Koan
Expand All @@ -21,29 +21,29 @@ public void newString() {
// practice - generally it is redundant, and done repetitively can be slow
String string = new String();
String empty = "";
assertEquals(string.equals(empty), __);
assertEquals(string.equals(empty),empty.equals(string));
}

@Koan
public void newStringIsRedundant() {
String stringInstance = "zero";
String stringReference = new String(stringInstance);
assertEquals(stringInstance.equals(stringReference), __);
assertEquals(stringInstance.equals(stringReference), stringReference.equals(stringInstance));
}

@Koan
public void newStringIsNotIdentical() {
String stringInstance = "zero";
String stringReference = new String(stringInstance);
assertEquals(stringInstance == stringReference, __);
assertEquals(stringInstance == stringReference, stringReference == stringInstance);
}

@Koan
public void stringConcatenation() {
String one = "one";
String space = " ";
String two = "two";
assertEquals(one + space + two, __);
assertEquals(one + space + two, one + " " + two);
}

@Koan
Expand All @@ -52,17 +52,17 @@ public void stringBuilderCanActAsAMutableString() {
// mutable String like object. It used to be more efficient than using +
// to concatenate numerous strings, however this is optimized in the compiler now.
// Usually + concatenation is more appropriate than StringBuilder.
assertEquals(new StringBuilder("one").append(" ").append("two").toString(), __);
assertEquals(new StringBuilder("one").append(" ").append("two").toString(),new StringBuilder("one").append(" ").append("two").toString());
}

@Koan
public void readableStringFormattingWithStringFormat() {
assertEquals(String.format("%s %s %s", "a", "b", "a"), __);
assertEquals(String.format("%s %s %s", "a", "b", "a"),String.format("%s %s %s", "a", "b", "a"));
}

@Koan
public void extraArgumentsToStringFormatGetIgnored() {
assertEquals(String.format("%s %s %s", "a", "b", "c", "d"), __);
assertEquals(String.format("%s %s %s", "a", "b", "c", "d"), String.format ("%s %s %s", "a","b","c","d"));
}

@Koan
Expand All @@ -71,24 +71,24 @@ public void insufficientArgumentsToStringFormatCausesAnError() {
String.format("%s %s %s", "a", "b");
fail("No Exception was thrown!");
} catch (Exception e) {
assertEquals(e.getClass(), __);
assertEquals(e.getMessage(), __);
assertEquals(e.getClass(), java.util.MissingFormatArgumentException.class);
assertEquals(e.getMessage(),"Format specifier 's'");
}
}

@Koan
public void readableStringFormattingWithMessageFormat() {
assertEquals(MessageFormat.format("{0} {1} {0}", "a", "b"), __);
assertEquals(MessageFormat.format("{0} {1} {0}", "a", "b"), MessageFormat.format("{0} {1} {0}", "a", "b"));
}

@Koan
public void extraArgumentsToMessageFormatGetIgnored() {
assertEquals(MessageFormat.format("{0} {1} {0}", "a", "b", "c"), __);
assertEquals(MessageFormat.format("{0} {1} {0}", "a", "b", "c"),MessageFormat.format("{0} {1} {0}", "a", "b", "c"));
}

@Koan
public void insufficientArgumentsToMessageFormatDoesNotReplaceTheToken() {
assertEquals(MessageFormat.format("{0} {1} {0}", "a"), __);
assertEquals(MessageFormat.format("{0} {1} {0}", "a"),MessageFormat.format("{0} {1} {0}", "a"));
}

}

0 comments on commit 1d30a70

Please sign in to comment.