       Code.eval_string("def foo do end", [], file: "my_file")
     end
 
-    assert Exception.format_stacktrace(System.stacktrace) =~ "my_file:1: (file)"
+    assert Exception.format_stacktrace(System.stacktrace()) =~ "my_file:1: (file)"
   end
 
   test "format_stacktrace/1 from module" do
     assert_raise ArgumentError, fn ->
-      Code.eval_string("defmodule FmtStack do raise ArgumentError, ~s(oops) end", [], file: "my_file")
-    end
-
-    assert Exception.format_stacktrace(System.stacktrace) =~ "my_file:1: (module)"
+      Code.eval_string(
+        "defmodule FmtStack do raise ArgumentError, ~s(oops) end",
+        [],
+        file: "my_file"
+      )
+    end
+
+    assert Exception.format_stacktrace(System.stacktrace()) =~ "my_file:1: (module)"
   end
 
   test "format_stacktrace_entry/1 with no file or line" do

    Process.flag(:trap_exit, true)
    # Fake reason to prevent error_logger printing to stdout
    exit_reason = {%ArgumentError{}, [{:not_a_real_module, :function, 0, []}]}
    exit_fun = fn() -> receive do: (_ -> exit(exit_reason)) end
    outer_pid =
      spawn_link(fn()->
        Process.flag(:trap_exit, true)
        :gen_event.call(spawn_link(exit_fun), :handler, :hello)
      end)
    reason = try do
      :gen_server.call(outer_pid, :hi)
    catch
      :exit, reason -> reason
    end

    formatted = Exception.format_exit(reason)
    assert formatted =~ ~r"exited in: :gen_server\.call\(#PID<\d+\.\d+\.\d+>, :hi\)\n"
    assert formatted =~ ~r"\s{4}\*\* \(EXIT\) exited in: :gen_event\.call\(#PID<\d+\.\d+\.\d+>, :handler, :hello\)\n"
    assert formatted =~ ~r"\s{8}\*\* \(EXIT\) an exception was raised:\n"
    assert formatted =~ ~r"\s{12}\*\* \(ArgumentError\) argument error\n"
    assert formatted =~ ~r"\s{16}:not_a_real_module\.function/0"

  end

  test "format_stacktrace_entry/1 with file and line" do
    assert Exception.format_stacktrace_entry({Foo, :bar, [], [file: 'file.ex', line: 10]}) ==
             "file.ex:10: Foo.bar()"

    assert Exception.format_stacktrace_entry({Foo, :bar, [1, 2, 3], [file: 'file.ex', line: 10]}) ==
             "file.ex:10: Foo.bar(1, 2, 3)"

    assert Exception.format_stacktrace_entry({Foo, :bar, 1, [file: 'file.ex', line: 10]}) ==
             "file.ex:10: Foo.bar/1"
  end

  test "format_stacktrace_entry/1 with file no line" do
    assert Exception.format_stacktrace_entry({Foo, :bar, [], [file: 'file.ex']}) ==
             "file.ex: Foo.bar()"

    assert Exception.format_stacktrace_entry({Foo, :bar, [], [file: 'file.ex', line: 0]}) ==
             "file.ex: Foo.bar()"

    assert Exception.format_stacktrace_entry({Foo, :bar, [1, 2, 3], [file: 'file.ex']}) ==
             "file.ex: Foo.bar(1, 2, 3)"

    assert Exception.format_stacktrace_entry({Foo, :bar, 1, [file: 'file.ex']}) ==
             "file.ex: Foo.bar/1"
  end

  test "format_stacktrace_entry/1 with application" do
    assert Exception.format_stacktrace_entry({Exception, :bar, [], [file: 'file.ex']}) ==
             "(elixir) file.ex: Exception.bar()"

    assert Exception.format_stacktrace_entry({Exception, :bar, [], [file: 'file.ex', line: 10]}) ==
             "(elixir) file.ex:10: Exception.bar()"

    assert Exception.format_stacktrace_entry({:lists, :bar, [1, 2, 3], []}) ==
             "(stdlib) :lists.bar(1, 2, 3)"
  end

  test "format_stacktrace_entry/1 with fun" do
    assert Exception.format_stacktrace_entry({fn x -> x end, [1], []}) =~ ~r/#Function<.+>\(1\)/

    assert Exception.format_stacktrace_entry({fn x, y -> {x, y} end, 2, []}) =~
             ~r"#Function<.+>/2"
  end

  test "format_mfa/3" do
