Skip to content

Commit 02a1f07

Browse files
committed
Avoid reusing modules across tests, see #13774
1 parent 1b4ec98 commit 02a1f07

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

lib/elixir/test/elixir/module/types/integration_test.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -824,8 +824,8 @@ defmodule Module.Types.IntegrationTest do
824824

825825
Map.new(modules, fn module ->
826826
{^module, binary, _filename} = :code.get_object_code(module)
827-
:code.purge(module)
828827
:code.delete(module)
828+
:code.purge(module)
829829
{module, binary}
830830
end)
831831
end

lib/elixir/test/elixir/typespec_test.exs

+12-17
Original file line numberDiff line numberDiff line change
@@ -1283,32 +1283,32 @@ defmodule TypespecTest do
12831283
end
12841284

12851285
test "spec_to_quoted with maps with __struct__ key" do
1286-
defmodule A do
1286+
defmodule StructA do
12871287
defstruct [:key]
12881288
end
12891289

1290-
defmodule B do
1290+
defmodule StructB do
12911291
defstruct [:key]
12921292
end
12931293

12941294
bytecode =
12951295
test_module do
1296-
@spec single_struct(%A{}) :: :ok
1296+
@spec single_struct(%StructA{}) :: :ok
12971297
def single_struct(arg), do: {:ok, arg}
12981298

1299-
@spec single_struct_key(%{__struct__: A}) :: :ok
1299+
@spec single_struct_key(%{__struct__: StructA}) :: :ok
13001300
def single_struct_key(arg), do: {:ok, arg}
13011301

13021302
@spec single_struct_key_type(%{__struct__: atom()}) :: :ok
13031303
def single_struct_key_type(arg), do: {:ok, arg}
13041304

1305-
@spec union_struct(%A{} | %B{}) :: :ok
1305+
@spec union_struct(%StructA{} | %StructB{}) :: :ok
13061306
def union_struct(arg), do: {:ok, arg}
13071307

1308-
@spec union_struct_key(%{__struct__: A | B}) :: :ok
1308+
@spec union_struct_key(%{__struct__: StructA | StructB}) :: :ok
13091309
def union_struct_key(arg), do: {:ok, arg}
13101310

1311-
@spec union_struct_key_type(%{__struct__: atom() | A | binary()}) :: :ok
1311+
@spec union_struct_key_type(%{__struct__: atom() | StructA | binary()}) :: :ok
13121312
def union_struct_key_type(arg), do: {:ok, arg}
13131313
end
13141314

@@ -1323,31 +1323,26 @@ defmodule TypespecTest do
13231323

13241324
assert Code.Typespec.spec_to_quoted(:single_struct, ast_single_struct)
13251325
|> Macro.to_string() ==
1326-
"single_struct(%TypespecTest.A{key: term()}) :: :ok"
1326+
"single_struct(%TypespecTest.StructA{key: term()}) :: :ok"
13271327

13281328
assert Code.Typespec.spec_to_quoted(:single_struct_key, ast_single_struct_key)
13291329
|> Macro.to_string() ==
1330-
"single_struct_key(%TypespecTest.A{}) :: :ok"
1330+
"single_struct_key(%TypespecTest.StructA{}) :: :ok"
13311331

13321332
assert Code.Typespec.spec_to_quoted(:single_struct_key_type, ast_single_struct_key_type)
13331333
|> Macro.to_string() ==
13341334
"single_struct_key_type(%{__struct__: atom()}) :: :ok"
13351335

13361336
assert Code.Typespec.spec_to_quoted(:union_struct, ast_union_struct) |> Macro.to_string() ==
1337-
"union_struct(%TypespecTest.A{key: term()} | %TypespecTest.B{key: term()}) :: :ok"
1337+
"union_struct(%TypespecTest.StructA{key: term()} | %TypespecTest.StructB{key: term()}) :: :ok"
13381338

13391339
assert Code.Typespec.spec_to_quoted(:union_struct_key, ast_union_struct_key)
13401340
|> Macro.to_string() ==
1341-
"union_struct_key(%{__struct__: TypespecTest.A | TypespecTest.B}) :: :ok"
1341+
"union_struct_key(%{__struct__: TypespecTest.StructA | TypespecTest.StructB}) :: :ok"
13421342

13431343
assert Code.Typespec.spec_to_quoted(:union_struct_key_type, ast_union_struct_key_type)
13441344
|> Macro.to_string() ==
1345-
"union_struct_key_type(%{__struct__: atom() | TypespecTest.A | binary()}) :: :ok"
1346-
after
1347-
for mod <- [A, B] do
1348-
:code.purge(mod)
1349-
:code.delete(mod)
1350-
end
1345+
"union_struct_key_type(%{__struct__: atom() | TypespecTest.StructA | binary()}) :: :ok"
13511346
end
13521347

13531348
test "non-variables are given as arguments" do

0 commit comments

Comments
 (0)