/[ttyrec]/jsttyplay/t/parser/04_parse_escape.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /jsttyplay/t/parser/04_parse_escape.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Tue Feb 17 18:12:32 2009 UTC (15 years, 2 months ago) by dpavlin
File MIME type: application/x-troff
File size: 4024 byte(s)
import upstream from http://encryptio.com/code/jsttyplay

1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4
5 use Test::More tests => 77;
6
7 use Term::Emulator::Parser;
8
9 my $term = Term::Emulator::Parser->new( width => 8, height => 4 );
10
11 is($term->as_string, " \n \n \n ");
12 is($term->bold_as_string, "00000000\n00000000\n00000000\n00000000");
13 is($term->underline_as_string, "00000000\n00000000\n00000000\n00000000");
14 is($term->fg_as_string, "77777777\n77777777\n77777777\n77777777");
15 is($term->bg_as_string, "00000000\n00000000\n00000000\n00000000");
16
17 $term->parse("a");
18 is($term->as_string, "a \n \n \n ");
19 is($term->curposx, 2);
20 is($term->curposy, 1);
21 $term->parse("\033[H");
22 is($term->as_string, "a \n \n \n ");
23 is($term->curposx, 1);
24 is($term->curposy, 1);
25 $term->parse("b");
26 is($term->as_string, "b \n \n \n ");
27 $term->parse("\010 ");
28 is($term->as_string, " \n \n \n ");
29 is($term->bold_as_string, "00000000\n00000000\n00000000\n00000000");
30 is($term->underline_as_string, "00000000\n00000000\n00000000\n00000000");
31 is($term->fg_as_string, "77777777\n77777777\n77777777\n77777777");
32 is($term->bg_as_string, "00000000\n00000000\n00000000\n00000000");
33
34 $term->parse("\033[2;3H");
35 is($term->curposx, 3);
36 is($term->curposy, 2);
37 $term->parse("q");
38 is($term->as_string, " \n q \n \n ");
39 $term->parse("\033[A");
40 is($term->curposx, 4);
41 is($term->curposy, 1);
42 $term->parse("z");
43 is($term->as_string, " z \n q \n \n ");
44 $term->parse("\033[2;3f");
45 is($term->curposx, 3);
46 is($term->curposy, 2);
47 $term->parse(" ");
48 is($term->as_string, " z \n \n \n ");
49 $term->parse("\033[3A");
50 is($term->curposx, 4);
51 is($term->curposy, 1);
52 $term->parse(" ");
53 is($term->as_string, " \n \n \n ");
54 is($term->bold_as_string, "00000000\n00000000\n00000000\n00000000");
55 is($term->underline_as_string, "00000000\n00000000\n00000000\n00000000");
56 is($term->fg_as_string, "77777777\n77777777\n77777777\n77777777");
57 is($term->bg_as_string, "00000000\n00000000\n00000000\n00000000");
58
59 $term->parse("\033[H");
60 is($term->curposx, 1);
61 is($term->curposy, 1);
62 $term->parse("\033[B");
63 is($term->curposx, 1);
64 is($term->curposy, 2);
65 $term->parse("\033[2B");
66 is($term->curposx, 1);
67 is($term->curposy, 4);
68 $term->parse("\033[A");
69 is($term->curposx, 1);
70 is($term->curposy, 3);
71 $term->parse("\033[19B");
72 is($term->curposx, 1);
73 is($term->curposy, 4);
74
75 $term->parse("\033[H\033[C");
76 is($term->curposx, 2);
77 is($term->curposy, 1);
78 $term->parse("\033[5C");
79 is($term->curposx, 7);
80 is($term->curposy, 1);
81 $term->parse("\033[93C");
82 is($term->curposx, 8);
83 is($term->curposy, 1);
84
85 $term->parse("\033[D");
86 is($term->curposx, 7);
87 is($term->curposy, 1);
88 $term->parse("\033[D");
89 is($term->curposx, 6);
90 is($term->curposy, 1);
91 $term->parse(" \033[D\033[D\033[D");
92 is($term->curposx, 4);
93 is($term->curposy, 1);
94
95 $term->parse("\033[Habc");
96 is($term->curposx, 4);
97 is($term->curposy, 1);
98 is($term->as_string, "abc \n \n \n ");
99 $term->parse("\n");
100 is($term->curposx, 1);
101 is($term->curposy, 2);
102
103 $term->parse("\033[0;0H ");
104 is($term->curposx, 2);
105 is($term->curposy, 1);
106 is($term->as_string, " bc \n \n \n ");
107 $term->parse(" ");
108 is($term->curposx, 4);
109 is($term->curposy, 1);
110 is($term->as_string, " \n \n \n ");
111
112 is($term->bold_as_string, "00000000\n00000000\n00000000\n00000000");
113 is($term->underline_as_string, "00000000\n00000000\n00000000\n00000000");
114 is($term->fg_as_string, "77777777\n77777777\n77777777\n77777777");
115 is($term->bg_as_string, "00000000\n00000000\n00000000\n00000000");
116
117 $term->parse("\r");
118 is($term->curposx, 1);
119 is($term->curposy, 1);
120
121 $term->parse(" \033D");
122 is($term->curposx, 3);
123 is($term->curposy, 2);
124 $term->parse("\ra");
125 is($term->curposx, 2);
126 is($term->curposy, 2);
127 is($term->as_string, " \na \n \n ");
128

  ViewVC Help
Powered by ViewVC 1.1.26