1%% 2%% Tests hardcoded dependent type info 3%% and the quality of the warnings that Dialyzer spits out 4%% 5-module(port_info_test). 6-export([t1/1, t2/1, t3/1, t4/1, t5/2, t6/1, buggy/1]). 7 8%% The following errors are correctly caught, but the messages are a bit weird 9t1(X) when is_port(X) -> 10 {connected, 42} = erlang:port_info(X, connected); 11t1(_) -> ok. 12 13t2(X) when is_port(X) -> 14 {registered_name, "42"} = erlang:port_info(X, registered_name); 15t2(_) -> ok. 16 17%% Here only one od the two errors is reported... 18t3(X) when is_atom(X) -> 19 {output, 42} = erlang:port_info(X, connected); 20t3(_) -> ok. 21 22t4(X) when is_atom(X) -> 23 {Atom, _} = erlang:port_info(X, connected), 24 Atom = links; 25t4(_) -> ok. 26 27t5(X, Atom) when is_port(X) -> 28 {gazonk, _} = erlang:port_info(X, Atom); 29t5(_, _) -> ok. 30 31t6(X) when is_port(X) -> 32 {os_pid, "42"} = erlang:port_info(X, os_pid); 33t6(_) -> ok. 34 35%% The type system is not strong enough to catch the following errors 36buggy(X) when is_atom(X) -> 37 {links, X} = erlang:port_info(foo, X). 38