Go to the documentation of this file.
11 #include <testing-utils/catch.hpp>
25 REQUIRE(type.
id() == ID_pointer);
44 const auto &componet = std::find_if(
48 return component.get_name() == component_name;
51 REQUIRE(componet != struct_type.
components().end());
60 REQUIRE(type.
id() == ID_code);
74 REQUIRE(code_type.
parameters().size() == num_params);
97 REQUIRE(method_type.
parameters().size() == num_params);
110 const auto param = std::find_if(
114 return param.get_base_name() == param_name;
117 REQUIRE(param != function_type.
parameters().end());
130 switch(expected.
kind)
182 REQUIRE(generic_type_arguments.size() == type_expectations.size());
185 generic_type_arguments.begin(),
186 generic_type_arguments.end(),
187 type_expectations.begin(),
220 return generic_param;
235 REQUIRE(type.
subtype() == expect_subtype.value());
244 REQUIRE(class_type.
id() == ID_struct);
247 REQUIRE(java_class_type.is_class());
248 REQUIRE_FALSE(java_class_type.get_is_stub());
250 return java_class_type;
258 REQUIRE(class_type.
id() == ID_struct);
261 REQUIRE(java_class_type.is_class());
262 REQUIRE(java_class_type.get_is_stub());
264 return java_class_type;
273 REQUIRE(class_type.
id() == ID_struct);
283 return java_generic_class_type;
292 const typet &class_type,
293 const std::initializer_list<irep_idt> &type_variables)
300 REQUIRE(generic_type_vars.size() == type_variables.size());
303 type_variables.begin(),
304 type_variables.end(),
305 generic_type_vars.begin(),
310 return param.type_variable().get_identifier() == type_var_name;
313 return java_generic_class_type;
332 const typet &class_type,
333 const std::initializer_list<irep_idt> &type_variables)
345 REQUIRE(class_type.
id() == ID_struct);
353 &java_implicitly_generic_class_type =
356 return java_implicitly_generic_class_type;
366 const typet &class_type,
367 const std::initializer_list<irep_idt> &implicit_type_variables)
370 &java_implicitly_generic_class_type =
374 &implicit_generic_type_vars =
376 REQUIRE(implicit_generic_type_vars.size() == implicit_type_variables.size());
379 implicit_type_variables.begin(),
380 implicit_type_variables.end(),
381 implicit_generic_type_vars.begin(),
386 return param.type_variable().get_identifier() == type_var_name;
389 return java_implicitly_generic_class_type;
397 const typet &class_type)
410 const typet &class_type,
411 const std::initializer_list<irep_idt> &implicit_type_variables)
415 class_type, implicit_type_variables);
424 REQUIRE(class_type.
id() == ID_struct);
433 return java_class_type;
453 REQUIRE(type.
id() == ID_struct_tag);
457 REQUIRE(result.get_identifier() == identifier);
469 const std::string &identifier)
492 const std::string &identifier,
500 REQUIRE(generic_type_arguments.size() == type_expectations.size());
503 generic_type_arguments.begin(),
504 generic_type_arguments.end(),
505 type_expectations.begin(),
508 return generic_base_type;
520 const std::vector<std::string> &expected_identifiers)
524 REQUIRE(lambda_method_handles.size() == expected_identifiers.size());
527 lambda_method_handles.begin(),
528 lambda_method_handles.end(),
529 expected_identifiers.begin(),
531 const irept &lambda_method_handle,
532 const std::string &expected_identifier) {
533 return lambda_method_handle.
id() == expected_identifier;
535 return lambda_method_handles;
const irep_idt & get_identifier() const
bool is_java_generic_class_type(const typet &type)
const componentst & components() const
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
code_typet require_code(const typet &type)
Checks a type is a code_type (i.e.
const typet & subtype() const
Class to hold type with generic type arguments, for example java.util.List in either a reference of t...
std::vector< reference_typet > generic_type_argumentst
java_generic_struct_tag_typet require_java_generic_struct_tag_type(const typet &type, const std::string &identifier)
Verify a given type is a java generic symbol type.
const implicit_generic_typest & implicit_generic_types() const
std::vector< java_generic_parametert > generic_typest
The type of an expression, extends irept.
std::initializer_list< expected_type_argumentt > expected_type_argumentst
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 typet to a class_typet.
java_class_typet::java_lambda_method_handlest java_lambda_method_handlest
Class to hold a Java generic type parameter (also called type variable), e.g., T in List<T>.
A struct tag type, i.e., struct_typet with an identifier.
auto component(T &struct_expr, const irep_idt &name, const namespacet &ns) -> decltype(struct_expr.op0())
bool is_java_implicitly_generic_class_type(const typet &type)
const java_generic_class_typet & to_java_generic_class_type(const java_class_typet &type)
const generic_typest & generic_types() const
const typet & require_java_non_generic_type(const typet &type, const optionalt< struct_tag_typet > &expect_subtype)
Test a type to ensure it is not a java generics type.
const generic_typest & generic_types() const
java_generic_typet require_java_generic_type(const typet &type)
Verify a given type is a java_generic_type.
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
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.
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.
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_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.
const java_generic_struct_tag_typet & to_java_generic_struct_tag_type(const typet &type)
const generic_type_argumentst & generic_type_arguments() const
class_typet require_complete_class(const typet &class_type)
Checks that the given type is a complete class.
bool base_type_eq(const typet &type1, const typet &type2, const namespacet &ns)
Check types for equality across all levels of hierarchy.
java_generic_parametert require_java_generic_parameter(const typet &type)
Verify a given type is a java_generic_parameter, e.g., T
bool is_java_generic_parameter(const typet &type)
Checks whether the type is a java generic parameter/variable, e.g., T in List<T>.
java_method_typet require_java_method(const typet &type)
Checks a type is a java_method_typet (i.e.
bool is_java_generic_struct_tag_type(const typet &type)
bool is_java_generic_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...
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 irep_idt & id() const
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
const parameterst & parameters() const
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
java_generic_class_typet require_java_generic_class(const typet &class_type)
Verify that a class is a valid java generic class.
const java_generic_typet & to_java_generic_type(const typet &type)
nonstd::optional< T > optionalt
Structure type, corresponds to C style structs.
class_typet require_incomplete_class(const typet &class_type)
Checks that the given type is an incomplete class.
const java_generic_parametert & to_java_generic_parameter(const typet &type)
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.
std::vector< java_generic_parametert > implicit_generic_typest
java_class_typet require_java_non_generic_class(const typet &class_type)
Verify that a class is a valid nongeneric java class.
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 can_cast_type< java_method_typet >(const typet &type)
const java_implicitly_generic_class_typet & to_java_implicitly_generic_class_type(const java_class_typet &type)
Type for a generic symbol, extends struct_tag_typet with a vector of java generic types.
pointer_typet require_pointer(const typet &type, const optionalt< typet > &subtype)
Checks a type is a pointer type optionally with a specific subtype.
Base class for tree-like data structures with sharing.
Class to hold a class with generics, extends the java class type with a vector of java generic type p...
const java_class_typet & to_java_class_type(const typet &type)
const java_method_typet & to_java_method_type(const typet &type)
The pointer type These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (they ...
const struct_tag_typet & require_struct_tag(const typet &type, const irep_idt &identifier="")
Verify a given type is a symbol type, optionally with a specific identifier.
const java_lambda_method_handlest & lambda_method_handles() const
java_generic_class_typet require_complete_java_generic_class(const typet &class_type)
Verify that a class is a complete, valid java generic class.
const type_variablet & type_variable() const