Skip to content
This repository
Newer
Older
100644 115 lines (81 sloc) 3.184 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
10 This is quick and dirty pointer to how tests for Parrot should be
11 written. The testing system is liable to change in the future, but
12 tests written following the guidelines below should be easy to port
13 into a new test suite.
14
1acea255 » Leopold Toetsch
2004-02-26 update info on pir tests in main; don't generate packfile-perl.pod
15 =head1 How to write a test
16
17 =head2 Assembler tests
8c4a44c5 » quidity
2001-11-07 This is a basic quide to writing tests with assembler.
18
c543d6fa » boemmels
2003-09-30 Add C test info to tests.pod (Courtesy of Michael Scott <michael_scot…
19 First, find an appropriate file in F<t/op/*.t> (for basic ops),
20 F<t/pmc/*.t> (for anything to do with PMCs), and F<t/src/*.t> for C
21 source code tests. If there isn't an appropriate file, create one.
8c4a44c5 » quidity
2001-11-07 This is a basic quide to writing tests with assembler.
22
553e254a » Nicholas Clark
2002-03-19 Patch from Simon Glover <scog@amnh.org>:
23 Near the top of each file, you'll see a line like:
24
25 use Parrot::Test tests => 8;
26
c543d6fa » boemmels
2003-09-30 Add C test info to tests.pod (Courtesy of Michael Scott <michael_scot…
27 This sets up the test harness used to assemble and run the tests, and
28 lets it know how many tests you plan to run. New tests should be added
29 by:
30
31 1. Incrementing the number of planned tests.
32
33 2. Putting some code in like this:
34
b38c8aa8 » bschmalhofer
2005-03-04 Some fiddling with test suite:
35 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…
36 *** a big chunk of assembler, eg:
37 print 1
38 print "\n" # you can even comment it if it's obscure
39 end # don't forget this...!
40 CODE
41 *** what you expect the output of the chunk to be, eg.
42 1
43 OUTPUT
44
1acea255 » Leopold Toetsch
2004-02-26 update info on pir tests in main; don't generate packfile-perl.pod
45 Tests in F<t/op/> or F<t/pmc/> are considered to be B<PASM> tests.
46 Tests in F<imcc/t/> are assumed to be B<PIR> tests. You can put B<PIR>
b38c8aa8 » bschmalhofer
2005-03-04 Some fiddling with test suite:
47 tests into F<t/op/> or F<t/pmc/> by using functions like 'pir_output_is'.
1acea255 » Leopold Toetsch
2004-02-26 update info on pir tests in main; don't generate packfile-perl.pod
48
49 =head2 C source tests
c543d6fa » boemmels
2003-09-30 Add C test info to tests.pod (Courtesy of Michael Scott <michael_scot…
50
51 c_output_is(<<'CODE', <<'OUTPUT', "name for test");
52 #include <stdio.h>
53 #include "parrot/parrot.h"
54 #include "parrot/embed.h"
58c0aa8c » Leopold Toetsch
2004-02-26 update info on src tests
55
56 static opcode_t *the_test(Parrot_Interp, opcode_t *, opcode_t *);
57
c543d6fa » boemmels
2003-09-30 Add C test info to tests.pod (Courtesy of Michael Scott <michael_scot…
58 int main(int argc, char* argv[]) {
58c0aa8c » Leopold Toetsch
2004-02-26 update info on src tests
59 Parrot_Interp interpreter;
01f4e37a » Jens Rieks
2004-09-16 Updated doc and some code to reflect new Parrot_new() interface
60 interpreter = Parrot_new(NULL);
c543d6fa » boemmels
2003-09-30 Add C test info to tests.pod (Courtesy of Michael Scott <michael_scot…
61
58c0aa8c » Leopold Toetsch
2004-02-26 update info on src tests
62 if (!interpreter)
9d8cce43 » Michael Scott
2004-02-28 a bit more tidying up
63 return 1;
58c0aa8c » Leopold Toetsch
2004-02-26 update info on src tests
64
c543d6fa » boemmels
2003-09-30 Add C test info to tests.pod (Courtesy of Michael Scott <michael_scot…
65 Parrot_init(interpreter);
58c0aa8c » Leopold Toetsch
2004-02-26 update info on src tests
66 Parrot_run_native(interpreter, the_test);
c543d6fa » boemmels
2003-09-30 Add C test info to tests.pod (Courtesy of Michael Scott <michael_scot…
67 printf("done\n");
9d8cce43 » Michael Scott
2004-02-28 a bit more tidying up
68 fflush(stdout);
c543d6fa » boemmels
2003-09-30 Add C test info to tests.pod (Courtesy of Michael Scott <michael_scot…
69 return 0;
70 }
58c0aa8c » Leopold Toetsch
2004-02-26 update info on src tests
71
72 static opcode_t*
73 the_test(Parrot_Interp interpreter,
9d8cce43 » Michael Scott
2004-02-28 a bit more tidying up
74 opcode_t *cur_op, opcode_t *start)
58c0aa8c » Leopold Toetsch
2004-02-26 update info on src tests
75 {
76 /* Your test goes here. */
77
78 return NULL; /* always return NULL */
79 }
c543d6fa » boemmels
2003-09-30 Add C test info to tests.pod (Courtesy of Michael Scott <michael_scot…
80 CODE
81 # Anything that might be output prior to "done".
82 done
83 OUTPUT
84
58c0aa8c » Leopold Toetsch
2004-02-26 update info on src tests
85 Note, it's always a good idea to output "done" to confirm that the compiled
86 code executed completely. When mixing C<printf> and C<PIO_printf> always
87 append a C<fflush(stdout);> after the former.
8c4a44c5 » quidity
2001-11-07 This is a basic quide to writing tests with assembler.
88
1acea255 » Leopold Toetsch
2004-02-26 update info on pir tests in main; don't generate packfile-perl.pod
89 =head1 Ideal tests:
8c4a44c5 » quidity
2001-11-07 This is a basic quide to writing tests with assembler.
90
91 =over 4
92
93 =item o
94
95 Probe the boundaries (including edge cases, errors thrown etc.) of
19b32a9c » Simon Glover
2003-05-14 Minor edits
96 whatever code they're testing. These should include potentially
8c4a44c5 » quidity
2001-11-07 This is a basic quide to writing tests with assembler.
97 out of band input unless we decide that compilers should check for this
98 themselves.
99
100 =item o
101
19b32a9c » Simon Glover
2003-05-14 Minor edits
102 Are small and self contained, so that if the tested feature breaks we
8c4a44c5 » quidity
2001-11-07 This is a basic quide to writing tests with assembler.
103 can identify where and why quickly.
104
105 =item o
106
19b32a9c » Simon Glover
2003-05-14 Minor edits
107 Are valid. Essentially, they should conform to the additional documentation
58c0aa8c » Leopold Toetsch
2004-02-26 update info on src tests
108 that accompanies the feature (if any). [If there isn't any documentation,
109 then 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.
110
111 =item o
112
113 Are a chunk of assembler and a chunk of expected output.
114
9b4e5d00 » Dan Sugalski
2002-08-27 Fixups to make parrotcode.org's autogenerated pages happier
115 =back
Something went wrong with that request. Please try again.