ZIO_test.pm

filter: Statementstmt 67.8% 38 / 56 Branchbran 21.4% 3 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 63.1% 12 / 19 Podpod 0.0% 0 / 16 totaltotal 50.4% 53 / 105 CC 8 SCAR 19.7
CC
8
Cov
59%
get_input
30.0
write_zchar
6.0
new
2.0
CRAP 7.2
« ZText.pm ↑ Summary ZObjectStatus.pm »
1 package Games::Rezrov::ZIO_test;
2 # z-machine i/o for test model - meant for capturing output as part of a test
3 # - contributed by Neil Bowers, Aug 2004
4 # - modified by Michael Edmonson:
5 # - stripped down even further.
6 # - avoid using ANY local system calls or external modules (GetKey/GetSize).
7 # This means single-key input will not work, but also "make test"
8 # might stop crashing in unusual configurations! :P
9
10 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11
12 1 ▶use Games::Rezrov::ZIO_Generic;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 @Games::Rezrov::ZIO_test::ISA = qw(Games::Rezrov::ZIO_Generic);
14
15 1 my $rows = 25;
16 1 my $columns = 80;
17 1 my $abs_x = 0;
18 1 my $abs_y = 0;
19
20 1 $|=1;
21
22 1 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod undocumented
23 1 my ($type, %options) = @_;
24 1 my $self = new Games::Rezrov::ZIO_Generic(%options);
25 1 bless $self, $type;
26
27 1 ▶ $columns = $options{columns} if $options{columns};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"columns"} 0 1 1
28 1 $self->zio_options(\%options);
29 1 ($columns, $rows) = get_size();
30
31 1 return $self;
32 }
33
34 1 ▶sub get_size {
Subroutine get_size: called CC=1 SCAR=0.0
Pod undocumented
35 1 return ($columns, $rows);
36 }
37
38 0 ▶sub get_key {
Subroutine get_key: not called CC=1 SCAR=6.9
Pod undocumented
39 # single-key input disabled!
40 0 return "";
41 }
42
43 24 ▶sub write_string {
Subroutine write_string: called CC=1 SCAR=0.0
Pod undocumented
44 24 my ($self, $string, $x, $y) = @_;
45 # $self->absolute_move($x, $y) if defined($x) and defined($y);
46 24 print $string;
47 24 $abs_x += length($string);
48 }
49
50 0 ▶sub clear_to_eol {
Subroutine clear_to_eol: not called CC=1 SCAR=0.0
Pod undocumented
51 # do nothing
52 }
53
54 0 ▶sub update {
Subroutine update: not called CC=1 SCAR=0.0
Pod undocumented
55 }
56
57 3 ▶sub can_split {
Subroutine can_split: called CC=1 SCAR=0.0
Pod undocumented
58 # true or false: can this zio split the screen?
59 3 return 0;
60 }
61
62 1 ▶sub set_version {
Subroutine set_version: called CC=1 SCAR=0.0
Pod undocumented
63 1 my ($self, $status_needed, $callback) = @_;
64 1 Games::Rezrov::StoryFile::rows($rows);
65 1 Games::Rezrov::StoryFile::columns($columns);
66 1 return 0;
67 }
68
69 4 ▶sub absolute_move {
Subroutine absolute_move: called CC=1 SCAR=0.0
Pod undocumented
70 4 ($abs_x, $abs_y) = @_[1,2];
71 }
72
73 28 ▶sub newline {
Subroutine newline: called CC=1 SCAR=0.0
Pod undocumented
74 28 print "\n";
75 28 $abs_x = 0;
76 # Games::Rezrov::StoryFile::register_newline();
77 # never register newlines to the interpreter,
78 # so [MORE] prompt will never appear.
79 }
80
81 0 ▶sub write_zchar {
Subroutine write_zchar: not called CC=2 SCAR=17.9
Pod undocumented
82 0 ▶ if ($_[0]->current_window() == Games::Rezrov::ZConst::LOWER_WIN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0]->current_window == 0) { } 0 0 0
83 0 print chr($_[1]);
84 0 $abs_x++;
85 } else {
86 # upper window character, ignore
87 # printf STDERR "ignoring char: %s\n", chr($_[1]);
88 }
89 }
90
91 0 ▶sub get_input {
Subroutine get_input: not called CC=5 SCAR=34.0
Pod undocumented
92 0 my ($self, $max, $single_char, %options) = @_;
93 0 ▶ if ($single_char) {
Branch: 1 branch
BranchTrueFalseTotal
if ($single_char) { } 0 0 0
94 0 return get_key();
95 } else {
96 0 my $line;
97 0 ▶ if ($self->listening) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->listening) { } 0 0 0
elsif ($self->using_term_readline) { } 0 0 0
98 # speech recognition; disable for this interface?
99 0 $line = $self->recognize_line();
100 0 print "$line\n";
101 } elsif ($self->using_term_readline()) {
102 # Term::ReadLine enabled
103 0 $line = $self->readline($options{"-preloaded"});
104 } else {
105 0 $line = <STDIN>;
106 # also doesn't work with v5+ preloaded input
107 }
108 0 ▶ unless (defined $line) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $line) 0 0 0
109 0 $line = "";
110 0 print "\n";
111 }
112 0 chomp $line;
113 0 return $line;
114 }
115 }
116
117 22 ▶sub get_position {
Subroutine get_position: called CC=2 SCAR=6.9
Pod undocumented
118 22 my ($self, $sub) = @_;
119 22 ▶ if ($sub) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub) { } 3 19 22
120 3 ▶ return sub { };
Subroutine __ANON__: not called CC=1 SCAR=0.0
121 } else {
122 19 return ($abs_x, $abs_y);
123 }
124 }
125
126 2 ▶sub clear_screen {
Subroutine clear_screen: called CC=1 SCAR=0.0
Pod undocumented
127 # do nothing
128 }
129
130 4 ▶sub set_window {
Subroutine set_window: called CC=1 SCAR=0.0
Pod undocumented
131 4 my ($self, $window) = @_;
132 4 $self->SUPER::set_window($window);
133 }
134
135 0 ▶sub erase_chars {
Subroutine erase_chars: not called CC=1 SCAR=0.0
Pod undocumented
136 # do nothing
137 }
138
139 1 1;
« ZText.pm ↑ Summary ZObjectStatus.pm »