File: single.t

package info (click to toggle)
libio-prompter-perl 0.003000-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 332 kB
  • sloc: perl: 1,176; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 653 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use 5.010;
use warnings;
use Test::More 'no_plan';

use IO::Prompter;

local *ARGV;
open *ARGV, '<', \<<END_INPUT or die $!;
a Line 1
b Line 2
c Line 3
END_INPUT

if (prompt -single, "Enter line 1") {
    is $_, 'a'  => 'First character retrieved';
}
else {
    fail 'First line retrieved'; 
}

$_ = 'UNDERBAR';
if (my $input = prompt -1, "Enter character 2") {
    is $input, 'b'        => 'Second character retrieved';
    is $_,     'UNDERBAR' => 'Second line left $_ alone'
}
else {
    fail 'Second line retrieved'; 
}

if (prompt -s_, "Enter line 1") {
    is $_, 'c'  => 'First character retrieved';
}
else {
    fail 'First line retrieved'; 
}