Giter Site home page Giter Site logo

java-koans's People

Contributors

alwozniak avatar chenzhang22 avatar connorkuehl avatar darsen avatar davidwhitlock avatar dcmoore avatar dfstrauss avatar gherson avatar godfreyduke avatar harryxp avatar hvolkmer avatar kjc avatar matyb avatar mcornell avatar michaelthessel avatar nurous avatar t-hill avatar takaczapka avatar zerg960 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

java-koans's Issues

How to run specific koan from command line?

I read instructions by running run.bat -help and tried to pass class name as an argument, but it is not working out for me. How do I pass the name of the koan to run.bat?

AboutMocks: simpleAnonymousMock() [cosmetic]

Two cosmetic gripes: The TODO comment on line 12 says to ponder ``why this assertion was failing'', when there is no failing assertion. Also, the only koan in the file comes before the interface and class it refers to.

error in instructions for toStringIsTestedForNullWhenInvokedImplicitly

In the instructions for toStringIsTestedForNullWhenInvokedImplicitly it says "String concatenation implicitly invokes toString on Objects, unless they are null"

However, I believe it will just use the string "null" in this case. Maybe it was different in an older version of Java?

Also I'm not sure what the code itself was supposed to demonstrate, since none of those values are null.

Assert that stream is auto-closed in AboutTryWithResources

Based on the discussion in #42, I suggest that we add an assertion that verifies that the close method of the InputStream is invoked in the "try with resources" try block in the AboutTryWithResources. lookMaNoClose() koan.

Unfortunately, there is no isClosed method on InputStream. @matyb suggests that the koan have a helper method that attempts to read from the closed InputStream to verify that it is closed.

See also http://stackoverflow.com/questions/8655901/how-to-check-whether-an-outputstream-is-closed

Intermediate AboutEquality not behaving as expected.

Hello,

After completing line 26 with noObjectShouldBeEqualToNull. I believe the overridden (to false) equals method should cause line 57 to flag as incorrect. However, the evaluation goes straight to line 94 and asks for a new hashCode method to be implemented.

Am I misunderstanding the koan here, am I required to write new equals and a new hashcode to get line 57 to flag?

Thanks

FileMonitorPolling error

We are experiencing intermittent failures while running the koans exercises:

Exception in thread "FileMonitorPolling" java.lang.IllegalArgumentException: Source path must actually exist. (U:\java-dojo\labs\01-koans\java-koans\k
oans.idea\workspace.xml___jb_old___)
at com.sandwich.util.io.ExistingFileAction.throwNonExistentFileError(ExistingFileAction.java:17)
at com.sandwich.util.io.ExistingFileAction.onNew(ExistingFileAction.java:13)
at com.sandwich.util.io.FileOperation.operate(FileOperation.java:12)
at com.sandwich.util.io.ForEachFileAction.onDirectory(ForEachFileAction.java:10)
at com.sandwich.util.io.FileOperation.operate(FileOperation.java:14)
at com.sandwich.util.io.ForEachFileAction.onDirectory(ForEachFileAction.java:10)
at com.sandwich.util.io.FileOperation.operate(FileOperation.java:14)
at com.sandwich.util.io.FileMonitor.getFilesystemHashes(FileMonitor.java:76)
at com.sandwich.util.io.FileMonitor.notifyListeners(FileMonitor.java:47)
at com.sandwich.util.io.FileMonitorFactory$2.run(FileMonitorFactory.java:37)
at java.lang.Thread.run(Unknown Source)

After restarting, it works again for a while and then this error appears again.
This is happening on different operating systems.

AboutContidionals: nestedIfsWithoutCurlysAreReallyMisleading()

Lines 54--56: The indentation (flush left) makes these ifs and elses not misleading at all:

// Ifs without curly braces are ugly and not recommended but still valid:
if (secretBoolean)  x++;
if (otherBooleanCondition) x = 10;
else x--;

Suggest indenting the second if to produce the illusion that the else belongs to the first if:

// Ifs without curly braces are ugly and not recommended but still valid:
if (secretBoolean)  x++;
    if (otherBooleanCondition) x = 10;
else x--;

Should Koan output "give away" the solution?

Hey, @matyb and friends.

One of my students was surprised by the fact that the output of the koans runner essentially "gives away" the answer for many of the koans.

image

The part where it says
"What went wrong:
expected:<2> but was:"

This part basically gives you the answers. Not sure if it's intended or not but it always appears before even giving my first attempt at the problem.

It got me thinking: I know the intent of the Koans is to encourage the student to think about the solution. A motivated and intentional student will do so. However, anyone just trying to "get through the koans" will be tempted to just replace the __ with the answer provided and move on to the next one.

Would it be appropriate for the koan runner to issue a different message when the actual value is __ (REPLACE ME) that doesn't immediately reveal the solution? Of course, a student could enter e bogus value instead of __ to reveal the answer, but that requires a little more thinking than just copying what's there in the runner output.

Only display the expected value after student has attempted koan

Hey, @matyb and all. My students this summer used the koans in my Java programming course and I got an interesting piece of feedback about them: Because the expected value of the "__" is always displayed before attempting to solve the koan, it was very tempting for the students to simply paste the expected value into the assertion statement and move on.

What would be the feasibility of displaying the expected result only after the student has attempted the koan once (or twice or whatever you think makes sense)?

So, information such as

What went wrong: 
expected:<true> but was:<REPLACE ME>

would not be displayed until the koan has already failed once.

AboutComparison: HorseSpeedComparator and HorseAgeComparator

Lines 51 and 56: The two static Comparators compare the wrong attributes --- they've got age and speed backward:

static class HorseSpeedComparator implements Comparator<RaceHorse> {
    public int compare(RaceHorse o1, RaceHorse o2) {
        return o1.age - o2.age;
    }
}
static class HorseAgeComparator implements Comparator<RaceHorse> {
    public int compare(RaceHorse o1, RaceHorse o2) {
        return o1.speed - o2.speed;
    }
}

The returns should be:

        return o1.speed - o2.speed;

...

        return o1.age - o2.age;

Koans won't run if there's a dot in the file path

From a mac, I'm trying to run the koans from my /Users/firstname.lastname/Project/java-koans/koans directory. Because of the dot in the file path (firstname.lastname) I get the following error:

Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key .lastname/Project/java-koans/koans/src/beginner/aboutkoans.java
    at com.sandwich.koan.runner.RunKoans.constructSuite(Unknown Source)
    at com.sandwich.koan.runner.RunKoans.safelyConstructSuite(Unknown Source)
    at com.sandwich.koan.runner.RunKoans.runKoans(Unknown Source)
    at com.sandwich.koan.runner.RunKoans.run(Unknown Source)
    at com.sandwich.koan.constant.ArgumentType.run(Unknown Source)
    at com.sandwich.koan.cmdline.CommandLineArgument.run(Unknown Source)
    at com.sandwich.koan.cmdline.CommandLineArgumentRunner.run(Unknown Source)
    at com.sandwich.koan.runner.AppLauncher.main(Unknown Source)
Caused by: java.lang.RuntimeException: java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key .lastname/Project/java-koans/koans/src/beginner/aboutkoans.java
    at com.sandwich.util.io.classloader.DynamicClassLoader.loadClass(Unknown Source)
    ... 8 more
Caused by: java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key .lastname/Project/java-koans/koans/src/beginner/aboutkoans.java
    at java.util.ResourceBundle.getObject(ResourceBundle.java:450)
    at java.util.ResourceBundle.getString(ResourceBundle.java:407)
    at com.sandwich.util.io.filecompiler.CompilerConfig.getCompilationCommand(Unknown Source)
    at com.sandwich.util.io.filecompiler.FileCompilerAction.onFile(Unknown Source)
    at com.sandwich.util.io.FileOperation.operate(Unknown Source)
    at com.sandwich.util.io.filecompiler.FileCompiler.compile(Unknown Source)
    at com.sandwich.util.io.classloader.DynamicClassLoader.compile(Unknown Source)
    ... 9 more

Source path must actually exist in AboutTryWithResources

I'm getting the following exception when running java7.AboutTryWithResources

Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Source path must actually exist. (/Users/luis/dev/java-koans/koans/src/java7/WorkException)

I've moved both WorkException and CloseException out of the class, And I get Symbol cannot be found.

Please can anyone tell what I'm doing wrong, How can I address this issue so I can move on with the koans

Test AboutObjects.toStringConcatenates() fails

The test beginner.AboutObjects.toStringContatenates() fails when run. The error is:

What went wrong:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sandwich.koan.runner.KoanMethodRunner.run(KoanMethodRunner.java:49)
at com.sandwich.koan.runner.RunKoans.runKoans(RunKoans.java:67)
at com.sandwich.koan.runner.RunKoans.run(RunKoans.java:40)
at com.sandwich.koan.constant.ArgumentType.run(ArgumentType.java:74)
at com.sandwich.koan.cmdline.CommandLineArgument.run(CommandLineArgument.java:36)
at com.sandwich.koan.cmdline.CommandLineArgumentRunner.run(CommandLineArgumentRunner.java:26)
at com.sandwich.koan.runner.AppLauncher.main(AppLauncher.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.IllegalAccessError: tried to access class beginner.AboutObjects$1 from class beginner.AboutObjects
at beginner.AboutObjects.toStringConcatenates(AboutObjects.java:64)
... 16 more

I haven't seen an error like this before - an inner class being inaccessible from the outer class. Perhaps it's a classpath issue?

AboutPrimitives

1.the compile error infomation

Compile Output:
D:\2015_the_last_semester\java-koans-master\koans\src\beginner\AboutPrimitives.j
ava:48: 错误: 过大的整数: -9223372036854775808
assertEquals(Long.MIN_VALUE,-9223372036854775808);
^
1 个错误

Compiling "D:\2015_the_last_semester\java-koans-master\koans\src\beginner\AboutP
rimitives.java" failed.
The exit status was: 1

2.the code i write down

    @Koan
    public void longsHaveALargerRangeThanInts() {
        assertEquals(Long.MIN_VALUE,-9223372036854775808);
        assertEquals(Long.MAX_VALUE,9223372036854775807);
    }

when i save the code ,the complie tell me that the Number is too large!

but i write another code to test it,the MAX_VALUE and MIN_VALUE is right,please tell me what happen? by the way,is there any way to skip some question?

public class NumberTest{
    public static void main(String[] args) {
        System.out.println("Long.MIN_VALUE : "+Long.MIN_VALUE);
        System.out.println("lONG.MAX_VALUE : "+Long.MAX_VALUE);
                // it print out Long.MIN_VALUE : -9223372036854775808
                //                  Long.MAX_VALUE : 9223372036854775807
    }
}

IDE support

I have figured out that there is support for eclipse from a closed issue: #58
It would be nice to mention in the README.
Also it would be nice if it would work:

$ ./gradlew --debug --stacktrace eclipse 2>&1 |tee /tmp/foo
22:02:55.793 [ERROR] [org.gradle.BuildExceptionReporter] 
22:02:55.817 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
22:02:55.819 [ERROR] [org.gradle.BuildExceptionReporter] 
22:02:55.820 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
22:02:55.820 [ERROR] [org.gradle.BuildExceptionReporter] Could not determine java version from '11.0.3'.
22:02:55.821 [ERROR] [org.gradle.BuildExceptionReporter] 
22:02:55.821 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
22:02:55.822 [ERROR] [org.gradle.BuildExceptionReporter] java.lang.IllegalArgumentException: Could not determine java version from '11.0.3'.
22:02:55.823 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.api.JavaVersion.toVersion(JavaVersion.java:64)
22:02:55.823 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.api.JavaVersion.current(JavaVersion.java:73)
22:02:55.823 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:32)
22:02:55.824 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
22:02:55.824 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
22:02:55.824 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
22:02:55.825 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
22:02:55.825 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
22:02:55.825 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.Main.doAction(Main.java:33)
22:02:55.825 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
22:02:55.826 [ERROR] [org.gradle.BuildExceptionReporter] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
22:02:55.826 [ERROR] [org.gradle.BuildExceptionReporter] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
22:02:55.826 [ERROR] [org.gradle.BuildExceptionReporter] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
22:02:55.827 [ERROR] [org.gradle.BuildExceptionReporter] 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
22:02:55.827 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
22:02:55.827 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
22:02:55.827 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
22:02:55.828 [ERROR] [org.gradle.BuildExceptionReporter] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
22:02:55.828 [ERROR] [org.gradle.BuildExceptionReporter] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
22:02:55.828 [ERROR] [org.gradle.BuildExceptionReporter] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
22:02:55.828 [ERROR] [org.gradle.BuildExceptionReporter] 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
22:02:55.829 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
22:02:55.829 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
22:02:55.829 [ERROR] [org.gradle.BuildExceptionReporter] 	at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
22:02:55.829 [ERROR] [org.gradle.BuildExceptionReporter] 

