@@ -259,30 +259,26 @@ defmodule Module.Types.DescrTest do
259
259
end
260
260
261
261
test "map_fetch" do
262
- assert map_fetch ( closed_map ( a: integer ( ) ) , :a ) == { false , integer ( ) }
263
-
264
262
assert map_fetch ( term ( ) , :a ) == :badmap
265
263
assert map_fetch ( union ( open_map ( ) , integer ( ) ) , :a ) == :badmap
266
- assert map_fetch ( dynamic ( ) , :a ) == { true , dynamic ( ) }
267
264
268
- assert intersection ( dynamic ( ) , open_map ( a: integer ( ) ) )
269
- |> map_fetch ( :a ) == { false , intersection ( integer ( ) , dynamic ( ) ) }
265
+ assert map_fetch ( closed_map ( a: integer ( ) ) , :a ) == { false , integer ( ) }
270
266
271
- { false , value_type } =
272
- open_map ( my_map: open_map ( foo: integer ( ) ) )
273
- |> intersection ( open_map ( my_map: open_map ( bar: boolean ( ) ) ) )
274
- |> map_fetch ( :my_map )
267
+ assert map_fetch ( union ( closed_map ( a: integer ( ) ) , closed_map ( b: atom ( ) ) ) , :a ) ==
268
+ :badkey
275
269
276
- assert equal? ( value_type , open_map ( foo: integer ( ) , bar: boolean ( ) ) )
270
+ assert map_fetch ( difference ( closed_map ( a: integer ( ) ) , closed_map ( a: term ( ) ) ) , :a ) ==
271
+ :badkey
277
272
278
273
assert map_fetch ( union ( closed_map ( a: integer ( ) ) , closed_map ( a: atom ( ) ) ) , :a ) ==
279
274
{ false , union ( integer ( ) , atom ( ) ) }
280
275
281
- assert map_fetch ( union ( closed_map ( a: integer ( ) ) , closed_map ( b: atom ( ) ) ) , :a ) ==
282
- :badkey
276
+ { false , value_type } =
277
+ open_map ( my_map: open_map ( foo: integer ( ) ) )
278
+ |> intersection ( open_map ( my_map: open_map ( bar: boolean ( ) ) ) )
279
+ |> map_fetch ( :my_map )
283
280
284
- assert map_fetch ( difference ( closed_map ( a: integer ( ) ) , closed_map ( a: term ( ) ) ) , :a ) ==
285
- :badkey
281
+ assert equal? ( value_type , open_map ( foo: integer ( ) , bar: boolean ( ) ) )
286
282
287
283
{ false , value_type } =
288
284
closed_map ( a: union ( integer ( ) , atom ( ) ) )
@@ -335,6 +331,21 @@ defmodule Module.Types.DescrTest do
335
331
|> difference ( open_map ( a: atom ( [ :foo , :baz ] ) ) )
336
332
|> map_fetch ( :a ) == { false , integer ( ) }
337
333
end
334
+
335
+ test "map_fetch with dynamic" do
336
+ assert map_fetch ( dynamic ( ) , :a ) == { true , dynamic ( ) }
337
+
338
+ assert intersection ( dynamic ( ) , open_map ( a: integer ( ) ) )
339
+ |> map_fetch ( :a ) == { false , intersection ( integer ( ) , dynamic ( ) ) }
340
+
341
+ { false , type } = union ( dynamic ( integer ( ) ) , open_map ( a: integer ( ) ) ) |> map_fetch ( :a )
342
+ assert equal? ( type , integer ( ) )
343
+
344
+ assert union ( dynamic ( integer ( ) ) , open_map ( a: if_set ( integer ( ) ) ) ) |> map_fetch ( :a ) == :badkey
345
+
346
+ assert union ( dynamic ( open_map ( a: atom ( ) ) ) , open_map ( a: integer ( ) ) )
347
+ |> map_fetch ( :a ) == { false , union ( dynamic ( atom ( ) ) , integer ( ) ) }
348
+ end
338
349
end
339
350
340
351
describe "to_quoted" do
0 commit comments