File: 02_editor.t

package info (click to toggle)
libproc-invokeeditor-perl 1.02-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny, squeeze
  • size: 88 kB
  • ctags: 13
  • sloc: perl: 216; makefile: 38
file content (45 lines) | stat: -rw-r--r-- 1,427 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
37
38
39
40
41
42
43
44
45
#!/usr/local/bin/perl -w

use strict;
use Proc::InvokeEditor;
use Test::More tests => 8;

# create a new object?
my $e = new Proc::InvokeEditor;
ok(defined($e), 'Object created');
is(ref($e), 'Proc::InvokeEditor', 'Object type correct');

# set and get editors
$e->editors(['vi', 'emacs', 'ed']);
my $editors = $e->editors;
ok(eq_array($editors, ['vi', 'emacs', 'ed']), 'can set editors');

# set and get cleanup
$e->cleanup(1);
my $cleanup = $e->cleanup;
is($cleanup, 1, 'Cleanup can be set');

# prepend something to editors, see if it works
$e->editors_prepend(['vim']);
$editors = $e->editors;
ok(eq_array($editors, ['vim', 'vi', 'emacs', 'ed']), 'can prepend');

# can prepend env
$ENV{FOO} = 'x';
$ENV{BAR} = 'y';
$e->editors_env(['FOO', 'BAR']);
$editors = $e->editors;
ok(eq_array($editors, ['x', 'y', 'vim', 'vi', 'emacs', 'ed']), 'can env prepend');

# can we find any first usable editor?
my $f = Proc::InvokeEditor->first_usable;
ok(defined $f, 'first usable editor was defined');
is(ref($f), 'ARRAY', 'usable editor was an array');

#my $templ = "PLEASE SAVE THIS FILE WITHOUT CHANGES\n";
#my $edited_text = Proc::InvokeEditor->edit($templ);
#is($edited_text, $templ, "template saved unchanged successfully");
#my @templ_lines = ("PLEASE SAVE THIS", "WITH NO CHANGES");
#my @edit_lines = Proc::InvokeEditor->edit(\@templ_lines);
#ok(eq_array(\@templ_lines, \@edit_lines), 'array template saved unchanged fine');
#