Navigation Menu

Skip to content

Commit

Permalink
fixes #33
Browse files Browse the repository at this point in the history
  • Loading branch information
matyb committed Feb 15, 2019
1 parent bb1a863 commit d443efa
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion koans/app/config/config.properties
@@ -1,5 +1,5 @@
compile_timeout_in_ms=5000
ignore_from_monitoring=.*\\.idea
ignore_from_monitoring=(.*\\.idea|^\\.#.*\\..*|^#.*\\..*)
debug=false
exit_character=Q
enable_encouragement=false
Expand Down
5 changes: 4 additions & 1 deletion lib/src/main/java/com/sandwich/util/io/StreamUtils.java
Expand Up @@ -7,10 +7,13 @@
public class StreamUtils {

public static String convertStreamToString(InputStream stream) {
Scanner scanner = new Scanner(stream);
try {
return new Scanner(stream).useDelimiter("\\A").next();
return scanner.useDelimiter("\\A").next();
} catch (NoSuchElementException e) {
return "";
} finally {
scanner.close();
}
}

Expand Down
30 changes: 15 additions & 15 deletions lib/src/test/java/com/sandwich/util/KoanComparatorTest.java
Expand Up @@ -44,20 +44,20 @@ public void testComparatorRanksByOrder() throws Exception {
assertSame(m2,methods.get(1));
}

@Test
public void testVariableNamesArentConfusedAsKoanMethodsWhenSorting() throws Exception {
Class<? extends Object> clazz = new Object(){
String foo;
@Koan public void bar(){}
@Koan public void foo(){}
}.getClass();
KoanMethod m1 = KoanMethod.getInstance("", clazz.getDeclaredMethod("bar"));
KoanMethod m2 = KoanMethod.getInstance("", clazz.getDeclaredMethod("foo"));
List<KoanMethod> methods = Arrays.asList(m2,m1);
Collections.sort(methods, new KoanComparator());
assertSame(m1,methods.get(0));
assertSame(m2,methods.get(1));
}

@Test
public void testVariableNamesArentConfusedAsKoanMethodsWhenSorting() throws Exception {
Class<? extends Object> clazz = new Object(){
@SuppressWarnings("unused")
String foo;
@Koan public void bar(){}
@Koan public void foo(){}
}.getClass();
KoanMethod m1 = KoanMethod.getInstance("", clazz.getDeclaredMethod("bar"));
KoanMethod m2 = KoanMethod.getInstance("", clazz.getDeclaredMethod("foo"));
List<KoanMethod> methods = Arrays.asList(m2,m1);
Collections.sort(methods, new KoanComparator());
assertSame(m1,methods.get(0));
assertSame(m2,methods.get(1));
}
}

0 comments on commit d443efa

Please sign in to comment.