summaryrefslogtreecommitdiffstats
path: root/t/100-errors.t
blob: 3bd23e1b404d7a8b1483ddcc25ea8758c31c48b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!perl -T
use strict;
use warnings;
use Test::More;
use Test::Exception;
use Language::TECO;

my @test_cmds = qw/j c d/;
plan tests => @test_cmds * 6;

my $buftext = "this is\nan initial buffer";
my $te = Language::TECO->new($buftext);
$te->execute("5j");
for my $cmd (@test_cmds) {
    throws_ok { $te->execute("100$cmd") } qr/Pointer off page/,
              "moving the pointer off the end of the buffer ($cmd)";
    is($te->pointer, 5);
    is($te->buffer, $buftext);
    throws_ok { $te->execute("-100$cmd") } qr/Pointer off page/,
              "moving the pointer off the beginning of the buffer ($cmd)";
    is($te->pointer, 5);
    is($te->buffer, $buftext);
}