Providing Libraries and Helper Files

This section has been moved to the top of the ConstantsAndHelpers page.

Outdated

You should be aware of how the various language levels and their function libraries interact across files. The test.rkt file is always evaluated in the same language level as the assignment, i.e. what is specified in the options.rkt file. You will not be able to call things like sort and local on Assignment 2, when the class is still in Beginning Student! However, the function (require …) is always available no matter which level of Racket you’re in, which is exactly what using the (modules …) line in options.rkt does. When you require another Racket module, that file is made visible to your working file, but you can only call on the identifiers which have been "revealed" in a (provide …) line.

It is recommended to work in full Racket for any provided modules you write. You can get this by selecting “Determine language from source” in DrRacket and having a “#lang racket” line at the top of your file. You’ll be able to use all the important functions from the teaching languages, plus lots of other useful functions. There won’t be any conflicts stemming from the language set in options.rkt, because a Racket file calls functions from a provided module with their definitions “hidden,” - the language level in your provided file operates independently of the language level where its functions are called. For example, you can have a provided file like this if the language is Beginning Student for the assignment:

(provide my-sort)

(define (my-sort lst pred) (sort lst pred))

Now, we haven’t talked about the disallowed functions from disallowed.rkt, but this actually doesn’t introduce any new issues. A disallowed.rkt file is used like any other module, and included at the top of the student’s submission file. It does not check for the banned functions in your provided files, even if those functions are called from within the student’s solution. However, in general, we try to have the disallowed file be the last module in the (modules …) line, because if it bans require, the testing will break once it tries to include any subsequent modules using require.

There are slight differences in full Racket that the test writer should get to know when making provided files. An important one is that structs are opaque (or private, if you’ve done OOP) by default, and you must add #:transparent if you want to access the fields.

Another one is that full Racket actually recognizes types (even though variables are not typed), so be especially careful working with floats: (= 3.0 3) is true, but (equal? 3.0 3) is false in full Racket! Even (equal? (list 1.0 2.0 3.0) (list 1.0 2.0 3)) is false! In test.rkt, the result and expected are compared using equal? in whatever teaching language is used, so you probably won’t have to worry about this. Incidentally, #i3 in the teaching languages is equivalent to what 3.0 does in full Racket, so you can have it go the other way where (equal? #i3 3.0) is true in full Racket but false in Beginning Student (because the 3.0 gets treated as the exact value, 3).

Outdated

If the course provides cs135-trace.rkt as a library file for students, then we will need to account for that in our testing set up.

When students submit their files, they might include ("require cs135-trace.rkt") and they might have some define/trace inside of their code still. None of these should affect our testing setup, but we have not tested this out thoroughly to know 100%. In order to prevent issues, we try to let students know when they submit to MarkUs that they should at least remove define/trace from their code.

To do this, move the cs135-trace-basic.rkt file located in marking/provided-library to the provided directory in test.pt for the assignment that you're setting up. Make sure to include this file in the instructor-script macro in the options.rkt file for the assignment. This should now fail students on the basic tests for including define/trace and give them a warning to remove it before they submit their code.

For correctness tests, we want to include the real cs135-trace.rkt file so that if students do happen to submit their file with define/trace, then we can still run correctness on them without any penalties. To do this, move the cs135-trace-correctness.rkt file located in marking/provided-library to the provided directory in test.0 for the assignment that you're setting up. Once again, make sure to include this file in the instructor-script macro. Also, make sure that you unban requires since students will probably still have (require "cs135-trace.rkt") in their file.

If ISAs are confident that cs135-trace.rkt will not cause any issues during correctness tests, then they can just set up the cs135-trace-correctness.rkt file for both public and private tests. Just be careful, because if there are issues that arise from this in correctness tests, then it with be course personnels' responsibility to deal with the issue.

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2021-12-21 - ShirleyWang
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback