Acme-Aheui

 view release on metacpan or  search on metacpan

t/01_aheui.t  view on Meta::CPAN

#!/usr/bin/env perl
use utf8;
use strict;
use warnings;
use Test::More;
use Capture::Tiny ':all';
use Encode qw/decode/;

BEGIN {
	use_ok( 'Acme::Aheui' );
}

{ # new interpreter and its internal codespace
    my $source = "가각\r\n힢힣\nA *";
    my $interpreter = Acme::Aheui->new( source => $source );
    ok( $interpreter );
    is( $$interpreter{_codespace}[0][0]{cho}, 0 );
    is( $$interpreter{_codespace}[0][0]{jung}, 0 );
    is( $$interpreter{_codespace}[0][0]{jong}, 0 );

    is( $$interpreter{_codespace}[0][1]{cho}, 0 );
    is( $$interpreter{_codespace}[0][1]{jung}, 0 );
    is( $$interpreter{_codespace}[0][1]{jong}, 1 );

    is( $$interpreter{_codespace}[1][0]{cho}, 18 );
    is( $$interpreter{_codespace}[1][0]{jung}, 20 );
    is( $$interpreter{_codespace}[1][0]{jong}, 26 );

    is( $$interpreter{_codespace}[1][1]{cho}, 18 );
    is( $$interpreter{_codespace}[1][1]{jung}, 20 );
    is( $$interpreter{_codespace}[1][1]{jong}, 27 );

    is( $$interpreter{_codespace}[2][0]{cho}, -1 );
    is( $$interpreter{_codespace}[2][0]{jung}, -1 );
    is( $$interpreter{_codespace}[2][0]{jong}, -1 );

    is( $$interpreter{_codespace}[2][1]{cho}, -1 );
    is( $$interpreter{_codespace}[2][1]{jung}, -1 );
    is( $$interpreter{_codespace}[2][1]{jong}, -1 );

    is( $$interpreter{_codespace}[2][2]{cho}, -1 );
    is( $$interpreter{_codespace}[2][2]{jung}, -1 );
    is( $$interpreter{_codespace}[2][2]{jong}, -1 );
}

{ # move cursor
    my $source = <<'__SOURCE__';
가나다
라마
바사아자차
ì¹´
타파하
__SOURCE__
    
    my $interpreter = Acme::Aheui->new( source => $source );
    is( $interpreter->{_x}, 0 );
    is( $interpreter->{_y}, 0 );
    is( $interpreter->{_dx}, 0 );
    is( $interpreter->{_dy}, 1 );

    $interpreter->{_dx} = 1;
    $interpreter->{_dy} = 0;
    $interpreter->_move_cursor();
    is_deeply( [$interpreter->{_x}, $interpreter->{_y}], [1, 0] );
    $interpreter->_move_cursor();



( run in 2.603 seconds using v1.01-cache-2.11-cpan-5a3173703d6 )