Scheme in BitterSuite has a relatively complex back-end, as it attempts to support a number of languages (the HtDP languages and PLT Scheme's module language), and attempts to make use of the scheme/sandbox library in a way that is both reasonably efficient and works with our testing system.
Also see BitterSuiteSchemeTesting for tips and tricks using the options described here.
The basic language is specified by (language scheme)
, but this does not allow a usable default for the loadcode
option. A particular default language can be specified by (language scheme/sublanguage)
, where sublanguage is one of beginner
, beginner-abbr
, intermediate
, intermediate-lambda
, advanced
, and module
. It is extremely important to specify in advance a particular language that is being used for a given assignment (or, if desired, a given question); while there is clearly intermediate-level code that is not valid in beginner, the reverse is also true. While the module language will load an HtDP submission properly in whatever language is specified by the student, this puts things like teachpack specification directly in the hands of the student and takes control of the particular language being used away from course staff. This can lead to problems; for example, the student can include a teachpack that the testing suite does not support, or which is supported but potentially trivializes a question.
(loadcode file)
file
in the default language. Note that only one evaluator can be active at a time at any particular level of the hierarchy. It is created in a context established by previous options; so, for example, the values of modules
must already be specified before this option is read. The values of timeout
and memory
also apply to the code loading. There are two types of loading that are done. In the intermediate and advanced families of languages, an evaluator is created by loading S-expressions from the student file one-by-one. This means that if any single S-expression causes a fatal error, this will be skipped over and the rest of the file will still be attempted. This will keep something like a student-supplied test that raises an error from preventing any code from being loaded. However, this is not possible in the beginner languages or module; in these, the entire file must be loaded at once, and any load error will mean the entire code base does not load. To accomodate potential timeout issues, the value of timeout
is quadrupled for the code loading.
(loadcode language file)
file
in the language language
, where this language is one of the sublanguages listed above.
(evaluator-reset frequency)
frequency
are never, before-test, before-expression, and standalone-program. The default is never, which means that after evaluator creation the contents of the evaluator are never re-created. However, languages like advanced and module are capable of mutating the global state of the evaluator, and this mutation will carry over to subsequent tests. As such, in cases where mutation is required, it is a good idea to specify before-test, which means that the evaluator state is reset before each test is run. The option before-expression should rarely be useful. In addition to resetting before running the student test, it also resets before evaluating any expected values and before running the equality function to compare the result of the student test and the expected value. However, these other evaluations generally should not involve mutating the evaluator's environment. The last option is a special case. Typically, standard input and standard output are effectively directed to /dev/null during evaluator load/reset, because it is undesirable for student tests to consume input and/or write to output, making their results incorrect. If standalone-program is specified as reset frequency, though, then loading the code into the evaluator must be part of the test (and often exclusively the test), and I/O will be active during this process.
(modules mod1 ... modN)
provided
subdirectory, but also potentially submitted by students) are to be included at the next loadcode
. This can be used for a variety of purposes, such as rewriting functions available for students, providing a required teachpack (or an equivalent, more testable alternate to a required teachpack), or providing equality testing functions.
(equal equal-fn)
equal?
.
(expected expr1 ... exprN)
diff
option.
(result expr)
Note that all options above are read into BitterSuite in a module language context. Because of this, care should be taken with numbers; you generally need to be sure you are not accidentally supplying inexact numbers where you should not be. See SchemeRationalNumbers for details.
For backward compatibility with BitterSuite 2, and for consistency with the conventions in other languages, the files test.ss
and test.scm
are understood by the scheme language. They are completely equivalent to the options.ss
and options.scm
files, but typically would include information relevant to a particular test (desc, expected, and result).