CBMC
require_type.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Unit test utilities
4 
5 Author: Diffblue Ltd.
6 
7 \*******************************************************************/
8 
14 
15 #ifndef CPROVER_JAVA_TESTING_UTILS_REQUIRE_TYPE_H
16 #define CPROVER_JAVA_TESTING_UTILS_REQUIRE_TYPE_H
17 
18 #include <util/std_types.h>
20 
21 // NOLINTNEXTLINE(readability/namespace)
22 namespace require_type
23 {
25 require_pointer(const typet &type, const std::optional<typet> &subtype);
26 
27 #if defined(__GNUC__) && __GNUC__ >= 14
28 [[gnu::no_dangling]]
29 #endif
30 const struct_tag_typet &
31 require_struct_tag(const typet &type, const irep_idt &identifier = "");
32 
34  const typet &type,
35  const irep_idt &identifier = irep_idt());
36 
38  const java_class_typet &java_class_type,
39  const irep_idt &component_name);
40 
42  const struct_typet &struct_type,
43  const irep_idt &component_name);
44 
45 code_typet require_code(const typet &type);
47 
49 require_parameter(const code_typet &function_type, const irep_idt &param_name);
50 
51 code_typet require_code(const typet &type, const size_t num_params);
53 require_java_method(const typet &type, const size_t num_params);
54 
55 // A mini DSL for describing an expected set of type arguments for a
56 // java_generic_typet
58 {
59  Inst,
60  Var
61 };
63 {
66 };
67 typedef std::initializer_list<expected_type_argumentt>
69 
71 
73  const typet &type,
74  const require_type::expected_type_argumentst &type_expectations);
75 
77 
79  const typet &type,
80  const irep_idt &parameter);
81 
83  const typet &type,
84  const std::optional<struct_tag_typet> &expect_subtype);
85 
86 class_typet require_complete_class(const typet &class_type);
87 
88 class_typet require_incomplete_class(const typet &class_type);
89 
91 
93  const typet &class_type,
94  const std::initializer_list<irep_idt> &type_variables);
95 
98 
100  const typet &class_type,
101  const std::initializer_list<irep_idt> &type_parameters);
102 
105 
107  const typet &class_type,
108  const std::initializer_list<irep_idt> &implicit_type_variables);
109 
112 
115  const typet &class_type,
116  const std::initializer_list<irep_idt> &implicit_type_variables);
117 
119 
122 
124  const typet &type,
125  const std::string &identifier);
126 
128  const typet &type,
129  const std::string &identifier,
130  const require_type::expected_type_argumentst &type_expectations);
131 
134 
136  const java_class_typet &class_type,
137  const std::vector<std::string> &expected_identifiers);
138 }
139 
140 #endif // CPROVER_JAVA_TESTING_UTILS_REQUIRE_TYPE_H
Class type.
Definition: std_types.h:325
Base type of functions.
Definition: std_types.h:583
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:38
std::vector< java_lambda_method_handlet > java_lambda_method_handlest
Definition: java_types.h:514
Class to hold a class with generics, extends the java class type with a vector of java generic type p...
Definition: java_types.h:972
Reference that points to a java_generic_parameter_tagt.
Definition: java_types.h:775
Class to hold type with generic type arguments, for example java.util.List in either a reference of t...
Definition: java_types.h:857
Reference that points to a java_generic_struct_tag_typet.
Definition: java_types.h:914
Type to hold a Java class that is implicitly generic, e.g., an inner class of a generic outer class o...
Definition: java_types.h:1067
The pointer type These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (they ...
Definition: pointer_expr.h:24
A struct tag type, i.e., struct_typet with an identifier.
Definition: std_types.h:493
Structure type, corresponds to C style structs.
Definition: std_types.h:231
The type of an expression, extends irept.
Definition: type.h:29
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_incomplete_class(const typet &class_type)
Checks that the given type is an incomplete class.
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.
pointer_typet require_pointer_to_tag(const typet &type, const irep_idt &identifier=irep_idt())
code_typet::parametert require_parameter(const code_typet &function_type, const irep_idt &param_name)
Verify that a function has a parameter of a specific name.
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.
java_generic_typet require_java_generic_type(const typet &type)
Verify a given type is a java_generic_type.
std::initializer_list< expected_type_argumentt > expected_type_argumentst
Definition: require_type.h:68
class_typet require_complete_class(const typet &class_type)
Checks that the given type is a complete class.
java_class_typet::java_lambda_method_handlest java_lambda_method_handlest
Definition: require_type.h:133
java_generic_parametert require_java_generic_parameter(const typet &type)
Verify a given type is a java_generic_parameter, e.g., T
java_class_typet require_complete_java_non_generic_class(const typet &class_type)
Verify that a class is a complete, valid nongeneric java class.
java_generic_class_typet require_java_generic_class(const typet &class_type)
Verify that a class is a valid java generic class.
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 typet & require_java_non_generic_type(const typet &type, const std::optional< struct_tag_typet > &expect_subtype)
Test a type to ensure it is not a java generics type.
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.
java_class_typet require_java_non_generic_class(const typet &class_type)
Verify that a class is a valid nongeneric java class.
code_typet require_code(const typet &type)
Checks a type is a code_type (i.e.
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.
java_method_typet require_java_method(const typet &type)
Checks a type is a java_method_typet (i.e.
pointer_typet require_pointer(const typet &type, const std::optional< typet > &subtype)
Checks a type is a pointer type optionally with a specific subtype.
java_class_typet::componentt require_component(const java_class_typet &java_class_type, const irep_idt &component_name)
Checks that a class has a component with a specific name.
Pre-defined types.
dstringt irep_idt