[plt-scheme] How to organize automated tests

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Mon May 25 19:53:35 EDT 2009

Hi Luciano,

The problem is that "include" includes the entire file, rather than
accessing the identifiers it provides. If instead, you "require" the
file, then your current configuration should work, other than
specifying a #lang at the top of test file. Here's an example:

batman.ss:
#lang planet plai/plai
(define x 5)

batman-tests.ss:
#lang planet plai/plai
(require "batman.ss")

(test x 5)

The PLAI language automatically puts (provide (all-defined-out)) in
your file, so all the definitions are available in batman-tests.

Jay

On Mon, May 25, 2009 at 7:05 PM, Luciano Ramalho <luciano at ramalho.org> wrote:
> Hello, I am an experienced Python programmer just learning Scheme
> while take a Programming Languages class using Prof. Krishnamurthi's
> book, "Programming Languages: Application and Interpretation".
>
> I'm using the PLAI Scheme extensions, which include a testing framework.
>
> I'd like to separate my tests from the main code I'm working on, but
> I've not found a good way to do it.
>
> What I'd like to have is two files, the main source code, say
> "myapp.scm" and tests in "myapp-tests.scm".
>
> I don't want any reference to tests in myapp.scm, so myapp-tests.scm
> starts with (include "myapp.scm"), and goes on to define and run the
> tests.
>
> This works, but there is a major nuisance: because DrScheme magically
> add that #reader line to any file it saves, I am forced to edit
> myapp.scm in an external editor, otherwise the #reader line generates
> an error when I do the include: "module: illegal use (not at
> top-level)".
>
> I am sure there's a better way of organizing my source code and tests.
> Can you point me in the right direction, perhaps recommend some
> documentation or suggest a better way arrange my code in DrScheme?
>
> Thanks for creating such a great learning environment!
>
> Cheers,
>
> Luciano
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://teammccarthy.org/jay

"The glory of God is Intelligence" - D&C 93


Posted on the users mailing list.