(t *testing.T)
| 1247 | } |
| 1248 | |
| 1249 | func TestSubsetFunction(t *testing.T) { |
| 1250 | tests := []struct { |
| 1251 | name string |
| 1252 | lib *LibrarySubset |
| 1253 | orig *decls.FunctionDecl |
| 1254 | subset *decls.FunctionDecl |
| 1255 | included bool |
| 1256 | }{ |
| 1257 | { |
| 1258 | name: "nil lib, included", |
| 1259 | orig: mustNewFunction(t, "size", decls.Overload("size_string", []*types.Type{types.StringType}, types.IntType)), |
| 1260 | subset: mustNewFunction(t, "size", decls.Overload("size_string", []*types.Type{types.StringType}, types.IntType)), |
| 1261 | included: true, |
| 1262 | }, |
| 1263 | { |
| 1264 | name: "empty, included", |
| 1265 | lib: NewLibrarySubset(), |
| 1266 | orig: mustNewFunction(t, "size", decls.Overload("size_string", []*types.Type{types.StringType}, types.IntType)), |
| 1267 | subset: mustNewFunction(t, "size", decls.Overload("size_string", []*types.Type{types.StringType}, types.IntType)), |
| 1268 | included: true, |
| 1269 | }, |
| 1270 | { |
| 1271 | name: "empty, disabled", |
| 1272 | lib: NewLibrarySubset().SetDisabled(true), |
| 1273 | orig: mustNewFunction(t, "size", decls.Overload("size_string", []*types.Type{types.StringType}, types.IntType)), |
| 1274 | included: false, |
| 1275 | }, |
| 1276 | { |
| 1277 | name: "lib, not included allow-list", |
| 1278 | lib: NewLibrarySubset().AddIncludedFunctions([]*Function{ |
| 1279 | {Name: "int"}, |
| 1280 | }...), |
| 1281 | orig: mustNewFunction(t, "size", decls.Overload("size_string", []*types.Type{types.StringType}, types.IntType)), |
| 1282 | included: false, |
| 1283 | }, |
| 1284 | { |
| 1285 | name: "lib, included whole function", |
| 1286 | lib: NewLibrarySubset().AddIncludedFunctions([]*Function{ |
| 1287 | {Name: "size"}, |
| 1288 | }...), |
| 1289 | orig: mustNewFunction(t, "size", decls.Overload("size_string", []*types.Type{types.StringType}, types.IntType)), |
| 1290 | subset: mustNewFunction(t, "size", decls.Overload("size_string", []*types.Type{types.StringType}, types.IntType)), |
| 1291 | included: true, |
| 1292 | }, |
| 1293 | { |
| 1294 | name: "lib, included overload subset", |
| 1295 | lib: NewLibrarySubset().AddIncludedFunctions([]*Function{ |
| 1296 | {Name: "size", Overloads: []*Overload{{ID: "size_string"}}}, |
| 1297 | }...), |
| 1298 | orig: mustNewFunction(t, "size", |
| 1299 | decls.Overload("size_string", []*types.Type{types.StringType}, types.IntType), |
| 1300 | decls.Overload("size_list", []*types.Type{types.NewListType(types.NewTypeParamType("T"))}, types.IntType), |
| 1301 | ), |
| 1302 | subset: mustNewFunction(t, "size", decls.Overload("size_string", []*types.Type{types.StringType}, types.IntType)), |
| 1303 | included: true, |
| 1304 | }, |
| 1305 | { |
| 1306 | name: "lib, included deny-list", |
nothing calls this directly
no test coverage detected