11 #include <testing-utils/catch.hpp> 23 REQUIRE(type.
id() == ID_pointer);
29 REQUIRE(pointer.subtype() == subtype.value());
42 const auto &componet = std::find_if(
46 return component.get_name() == component_name;
49 REQUIRE(componet != struct_type.
components().end());
58 REQUIRE(type.
id() == ID_code);
72 REQUIRE(code_type.
parameters().size() == num_params);
85 const auto param = std::find_if(
89 return param.get_base_name() == param_name;
92 REQUIRE(param != function_type.
parameters().end());
105 switch(expected.
kind)
157 REQUIRE(generic_type_arguments.size() == type_expectations.size());
160 generic_type_arguments.begin(),
161 generic_type_arguments.end(),
162 type_expectations.begin(),
195 return generic_param;
210 REQUIRE(type.
subtype() == expect_subtype.value());
219 REQUIRE(class_type.
id() == ID_struct);
222 REQUIRE(class_class_type.is_class());
223 REQUIRE_FALSE(class_class_type.get_bool(ID_incomplete_class));
225 return class_class_type;
233 REQUIRE(class_type.
id() == ID_struct);
236 REQUIRE(class_class_type.is_class());
237 REQUIRE(class_class_type.get_bool(ID_incomplete_class));
239 return class_class_type;
248 REQUIRE(class_type.
id() == ID_struct);
258 return java_generic_class_type;
267 const typet &class_type,
268 const std::initializer_list<irep_idt> &type_variables)
275 REQUIRE(generic_type_vars.size() == type_variables.size());
278 type_variables.begin(),
279 type_variables.end(),
280 generic_type_vars.begin(),
285 return param.type_variable().get_identifier() == type_var_name;
288 return java_generic_class_type;
307 const typet &class_type,
308 const std::initializer_list<irep_idt> &type_variables)
320 REQUIRE(class_type.
id() == ID_struct);
328 &java_implicitly_generic_class_type =
331 return java_implicitly_generic_class_type;
341 const typet &class_type,
342 const std::initializer_list<irep_idt> &implicit_type_variables)
345 &java_implicitly_generic_class_type =
349 &implicit_generic_type_vars =
351 REQUIRE(implicit_generic_type_vars.size() == implicit_type_variables.size());
354 implicit_type_variables.begin(),
355 implicit_type_variables.end(),
356 implicit_generic_type_vars.begin(),
361 return param.type_variable().get_identifier() == type_var_name;
364 return java_implicitly_generic_class_type;
372 const typet &class_type)
385 const typet &class_type,
386 const std::initializer_list<irep_idt> &implicit_type_variables)
390 class_type, implicit_type_variables);
399 REQUIRE(class_type.
id() == ID_struct);
408 return java_class_type;
428 REQUIRE(type.
id() == ID_symbol);
432 REQUIRE(result.get_identifier() == identifier);
443 const std::string &identifier)
465 const std::string &identifier,
473 REQUIRE(generic_type_arguments.size() == type_expectations.size());
476 generic_type_arguments.begin(),
477 generic_type_arguments.end(),
478 type_expectations.begin(),
481 return generic_base_type;
493 const std::vector<std::string> &expected_identifiers)
497 REQUIRE(lambda_method_handles.size() == expected_identifiers.size());
501 lambda_method_handles.begin(),
502 lambda_method_handles.end(),
503 expected_identifiers.begin(),
506 const std::string &expected_identifier) {
507 return lambda_method_handle.
get_identifier() == expected_identifier;
509 return lambda_method_handles;
The type of an expression.
java_generic_class_typet require_complete_java_generic_class(const typet &class_type)
Verify that a class is a complete, valid java generic class.
std::vector< java_generic_parametert > implicit_generic_typest
const java_lambda_method_handlest & lambda_method_handles() const
bool is_java_generic_symbol_type(const typet &type)
java_generic_symbol_typet require_java_generic_symbol_type(const typet &type, const std::string &identifier)
Verify a given type is a java generic symbol type.
const java_generic_class_typet & to_java_generic_class_type(const java_class_typet &type)
const typet & require_java_non_generic_type(const typet &type, const optionalt< symbol_typet > &expect_subtype)
Test a type to ensure it is not a java generics type.
const code_typet & to_code_type(const typet &type)
Cast a generic typet to a code_typet.
bool is_java_generic_parameter(const typet &type)
Checks whether the type is a java generic parameter/variable, e.g., T in List<T>. ...
const irep_idt & get_identifier() const
const symbol_typet & to_symbol_type(const typet &type)
Cast a generic typet to a symbol_typet.
const java_generic_parametert & to_java_generic_parameter(const typet &type)
const componentst & components() const
java_implicitly_generic_class_typet require_complete_java_implicitly_generic_class(const typet &class_type)
Verify that a class is a complete, valid java implicitly generic class.
const class_typet & to_class_type(const typet &type)
Cast a generic typet to a class_typet.
java_lambda_method_handlest require_lambda_method_handles(const java_class_typet &class_type, const std::vector< std::string > &expected_identifiers)
Verify that the lambda method handles of a class match the given expectation.
std::initializer_list< expected_type_argumentt > expected_type_argumentst
java_class_typet::java_lambda_method_handlest java_lambda_method_handlest
const generic_type_argumentst & generic_type_arguments() const
const irep_idt & id() const
const java_generic_symbol_typet & to_java_generic_symbol_type(const typet &type)
const type_variablet & type_variable() const
std::vector< reference_typet > generic_type_argumentst
Class to hold a class with generics, extends the java class type with a vector of java generic type p...
A reference into the symbol table.
java_generic_parametert require_java_generic_parameter(const typet &type)
Verify a given type is a java_generic_parameter, e.g., T
nonstd::optional< T > optionalt
const java_implicitly_generic_class_typet & to_java_implicitly_generic_class_type(const java_class_typet &type)
java_implicitly_generic_class_typet require_java_implicitly_generic_class(const typet &class_type)
Verify that a class is a valid java implicitly generic class.
class_typet require_complete_class(const typet &class_type)
Checks that the given type is a complete class.
const symbol_typet & require_symbol(const typet &type, const irep_idt &identifier="")
Verify a given type is a symbol type, optionally with a specific identifier.
java_generic_typet require_java_generic_type(const typet &type)
Verify a given type is a java_generic_type.
java_class_typet require_complete_java_non_generic_class(const typet &class_type)
Verify that a class is a complete, valid nongeneric java class.
const generic_typest & generic_types() const
bool is_java_generic_class_type(const typet &type)
symbol_exprt require_symbol(const exprt &expr, const irep_idt &symbol_name)
Verify a given exprt is an symbol_exprt with a identifier name equal to the symbol_name.
Type for a generic symbol, extends symbol_typet with a vector of java generic types.
java_generic_class_typet require_java_generic_class(const typet &class_type)
Verify that a class is a valid java generic class.
const implicit_generic_typest & implicit_generic_types() const
code_typet::parametert require_parameter(const code_typet &function_type, const irep_idt ¶m_name)
Verify that a function has a parameter of a specific name.
java_class_typet require_java_non_generic_class(const typet &class_type)
Verify that a class is a valid nongeneric java class.
Class to hold type with generic type arguments, for example java.util.List in either a reference of t...
const java_generic_typet & to_java_generic_type(const typet &type)
const parameterst & parameters() const
pointer_typet require_pointer(const typet &type, const optionalt< typet > &subtype)
Checks a type is a pointer type optionally with a specific subtype.
Class to hold a Java generic type parameter (also called type variable), e.g., T in List<T>...
code_typet require_code(const typet &type)
Checks a type is a code_type (i.e.
Expression to hold a symbol (variable)
bool is_java_generic_type(const typet &type)
const pointer_typet & to_pointer_type(const typet &type)
Cast a generic typet to a pointer_typet.
class_typet require_incomplete_class(const typet &class_type)
Checks that the given type is an incomplete class.
const typet & subtype() const
struct_typet::componentt require_component(const struct_typet &struct_type, const irep_idt &component_name)
Checks a struct like type has a component with a specific name.
bool is_java_implicitly_generic_class_type(const typet &type)
Type to hold a Java class that is implicitly generic, e.g., an inner class of a generic outer class o...
Helper functions for requiring specific types If the type is of the wrong type, throw a CATCH excepti...
const java_class_typet & to_java_class_type(const typet &type)
const irep_idt & get_identifier() const
const generic_typest & generic_types() const
bool require_java_generic_type_argument_expectation(const reference_typet &type_argument, const require_type::expected_type_argumentt &expected)
Helper function for testing that java generic type arguments match a given expectation.
std::vector< java_generic_parametert > generic_typest