Create a JavaKones Organization

I see this project is having 2 -3 internal project which are really valid and useful. Its better to create a org in github and make them as a individual repo this not only gives a collaboration but also a good website option and easy to manage more repo based on Kones.

Occasional freeze on save

Sometimes the app freezes, perhaps when the file saved contains syntax errors preventing it from compiling. This was noted in windows, running the koans in succession, on the AboutPrimitives suite.

Add ANSI colors to terminal output?

What an interesting project!

To make the block our output text more readable, I'd love to see the use of ANSI bold and colors in the terminal output.

For example,

  1. bold the category labels (i.e. "Level", "Progress", "Passing Suites", "Remaining Suites") and class/method name
  2. Make passing suite names green, remaining suite names red.
  3. (possibly, if it's not too visually jarring), provide zen advice in blue.

Koan are not re-evaluated when file is edited using emacs

I'm using the koans on Ubuntu 12.04 and started out using emacs, but the Koan evaluation loop doesn't work properly while using emacs (nano, vim, and gedit all seem to work as expected, so this isn't a show-stopper or anything). The Koans are evaluated properly initially, but after the file is edited and saved, an error is emitted and the Koans are not re-evaluated.

Here's the full output:
Ponder what's going wrong in the: AboutPrimitives class's wholeNumbersAreOfTypeInt method.

Line 12 may offer a clue as to how you may progress, now make haste!
What went wrong:
expected: but was:

Level: Novice
Progress [XXXX----------------------------------------------] 16/193
Passing Suites: AboutKoans, AboutAssertions, AboutEquality
Remaining Suites: AboutPrimitives, AboutStrings, AboutObjects, AboutLoops, AboutInheritance, AboutCasting, AboutConditionals, AboutConstructors, AboutEnums, AboutExceptions, AboutMethodPreference, AboutOperators, AboutArrays, AboutAutoboxing, AboutCollections, AboutComparison, AboutDates, AboutEquality, AboutFileIO, AboutInnerClasses, AboutLocale, AboutRegularExpressions, AboutSerialization, AboutMocks

Edit & save a koan to reload or enter 'Q' to exit

User edits AboutPrimitives.java and saves it at this point

Exception in thread "Thread-2" java.lang.RuntimeException: java.io.IOException: File or directory does not exist: /home/local/ANT/dougwade/java-koans-master/koans/src/beginner/.#AboutPrimitives.java
at com.sandwich.util.io.FileMonitor.notifyListeners(FileMonitor.java:61)
at com.sandwich.util.io.FileMonitorFactory$2.run(FileMonitorFactory.java:34)
at java.lang.Thread.run(Thread.java:701)
Caused by: java.io.IOException: File or directory does not exist: /home/local/ANT/dougwade/java-koans-master/koans/src/beginner/.#AboutPrimitives.java
at com.sandwich.util.io.FileUtils.forEachFile(FileUtils.java:57)
at com.sandwich.util.io.FileUtils.forEachFile(FileUtils.java:53)
at com.sandwich.util.io.FileUtils.forEachFile(FileUtils.java:53)
at com.sandwich.util.io.FileUtils.forEachFile(FileUtils.java:53)
at com.sandwich.util.io.FileMonitor.getFilesystemHashes(FileMonitor.java:67)
at com.sandwich.util.io.FileMonitor.notifyListeners(FileMonitor.java:47)
... 2 more

Outdated Gradle version?

I found that the 2.12 version of gradle encoded in the gradle-wrapper.properties file fails on my system (Ubuntu 16.04). Running ./gradlew idea resulted in

FAILURE: Build failed with an exception.                     
                                                                         
* What went wrong:                                                                                                                                                                                             
Could not determine java version from '10.0.1'.                                                                                                                                                                
                                                                                                                                                                                                               
* Try:                                                                                                                                                                                                         
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

When I manually updated the version to 4.9 everything went fine. Shall I create a PR?

netbeans can´t run jInternal frame

I´m new user of java, and I´m using IDE netbenas 8.02, when I run a project with several jmenu, which call Jinternalframe, some of them show me a mistake.
I tried to begin a new project, but the error appear in other Jmenu.

Exception in thread "AWT-EventQueue-0" java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key frmboleta.lblnumboleta.text
at java.util.ResourceBundle.getObject(ResourceBundle.java:450)
at java.util.ResourceBundle.getString(ResourceBundle.java:407)
at demol.tienda.frmboleta.initComponents(frmboleta.java:155)
at demol.tienda.frmboleta.(frmboleta.java:19)
at demol.tienda.frmmenuprincipal.mnuventboletActionPerformed(frmmenuprincipal.java:223)
at demol.tienda.frmmenuprincipal.access$000(frmmenuprincipal.java:12)
at demol.tienda.frmmenuprincipal$1.actionPerformed(frmmenuprincipal.java:99)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877)
at java.awt.Component.processMouseEvent(Component.java:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

demonstrate lambda sans multithreading or sleeping

AboutLambdas.simpleLambda doesnt need to use a thread nor sleep to prove its point. Using lambdas in a new thread could be its own lesson. As it stands it could mislead users into thinking its necessary to spawn a thread.

AboutDates: usingDateFormatToParseDates()

Line 68: The hard-coded date string fed to dateFormat.parse() cannot be parsed (Java 1.6.0_18).

@Koan
public void usingDateFormatToParseDates() throws ParseException {
    DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
    Date date2 = dateFormat.parse("Sat Sep 01 12:34:46 CET 2001");
    assertEquals(date2.toString(), __);
    // What happened to the time? What do you need to change to keep the time as well?
}

After much trial and error, I found a date and time format that parsed:

    DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
    Date date2 = dateFormat.parse("Saturday, September 1, 2001 12:34:46 pm CET");

Error produced before the change:

Ponder what's going wrong in the: AboutDates class's usingDateFormatToParseDates method.

Line 68 may offer a clue as to how you may progress, now make haste!
What went wrong: 
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at com.sandwich.koan.runner.KoanMethodRunner.run(KoanMethodRunner.java:28)
        at com.sandwich.koan.runner.RunKoans.runKoans(RunKoans.java:67)
        at com.sandwich.koan.runner.RunKoans.run(RunKoans.java:40)
        at com.sandwich.koan.constant.ArgumentType.run(ArgumentType.java:74)
        at com.sandwich.koan.cmdline.CommandLineArgument.run(CommandLineArgument.java:36)
        at com.sandwich.koan.cmdline.CommandLineArgumentRunner.run(CommandLineArgumentRunner.java:26)
        at com.sandwich.util.io.KoanFileCompileAndRunListener.fileSaved(KoanFileCompileAndRunListener.java:37)
        at com.sandwich.util.io.FileMonitor.notifyListeners(FileMonitor.java:57)
        at com.sandwich.util.io.FileMonitorFactory$1.run(FileMonitorFactory.java:29)
        at java.lang.Thread.run(Thread.java:636)
Caused by: java.text.ParseException: Unparseable date: "Sat Sep 01 12:34:46 CET 2001"
        at java.text.DateFormat.parse(DateFormat.java:354)
        at intermediate.AboutDates.usingDateFormatToParseDates(AboutDates.java:68)
        ... 14 more

Run koans in "non-interactive" mode

Hey, @matyb and friends. As you may recall, I use the Java Koans in my Advanced Java Programming course at Portland State University. The students find the koans to be very valuable and I feel they provide an appropriately broad introduction to the Java language and its core APIs.

My students work on the koans during the first couple of weeks of classes and then they submit them to me for grading. Currently, I have a script that runs the koans for a student, sleeps while koans compile and run, send the letter 'Q' to standard input, captures the output into a file, and then moves on to the next student.

The school's machine that I run the koans on can be under heavy load at times and I've had to adjust the script to sleep for 4 minutes in order to ensure that all of the koans are compiled before sending the 'Q' to exit. When I've got more than 30 student submissions to grade, this process can take a long time.

Last summer, my grader suggested that I add a "run in non-interactive mode" to the koans framework that would wait for all of the koans to compile and report their results before simply exiting. It wouldn't need to prompt for the user to enter 'Q' in standard in.

I'm not sure if the koans framework can easily handle this use case, so I wanted to ask you guys about its feasibility before diving into it too deeply.

So, what do you think? Would running the koans in a non-interactive mode be feasible? If so, do you have any recommendations about how I might approach adding a non-interactive mode?

Thanks,

Dave

NPE in Ubuntu 11.04 with Java 1.6.0_24

When i execute the run.sh command, i get the following error:

Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException
at com.sandwich.koan.runner.AppLauncher.run(AppLauncher.java:32)
at com.sandwich.koan.runner.AppLauncher.main(AppLauncher.java:15)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
at com.sandwich.koan.path.PathToEnlightenment.createPath(PathToEnlightenment.java:26)
at com.sandwich.koan.path.PathToEnlightenment.getPathToEnlightment(PathToEnlightenment.java:32)
at com.sandwich.koan.runner.RunKoans.getPathToEnlightement(RunKoans.java:150)
at com.sandwich.koan.runner.RunKoans.runKoans(RunKoans.java:59)
at com.sandwich.koan.runner.RunKoans.run(RunKoans.java:46)
at com.sandwich.koan.constant.ArgumentType.run(ArgumentType.java:74)
at com.sandwich.koan.cmdline.CommandLineArgument.run(CommandLineArgument.java:36)
at com.sandwich.koan.runner.KoanSuiteRunner.run(KoanSuiteRunner.java:41)
at com.sandwich.koan.runner.AppLauncher.run(AppLauncher.java:30)
... 1 more
Caused by: java.lang.NullPointerException
at com.sandwich.koan.path.xmltransformation.XmlToPathTransformer.getKoanMethods(XmlToPathTransformer.java:131)
at com.sandwich.koan.path.xmltransformation.XmlToPathTransformer.createKoanMethods(XmlToPathTransformer.java:76)
at com.sandwich.koan.path.xmltransformation.XmlToPathTransformer.createSuitesAndKoans(XmlToPathTransformer.java:68)
at com.sandwich.koan.path.xmltransformation.XmlToPathTransformer.transform(XmlToPathTransformer.java:55)
at com.sandwich.koan.path.PathToEnlightenment.createPath(PathToEnlightenment.java:24)
... 9 more

Any ideas?

Best regards,
RIcardo

AboutInnerClasses: Igorable interface

Line 8: The Ignorable interface is defined outside the AboutInnerClasses class, causing Java Koans to crash looking for src/intermediate/Ignorable.java. It should be inside the class... probably just above the creatingAnonymousInnerClassesToImplementInterface() method that first uses it.

Misleading koan about chars

I am going through the koans, which are awesome, and noticed a bit of a misnamed koan. The koan "charsCanOnlyBePositive" is misleading as a char can have a value of 0. Renaming this to "charsCanOnlyBeNonNegative" would be more accurate.

Super minor nitpick for this awesome program. Thank you for making this.

AboutStrings: StringConcatenation Koan

Hi Mat,
I've been going through the koans (good stuff so far), and I'm on AboutStrings.java.
I see this Koan:
@koan
public void efficientStringConcatenation() {
// the above implicit string concatenation looks nice - but, it is expensive.
// it creates a new string instance on each concatenation. here's a better alternative:
assertEquals(new StringBuilder("one").append(" ").append("two").toString(), "one two");
}
This isn't entirely true anymore, because the compiler will convert the + to StringBuilder.append internally.
See here: http://stackoverflow.com/questions/1532461/stringbuilder-vs-string-concatenation-in-tostring-in-java

AboutCasting: upCastAndPolymorphism()

Reflection failure apparently caused by the cast from GrandParent to Parent on line 75. Creating grandParent as a new Parent instead cures it, but I can't tell if that's what you wanted.

I'm using Java 1.6.0_18 on Linux 26.34.9-69.fc13.x86_64.

Ponder what's going wrong in the: AboutCasting class's upCastAndPolymophism method.

Line 75 may offer a clue as to how you may progress, now make haste!
What went wrong: 
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at com.sandwich.koan.runner.KoanMethodRunner.run(KoanMethodRunner.java:28)
        at com.sandwich.koan.runner.RunKoans.runKoans(RunKoans.java:67)
        at com.sandwich.koan.runner.RunKoans.run(RunKoans.java:40)
        at com.sandwich.koan.constant.ArgumentType.run(ArgumentType.java:74)
        at com.sandwich.koan.cmdline.CommandLineArgument.run(CommandLineArgument.java:36)
        at com.sandwich.koan.cmdline.CommandLineArgumentRunner.run(CommandLineArgumentRunner.java:26)
        at com.sandwich.util.io.KoanFileCompileAndRunListener.fileSaved(KoanFileCompileAndRunListener.java:37)
        at com.sandwich.util.io.FileMonitor.notifyListeners(FileMonitor.java:57)
        at com.sandwich.util.io.FileMonitorFactory$1.run(FileMonitorFactory.java:29)
        at java.lang.Thread.run(Thread.java:636)
Caused by: java.lang.ClassCastException: beginner.AboutCasting$GrandParent cannot be cast to beginner.AboutCasting$Parent
        at beginner.AboutCasting.upCastAndPolymophism(AboutCasting.java:75)
        ... 14 more

AboutEquality updated but not being read through correctly

Getting continual error on line 26 expected but was :.

Code on Line 26 of About Equality

@Koan 
public void noObjectShouldbeEqualToNull() {
    assertEquals(new Object().equals(null),false);
}

Running on Mac 10.7:
java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03-383-11A511)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02-383, mixed mode)

AboutStrings suite missing from PathToEnlightenment.xml

I'm brand new to Git Hub, and just created my account now to post these bug reports. I looked for an etiquette guide but didn't find one, so apologies in advance if there's a better way to do this. I couldn't find your email address (in fact, you don't identify yourself at all in the README).

Also, I ran through all the koans on Thu 10 and Fri 11 Nov, just before your latest update. None of the koans themselves have changed so most of these should still be valid, but if anything can't be reproduced, it might have been specific to the 528c385 version. I'll double-check as many as I can.

Although there is a beginner/src/AboutStrings.java (and it works), it is not mentioned in the XMl file PathToEnlightenment.xml, so it does not get included with the other koans.

In fact, a lot of the XML file seems to be missing. Contrast the current version with version a7d3417, which included a text hint ("lesson") for almost every koan. (But the XML didn't include AboutStrings then, either.)

IllegalAccessError in beginner.AboutObjects.toStringConcatenates

I got the following error:

Ponder what's going wrong in the: AboutObjects class's toStringConcatenates method.

Line 64 may offer a clue as to how you may progress, now make haste!

What went wrong:
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at com.sandwich.koan.runner.KoanMethodRunner.run(KoanMethodRunner.java:28)
        at com.sandwich.koan.runner.RunKoans.runKoans(RunKoans.java:67)
        at com.sandwich.koan.runner.RunKoans.run(RunKoans.java:40)
        at com.sandwich.koan.constant.ArgumentType.run(ArgumentType.java:74)
        at com.sandwich.koan.cmdline.CommandLineArgument.run(CommandLineArgument.java:36)
        at com.sandwich.koan.cmdline.CommandLineArgumentRunner.run(CommandLineArgumentRunner.java:26)
        at com.sandwich.util.io.KoanFileCompileAndRunListener.fileSaved(KoanFileCompileAndRunListener.java:37)
        at com.sandwich.util.io.FileMonitor.notifyListeners(FileMonitor.java:57)
        at com.sandwich.util.io.FileMonitorFactory$1.run(FileMonitorFactory.java:29)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalAccessError: tried to access class beginner.AboutObjects$1 from class beginner.AboutObjects
        at beginner.AboutObjects.toStringConcatenates(AboutObjects.java:64)
        ... 14 more
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)

I don't know what other info is needed.

Andrew :)

