Skip to content
This repository
Newer
Older
100644 141 lines (98 sloc) 3.887 kb
b38c8aa8 » bschmalhofer
2005-03-04 Some fiddling with test suite:
1 # Copyright: 2001-2005 The Perl Foundation. All Rights Reserved.
9d8cce43 » Michael Scott
2004-02-28 a bit more tidying up
2 # $Id$
9b4e5d00 » Dan Sugalski
2002-08-27 Fixups to make parrotcode.org's autogenerated pages happier
3
9d8cce43 » Michael Scott
2004-02-28 a bit more tidying up
4 =head1 NAME
5
6 docs/tests.pod - Testing Parrot
8c4a44c5 » quidity
2001-11-07 This is a basic quide to writing tests with assembler.
7
8 =head1 A basic guide to writing tests for Parrot
9
05a7e7bd » bschmalhofer
2005-09-07 This patch is huge because of all the whitespace reformatting. This was
10 This is quick and dirty pointer to how tests for Parrot should be written. The
11 testing system is liable to change in the future, but tests written following
12 the guidelines below should be easy to port into a new test suite.
8c4a44c5 » quidity
2001-11-07 This is a basic quide to writing tests with assembler.
13
1acea255 » Leopold Toetsch
2004-02-26 update info on pir tests in main; don't generate packfile-perl.pod
14 =head1 How to write a test
15
05a7e7bd » bschmalhofer
2005-09-07 This patch is huge because of all the whitespace reformatting. This was
16 New tests should be added to F<*.t> files. These test files can be found in the
17 directories F<t>, F<imcc/t> and F<languages/*/t>. If a new feature is tested,
a754c8cd » bschmalhofer
2005-04-06 Mention 'pir_output_is', 'language_output_is' and TODO in docs/tests.…
18 it might also make sense to create a new F<*.t> file.
8c4a44c5 » quidity
2001-11-07 This is a basic quide to writing tests with assembler.
19
05a7e7bd » bschmalhofer
2005-09-07 This patch is huge because of all the whitespace reformatting. This was
20 The testing framework needs to know how many tests it should expect. So the
21 number of planned tests needs to be incremented when adding a new test. This
22 is done near the top of a test file, in a line that looks like:
553e254a » Nicholas Clark
2002-03-19 Patch from Simon Glover <scog@amnh.org>:
23
24 use Parrot::Test tests => 8;
25
a754c8cd » bschmalhofer
2005-04-06 Mention 'pir_output_is', 'language_output_is' and TODO in docs/tests.…
26 =head2 Parrot Assembler
c543d6fa » boemmels
2003-09-30 Add C test info to tests.pod (Courtesy of Michael Scott <michael_scot…
27
05a7e7bd » bschmalhofer
2005-09-07 This patch is huge because of all the whitespace reformatting. This was
28 PASM test are mostly used for testing ops. Appropriate test files for basic
29 ops are F<t/op/*.t>. Perl Magic Cookies are tested in F<t/pmc/*.t>. Add the
30 new test like this:
c543d6fa » boemmels
2003-09-30 Add C test info to tests.pod (Courtesy of Michael Scott <michael_scot…
31
b38c8aa8 » bschmalhofer
2005-03-04 Some fiddling with test suite:
32 pasm_output_is(<<'CODE', <<'OUTPUT', "name for test");
c543d6fa » boemmels
2003-09-30 Add C test info to tests.pod (Courtesy of Michael Scott <michael_scot…
33 *** a big chunk of assembler, eg:
34 print 1
35 print "\n" # you can even comment it if it's obscure
36 end # don't forget this...!
37 CODE
38 *** what you expect the output of the chunk to be, eg.
39 1
40 OUTPUT
41
a754c8cd » bschmalhofer
2005-04-06 Mention 'pir_output_is', 'language_output_is' and TODO in docs/tests.…
42 =head2 Parrot Intermediate Representation
43
05a7e7bd » bschmalhofer
2005-09-07 This patch is huge because of all the whitespace reformatting. This was
44 Tests can also be written in B<PIR>. This is done with C<pir_output_is> and
45 friends.
a754c8cd » bschmalhofer
2005-04-06 Mention 'pir_output_is', 'language_output_is' and TODO in docs/tests.…
46
47 pir_output_is(<<'CODE',<<'OUT','nothing useful');
48 .include 'library/config.imc'
49
50 .sub main @MAIN
51 print "hi\n"
52 .end
53 CODE
54 hi
55 OUT
1acea255 » Leopold Toetsch
2004-02-26 update info on pir tests in main; don't generate packfile-perl.pod
56
57 =head2 C source tests
c543d6fa » boemmels
2003-09-30 Add C test info to tests.pod (Courtesy of Michael Scott <michael_scot…
58
ea0630c1 » jhoblitt
2005-10-05 reformat all Pod files under docs with podtidy (modified to also remo…
59 C source tests are usually located in F<t/src/*.t>. A simple test looks like:
280b750b » jhoblitt
2005-10-05 fix verbatim block in docs/tests.pod
60
c543d6fa » boemmels
2003-09-30 Add C test info to tests.pod (Courtesy of Michael Scott <michael_scot…
61 c_output_is(<<'CODE', <<'OUTPUT', "name for test");
62 #include <stdio.h>
63 #include "parrot/parrot.h"
64 #include "parrot/embed.h"
58c0aa8c » Leopold Toetsch
2004-02-26 update info on src tests
65
66 static opcode_t *the_test(Parrot_Interp, opcode_t *, opcode_t *);
67
c543d6fa » boemmels
2003-09-30 Add C test info to tests.pod (Courtesy of Michael Scott <michael_scot…
68 int main(int argc, char* argv[]) {
58c0aa8c » Leopold Toetsch
2004-02-26 update info on src tests
69 Parrot_Interp interpreter;
01f4e37a » Jens Rieks
2004-09-16 Updated doc and some code to reflect new Parrot_new() interface
70 interpreter = Parrot_new(NULL);
c543d6fa » boemmels
2003-09-30 Add C test info to tests.pod (Courtesy of Michael Scott <michael_scot…
71
58c0aa8c » Leopold Toetsch
2004-02-26 update info on src tests
72 if (!interpreter)
9d8cce43 » Michael Scott
2004-02-28 a bit more tidying up
73 return 1;
58c0aa8c » Leopold Toetsch
2004-02-26 update info on src tests
74
c543d6fa » boemmels
2003-09-30 Add C test info to tests.pod (Courtesy of Michael Scott <michael_scot…
75 Parrot_init(interpreter);
58c0aa8c » Leopold Toetsch
2004-02-26 update info on src tests
76 Parrot_run_native(interpreter, the_test);
c543d6fa » boemmels
2003-09-30 Add C test info to tests.pod (Courtesy of Michael Scott <michael_scot…
77 printf("done\n");
9d8cce43 » Michael Scott
2004-02-28 a bit more tidying up
78 fflush(stdout);
c543d6fa » boemmels
2003-09-30 Add C test info to tests.pod (Courtesy of Michael Scott <michael_scot…
79 return 0;
80 }
58c0aa8c » Leopold Toetsch
2004-02-26 update info on src tests
81
82 static opcode_t*
83 the_test(Parrot_Interp interpreter,
9d8cce43 » Michael Scott
2004-02-28 a bit more tidying up
84 opcode_t *cur_op, opcode_t *start)
58c0aa8c » Leopold Toetsch
2004-02-26 update info on src tests
85 {
86 /* Your test goes here. */
87
88 return NULL; /* always return NULL */
89 }
c543d6fa » boemmels
2003-09-30 Add C test info to tests.pod (Courtesy of Michael Scott <michael_scot…
90 CODE
91 # Anything that might be output prior to "done".
92 done
93 OUTPUT
94
a754c8cd » bschmalhofer
2005-04-06 Mention 'pir_output_is', 'language_output_is' and TODO in docs/tests.…
95 Note that it's always a good idea to output "done" to confirm that the compiled
05a7e7bd » bschmalhofer
2005-09-07 This patch is huge because of all the whitespace reformatting. This was
96 code executed completely. When mixing C<printf> and C<PIO_printf> always append
97 a C<fflush(stdout);> after the former.
8c4a44c5 » quidity
2001-11-07 This is a basic quide to writing tests with assembler.
98
a754c8cd » bschmalhofer
2005-04-06 Mention 'pir_output_is', 'language_output_is' and TODO in docs/tests.…
99 =head2 Testing language implementations
100
05a7e7bd » bschmalhofer
2005-09-07 This patch is huge because of all the whitespace reformatting. This was
101 Language implementations are usually tested with the test function
a754c8cd » bschmalhofer
2005-04-06 Mention 'pir_output_is', 'language_output_is' and TODO in docs/tests.…
102 C<language_output_is>.
103
1acea255 » Leopold Toetsch
2004-02-26 update info on pir tests in main; don't generate packfile-perl.pod
104 =head1 Ideal tests:
8c4a44c5 » quidity
2001-11-07 This is a basic quide to writing tests with assembler.
105
106 =over 4
107
108 =item o
109
05a7e7bd » bschmalhofer
2005-09-07 This patch is huge because of all the whitespace reformatting. This was
110 Probe the boundaries (including edge cases, errors thrown etc.) of whatever
111 code they're testing. These should include potentially out of band input
112 unless we decide that compilers should check for this themselves.
8c4a44c5 » quidity
2001-11-07 This is a basic quide to writing tests with assembler.
113
114 =item o
115
05a7e7bd » bschmalhofer
2005-09-07 This patch is huge because of all the whitespace reformatting. This was
116 Are small and self contained, so that if the tested feature breaks we can
117 identify where and why quickly.
8c4a44c5 » quidity
2001-11-07 This is a basic quide to writing tests with assembler.
118
119 =item o
120
19b32a9c » Simon Glover
2003-05-14 Minor edits
121 Are valid. Essentially, they should conform to the additional documentation
05a7e7bd » bschmalhofer
2005-09-07 This patch is huge because of all the whitespace reformatting. This was
122 that accompanies the feature (if any). [If there isn't any documentation, then
123 feel free to add some and/or complain to the mailing list].
8c4a44c5 » quidity
2001-11-07 This is a basic quide to writing tests with assembler.
124
125 =item o
126
127 Are a chunk of assembler and a chunk of expected output.
128
9b4e5d00 » Dan Sugalski
2002-08-27 Fixups to make parrotcode.org's autogenerated pages happier
129 =back
a754c8cd » bschmalhofer
2005-04-06 Mention 'pir_output_is', 'language_output_is' and TODO in docs/tests.…
130
131 =head1 TODO tests
132
05a7e7bd » bschmalhofer
2005-09-07 This patch is huge because of all the whitespace reformatting. This was
133 In test driven development, tests are implemented first. So the tests are
134 initially expected to fail. This can be expressed by marking the tests as
135 TODO. See L<Test::More> on how to do that.
a754c8cd » bschmalhofer
2005-04-06 Mention 'pir_output_is', 'language_output_is' and TODO in docs/tests.…
136
137 =head1 SEE ALSO
138
139 L<http://qa.perl.org>
140
141 =cut
Something went wrong with that request. Please try again.