Journal(2005) | Blog(2006) | RandomLink | WhoAmI | LiveBookmark | HomePage

<<Previous: Yap, I recieved a book  >>Next: Share the URLs with u (Mar. 2005)

Day [05.3.29] POD && Pugs

Category: Diary   Keywords: pod pugs

Hoowa 说 Perl::Pugs 项目要 port 些 Perl 5 模块到 Pugs 上,叫我起个头。真是为难死我了。
他给我找了个纯 Perl 模块 Digest::Perl::MD5 让我试着移植。

Digest::Perl::MD5 里有段 __DATA__ 我不知道到 Perl 6 中咋变化,于是翻阅了下 Synopsis 2: Atom. 里面倒是说了用 =begin DATA 写入和用 (%|@|$)=DATA 来获取。
在 Pugs 里试了一下,发现还没实现。于是想着先给 pugs 写个 t 测试文件。因为 Synopsis 2 里我看不太懂,就想着去找点资料。Google Search 了下,找到些资料:

这一看不打紧那,可把我给弄糊涂了。
第一个是对 Pod 的建议改革。The Predefined POD Streams are C, C, and C. 个人觉得说得挺不错的。
第二帖因为不完整,所以在新闻组 perl.perl6.language 里搜索了下。发现这是个很长的帖子:A more extensible/flexible POD (ROUGH-DRAFT). 里面有 Pod vs Kwid, 个人觉得 Kwid 很棒。

我不打算把这个 t 文件传到 pugs 里了。一是因为还不完整,只有测试了一部分 @=DATA, 二是我也不知道 Pod 在 Perl 6 中到底是如何。
把这个 t 文件列于下:


#!/usr/bin/pugs

use v6;
require Test;

plan 6;

# L<S02/"Literals">
# L<S02/"Molecules" /Multiline comments/>

todo_eval_ok '
=begin DATA LABEL1
LABEL1.1
LABEL1.2
LABEL1.3
=end DATA

=begin DATA LABEL2
LABEL2.1
LABEL2.2
=end DATA
', "=begin DATA works";

todo_eval_is('%=DATA<LABEL1>[0]', 'LABEL1.1', '@=DATA<LABEL1>[0] is correct');
todo_eval_is('%=DATA<LABEL1>[2]', 'LABEL1.3', '@=DATA<LABEL1>[2] is correct');
todo_eval_is('~ %=DATA<LABEL1>', 'LABEL1.1LABEL1.2LABEL1.3', '~ %=DATA<LABEL1> is correct');

todo_eval_is('~ $=LABEL2', 'LABEL2.1LABEL2.2', '~ $=LABEL2 is correct');
todo_eval_is('$=LABEL2[1]', 'LABEL2.2', '$=LABEL2[1] is correct');
最后还发现我以前写的部分关于 x= 的测试可以运行了。 Pugs 发展得够快的。
# test x=
my $twin = 'Lintilla';
ok(eval '$twin x= 2;', 'operator x= for string works');
is ($twin, 'LintillaLintilla', 'operator x= for string repeats correct');

my @array = (4, 2);
ok(eval '@array xx= 2;', 'operator xx= for list works');
is (@array[0], 4, 'operator xx= for list repeats correct');
is (@array[3], 2, 'operator xx= for list repeats correct');
is (+@array, 4, 'operator xx= for list created the right size');

<<Previous: Yap, I recieved a book  >>Next: Share the URLs with u (Mar. 2005)

Options: +Del.icio.us

Related items Created on 2005-03-29 16:04:20, Last modified on 2005-04-24 22:21:06
Copyright 2004-2005 All Rights Reserved. Powered by Eplanet && Catalyst 5.62.