|
5 | 5 |
|
6 | 6 | string_test() -> |
7 | 7 | gleam@expect:equal(gleam@any:string(gleam@any:from(<<"">>)), {ok, <<"">>}), |
8 | | - gleam@expect:equal(gleam@any:string(gleam@any:from(<<"Hello">>)), |
9 | | - {ok, <<"Hello">>}), |
10 | | - gleam@expect:equal(gleam@any:string(gleam@any:from(1)), |
11 | | - {error, <<"Expected a String, got `1`">>}), |
12 | | - gleam@expect:equal(gleam@any:string(gleam@any:from([])), |
13 | | - {error, <<"Expected a String, got `[]`">>}). |
| 8 | + gleam@expect:equal( |
| 9 | + gleam@any:string(gleam@any:from(<<"Hello">>)), |
| 10 | + {ok, <<"Hello">>} |
| 11 | + ), |
| 12 | + gleam@expect:equal( |
| 13 | + gleam@any:string(gleam@any:from(1)), |
| 14 | + {error, <<"Expected a String, got `1`">>} |
| 15 | + ), |
| 16 | + gleam@expect:equal( |
| 17 | + gleam@any:string(gleam@any:from([])), |
| 18 | + {error, <<"Expected a String, got `[]`">>} |
| 19 | + ). |
14 | 20 |
|
15 | 21 | int_test() -> |
16 | 22 | gleam@expect:equal(gleam@any:int(gleam@any:from(1)), {ok, 1}), |
17 | 23 | gleam@expect:equal(gleam@any:int(gleam@any:from(2)), {ok, 2}), |
18 | | - gleam@expect:equal(gleam@any:int(gleam@any:from(1.0)), |
19 | | - {error, <<"Expected an Int, got `1.0`">>}), |
20 | | - gleam@expect:equal(gleam@any:int(gleam@any:from([])), |
21 | | - {error, <<"Expected an Int, got `[]`">>}). |
| 24 | + gleam@expect:equal( |
| 25 | + gleam@any:int(gleam@any:from(1.0)), |
| 26 | + {error, <<"Expected an Int, got `1.0`">>} |
| 27 | + ), |
| 28 | + gleam@expect:equal( |
| 29 | + gleam@any:int(gleam@any:from([])), |
| 30 | + {error, <<"Expected an Int, got `[]`">>} |
| 31 | + ). |
22 | 32 |
|
23 | 33 | float_test() -> |
24 | 34 | gleam@expect:equal(gleam@any:float(gleam@any:from(1.0)), {ok, 1.0}), |
25 | 35 | gleam@expect:equal(gleam@any:float(gleam@any:from(2.2)), {ok, 2.2}), |
26 | | - gleam@expect:equal(gleam@any:float(gleam@any:from(1)), |
27 | | - {error, <<"Expected a Float, got `1`">>}), |
28 | | - gleam@expect:equal(gleam@any:float(gleam@any:from([])), |
29 | | - {error, <<"Expected a Float, got `[]`">>}). |
| 36 | + gleam@expect:equal( |
| 37 | + gleam@any:float(gleam@any:from(1)), |
| 38 | + {error, <<"Expected a Float, got `1`">>} |
| 39 | + ), |
| 40 | + gleam@expect:equal( |
| 41 | + gleam@any:float(gleam@any:from([])), |
| 42 | + {error, <<"Expected a Float, got `[]`">>} |
| 43 | + ). |
30 | 44 |
|
31 | 45 | thunk_test() -> |
32 | 46 | gleam@expect:is_ok(gleam@any:thunk(gleam@any:from(fun() -> 1 end))), |
33 | | - gleam@expect:equal(gleam@result:map(gleam@any:thunk(gleam@any:from(fun() -> |
34 | | - 1 |
35 | | - end)), |
36 | | - fun(F) -> F() end), |
37 | | - {ok, gleam@any:from(1)}), |
| 47 | + gleam@expect:equal( |
| 48 | + gleam@result:map( |
| 49 | + gleam@any:thunk(gleam@any:from(fun() -> 1 end)), |
| 50 | + fun(F) -> F() end |
| 51 | + ), |
| 52 | + {ok, gleam@any:from(1)} |
| 53 | + ), |
38 | 54 | gleam@expect:is_error(gleam@any:thunk(gleam@any:from(fun(X) -> X end))), |
39 | 55 | gleam@expect:is_error(gleam@any:thunk(gleam@any:from(1))), |
40 | 56 | gleam@expect:is_error(gleam@any:thunk(gleam@any:from([]))). |
41 | 57 |
|
42 | 58 | bool_test() -> |
43 | 59 | gleam@expect:equal(gleam@any:bool(gleam@any:from(true)), {ok, true}), |
44 | 60 | gleam@expect:equal(gleam@any:bool(gleam@any:from(false)), {ok, false}), |
45 | | - gleam@expect:equal(gleam@any:bool(gleam@any:from(1)), |
46 | | - {error, <<"Expected a Bool, got `1`">>}), |
47 | | - gleam@expect:equal(gleam@any:bool(gleam@any:from([])), |
48 | | - {error, <<"Expected a Bool, got `[]`">>}). |
| 61 | + gleam@expect:equal( |
| 62 | + gleam@any:bool(gleam@any:from(1)), |
| 63 | + {error, <<"Expected a Bool, got `1`">>} |
| 64 | + ), |
| 65 | + gleam@expect:equal( |
| 66 | + gleam@any:bool(gleam@any:from([])), |
| 67 | + {error, <<"Expected a Bool, got `[]`">>} |
| 68 | + ). |
49 | 69 |
|
50 | 70 | atom_test() -> |
51 | | - gleam@expect:equal(gleam@any:atom(gleam@any:from(gleam@atom:create_from_string(<<"">>))), |
52 | | - {ok, gleam@atom:create_from_string(<<"">>)}), |
53 | | - gleam@expect:equal(gleam@any:atom(gleam@any:from(gleam@atom:create_from_string(<<"ok">>))), |
54 | | - {ok, gleam@atom:create_from_string(<<"ok">>)}), |
| 71 | + gleam@expect:equal( |
| 72 | + gleam@any:atom(gleam@any:from(gleam@atom:create_from_string(<<"">>))), |
| 73 | + {ok, gleam@atom:create_from_string(<<"">>)} |
| 74 | + ), |
| 75 | + gleam@expect:equal( |
| 76 | + gleam@any:atom(gleam@any:from(gleam@atom:create_from_string(<<"ok">>))), |
| 77 | + {ok, gleam@atom:create_from_string(<<"ok">>)} |
| 78 | + ), |
55 | 79 | gleam@expect:is_error(gleam@any:atom(gleam@any:from(1))), |
56 | 80 | gleam@expect:is_error(gleam@any:atom(gleam@any:from([]))). |
57 | 81 |
|
58 | 82 | list_test() -> |
59 | | - gleam@expect:equal(gleam@any:list(gleam@any:from([]), |
60 | | - fun gleam@any:string/1), |
61 | | - {ok, []}), |
62 | | - gleam@expect:equal(gleam@any:list(gleam@any:from([]), fun gleam@any:int/1), |
63 | | - {ok, []}), |
64 | | - gleam@expect:equal(gleam@any:list(gleam@any:from([1, 2, 3]), |
65 | | - fun gleam@any:int/1), |
66 | | - {ok, [1, 2, 3]}), |
67 | | - gleam@expect:equal(gleam@any:list(gleam@any:from([[1], [2], [3]]), |
68 | | - fun(Capture1) -> |
69 | | - gleam@any:list(Capture1, |
70 | | - fun gleam@any:int/1) |
71 | | - end), |
72 | | - {ok, [[1], [2], [3]]}), |
73 | | - gleam@expect:is_error(gleam@any:list(gleam@any:from(1), |
74 | | - fun gleam@any:string/1)), |
75 | | - gleam@expect:is_error(gleam@any:list(gleam@any:from(1.0), |
76 | | - fun gleam@any:int/1)), |
77 | | - gleam@expect:is_error(gleam@any:list(gleam@any:from([<<"">>]), |
78 | | - fun gleam@any:int/1)), |
79 | | - gleam@expect:is_error(gleam@any:list(gleam@any:from([gleam@any:from(1), |
80 | | - gleam@any:from(<<"not an int">>)]), |
81 | | - fun gleam@any:int/1)). |
| 83 | + gleam@expect:equal( |
| 84 | + gleam@any:list(gleam@any:from([]), fun gleam@any:string/1), |
| 85 | + {ok, []} |
| 86 | + ), |
| 87 | + gleam@expect:equal( |
| 88 | + gleam@any:list(gleam@any:from([]), fun gleam@any:int/1), |
| 89 | + {ok, []} |
| 90 | + ), |
| 91 | + gleam@expect:equal( |
| 92 | + gleam@any:list(gleam@any:from([1, 2, 3]), fun gleam@any:int/1), |
| 93 | + {ok, [1, 2, 3]} |
| 94 | + ), |
| 95 | + gleam@expect:equal( |
| 96 | + gleam@any:list( |
| 97 | + gleam@any:from([[1], [2], [3]]), |
| 98 | + fun(Capture1) -> gleam@any:list(Capture1, fun gleam@any:int/1) end |
| 99 | + ), |
| 100 | + {ok, [[1], [2], [3]]} |
| 101 | + ), |
| 102 | + gleam@expect:is_error( |
| 103 | + gleam@any:list(gleam@any:from(1), fun gleam@any:string/1) |
| 104 | + ), |
| 105 | + gleam@expect:is_error( |
| 106 | + gleam@any:list(gleam@any:from(1.0), fun gleam@any:int/1) |
| 107 | + ), |
| 108 | + gleam@expect:is_error( |
| 109 | + gleam@any:list(gleam@any:from([<<"">>]), fun gleam@any:int/1) |
| 110 | + ), |
| 111 | + gleam@expect:is_error( |
| 112 | + gleam@any:list( |
| 113 | + gleam@any:from( |
| 114 | + [gleam@any:from(1), gleam@any:from(<<"not an int">>)] |
| 115 | + ), |
| 116 | + fun gleam@any:int/1 |
| 117 | + ) |
| 118 | + ). |
82 | 119 |
|
83 | 120 | tuple_test() -> |
84 | | - gleam@expect:equal(gleam@any:tuple(gleam@any:from({1, []})), |
85 | | - {ok, {gleam@any:from(1), gleam@any:from([])}}), |
86 | | - gleam@expect:equal(gleam@any:tuple(gleam@any:from({<<"ok">>, <<"ok">>})), |
87 | | - {ok, |
88 | | - {gleam@any:from(<<"ok">>), gleam@any:from(<<"ok">>)}}), |
| 121 | + gleam@expect:equal( |
| 122 | + gleam@any:tuple(gleam@any:from({1, []})), |
| 123 | + {ok, {gleam@any:from(1), gleam@any:from([])}} |
| 124 | + ), |
| 125 | + gleam@expect:equal( |
| 126 | + gleam@any:tuple(gleam@any:from({<<"ok">>, <<"ok">>})), |
| 127 | + {ok, {gleam@any:from(<<"ok">>), gleam@any:from(<<"ok">>)}} |
| 128 | + ), |
89 | 129 | gleam@expect:is_error(gleam@any:tuple(gleam@any:from({1}))), |
90 | 130 | gleam@expect:is_error(gleam@any:tuple(gleam@any:from({1, 2, 3}))), |
91 | | - gleam@expect:equal(gleam@result:then(gleam@result:then(gleam@any:tuple(gleam@any:from({1, |
92 | | - 2.0})), |
93 | | - fun(X) -> |
94 | | - gleam@result:map(gleam@any:int(gleam@tuple:first(X)), |
95 | | - fun(F) -> |
96 | | - {F, |
97 | | - gleam@tuple:second(X)} |
98 | | - end) |
99 | | - end), |
100 | | - fun(X) -> |
101 | | - gleam@result:map(gleam@any:float(gleam@tuple:second(X)), |
102 | | - fun(F) -> |
103 | | - {gleam@tuple:first(X), |
104 | | - F} |
105 | | - end) |
106 | | - end), |
107 | | - {ok, {1, 2.0}}). |
| 131 | + gleam@expect:equal( |
| 132 | + gleam@result:then( |
| 133 | + gleam@result:then( |
| 134 | + gleam@any:tuple(gleam@any:from({1, 2.0})), |
| 135 | + fun(X) -> |
| 136 | + gleam@result:map( |
| 137 | + gleam@any:int(gleam@tuple:first(X)), |
| 138 | + fun(F) -> {F, gleam@tuple:second(X)} end |
| 139 | + ) |
| 140 | + end |
| 141 | + ), |
| 142 | + fun(X) -> |
| 143 | + gleam@result:map( |
| 144 | + gleam@any:float(gleam@tuple:second(X)), |
| 145 | + fun(F) -> {gleam@tuple:first(X), F} end |
| 146 | + ) |
| 147 | + end |
| 148 | + ), |
| 149 | + {ok, {1, 2.0}} |
| 150 | + ). |
108 | 151 |
|
109 | 152 | field_test() -> |
110 | 153 | {ok, OkAtom} = gleam@atom:from_string(<<"ok">>), |
111 | | - gleam@expect:equal(gleam@any:field(gleam@any:from(#{}#{ok => 1}), OkAtom), |
112 | | - {ok, gleam@any:from(1)}), |
113 | | - gleam@expect:equal(gleam@any:field(gleam@any:from(#{}#{ok => 3}#{earlier => 2}), |
114 | | - OkAtom), |
115 | | - {ok, gleam@any:from(3)}), |
| 154 | + gleam@expect:equal( |
| 155 | + gleam@any:field(gleam@any:from(#{}#{ok => 1}), OkAtom), |
| 156 | + {ok, gleam@any:from(1)} |
| 157 | + ), |
| 158 | + gleam@expect:equal( |
| 159 | + gleam@any:field(gleam@any:from(#{}#{ok => 3}#{earlier => 2}), OkAtom), |
| 160 | + {ok, gleam@any:from(3)} |
| 161 | + ), |
116 | 162 | gleam@expect:is_error(gleam@any:field(gleam@any:from(#{}), OkAtom)), |
117 | 163 | gleam@expect:is_error(gleam@any:field(gleam@any:from(1), OkAtom)), |
118 | 164 | gleam@expect:is_error(gleam@any:field(gleam@any:from([]), [])). |
0 commit comments