TestCasesGuidelines
This page gives a full explanation of how test cases are treated in order to get executed automatically.
Overview
In order to enable the test cases to be executed automatically a couple of constraints must be respected.
That's what the automatic test procedure does:
- The code marked up as test case in a given phrase page is extracted.
The expression r← as added to to front of the headline in order to make the test function return a result.
The line that contains the expression ⍝ ---- Start Test cases is located.
After that line the expression r←⍬ is inserted as a new, additional line.
All subsequent lines that contain the ≡ (match) symbol are prefixed by r,←.
- The function is executed in Dyalog APL.
As a result of that the function returns a vector of Booleans with a 1 for success and a 0 for failure. The length depends on the number of test cases. If there is at least one 0, the according test case is reported as faulty.
Of course all errors that might occur during the course of action are trapped. If such an error occurs the page is reported accordingly with a complete failure of the test cases.
What to Avoid
Don't delete the ⍝ ---- Start Test cases line.
You must use the ≡ (match) function in order to compare the result with what is expected to be the result.
You must avoid using the ≡ (match) function elsewhere.
That's it - not too complicated.
Who, when, where
- You can execute both, examples as well as the test cases, on any phrase by clicking on the "Test my code" link on any phrase page.
Once a day all pages are checked automatically. The results is shown on the TestReport page.
An Example
This is a test case from the LeapYear page:
Test ⎕IO←0 ⍝ You may change this; however, zero IS the default in the Phrasebook ⍝⎕ML←3 ⍝ Enable this line in Dyalog APL if appropriate ⎕FX'r←LeapYear ia' 'r←0≠.=4 100 400∘.|ia' ⍝ ---- Start Test cases (do not delete this!) im←1900 2000 2100∘.+¯4 ¯1 0 1 4 (3 5⍴1 0 0 0 1 1 0 1 0 1)≡LeapYear im leapyrs←(LeapYear yrs)/yrs←1753+⍳50 (1756+4×⍳11)≡leapyrs leapcent←(LeapYear cent)/cent←100×16+⍳24 (1600+400×⍳6)≡leapcent
Before it gets finally executed, this code is transformed into this:
r←Test ⎕IO←0 ⍝ You may change this; however, zero IS the default in the Phrasebook ⍝⎕ML←3 ⍝ Enable this line in Dyalog APL if appropriate ⎕FX'r←LeapYear ia' 'r←0≠.=4 100 400∘.|ia' ⍝ ---- Start Test cases (do not delete this!) r←⍬ im←1900 2000 2100∘.+¯4 ¯1 0 1 4 r,←(3 5⍴1 0 0 0 1 1 0 1 0 1)≡LeapYear im leapyrs←(LeapYear yrs)/yrs←1753+⍳50 r,←(1756+4×⍳11)≡leapyrs leapcent←(LeapYear cent)/cent←100×16+⍳24 r,←(1600+400×⍳6)≡leapcent
APL Wiki