             {{:my_fun2, 0}, [{:type, _, :fun, [{:type, _, :product, []}, {:type, _, :integer, []}]}]},
             {{:my_fun3, 2}, [{:type, _, :fun, [{:type, _, :product, [{:type, _, :integer, []}, {:type, _, :integer, []}]}, {:type, _, :tuple, [{:type, _, :integer, []}, {:type, _, :integer, []}]}]}]},
             {{:my_fun4, 1}, [{:type, _, :fun, [{:type, _, :product, [{:ann_type, _, [{:var, _, :x}, {:type, _, :integer, []}]}]}, {:type, _, :integer, []}]}]}] =
-           specs(module)
+           specs(bytecode)
   end
 
   test "@spec(spec) for unreachable private function" do
     # Run it inside capture_io/2 so that the "my_fun/1 is unused"
     # warning doesn't get printed among the ExUnit test results.
     output = ExUnit.CaptureIO.capture_io :stderr, fn ->
-      module = test_module do
+      bytecode = test_module do
         defp my_fun(x), do: x
         @spec my_fun(integer) :: integer
       end
 
-      assert [] == specs(module)
-    end
-
-    assert output =~ "function my_fun/1 is unused"
+      assert [] == specs(bytecode)
+    end
+
+    assert output != ""
   end
 
   test "@spec(spec) with guards" do
-    module = test_module do
+    bytecode = test_module do
       def my_fun1(x), do: x
       @spec my_fun1(x) :: boolean when [x: integer]
 

             {:type, _, :tuple, [
               {:atom, 0, :timestamp}, {:type, 0, :term, []}, {:atom, 0, :foo}
             ]},
            []}] = types(module)
  end

  test "@type with undefined record" do
    assert_raise CompileError, ~r"unknown record :this_record_does_not_exist", fn ->
      test_module do
        @type mytype :: record(:this_record_does_not_exist, [])
      end
    end
  end

             {:type, _, :map, [
               {:type, _, :map_field_exact, [{:atom, _, :hello}, {:atom, _, :world}]}
             ]},
            []}] = types(bytecode)
  end

  test "@type with a map" do
    bytecode = test_module do
      @type my_type :: %{required(:a) => :b, optional(:c) => :d}
    end

