(t *testing.T)
| 1140 | } |
| 1141 | |
| 1142 | func TestSubsetFunction(t *testing.T) { |
| 1143 | tests := []struct { |
| 1144 | name string |
| 1145 | lib *LibrarySubset |
| 1146 | orig *decls.FunctionDecl |
| 1147 | subset *decls.FunctionDecl |
| 1148 | included bool |
| 1149 | }{ |
| 1150 | { |
| 1151 | name: "nil lib, included", |
| 1152 | orig: mustNewFunction(t, "size", decls.Overload("size_string", []*types.Type{types.StringType}, types.IntType)), |
| 1153 | subset: mustNewFunction(t, "size", decls.Overload("size_string", []*types.Type{types.StringType}, types.IntType)), |
| 1154 | included: true, |
| 1155 | }, |
| 1156 | { |
| 1157 | name: "empty, included", |
| 1158 | lib: NewLibrarySubset(), |
| 1159 | orig: mustNewFunction(t, "size", decls.Overload("size_string", []*types.Type{types.StringType}, types.IntType)), |
| 1160 | subset: mustNewFunction(t, "size", decls.Overload("size_string", []*types.Type{types.StringType}, types.IntType)), |
| 1161 | included: true, |
| 1162 | }, |
| 1163 | { |
| 1164 | name: "empty, disabled", |
| 1165 | lib: NewLibrarySubset().SetDisabled(true), |
| 1166 | orig: mustNewFunction(t, "size", decls.Overload("size_string", []*types.Type{types.StringType}, types.IntType)), |
| 1167 | included: false, |
| 1168 | }, |
| 1169 | { |
| 1170 | name: "lib, not included allow-list", |
| 1171 | lib: NewLibrarySubset().AddIncludedFunctions([]*Function{ |
| 1172 | {Name: "int"}, |
| 1173 | }...), |
| 1174 | orig: mustNewFunction(t, "size", decls.Overload("size_string", []*types.Type{types.StringType}, types.IntType)), |
| 1175 | included: false, |
| 1176 | }, |
| 1177 | { |
| 1178 | name: "lib, included whole function", |
| 1179 | lib: NewLibrarySubset().AddIncludedFunctions([]*Function{ |
| 1180 | {Name: "size"}, |
| 1181 | }...), |
| 1182 | orig: mustNewFunction(t, "size", decls.Overload("size_string", []*types.Type{types.StringType}, types.IntType)), |
| 1183 | subset: mustNewFunction(t, "size", decls.Overload("size_string", []*types.Type{types.StringType}, types.IntType)), |
| 1184 | included: true, |
| 1185 | }, |
| 1186 | { |
| 1187 | name: "lib, included overload subset", |
| 1188 | lib: NewLibrarySubset().AddIncludedFunctions([]*Function{ |
| 1189 | {Name: "size", Overloads: []*Overload{{ID: "size_string"}}}, |
| 1190 | }...), |
| 1191 | orig: mustNewFunction(t, "size", |
| 1192 | decls.Overload("size_string", []*types.Type{types.StringType}, types.IntType), |
| 1193 | decls.Overload("size_list", []*types.Type{types.NewListType(types.NewTypeParamType("T"))}, types.IntType), |
| 1194 | ), |
| 1195 | subset: mustNewFunction(t, "size", decls.Overload("size_string", []*types.Type{types.StringType}, types.IntType)), |
| 1196 | included: true, |
| 1197 | }, |
| 1198 | { |
| 1199 | name: "lib, included deny-list", |
nothing calls this directly
no test coverage detected