| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- # Expected results for tests/fixtures/*.pas - one line per fixture:
- #
- # <fixture-basename> OK <code> <data>
- # <fixture-basename> ERR <tp3-error-no> <relative-pos>
- #
- # Both the verdict AND the numbers are asserted by run_compile_tests.sh, so a
- # regression in the *reported error position* fails the suite just like a
- # regression in the generated code. That matters: error positions were once
- # silently wrong (a multi-character string literal swallowed the rest of the
- # source, so every later error pointed at end-of-file), and nothing caught it
- # because the old harness only printed the position for a human to squint at.
- #
- # Re-baseline deliberately, never to make a red test go green: if a fixture's
- # expectation has to change because the compiler legitimately improved, change
- # it in the same commit as the fix and say why in the message.
- #
- # ERR 102 = ENoLib, the original's "not implemented" path. The remaining ERR
- # rows are unimplemented features, not parser bugs:
- # t14 'array [..] of <type>' at its point of use
- # t25 a string literal used where a 16-bit word is wanted
- # uierror deliberate syntax error, pinned by the editor UI test
- #
- # The nine control-flow fixtures (t08 t09 t10 t11 t12 t13 t15 t27 t28) were
- # re-baselined upward when they were rewritten to PRINT their result, so each
- # has a .out file and is executed under qemu (run_com_exec.py) as well as
- # compiled here. Before that they assigned to a variable and fell off the end:
- # they asserted that the compiler produced bytes, and nothing about behaviour.
- # t13 also gained a second procedure, which is why it is bigger than the sum of
- # its parts. t08's data went 6 -> 7 because a CHAR variable joined the INTEGER.
- #
- # t02 t03 t05 t17 used to be ERR 102 as well: a multi-character literal was
- # rejected because writeln had no string support. They compile now, via the
- # inline-string path (CALL wrtinl, then <length><chars> in the code stream -
- # TPSRC8 pwrinlin / TPSRC4 xwrtinl), so their rows changed from ERR to OK and
- # their code sizes went up by the literal's own bytes.
- #
- # RE-BASELINED for v-TP3-8086-LOWERING, when conditional branches and SETcc
- # stopped being 386-only. Nine rows moved, every one of them UPWARD, and every
- # one of them by exactly the number of conditional sites in that fixture:
- #
- # +1 per site. A branch was 4 bytes (0F 8x rel16) and is now 5 (7x 03,
- # then the 3-byte EJMP). A comparison VALUE was 5 bytes (0F 9x rel8, then
- # MOV AH,0) and is now 6 (B8 01 00, 7x 01, DEC AX). So the deltas are
- # t09 +6 = 3 values + 3 branches, t10 +4 = 2+2, t11 +2 = 0+2,
- # t12 +4 = 2+2, t15 +2 = 1+1, t22 +2 = 0+2, t30 +1 = 0+1, t32 +3 = 1+2,
- # t33 +13 = 13 values.
- #
- # That arithmetic was CHECKED, not assumed: the site counts were counted out of
- # the linked images (the same CMP AX,CX and CMP AX,0000 anchors and the same
- # 7x 03 E9 shape that check_8086.py uses) and each row was only written after
- # its delta matched its count. Data sizes did not move at all. The bytes
- # themselves are pinned by check_8086.py, and the BEHAVIOUR is pinned by
- # run_com_exec.py -- this row only says how big the code is.
- #
- # RE-BASELINED when the runtime was wired into the code buffer. Every OK row
- # changed by exactly +3 code and -256 data, and both numbers are correct:
- #
- # +3 code the prologue now emits MOV AX,<header offset> before
- # CALL TU_InitMem, because InitMem takes the header offset in a
- # register (B8 lo hi) rather than on the stack. Previously the
- # prologue called offset 8, which is the hdrMax word - it only
- # "worked" because the runtime was not in the image at all.
- #
- # -256 data DataBytes() used to return dc, the ABSOLUTE end of the data
- # area, not a size. dc started at 100H, so every program reported
- # 256 more than it allocated - 260 for a program whose only data is
- # the two @@T1/@@T2 scratch words. The field is documented as
- # "emitted data size in bytes", so 4 is the true size and 260 was
- # the bug. It is a real correction, not a fit-to-the-test change:
- # the 6-byte rows are the fixtures that declare one global.
- #
- # ADDED for the BP displacement fix. These two fixtures are the first with
- # any frame access at all -- every earlier fixture put its variables in the
- # DATA segment, addressed absolutely, so the whole [BP+off] path had zero
- # coverage and a truncation there was invisible.
- #
- # t27_localvar five LOCAL variables, assigned and read back. Locals are
- # allocated downward from 0FFFEh and each access now costs 4
- # bytes (mod=10 + disp16) where it cost 3 (disp8), so its code
- # size reflects the fix rather than predating it. Both
- # encodings address the same place; only the rule for choosing
- # between them changed.
- # t28_farparam 70 declared parameters; the call passes 16, which is the
- # argument cap at the call site. p63 lands at BP+128 and p70
- # at BP+142 - the first offsets a disp8 cannot represent,
- # since 80h is -128 and not +128. Under the old code these
- # two reads came from the wrong side of BP. This fixture
- # tests the ENCODING and is never executed; do not read it as
- # a claim that a 70-argument call works. Its 123 bytes are
- # 1 more than t27's because the body is one ADD and one
- # store rather than five of each.
- #
- # RE-BASELINED for the case-label fix, and this is the one re-baseline in this
- # file that is a CORRECTION rather than a new feature. EmMovAxSp used to emit
- #
- # 8B 44 24 00 MOV AX,[SP] <- 386 encoding, SIB byte
- #
- # which is 4 bytes. [SP] is not encodable on the 8086 at all: mod=00/rm=100
- # is [SI], and the SIB byte that 8B 44 needs did not exist until the 386. The
- # bytes were well formed, so every byte-level check passed, and fcml and qemu
- # both DECODED it - as MOV AX,[SI+0x24h], because that is what it is. Every
- # CASE label test therefore loaded a garbage address, every comparison failed,
- # and a case statement fell straight past its body. It now emits
- #
- # 58 50 POP AX ; PUSH AX <- 2 bytes
- #
- # which is observationally a peek. t22 has two labels, so its code is exactly
- # 4 bytes smaller: 96 -> 92. The number moving is the point - the old size was
- # the size of a wrong encoding, and a case fixture that is not executed cannot
- # tell you that from its size alone. t22 is executed (tests/run_com_exec.py).
- #
- # ADDED t29_readln: the first fixture that reads. It needs the CHAR class to
- # exist at all - see the note on TChar in Compiler.mod - so 7 data bytes where
- # t19 has 4 (n is 2, c is 1, and the two are 2-byte aligned, so 4 + 2 + 1
- # rounds up to 7) and 82 code bytes for the four runtime calls plus a literal
- # char argument. Its .out is compared byte for byte against qemu.
- #
- # RE-BASELINED for the procedure-skip jump. t13, t27 and t28 gained exactly
- # +3 code bytes: `E9 rel16`. These are the only three fixtures that declare a
- # PROCEDURE, and they are the only three rows that moved.
- #
- # The reason is a bug that only execution could find. The declaration part is
- # compiled BEFORE the main statement part, so a procedure's code lands between
- # the program prologue and the main body - and nothing jumped over it. A
- # program with a procedure ran off the end of the prologue straight into the
- # first procedure, which read its argument out of an uninitialised frame and
- # returned to address 0000h. t13_proc compiled, produced a plausible 53 bytes,
- # and was never run, so the suite was green over a program that could not
- # execute at all.
- #
- # The jump is emitted ONLY when a procedure or function is declared, which is
- # why the other 27 OK rows did not move. That condition is a lookahead over
- # the source buffer, because the jump must be emitted before the declaration
- # part but whether one is needed is only known after - see DeclaresProc in
- # Compiler.mod for why the alternative (always emit it) was rejected.
- #
- # t13_proc 53 -> 56
- # t27_localvar 122 -> 125
- # t28_farparam 123 -> 126
- # t31_procparam 66 -> 69
- #
- # t31_procparam is the fixture that proves the fix by running: it declares a
- # procedure, calls it, and prints what the procedure wrote. Before the fix it
- # never halted at all.
- #
- # ADDED t30/t31/t32, all three now EXECUTED (not just compiled):
- #
- # t30_forloop `for i := 1 to 5 do s := s + i` printed 21, not 15. The loop
- # test was emitted AFTER the body, making it a post-test loop:
- # the body ran a sixth time with i = 6. The code size and the
- # instruction bytes were both already correct - only the ORDER
- # was wrong, and no byte-level check can observe an order. The
- # test now precedes the body, so 96 bytes both before and after
- # this fix, which is the whole point: the number never moved and
- # the behaviour did.
- # t31_procparam procedure + one parameter. The non-termination above.
- # t32_forexit `for` with `exit` in the body. Two faults, both invisible to
- # a size check: the loop's exits were patched to the position
- # just past the body, which in a FOR is the STEP, so `exit`
- # incremented the control variable and jumped back into the test
- # - it did not exit; and the EXIT handler also emitted ADD SP,2
- # while the loop's `done` label emitted it again, dropping four
- # bytes off a stack that had two to give. Exits are now patched
- # at `done`, and the handler no longer touches the stack.
- # t33_cmpops all six relational operators as VALUES, each with a true case,
- # a false case and the equality boundary, plus one signed pair.
- # Added while making the 8086 branch/compare lowering checkable:
- # measuring which conditions the suite actually emitted showed
- # that `=', `<>' and `<=' were never used in a comparison at all,
- # because `writeln (a = b)` had no fixture. Only `<', `>' and
- # `>=' had coverage - and `>' vs `>=' had ALREADY been swapped
- # once (bug 29), so a hole either side of the operators that
- # were covered is the last place to leave one. m := -1, n := -2
- # makes the last line signed: unsigned, -1 > -2 is FALSE, so that
- # one line is what tells SETG from a byte compare.
- t01_minimal OK 29 4
- t02_writeln OK 38 4
- t03_inline_comment OK 38 4
- t04_var OK 48 6
- t05_own_line_comment OK 38 4
- t06_two_args OK 52 4
- t07_big OK 102 6
- t08_const OK 76 7
- t09_if OK 195 6
- t10_while OK 151 6
- t11_for OK 144 6
- t12_repeat OK 137 6
- t13_proc OK 126 6
- t14_types ERR 102 83
- t15_label OK 90 6
- t16_str1 OK 42 4
- t17_two_str OK 45 4
- t18_writeln_bare OK 32 4
- t19_int1 OK 42 4
- t20_str3 OK 62 4
- t21_mixed OK 62 4
- t22_case OK 94 6
- t23_str_empty OK 36 4
- t24_str_quote OK 41 4
- t25_str_as_value ERR 102 48
- t26_str_mixed_args OK 58 4
- t27_localvar OK 256 6
- t28_farparam OK 153 8
- t29_readln OK 82 7
- t30_forloop OK 97 8
- t31_procparam OK 69 6
- t32_forexit OK 138 8
- t33_cmpops OK 404 12
- t34_arith OK 448 8
- t35_not OK 224 7
- uierror ERR 41 331
|