@@ -1283,32 +1283,32 @@ defmodule TypespecTest do
1283
1283
end
1284
1284
1285
1285
test "spec_to_quoted with maps with __struct__ key" do
1286
- defmodule A do
1286
+ defmodule StructA do
1287
1287
defstruct [ :key ]
1288
1288
end
1289
1289
1290
- defmodule B do
1290
+ defmodule StructB do
1291
1291
defstruct [ :key ]
1292
1292
end
1293
1293
1294
1294
bytecode =
1295
1295
test_module do
1296
- @ spec single_struct ( % A { } ) :: :ok
1296
+ @ spec single_struct ( % StructA { } ) :: :ok
1297
1297
def single_struct ( arg ) , do: { :ok , arg }
1298
1298
1299
- @ spec single_struct_key ( % { __struct__: A } ) :: :ok
1299
+ @ spec single_struct_key ( % { __struct__: StructA } ) :: :ok
1300
1300
def single_struct_key ( arg ) , do: { :ok , arg }
1301
1301
1302
1302
@ spec single_struct_key_type ( % { __struct__: atom ( ) } ) :: :ok
1303
1303
def single_struct_key_type ( arg ) , do: { :ok , arg }
1304
1304
1305
- @ spec union_struct ( % A { } | % B { } ) :: :ok
1305
+ @ spec union_struct ( % StructA { } | % StructB { } ) :: :ok
1306
1306
def union_struct ( arg ) , do: { :ok , arg }
1307
1307
1308
- @ spec union_struct_key ( % { __struct__: A | B } ) :: :ok
1308
+ @ spec union_struct_key ( % { __struct__: StructA | StructB } ) :: :ok
1309
1309
def union_struct_key ( arg ) , do: { :ok , arg }
1310
1310
1311
- @ spec union_struct_key_type ( % { __struct__: atom ( ) | A | binary ( ) } ) :: :ok
1311
+ @ spec union_struct_key_type ( % { __struct__: atom ( ) | StructA | binary ( ) } ) :: :ok
1312
1312
def union_struct_key_type ( arg ) , do: { :ok , arg }
1313
1313
end
1314
1314
@@ -1323,31 +1323,26 @@ defmodule TypespecTest do
1323
1323
1324
1324
assert Code.Typespec . spec_to_quoted ( :single_struct , ast_single_struct )
1325
1325
|> Macro . to_string ( ) ==
1326
- "single_struct(%TypespecTest.A {key: term()}) :: :ok"
1326
+ "single_struct(%TypespecTest.StructA {key: term()}) :: :ok"
1327
1327
1328
1328
assert Code.Typespec . spec_to_quoted ( :single_struct_key , ast_single_struct_key )
1329
1329
|> Macro . to_string ( ) ==
1330
- "single_struct_key(%TypespecTest.A {}) :: :ok"
1330
+ "single_struct_key(%TypespecTest.StructA {}) :: :ok"
1331
1331
1332
1332
assert Code.Typespec . spec_to_quoted ( :single_struct_key_type , ast_single_struct_key_type )
1333
1333
|> Macro . to_string ( ) ==
1334
1334
"single_struct_key_type(%{__struct__: atom()}) :: :ok"
1335
1335
1336
1336
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"
1338
1338
1339
1339
assert Code.Typespec . spec_to_quoted ( :union_struct_key , ast_union_struct_key )
1340
1340
|> Macro . to_string ( ) ==
1341
- "union_struct_key(%{__struct__: TypespecTest.A | TypespecTest.B }) :: :ok"
1341
+ "union_struct_key(%{__struct__: TypespecTest.StructA | TypespecTest.StructB }) :: :ok"
1342
1342
1343
1343
assert Code.Typespec . spec_to_quoted ( :union_struct_key_type , ast_union_struct_key_type )
1344
1344
|> 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"
1351
1346
end
1352
1347
1353
1348
test "non-variables are given as arguments" do
0 commit comments