Permalink
Browse files

Add C test info to tests.pod (Courtesy of Michael Scott <michael_scot…

…t@mac.com>)

git-svn-id: https://svn.parrot.org/parrot/trunk@4252 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent 662ac24 commit c543d6fa2d5ec1770571a5f4c349531d57646307 @boemmels boemmels committed Sep 30, 2003
Showing with 53 additions and 20 deletions.
  1. +53 −20 docs/tests.pod
View
73 docs/tests.pod
@@ -11,31 +11,64 @@ into a new test suite.
=head2 How to write a test
-First, find an appropriate file in F<t/op/*.t> (for basic ops) or
-F<t/pmc/*.t> (for anything to do with PMCs). If there isn't an
-appropriate file, create one.
+First, find an appropriate file in F<t/op/*.t> (for basic ops),
+F<t/pmc/*.t> (for anything to do with PMCs), and F<t/src/*.t> for C
+source code tests. If there isn't an appropriate file, create one.
Near the top of each file, you'll see a line like:
use Parrot::Test tests => 8;
-This sets up the test harness used to assemble and run the tests,
-and lets it know how many tests you plan to run. New tests should be
-added by:
-
- 1. Incrementing the number of planned tests.
-
- 2. Putting some code in like this:
-
- output_is(<<'CODE', <<'OUTPUT', "name for test");
- *** a big chunk of assembler, eg:
- print 1
- print "\n" # you can even comment it if it's obscure
- end # don't forget this...!
- CODE
- *** what you expect the output of the chunk to be, eg.
- 1
- OUTPUT
+This sets up the test harness used to assemble and run the tests, and
+lets it know how many tests you plan to run. New tests should be added
+by:
+
+1. Incrementing the number of planned tests.
+
+2. Putting some code in like this:
+
+ output_is(<<'CODE', <<'OUTPUT', "name for test");
+ *** a big chunk of assembler, eg:
+ print 1
+ print "\n" # you can even comment it if it's obscure
+ end # don't forget this...!
+ CODE
+ *** what you expect the output of the chunk to be, eg.
+ 1
+ OUTPUT
+
+or, if it is a C test, some code like this:
+
+ c_output_is(<<'CODE', <<'OUTPUT', "name for test");
+ #include <stdio.h>
+ #include "parrot/parrot.h"
+ #include "parrot/embed.h"
+
+ int do_test(Interp *interpreter);
+
+ int main(int argc, char* argv[]) {
+ Interp* interpreter;
+ interpreter = Parrot_new();
+
+ if ( interpreter == NULL ) return 1;
+ interpreter->lo_var_ptr = &interpreter;
+
+ Parrot_init(interpreter);
+ return do_test(interpreter);
+ }
+
+ int do_test(Interp *interpreter) {
+ /* Your test goes here. */
+ printf("done\n");
+ return 0;
+ }
+ CODE
+ # Anything that might be output prior to "done".
+ done
+ OUTPUT
+
+Note, it's always a good idea to output "done" to confirm that the
+compiled code executed completely.
=head2 Ideal tests:

0 comments on commit c543d6f

Please sign in to comment.