/[suikacvs]/messaging/manakai/t/util-formatter-base.t
Suika

Contents of /messaging/manakai/t/util-formatter-base.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations) (download) (as text)
Fri Sep 21 08:11:38 2007 UTC (17 years, 7 months ago) by wakaba
Branch: MAIN
CVS Tags: manakai-release-0-4-0, HEAD
Changes since 1.5: +3 -0 lines
File MIME type: application/x-troff
++ manakai/bin/ChangeLog	21 Sep 2007 07:55:21 -0000
2007-09-21  Wakaba  <wakaba@suika.fam.cx>

	* daf.pl, mkdisdump.pl, grep-dis.pl, mkdommemlist.pl: Removed.

++ manakai/lib/Message/IMT/ChangeLog	21 Sep 2007 08:02:20 -0000
2007-09-21  Wakaba  <wakaba@suika.fam.cx>

	* InternetMediaType.pm: Don't raise CoreException even if
	a read-only attribute is attempted to be modified.

++ manakai/lib/Message/Markup/ChangeLog	21 Sep 2007 07:46:59 -0000
2007-09-21  Wakaba  <wakaba@suika.fam.cx>

	* SuikaWikiConfig21.dis, SuikaWikiConfig21.pm, common.dis,
	H2H.dis: Removed.

++ manakai/lib/Message/Util/ChangeLog	21 Sep 2007 07:44:10 -0000
2007-09-21  Wakaba  <wakaba@suika.fam.cx>

	* Makefile (clean): Don't remove generated files.

	* ManakaiNode.dis, ManakaiNodeTest.dis, PerlCode.dis,
	PerlCode.pm, ManakaiNode.pm, common.dis, DIS.dis, DIS.pm: Removed.

	* DIS/, AutoLoad/: Removed.

++ manakai/lib/Message/Util/Error/ChangeLog	21 Sep 2007 07:44:55 -0000
2007-09-21  Wakaba  <wakaba@suika.fam.cx>

	* Core.dis, DOMException.pm, DOMException.dis: Removed.

++ manakai/lib/Message/Util/Formatter/ChangeLog	21 Sep 2007 08:09:07 -0000
2007-09-21  Wakaba  <wakaba@suika.fam.cx>

	* Base.pm (___error_def): Error description key names
	are updated.

	* Muf2003.dis: Removed.

++ manakai/lib/manakai/ChangeLog	21 Sep 2007 07:52:20 -0000
2007-09-21  Wakaba  <wakaba@suika.fam.cx>

	* DISLang.dis, Document.dis, NaturalLanguage.dis, DISMarkup.dis,
	ECMAScript.dis, Test.dis, Charset.dis, DISPerl.dis, Java.dis,
	XML.dis, DISCore.dis, DISRDF.dis, DISIDL.dis, DISSource.dis,
	Message.dis, daf-perl-t.pl, daf-dtd-modules.pl, daf-perl-pm.pl,
	dis-catalog, mndebug.pl: Removed.

++ manakai/t/ChangeLog	21 Sep 2007 08:00:31 -0000
2007-09-21  Wakaba  <wakaba@suika.fam.cx>

	* util-mnode.t: Removed.

1 #!/usr/bin/perl
2 use Message::Util::Formatter::Base;
3 use Test::Simple tests => 10;
4
5 sub OK ($$) {
6 ok $_[0] eq $_[1], $_[0] eq $_[1] ? undef : qq("$_[0]" ("$_[1]" expected));
7 }
8
9 my $f = Message::Util::Formatter::Base->new
10 (rule => {
11 bar => {
12 pre => sub {
13 my ($f, $name, $p, $o) = @_;
14 $p->{-result} = '<:bar:>';
15 },
16 post => sub {
17 my ($f, $name, $p, $o) = @_;
18 $p->{-result} .= '</:bar:>';
19 },
20 },
21 -default => {
22 pre => sub {
23 my ($f, $name, $p, $o) = @_;
24 $p->{-result} = "<$name>";
25 },
26 post => sub {
27 my ($f, $name, $p, $o) = @_;
28 $p->{-result} .= "</$name>";
29 },
30 attr => sub {
31 my ($f, $name, $p, $o, $key => $val, %opt) = @_;
32 $key = "$key\[$opt{-name_flag}]" if $opt{-name_flag};
33 $val = "$val\[$opt{-value_flag}]" if $opt{-value_flag};
34 $p->{-result} .= "{$key=$val}";
35 },
36 },
37 -entire => {
38 pre => sub {
39 my ($f, $name, $p, $o) = @_;
40 $p->{-result} = '<<';
41 },
42 post => sub {
43 my ($f, $name, $p, $o) = @_;
44 $p->{-result} .= '>>';
45 },
46 attr => sub {
47 my ($f, $name, $p, $o, $key => $val) = @_;
48 $p->{-result} .= "[[$key:$val->{-result}]]";
49 },
50 },
51 });
52
53 OK $f->replace ("foo%bar;%baz;foo&% % \n%% foo"), qq<<<[[-bare_text:<-bare_text>{-bare_text=foo}</-bare_text>]][[bar:<:bar:></:bar:>]][[baz:<baz></baz>]][[-bare_text:<-bare_text>{-bare_text=foo&% % \n%% foo}</-bare_text>]]>>>;
54
55 OK $f->replace (q(%foo({attr3}=>{value3});)),
56 q<<<[[foo:<foo>{attr3=value3}</foo>]]>>>;
57
58 OK $f->replace (q(%foo(attr1=>value1,"attr2"=>"value2",{attr3}=>{value3});)),
59 q<<<[[foo:<foo>{attr1=value1}{attr2=value2}{attr3=value3}</foo>]]>>>;
60
61 OK $f->replace (q(%foo(attr1,"\\\\attr\2"=>"\\\\value\2");)),
62 q<<<[[foo:<foo>{-boolean=attr1}{\\attr2=\\value2}</foo>]]>>>;
63
64 OK $f->replace (q(%foo({{attr{1}}}=>{{value{1}}});)),
65 q<<<[[foo:<foo>{{attr{1}}={value{1}}}</foo>]]>>>;
66
67 OK $f->replace (q(%foo
68 ( , attr1 => value1
69 , ,) ;)),
70 q<<<[[foo:<foo>{attr1=value1}</foo>]]>>>;
71
72 OK $f->replace (q(%foo({{attr{1}}} flag =>{{value{1}}} flag);)),
73 q<<<[[foo:<foo>{{attr{1}}[flag]={value{1}}[flag]}</foo>]]>>>;
74
75 use Message::Util::Error;
76 try {
77 $f->replace (q(%invalid));
78 OK 0, 1;
79 } catch Message::Util::Formatter::Base::error with {
80 my $err = shift;
81 OK $err->text, qq(Semicolon (";") expected at "%invalid"**here**"<empty>");
82 };
83
84 try {
85 $f->replace (q(Something, Something%invalid! Syntax error! Syntax error!));
86 OK 0, 2;
87 } catch Message::Util::Formatter::Base::error with {
88 my $err = shift;
89 OK $err->text, q(Semicolon (";") expected at "g, Something%invalid"**here**"! Syntax error! Synt");
90 };
91
92 try {
93 $f->replace (q(%invalid(a=>b!);));
94 OK 0, 3;
95 } catch Message::Util::Formatter::error with {
96 my $err = shift;
97 OK $err->text, q[Separator ("," or ")") expected at "%invalid(a=>b"**here**"!);"];
98 };

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24