File: 2.t

package info (click to toggle)
libtext-context-perl 3.7-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 96 kB
  • sloc: perl: 167; makefile: 2
file content (134 lines) | stat: -rw-r--r-- 3,428 bytes parent folder | download | duplicates (4)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
use strict;
use warnings;

use Test::More tests => 9;
use Text::Context;

undef $/; my $text = <DATA>;

{
my $snippet = Text::Context->new($text);
isa_ok($snippet, "Text::Context");

$snippet->keywords(qw(Wadler XQuery));
is(join (" ", $snippet->keywords), "wadler xquery", 
    "Keywords can be set (and are l/c'ed)");
}

{
my $snippet = Text::Context->new($text, "Wadler", "XQuery");
isa_ok($snippet, "Text::Context");
is(
    join (" ", $snippet->keywords),
    "wadler xquery",
    "Keywords can be set in constructor and retrieved (and are l/c'ed)"
);
}

{
my $snippet = Text::Context->new($text, "Wadler", "XQuery");

my $expected = 
    "... quoting Phil Wadler, who recently ... "
        . "lecture about XQuery said that ...";
is($snippet->as_text, $expected, "...and the text is correct");
}

my $snippet = Text::Context->new($text, "Wadler", "XQuery");

my $expected =
    "... quoting Phil <B>Wadler</B>, who recently ... "
    . "lecture about <B>XQuery</B> said that ...";

is($snippet->as_html(start => "<B>", end => "</B>"),
    $expected, "as_html can take custom delimiters");

$expected =~ s/<B>/<span class="quoted">/g;
$expected =~ s/<\/B>/<\/span>/g;

is($snippet->as_html(), $expected,
    "as_html uses span as default delimiters");

{
my $snippet = Text::Context->new($text, "functional language");

is($snippet->as_text, 
'... XSLT is considered to be a functional language by experts in > this > ...',
"and the text is correct",
);
$snippet = Text::Context->new($text, "functional language");
$snippet->keywords("functional", "language");
is($snippet->as_text, 
'... XSLT is considered to be a functional language by experts in > this > ...',
"and the text is correct",
);
}

1;

__DATA__

--- bryan wrote:
> 
> >While XSLT is considered to be a functional language by experts in
> this 
> >field, it is definitely not a very nice representative of this class
> of 
> >programming languages. 
> 
> OOOOH that's a baaad thing you said. :) 

I'm just quoting Phil Wadler, who recently (at the School of Advanced
FP in Oxford, England, August) in his lecture about XQuery said that
"XSLT is probably the most used functional language and the ugliest
one".


> 
> Anyway, it seems to me that you prefer Haskell out of the various
> functional languages, do you have a particular reason for this? I
> have
> problems with Haskell, I've tried and I've tried but it's frankly
> quite
> hard for me to follow programs written in Haskell once they get
> beyond
> a
> couple pages when printed, for functional languages I prefer Lisp and
> Erlang. Especially Erlang. 
> 
> So anyway what do you like especially about Haskell? 


Strong typing, polymorphic types, type classes

Higher order functions

Huge expressiveness

Lazy evaluation + pattern matching

The (built-in support for the) very precise (monadic) approach to
encapsulating operations with side effects.


They even joke that once you have specified the types correctly, then
the solution just starts working... :o)  and in reality quite often
this is really the case.

But I'm not comparing Haskell to other languages, just saying that I
like it.



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list