r4984@merlin: jquelin | 2007-05-24 15:04:54 +0200
[acme-tie-eleet.git] / t / words.t
blobd0ae333b452bf3bf8364030e833e441d9177c012
1 #-*-perl-*-
3 # Words replacement.
6 #-----------------------------------#
7 #          Initialization.          #
8 #-----------------------------------#
10 # Modules we rely on.
11 use Test;
12 # use POSIX qw(tmpnam);
14 # Initialization.
15 # BEGIN { plan tests => 6 };
16 BEGIN { plan tests => 3 };
18 # Our stuff.
19 require Acme::Tie::Eleet;
20 # untie *STDIN;
21 # untie *STDOUT;
22 # untie *STDERR;
24 # Vars.
25 # my $file = tmpnam();
26 my $line;
27 my @opts =
28     ( letters    => 0,
29       spacer     => 0,
30       case_mixer => 0,
31       words      => 0,
32       add_before => 0,
33       add_after  => 0,
34       extra_sent => 0
38 #------------------------------#
39 #          TIEHANDLE.          #
40 #------------------------------#
42 # # No replacement.
43 # open OUT, ">$file" or die "Unable to create temporary file: $!";
44 # tie *OUT, 'Acme::Tie::Eleet', *OUT, @opts, words=>0;
45 # print OUT "sthg";
46 # untie *OUT;
47 # open IN, "<$file" or die "Unable to open temporary file: $!";
48 # $line = <IN>;
49 # ok($line, qr/^sthg/);
51 # # Word replacement.
52 # open OUT, ">$file" or die "Unable to create temporary file: $!";
53 # tie *OUT, 'Acme::Tie::Eleet', *OUT, @opts, words=>1;
54 # print OUT "hacker";
55 # untie *OUT;
56 # open IN, "<$file" or die "Unable to open temporary file: $!";
57 # $line = <IN>;
58 # ok($line, qr/^haxor/);
60 # # Word replacement with an anonymous array.
61 # open OUT, ">$file" or die "Unable to create temporary file: $!";
62 # tie *OUT, 'Acme::Tie::Eleet', *OUT, @opts, words=>1;
63 # print OUT "cool";
64 # untie *OUT;
65 # open IN, "<$file" or die "Unable to open temporary file: $!";
66 # $line = <IN>;
67 # ok($line, qr/^(kewl|kool)/);
69 # unlink $file;
72 #------------------------------#
73 #          TIESCALAR.          #
74 #------------------------------#
76 # No replacement.
77 tie $line, 'Acme::Tie::Eleet', @opts, words=>0;
78 $line = "sthg";
79 ok($line, qr/^sthg/);
80 untie $line;
82 # Word replacement.
83 tie $line, 'Acme::Tie::Eleet', @opts, words=>1;
84 $line = "hacker";
85 ok($line, qr/^haxor/);
86 untie $line;
88 # Word replacement with an anonymous array.
89 tie $line, 'Acme::Tie::Eleet', @opts, words=>1;
90 $line = "cool";
91 ok($line, qr/^(kewl|kool)/);
92 untie $line;