codewars / testbox-codewars

Custom TestBox reporter and runner for Codewars
MIT License
5 stars 2 forks source link

CML Template suggestions #4

Open bdw429s opened 4 years ago

bdw429s commented 4 years ago

I don't know to what extend these are customizable or debatable, but after knocking out a few more CFML translations, I'd like to recommend a few changes to the defaults that load when starting a new translation. This is just for consistency and to reduce as much copy paste as possible

Default Solution

component {

    function fnName( numeric n ){
        return n;
    }

}

Default Solution Setup

component {

    function fnName(){
        // Your code here...
    }

}

Default Test Cases

// https://testbox.ortusbooks.com/
component extends="CodewarsBaseSpec" {
    // Submitted solution is written to Solution.cfc
    function beforeAll(){
        SUT = createObject( 'Solution' );
    }

    function run(){
        given( "Example", () => {

            when( "Basic tests", () => {
                then( "Input of 42", () => expect( SUT.fnName( 42 ) ).toBe( 42 ) );
                then( "Input of 3.14", () => expect( SUT.fnName( 3.14 ) ).toBe( 3.14 ) );
            });

            when( "Random tests", () => {
                then( "with random data", () => {
                    loop from=1 to=500 index='local.i' {
                        var n = randRange( 1, 5 );
                        expect( SUT.fnName( n ) ).toBe( fnNameRef( s ), "Input of #n# " );
                    }
                });
            });

        });
    }

    // Reference solution for random tests
    function fnNameRef(){
    }
}

Default Sample Test Cases

// https://testbox.ortusbooks.com/
component extends="CodewarsBaseSpec" {
    // Submitted solution is written to Solution.cfc
    function beforeAll(){
        SUT = createObject( 'Solution' );
    }

    function run(){
        given( "Example", () => {
            when( "Basic tests", () => {
                then( "Input of 42", () => expect( SUT.fnName( 42 ) ).toBe( 42 ) );
            });
        });
    }
}

Feedback welcome.

bdw429s commented 4 years ago

@scottsteinbeck @jsteinshouer @steffan153 and @irmantas you all have submitted CFML kata translations. Any feedback on my suggestions above?

bdw429s commented 4 years ago

@kazk It looks like no one has any input here (Other than @scottsteinbeck who replied directly to me in a Slack team). Can you respond?

kazk commented 4 years ago

I don't know to what extend these are customizable

These are currently not customizable. Only the default test cases can be changed and it's used for both sample and submission tests. I can technically append some of these as comments, but it's also used when starting a regular kumite.

bdw429s commented 4 years ago

@kazk Hmm, so maybe we need a ticket that allows each of these to be customization. I can say after writing a handful of translations, it was getting pretty old pretty quick to put the same boilerplate in every kata. The consistency here seems like it would be nice. I've actually had this tab open in the last week and just been copy pasting my suggestions into each kata translations as I write them. (I loathe redundant work 😃 )

kazk commented 4 years ago

Please open a new issue requesting it on https://github.com/Codewars/codewars.com.

bdw429s commented 4 years ago

@kazk I hate to tag you here on an unrelated matter, but my coworker @gpickin has been trying to reach out to info@codewars.com for a few days now with no response. Can you confirm if that E-mail address is monitored, and if not, is there a better way to reach you or whoever else is in charge of Codewars to discuss things that don't really fall in the purview of a Github ticket?

kazk commented 4 years ago

Unfortunately I don't have access to that email. My email is kaz at qualified.io