AboutConstructors: complexConstructorOrder()

Typo: The koan doesn't use the new classes (Aa and Bb) that were created just for it:

@Koan
public void complexConstructorOrder(){
    assertEquals(new B().someString, __);
}

The assertion should be:

    assertEquals(new Bb().someString, __);

Is this tested in windows ?

I just installed jdk in windows, with javac in the path, however it can't compile AboutKoans.java and complains with the following error:

*****************************************************************
Compile Output:
Cannot execute:
    javac -d C:\Users\saxon\Downloads\java-koans-master\java-koans-master\koans\app\bin -classpath C:\Users\saxon\Downloads\java-koans-master\java-koans-master\koans\app\
lib\file-compiler.jar;C:\Users\saxon\Downloads\java-koans-master\java-koans-master\koans\app\lib\file-monitor.jar;C:\Users\saxon\Downloads\java-koans-master\java-koans-ma
ster\koans\app\lib\koans.jar;C:\Users\saxon\Downloads\java-koans-master\java-koans-master\koans\app\lib\util.jar; C:\Users\saxon\Downloads\java-koans-master\java-koans-ma
ster\koans\src\beginner\AboutKoans.java
    Please check that the appropriate compiler (javac) is installed, is executable and is listed in your PATH environment variable value.
Compiling "C:\Users\saxon\Downloads\java-koans-master\java-koans-master\koans\src\beginner\AboutKoans.java" failed.
The exit status was: 2
*****************************************************************


