Skip to content

CML Template suggestions #4

Description

@bdw429s

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions