@include test-module('_after') {
    @include test('should create a function that invokes func after n calls') {
        $test-after: __after(5, length);

        $result: __call($test-after, null, (1, 2));
        $result: __call($test-after, null, (1, 2));
        $result: __call($test-after, null, (1, 2));
        $result: __call($test-after, null, (1, 2));
        $result: __call($test-after, null, (1, 2));
        $result: __call($test-after, null, (1, 2));

        @include assert-equal($result, 2);

        $test-after: __after(5, length);

        $result: __call($test-after, null, (1, 2));
        $result: __call($test-after, null, (1, 2));
        $result: __call($test-after, null, (1, 2));
        $result: __call($test-after, null, (1, 2));

        @include assert-equal($result, null);

        $test-after: __after(0, length);

        $result: __call($test-after, null, (1, 2));

        @include assert-equal($result, 2);
    }

    @include test('should allow func as the first argument') {
        $test-after: __after(length, 0);

        $result: __call($test-after, null, (1, 2));

        @include assert-equal($result, 2);
    }
}