@@ -1159,6 +1159,17 @@ defmodule Module.Types.PatternTest do
11591159
11601160 assert typecheck! ( [ x ] , 0 != length ( x ) , x ) == dynamic ( non_empty_list ( term ( ) ) )
11611161 assert typecheck! ( [ x ] , not ( 0 != length ( x ) ) , x ) == dynamic ( empty_list ( ) )
1162+
1163+ assert typecheck! ( [ x ] , length ( x ) == 1 , x ) == dynamic ( non_empty_list ( term ( ) ) )
1164+ assert typecheck! ( [ x ] , not ( length ( x ) != 1 ) , x ) == dynamic ( non_empty_list ( term ( ) ) )
1165+ assert typecheck! ( [ x ] , 1 == length ( x ) , x ) == dynamic ( non_empty_list ( term ( ) ) )
1166+
1167+ assert typecheck! ( [ x ] , length ( x ) != 1 , x ) == dynamic ( list ( term ( ) ) )
1168+ assert typecheck! ( [ x ] , not ( length ( x ) == 1 ) , x ) == dynamic ( list ( term ( ) ) )
1169+ assert typecheck! ( [ x ] , 1 != length ( x ) , x ) == dynamic ( list ( term ( ) ) )
1170+
1171+ assert typecheck! ( [ x ] , is_list ( x ) and length ( x ) != 1 and x != [ ] , hd ( x ) ) ==
1172+ dynamic ( term ( ) )
11621173 end
11631174
11641175 test "length ordered" do
@@ -1206,6 +1217,20 @@ defmodule Module.Types.PatternTest do
12061217 assert typecheck! ( [ x ] , 0 != map_size ( x ) , x ) == dynamic ( @ non_empty_map )
12071218 assert typecheck! ( [ x ] , not ( 0 == map_size ( x ) ) , x ) == dynamic ( @ non_empty_map )
12081219 assert typecheck! ( [ x ] , not ( 0 != map_size ( x ) ) , x ) == dynamic ( empty_map ( ) )
1220+
1221+ assert typecheck! ( [ x ] , map_size ( x ) == 1 , x ) == dynamic ( @ non_empty_map )
1222+ assert typecheck! ( [ x ] , not ( map_size ( x ) != 1 ) , x ) == dynamic ( @ non_empty_map )
1223+ assert typecheck! ( [ x ] , 1 == map_size ( x ) , x ) == dynamic ( @ non_empty_map )
1224+
1225+ assert typecheck! ( [ x ] , map_size ( x ) != 1 , x ) == dynamic ( open_map ( ) )
1226+ assert typecheck! ( [ x ] , not ( map_size ( x ) == 1 ) , x ) == dynamic ( open_map ( ) )
1227+ assert typecheck! ( [ x ] , 1 != map_size ( x ) , x ) == dynamic ( open_map ( ) )
1228+
1229+ assert typecheck! (
1230+ [ x ] ,
1231+ is_map ( x ) and map_size ( x ) != 1 and is_map_key ( x , :a ) and is_map_key ( x , :b ) ,
1232+ x
1233+ ) == dynamic ( open_map ( a: term ( ) , b: term ( ) ) )
12091234 end
12101235
12111236 test "map_size ordered" do
@@ -1270,6 +1295,16 @@ defmodule Module.Types.PatternTest do
12701295 assert typecheck! ( [ x ] , 2 != tuple_size ( x ) , x ) == dynamic ( @ non_binary_tuple )
12711296 assert typecheck! ( [ x ] , not ( 2 == tuple_size ( x ) ) , x ) == dynamic ( @ non_binary_tuple )
12721297 assert typecheck! ( [ x ] , not ( 2 != tuple_size ( x ) ) , x ) == dynamic ( tuple ( [ term ( ) , term ( ) ] ) )
1298+
1299+ assert typecheck! ( [ x ] , tuple_size ( x ) != 1 , x ) ==
1300+ dynamic ( difference ( open_tuple ( [ ] ) , tuple ( [ term ( ) ] ) ) )
1301+
1302+ assert typecheck! (
1303+ [ x ] ,
1304+ is_tuple ( x ) and tuple_size ( x ) != 1 and tuple_size ( x ) != 0 ,
1305+ x
1306+ )
1307+ |> equal? ( dynamic ( open_tuple ( [ term ( ) , term ( ) ] ) ) )
12731308 end
12741309
12751310 test "tuple_size ordered" do
0 commit comments