java.io.FileNotFoundException: C:\Users\saxon\Downloads\java-koans-master\java-koans-master\koans\app\bin\beginner\AboutKoans.class (The system cannot find the path speci
fied)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(Unknown Source)
        at java.io.FileInputStream.<init>(Unknown Source)
        at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
        at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
        at com.sandwich.util.io.classloader.DynamicClassLoader.loadClass(Unknown Source)
        at com.sandwich.util.io.classloader.DynamicClassLoader.loadClass(Unknown Source)
        at com.sandwich.koan.runner.RunKoans.constructSuite(Unknown Source)
        at com.sandwich.koan.runner.RunKoans.safelyConstructSuite(Unknown Source)
        at com.sandwich.koan.runner.RunKoans.runKoans(Unknown Source)
        at com.sandwich.koan.runner.RunKoans.run(Unknown Source)
        at com.sandwich.koan.constant.ArgumentType.run(Unknown Source)
        at com.sandwich.koan.cmdline.CommandLineArgument.run(Unknown Source)
        at com.sandwich.koan.cmdline.CommandLineArgumentRunner.run(Unknown Source)
        at com.sandwich.koan.runner.AppLauncher.main(Unknown Source)
Exception in thread "main" java.lang.RuntimeException: java.lang.ClassFormatError: Truncated class file
        at com.sandwich.koan.runner.RunKoans.constructSuite(Unknown Source)
        at com.sandwich.koan.runner.RunKoans.safelyConstructSuite(Unknown Source)
        at com.sandwich.koan.runner.RunKoans.runKoans(Unknown Source)
        at com.sandwich.koan.runner.RunKoans.run(Unknown Source)
        at com.sandwich.koan.constant.ArgumentType.run(Unknown Source)
        at com.sandwich.koan.cmdline.CommandLineArgument.run(Unknown Source)
        at com.sandwich.koan.cmdline.CommandLineArgumentRunner.run(Unknown Source)
        at com.sandwich.koan.runner.AppLauncher.main(Unknown Source)
Caused by: java.lang.ClassFormatError: Truncated class file
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at com.sandwich.util.io.classloader.DynamicClassLoader.loadClass(Unknown Source)
        at com.sandwich.util.io.classloader.DynamicClassLoader.loadClass(Unknown Source)
        ... 8 more

assertNotSameInstance a bit unclear

Thanks for creating these koans.

I think the goal/instructions for assertNotSameInstance is a bit unclear. It's the same code as the previous one, just with assertNot instead of assert. I can just delete the "Not" but that feels like the wrong way. Still, I'm guessing that's how it's suggested to proceed.

AboutDates: changingDateValue()

Line 25: The local variable oneHourInMilliseconds is missing a zero. It should be 3_600_000, not 360_000 (PERL-style underscore separators used for emphasis).

AboutFileIO Koan basicFileWritingAndReading() line 29

There is (garbage?) output that is inside the expected string on line 45. This makes comparing the string difficult unless one passes in the identical String constructor new String(in)) into the assert or uses the trim function.
expected

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.