Creating Instances of Student-Defined Structures
If you are going to require students to use a particular structure (for example, to represent nodes of a tree), the ideal is to place the structure definition in a module, provide the necessary creation, accessor, and if necessary mutator functions, and then either have students
(require ...)
it or import it as a teachpack. You can then supply this module as part of the testing suite, and add an extra function that returns particular pre-defined testing values. The reason to want pre-defined values is if the structures are complex, and you will want to use a given one for more than one test.
If this is not done in a teachpack, your module has no direct way of seeing the student-defined structure's creation function. The way around this is to provide an appropriate macro (instead of a function, so that it's usable in a Beginning Student context) from one of your testing modules.
As an example for a tree:
#lang scheme
(provide get-tree)
(define-syntax get-tree
(syntax-rules (small medium)
((_ small mknode)
(mknode 1 'apple empty empty))
((_ medium mknode)
(mknode 1 'banana
(mknode 2 'orange empty empty)
(mknode 3 'pineapple
(mknode 4 'mango empty empty)
empty)))))
Then, you can grab one of these trees with an expression such as
(get-tree medium make-node)
Note that this still requires the students to name their structure very precisely; otherwise, the testing suite still will not be able to find it.
See also:
SchemeModuleCompareUnknownStructs.