/
koan.t
95 lines (84 loc) · 1.88 KB
/
koan.t
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
#!/usr/bin/perl
use strict;
use warnings;
use Test::More qw(no_plan);
use FindBin;
use lib "$FindBin::Bin/../lib";
BEGIN {
use_ok "Zen::Koan";
}
Create_Koan: {
my $k = Zen::Koan->new( title => 'foo', body => 'bar' );
isa_ok $k, 'Zen::Koan';
is $k->title, 'foo';
is $k->body, 'bar';
is $k->as_html, <<EOT;
<div id='koan_title'>foo</div>
<div id='koan_body'>
<p>bar</p>
</div>
EOT
}
Create_by_hashref: {
my $k = Zen::Koan->new( { title => 'foo' } );
isa_ok $k, 'Zen::Koan';
is $k->title, 'foo';
}
Multi_paragraph_koan: {
my $body = "this\nand that\n\nand others.\n";
my $k = Zen::Koan->new( title => 'foo',
body => $body,
);
isa_ok $k, 'Zen::Koan';
is $k->title, 'foo';
is $k->body, $body;
is $k->as_html, <<EOT;
<div id='koan_title'>foo</div>
<div id='koan_body'>
<p>this</p>
<p>and that</p>
<p>and others.</p>
</div>
EOT
}
sub poem_koan { Zen::Koan->new( body => <<EOK ) }
Here is my poem:
No more water in the pail!
No more moon in the water!
That is my poem.
EOK
Koan_with_poem: {
my $k = poem_koan();
is $k->as_html, <<EOK;
<div id='koan_title'>A koan by no other name</div>
<div id='koan_body'>
<p>Here is my poem:</p>
<blockquote>
<p>No more water in the pail!</p>
<p>No more moon in the water!</p>
</blockquote>
<p>That is my poem.</p>
</div>
EOK
}
Koan_as_text: {
my $k = poem_koan();
is $k->as_text, <<EOK;
A koan by no other name
Here is my poem:
No more water in the pail!
No more moon in the water!
That is my poem.
EOK
}
Less_specified_koans: {
my $k = Zen::Koan->new;
isa_ok $k, 'Zen::Koan';
is $k->title, 'A koan by no other name';
is $k->body, 'This koan offers little wisdom. It just is.';
}
Other_functions: {
my $k = Zen::Koan->new;
isa_ok $k, 'Zen::Koan';
like $k->underlying_meaning, qr#You are expecting too much#;
}