| 1209 | } |
| 1210 | |
| 1211 | func TestType3(t *testing.T) { |
| 1212 | // functions with named types... |
| 1213 | testCases := map[string]*Type{ |
| 1214 | "func(input str) bool": { |
| 1215 | Kind: KindFunc, |
| 1216 | Map: map[string]*Type{ |
| 1217 | "input": { |
| 1218 | Kind: KindStr, |
| 1219 | }, |
| 1220 | }, |
| 1221 | Ord: []string{ |
| 1222 | "input", // must match |
| 1223 | }, |
| 1224 | Out: &Type{ |
| 1225 | Kind: KindBool, |
| 1226 | }, |
| 1227 | }, |
| 1228 | "func(a str) bool": { |
| 1229 | Kind: KindFunc, |
| 1230 | // key names are arbitrary... |
| 1231 | Map: map[string]*Type{ |
| 1232 | "a": { |
| 1233 | Kind: KindStr, |
| 1234 | }, |
| 1235 | }, |
| 1236 | Ord: []string{ |
| 1237 | "a", // must match |
| 1238 | }, |
| 1239 | Out: &Type{ |
| 1240 | Kind: KindBool, |
| 1241 | }, |
| 1242 | }, |
| 1243 | "func(aaa str, bb int) bool": { |
| 1244 | Kind: KindFunc, |
| 1245 | // key names are arbitrary... |
| 1246 | Map: map[string]*Type{ |
| 1247 | "aaa": { |
| 1248 | Kind: KindStr, |
| 1249 | }, |
| 1250 | "bb": { |
| 1251 | Kind: KindInt, |
| 1252 | }, |
| 1253 | }, |
| 1254 | Ord: []string{ |
| 1255 | "aaa", |
| 1256 | "bb", |
| 1257 | }, |
| 1258 | Out: &Type{ |
| 1259 | Kind: KindBool, |
| 1260 | }, |
| 1261 | }, |
| 1262 | "func(aaa map{str: int}) bool": { |
| 1263 | Kind: KindFunc, |
| 1264 | // key names are arbitrary... |
| 1265 | Map: map[string]*Type{ |
| 1266 | "aaa": { |
| 1267 | Kind: KindMap, |
| 1268 | Key: &Type{ |