         # Put all tests into one context
         unquote_splicing(tests)
       rescue
-        e in [ExUnit.ExpectationError] ->
+        e in [ExUnit.AssertionError] ->
           raise e, [], stack
 
         error ->
-          raise ExUnit.ExpectationError,
-            [ prelude: "Expected doctest",
+          raise ExUnit.AssertionError,
+            [ message: "Doctest failed—incorrect assertion generated",
               expr: unquote(whole_expr),
-              expected: unquote(exception),
+              left: unquote(exception),
               # We're using a combined message here because all expressions
               # (those that are expected to raise and those that aren't) are in
               # the same try block above.
-              assertion: "complete or raise",
-              actual: inspect(elem(error, 0)) <> " with message " <> inspect(error.message) ],
+              right: inspect(elem(error, 0)) <> " with message " <> error.message ],
             stack
       end
     end

      Code.string_to_quoted!(expr, line: line, file: file)
    rescue e ->
      quote do
        raise ExUnit.ExpectationError,
          [ prelude: "Expected doctest",
            expr: unquote(String.strip(expr)),
            expected: "successfully",
            assertion: "compile",
            actual: unquote("** #{inspect e.__record__(:name)} #{e.message}") ],
          unquote(stack)
      end
    end

      case unquote(expr_ast) do
        ^v -> :ok
        actual ->
          raise ExUnit.AssertionError,
            [ message: "Doctest failed",
              expr: "#{unquote(expr)} should equal #{inspect(v)}",
              left: inspect(actual) ],
            unquote(stack)
      end
    end
