root/t/deprecated-syntax.pod

Revision 22701, 3.3 kB (checked in by moritz, 4 weeks ago)

[t] move instance.t to spec/, some small updates.
Also updated deprecated-syntax.pod

  • Property svn:mime-type set to text/plain; charset=UTF-8
  • Property svn:eol-style set to native
Line 
1=head1 NAME
2
3Deprecated Syntax
4
5=head1 SYNOPSIS
6
7This document tries summarized common mistakes in the test suite. If you
8help refactoring the suite, or write new tests, read this document first.
9
10=head1 DEPRECATED SYNTAX
11
12=head2 Old POD
13
14Old POD looks like this:
15
16    =head1 heading
17    ...
18    =cut
19
20The new POD looks like this:
21
22    =begin stuff
23    ...
24    =end stuff
25
26All new files, and all below C<t/spec/> should follow the new conventions.
27
28=head2 Array indexes with negative numbers
29
30The Perl 5 style negative array indexes C<@array[-1]> are spelled
31C<@array[*-1]> in Perl 6.
32
33=head2 pos()
34
35C<pos> is dead. C<$/.to> is the replacement.
36
37=head2 length()
38
39C<length> is gone. Hashes should use C<keys>, C<values>, or the hash in numeric
40context. For arrays, you want C<elems> or the array in numeric context. For
41strings, you want one of C<chars>, C<graphs>, C<codes>, or C<bytes>.
42
43=head2 try takes a statement
44
45C<try> is followed by a statement, so
46
47  is try { $operation }, 'foo', '$operation worked'
48
49is parsed as
50 
51  is try( { $operation }, 'foo', '$operation worked')
52
53which means only one argument to C<is()>, but three to C<try>. So don't use
54this if it's not what you want. This is wrongly used in the test suite right
55now in multiple places.
56
57=head2 Interpolation in test descritions
58
59    lives_ok({ $a := $b }, "can bind $b to $a";
60
61is certainly not what you want; remeber that variables in double quoted
62strings are interpolated, and use single quotes as string delimiters where
63appropriate.
64
65=head2 Special Pugs variables
66
67Some tests rely on C<$?PUGS_BACKEND> and similar variables. Since they are not
68specced, they cause failures on other implementations. Either remove these
69variables alltogether, or fudge them by prepending C<#?pugs emit> on every
70such line.
71
72=head2 "my" in pointy block signatures
73
74C<<for @list -> my $x >> is wrong, no need for a C<my> here. The current test
75suite seems clear of that error.
76
77=head2 dies_ok for tests that can fail at compile time
78
79C<dies_ok> should only be used for tests that have to fail at run time. For
80example non-existant subs are no such case. Always bare in mind that a clever
81compiler might do some type inference and prove that there always will be an
82error, and throw it at compile time.
83
84If in doubt, use C<eval_dies_ok> instead. If you have a case where C<dies_ok>
85is fine, remeber to pass a code ref to it.
86
87=head2 .perl isn't canonical
88
89The C<perl> method (which does roughly the same as perl 5's Data::Dumper)
90returns a string that, when evaluated, returns the same value as the original
91one.
92
93However it's result isn't guarantued to be of any canonical form, for example
94C<Str.perl> might return any legal quoting syntax. Testing for the exact value
95of C<$anything.perl> is most likely an error
96
97=head2 Junctions are unordered
98
99Junctions are unordered assemblies, and C<Junction.values> returns these
100values in an arbitrary order, just like C<keys %hash> and the like. Don't rely
101on that order.
102
103=head2 A note on :todo<bug> and similar
104
105Some tests (mostly outside of t/spec) look like this:
106
107    is(foo(), bar(), 'testing whatever', :todo<bug>);
108
109This form is a todo note for Pugs. Since this test suite is used by multiple
110implementations, this should be replaced with a fudge command:
111
112    #?pugs todo 'bug'
113    is(foo(), bar(), 'testing whatever');
114
115=cut
Note: See TracBrowser for help on using the browser.