ab5tract / Terminal-Print

Terminal::Print is a pure Raku layer for printing to terminal screens
Other
25 stars 18 forks source link

Use constants for method constraints in BoxDrawing #76

Closed jjatria closed 4 years ago

jjatria commented 4 years ago

Rakudo does not seem to allow constraints that use hashes in role methods (see https://github.com/rakudo/rakudo/issues/3172), but the issue disappears if the hashes are declared as constants rather.

At least until the issue is resolved upstream, this allows classes to consume the BoxDrawing role without needing to disable precompilation.

Fixes #74.

jjatria commented 4 years ago

Hm, actually, let me add some tests for this.

jjatria commented 4 years ago

I've added some extremely non-DRY tests for this. Maybe tomorrow I can be more clever about how to avoid repeating myself repeating myself.

japhb commented 4 years ago

To make the tests simpler and shorter, why not .join the grids, so you can just compare each against a single nine-character string? Then you could even make a little helper:

sub border-check($expected, $style) {
    given A.new(x => 0, y => 0, h => 3, w => 3) {
        .draw-box(0, 0, 2, 2, ($style if $style));
        is .grid.grid.join, $expected, $style || $default;
    }
}

... and similarly for border-check-with-color or so.

jjatria commented 4 years ago

I've updated the tests, so they're more DRY now

japhb commented 4 years ago

Merged, thanks!