10
10
#include < testing-utils/require_goto_statements.h>
11
11
#include < util/config.h>
12
12
#include < testing-utils/require_type.h>
13
+ #include < testing-utils/require_symbol.h>
13
14
14
15
// NOTE: To inspect these tests at any point, use expr2java.
15
16
// A good way to verify the validity of a test is to iterate
@@ -504,18 +505,20 @@ SCENARIO(
504
505
505
506
THEN (" The struct for UnsupportedWrapper2 is complete and non-generic" )
506
507
{
507
- const std::string superclass_name = " java::UnsupportedWrapper2" ;
508
- REQUIRE (symbol_table.has_symbol (superclass_name));
509
-
508
+ const std::string field_class_name = " java::UnsupportedWrapper2" ;
510
509
const symbolt &superclass_symbol =
511
- symbol_table.lookup_ref (superclass_name);
512
- require_type::require_java_non_generic_class (superclass_symbol.type );
510
+ require_symbol::require_symbol_exists (symbol_table, field_class_name);
511
+
512
+ require_type::require_complete_java_non_generic_class (
513
+ superclass_symbol.type );
513
514
}
514
515
515
516
WHEN (" The method input argument is created in the entry point function" )
516
517
{
517
- // For an explanation of this part, look at the comments for the similar
518
- // parts of the previous tests.
518
+ // We trace the creation of the object that is being supplied as
519
+ // the input to the method under test. There must be one non-null
520
+ // assignment only, and usually looks like this:
521
+ // this = &tmp_object_factory$1;
519
522
const std::vector<codet> &entry_point_code =
520
523
require_goto_statements::require_entry_point_statements (symbol_table);
521
524
@@ -525,6 +528,10 @@ SCENARIO(
525
528
526
529
THEN (" Object 'this' has field 'f' of type UnsupportedWrapper2" )
527
530
{
531
+ // tmp_object_factory$1.f = &tmp_object_factory$2;
532
+ // struct UnsupportedWrapper2 { struct java.lang.Object
533
+ // @java.lang.Object; struct java.lang.Object *field; }
534
+ // tmp_object_factory$2;
528
535
const auto &field_input_name =
529
536
require_goto_statements::require_struct_component_assignment (
530
537
tmp_object_name,
@@ -536,6 +543,9 @@ SCENARIO(
536
543
537
544
THEN (" Object 'f' has unspecialized field 'field'" )
538
545
{
546
+ // tmp_object_factory$2.field = &tmp_object_factory$3;
547
+ // struct java.lang.Object { __CPROVER_string @class_identifier;
548
+ // boolean @lock; } tmp_object_factory$3;
539
549
require_goto_statements::require_struct_component_assignment (
540
550
field_input_name,
541
551
{},
@@ -553,23 +563,18 @@ SCENARIO(
553
563
" incomplete and not marked as generic)" )
554
564
{
555
565
const symbol_tablet &symbol_table = load_java_class (
556
- " GenericFieldMocked " ,
566
+ " GenericFieldOpaque " ,
557
567
" ./goto-programs/goto_program_generics" ,
558
- " GenericFieldMocked .foo" );
568
+ " GenericFieldOpaque .foo" );
559
569
560
- THEN (" The struct for MockedWrapper is incomplete and not-generic" )
570
+ THEN (" The struct for OpaqueWrapper is incomplete and not-generic" )
561
571
{
562
- const std::string superclass_name = " java::MockedWrapper" ;
563
- REQUIRE (symbol_table.has_symbol (superclass_name));
572
+ const std::string field_class_name = " java::OpaqueWrapper" ;
573
+ const symbolt &field_class_symbol =
574
+ require_symbol::require_symbol_exists (symbol_table, field_class_name);
564
575
565
- const symbolt &superclass_symbol =
566
- symbol_table.lookup_ref (superclass_name);
567
- const java_class_typet &superclass_type =
568
- to_java_class_type (to_class_type (superclass_symbol.type ));
569
- REQUIRE (
570
- to_class_type (superclass_symbol.type ).get_bool (ID_incomplete_class));
571
- REQUIRE (!is_java_generic_class_type (superclass_type));
572
- REQUIRE (!is_java_implicitly_generic_class_type (superclass_type));
576
+ require_type::require_incomplete_class (field_class_symbol.type );
577
+ require_type::require_java_non_generic_class (field_class_symbol.type );
573
578
}
574
579
575
580
WHEN (" The method input argument is created in the entry point function" )
@@ -583,14 +588,14 @@ SCENARIO(
583
588
require_goto_statements::require_entry_point_argument_assignment (
584
589
" this" , entry_point_code);
585
590
586
- THEN (" Object 'this' has field 'f' of type MockedWrapper " )
591
+ THEN (" Object 'this' has field 'f' of type OpaqueWrapper " )
587
592
{
588
593
const auto &field_input_name =
589
594
require_goto_statements::require_struct_component_assignment (
590
595
tmp_object_name,
591
596
{},
592
597
" f" ,
593
- " java::MockedWrapper " ,
598
+ " java::OpaqueWrapper " ,
594
599
{},
595
600
entry_point_code);
596
601
0 commit comments