Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Sam Warner
@sjwarner-bp
What's exactly the problem?
MikeIsAnAsset
@MikeIsAnAsset
@sjwarner-bp
class Twofer {
    String expected = ""
    String twofer(String name) {
        if (name == null){
            String expected = "One for you, one for me.";
            return expected;
        } else {
            String expected = "One for " + name + ", one for me.";
            return expected;
        }
    }
}
Sam Warner
@sjwarner-bp
class Twofer {String expected = "" String twofer(String name) { if (name == null){ String expected = "One for you, one for me."; return expected; } else { String expected = "One for " + name + ", one for me."; return expected; } } }
I've pasted it back in using triple backtracks, if this helps you understand how to style it ☺️
Ok @MikeIsAnAsset, and what's the first test again? And what's your output from the test?
MikeIsAnAsset
@MikeIsAnAsset
@Test
    public void noNameGiven() {
        String input = null;
        String expected = "One for you, one for me.";

        assertEquals(expected, twofer.twofer(input));
    }
Sam Warner
@sjwarner-bp
Ok, so what is the output of this test when run?
You should have some message explaining why it fails.
MikeIsAnAsset
@MikeIsAnAsset
same message that I started with. basically to implement code for the twofer method
TwoferTest > noNameGiven FAILED
    java.lang.UnsupportedOperationException: Delete this statement and write your own implementation.
        at Twofer.twofer(Twofer.java:3)
        at TwoferTest.noNameGiven(TwoferTest.java:21)
Sam Warner
@sjwarner-bp
Ok, so it sounds like you might not have saved your code?
MikeIsAnAsset
@MikeIsAnAsset
never thought about that lol
Sam Warner
@sjwarner-bp
class Twofer {
    String twofer(String name) {
        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
    }
}
This is what you'd start out with. The error message comes from here. If you've deleted the third line (throw new UnsupportedOperationException) then you shouldn't be getting that message.
MikeIsAnAsset
@MikeIsAnAsset
nope same error. in place of that 3rd line is the first var code block I posted
that if else block
Sam Warner
@sjwarner-bp
Is the file you are editing in the correct place? i.e. two-fer/src/java/main/TwoFer.java or something like that?
MikeIsAnAsset
@MikeIsAnAsset
just got it to pass!
forgot semicolon after String expected = ""
Sam Warner
@sjwarner-bp
What was the problem?
MikeIsAnAsset
@MikeIsAnAsset
forgot semicolon after String expected = ""
Sam Warner
@sjwarner-bp
Hmm that is odd. I would have expected you to get compiler errors instead of a failing test.
MikeIsAnAsset
@MikeIsAnAsset
I had a lot in my terminal, so maybe I overlooked it
oh
so I think the first time it was a save problem (failed test) second was compile error
thanks for all your help!
Sam Warner
@sjwarner-bp
That's ok! No problem, that's why we have this channel :smile:
Drop another message if you run in to any more problems
MikeIsAnAsset
@MikeIsAnAsset
awesome. thank you!
Jeffrey Sander
@jssander
I would like to try and implement the go-counting exercise for the java track, but there is no canonical data file for it as far as I can tell. What should I do?
Sam Warner
@sjwarner-bp
Hmm
Let me take a look quickly πŸ™‚
So it looks as though Python has a (fairly minimal) test suite, which we could mimic
The F# track looks like it uses almost the same tests
So I'd suggest doing that. If you are feeling particularly outgoing, it would be super useful to raise a PR for implementing canonical data in problem specifications! That way other people won't run in to issues, and we can properly version this suite. Because the tests are already in two places, it might even be quicker than making it from scratch.
What do you think?
Jeffrey Sander
@jssander
I've never done a PR for problem specifications before
Jeffrey Sander
@jssander
It looks like there is already an issue on github for the go-counting canonical data in the problem specifications repository
maybe I will take care of that first
Sam Warner
@sjwarner-bp
Whichever you prefer - of course all of this is up to you! πŸ™‚
Jeffrey Sander
@jssander
go-counting has two large 2-dimensional arrays which are used as input to the tests. I am unsure how to put this into the canonical data file
Sam Warner
@sjwarner-bp
I would look at the diamond exercise for inspiration - have you checked that out?
Jeffrey Sander
@jssander
ok
Well in diamond the 2-dim array is different for every test. Here it is the same array for many of the tests. Is there a way to have a constant or should I repeat the array for every test case in the canonical file? Does that make sense?
I think I will just copy it over a new for each test case in the canonical file and then see what they say about that.
Sam Warner
@sjwarner-bp
Implement it as sensibly as you can, and then submit a PR - we will then be able to review it and see if there is anything extra we can do to it πŸ™‚
Jeffrey Sander
@jssander
ok
thanks
What should I use as the version number?
Jeffrey Sander
@jssander
I submitted a PR, but the build failed.
Sam Warner
@sjwarner-bp
I'll take a look now :smile: