Skip to content

compiler-tests-suite cannot check answers for self-defined var_test (unless the real answer is 42) #20

Open
@rundong08

Description

@rundong08

Description

When you have self defined var_test cases, for example, a var_test_4.rkt file with simple content

43

and when you run racket run-tests.rkt, it will generate error like

--------------------
var_test_4 > compiler tests > code generation
FAILURE
name:       check
location:   utilities.rkt:2275:46
params:     '(#<procedure:result-check> 43 "42")
message:    "Mismatched output from x86 execution"
--------------------

Expected Behavior (assuming your compiler implementation is correct)

All tests should pass

Cause

compiler-tests-suite expect to read the expected output from some .res file, for examplevar_test_4.res, otherwise it will assume the expected output should be 42.

Workaround

In the check-passes-suite function, add the following before (let loop ([passes passes]

 (cond [initial-interp
              (with-output-to-file result-file-name #:exists 'replace
                (lambda () (printf "~a" expected-result)))])

This will write the expected output to the corresponding result file in the interpreter run (before the compiler run).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions