Skip to content

do-check-condition should catch <condition>, not <serious-condition> #184

Open
@cgay

Description

@cgay

The inner block, where thunk() is called, should catch <condition>, as the comment suggests. Consider using assert-signals on compiler warning conditions, which are not <serious-condition>s. If the compiler signals a disjoint condition class we won't catch and record it correctly.

Potentially overlaps with #183

define function do-check-condition
    (description-thunk :: <function>, get-arguments :: <function>, caller :: <string>,
     #key terminate? :: <boolean>)
 => ()
  let phase = format-to-string("evaluating %s description", caller);
  let description :: false-or(<string>) = #f;
  block ()
    description := eval-check-description(description-thunk);
    phase := format-to-string("evaluating %s expression", caller);
    let (condition-class, thunk :: <function>, expr :: <string>) = get-arguments();
    phase := format-to-string("checking if %= signals a condition of class %s",
                              expr, condition-class);
    block ()
      thunk();
      record-check(description, $failed, "no condition signaled");
      terminate? & signal(make(<assertion-failure>));
    exception (ex :: condition-class)
      record-check(description, $passed, #f);
      // Not really sure if this should catch something broader, like
      // <condition>, but leaving it this way for compat with old code.
    exception (ex :: <serious-condition>)
      record-check(description, $failed,
                   format-to-string("condition of class %s signaled; "
                                      "expected a condition of class %s. "
                                      "The error was: %s",
                                    ex.object-class, condition-class, ex));
      terminate? & signal(make(<assertion-failure>));
    end;
  exception (err :: <serious-condition>, test: method (cond) ~debug?() end)
    record-check(description | $invalid-description,
                 $crashed,
                 format-to-string("Error %s: %s", phase, err));
    terminate? & signal(make(<assertion-failure>));
  end block
end function do-check-condition;

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA problem with existing functionality or documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions