From d3299c163f57c77255120b45841f6753d0395811 Mon Sep 17 00:00:00 2001 From: Konan Denisman Date: Fri, 20 Oct 2023 11:56:56 +0300 Subject: [PATCH] [ets] added tests for 15.2 least upper bound Signed-off-by: Konan Denisman --- .../array_type.ets | 0 .../cast_to_object.ets | 0 .../cast_to_object_array.ets | 0 .../cast_to_superclass.ets | 0 .../primitive_cast_to_object.ets | 0 .../generic_cast_to_generic_superclass.ets | 0 .../generic_cast_to_object.ets | 0 ...generic_cast_to_object_with_parameters.ets | 0 .../generic_cast_to_superclass.ets | 0 .../generic_sub_and_superinterfaces.ets | 0 .../generic_suberinterface.ets | 0 .../non_generic_cast_to_object.ets | 0 .../non_generic_cast_to_superclass.ets | 0 .../non_generic_superinterface.ets | 0 .../primitive_types_cast.ets | 0 .../primitive_types_cast.params.yaml | 0 .../02.least_upper_bound/negative_cases.ets | 15 +++++++++++++ .../negative_cases.params.yaml | 12 ++++++++++ .../02.least_upper_bound/positive_cases.ets | 15 +++++++++++++ .../positive_cases.params.yaml | 22 +++++++++++++++++++ .../03.override_equivalent_signatures/neg.ets | 0 .../neg.params.yaml | 0 .../03.override_equivalent_signatures/pos.ets | 0 .../pos.params.yaml | 0 .../runner/plugins/ets/ets-cts-ignored.txt | 4 ++-- 25 files changed, 66 insertions(+), 2 deletions(-) rename plugins/ets/tests/ets-templates/{14.semantic_rules => 15.semantic_rules}/01.subtyping/subtyping_among_array_types/array_type.ets (100%) rename plugins/ets/tests/ets-templates/{14.semantic_rules => 15.semantic_rules}/01.subtyping/subtyping_among_array_types/cast_to_object.ets (100%) rename plugins/ets/tests/ets-templates/{14.semantic_rules => 15.semantic_rules}/01.subtyping/subtyping_among_array_types/cast_to_object_array.ets (100%) rename plugins/ets/tests/ets-templates/{14.semantic_rules => 15.semantic_rules}/01.subtyping/subtyping_among_array_types/cast_to_superclass.ets (100%) rename plugins/ets/tests/ets-templates/{14.semantic_rules => 15.semantic_rules}/01.subtyping/subtyping_among_array_types/primitive_cast_to_object.ets (100%) rename plugins/ets/tests/ets-templates/{14.semantic_rules => 15.semantic_rules}/01.subtyping/subtyping_among_class_and_interface_types/generic_cast_to_generic_superclass.ets (100%) rename plugins/ets/tests/ets-templates/{14.semantic_rules => 15.semantic_rules}/01.subtyping/subtyping_among_class_and_interface_types/generic_cast_to_object.ets (100%) rename plugins/ets/tests/ets-templates/{14.semantic_rules => 15.semantic_rules}/01.subtyping/subtyping_among_class_and_interface_types/generic_cast_to_object_with_parameters.ets (100%) rename plugins/ets/tests/ets-templates/{14.semantic_rules => 15.semantic_rules}/01.subtyping/subtyping_among_class_and_interface_types/generic_cast_to_superclass.ets (100%) rename plugins/ets/tests/ets-templates/{14.semantic_rules => 15.semantic_rules}/01.subtyping/subtyping_among_class_and_interface_types/generic_sub_and_superinterfaces.ets (100%) rename plugins/ets/tests/ets-templates/{14.semantic_rules => 15.semantic_rules}/01.subtyping/subtyping_among_class_and_interface_types/generic_suberinterface.ets (100%) rename plugins/ets/tests/ets-templates/{14.semantic_rules => 15.semantic_rules}/01.subtyping/subtyping_among_class_and_interface_types/non_generic_cast_to_object.ets (100%) rename plugins/ets/tests/ets-templates/{14.semantic_rules => 15.semantic_rules}/01.subtyping/subtyping_among_class_and_interface_types/non_generic_cast_to_superclass.ets (100%) rename plugins/ets/tests/ets-templates/{14.semantic_rules => 15.semantic_rules}/01.subtyping/subtyping_among_class_and_interface_types/non_generic_superinterface.ets (100%) rename plugins/ets/tests/ets-templates/{14.semantic_rules => 15.semantic_rules}/01.subtyping/subtyping_among_primitive_types/primitive_types_cast.ets (100%) rename plugins/ets/tests/ets-templates/{14.semantic_rules => 15.semantic_rules}/01.subtyping/subtyping_among_primitive_types/primitive_types_cast.params.yaml (100%) create mode 100644 plugins/ets/tests/ets-templates/15.semantic_rules/02.least_upper_bound/negative_cases.ets create mode 100644 plugins/ets/tests/ets-templates/15.semantic_rules/02.least_upper_bound/negative_cases.params.yaml create mode 100644 plugins/ets/tests/ets-templates/15.semantic_rules/02.least_upper_bound/positive_cases.ets create mode 100644 plugins/ets/tests/ets-templates/15.semantic_rules/02.least_upper_bound/positive_cases.params.yaml rename plugins/ets/tests/ets-templates/{14.semantic_rules => 15.semantic_rules}/03.override_equivalent_signatures/neg.ets (100%) rename plugins/ets/tests/ets-templates/{14.semantic_rules => 15.semantic_rules}/03.override_equivalent_signatures/neg.params.yaml (100%) rename plugins/ets/tests/ets-templates/{14.semantic_rules => 15.semantic_rules}/03.override_equivalent_signatures/pos.ets (100%) rename plugins/ets/tests/ets-templates/{14.semantic_rules => 15.semantic_rules}/03.override_equivalent_signatures/pos.params.yaml (100%) diff --git a/plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_array_types/array_type.ets b/plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_array_types/array_type.ets similarity index 100% rename from plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_array_types/array_type.ets rename to plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_array_types/array_type.ets diff --git a/plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_array_types/cast_to_object.ets b/plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_array_types/cast_to_object.ets similarity index 100% rename from plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_array_types/cast_to_object.ets rename to plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_array_types/cast_to_object.ets diff --git a/plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_array_types/cast_to_object_array.ets b/plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_array_types/cast_to_object_array.ets similarity index 100% rename from plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_array_types/cast_to_object_array.ets rename to plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_array_types/cast_to_object_array.ets diff --git a/plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_array_types/cast_to_superclass.ets b/plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_array_types/cast_to_superclass.ets similarity index 100% rename from plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_array_types/cast_to_superclass.ets rename to plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_array_types/cast_to_superclass.ets diff --git a/plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_array_types/primitive_cast_to_object.ets b/plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_array_types/primitive_cast_to_object.ets similarity index 100% rename from plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_array_types/primitive_cast_to_object.ets rename to plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_array_types/primitive_cast_to_object.ets diff --git a/plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_cast_to_generic_superclass.ets b/plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_cast_to_generic_superclass.ets similarity index 100% rename from plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_cast_to_generic_superclass.ets rename to plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_cast_to_generic_superclass.ets diff --git a/plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_cast_to_object.ets b/plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_cast_to_object.ets similarity index 100% rename from plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_cast_to_object.ets rename to plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_cast_to_object.ets diff --git a/plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_cast_to_object_with_parameters.ets b/plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_cast_to_object_with_parameters.ets similarity index 100% rename from plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_cast_to_object_with_parameters.ets rename to plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_cast_to_object_with_parameters.ets diff --git a/plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_cast_to_superclass.ets b/plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_cast_to_superclass.ets similarity index 100% rename from plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_cast_to_superclass.ets rename to plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_cast_to_superclass.ets diff --git a/plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_sub_and_superinterfaces.ets b/plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_sub_and_superinterfaces.ets similarity index 100% rename from plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_sub_and_superinterfaces.ets rename to plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_sub_and_superinterfaces.ets diff --git a/plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_suberinterface.ets b/plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_suberinterface.ets similarity index 100% rename from plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_suberinterface.ets rename to plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/generic_suberinterface.ets diff --git a/plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/non_generic_cast_to_object.ets b/plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/non_generic_cast_to_object.ets similarity index 100% rename from plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/non_generic_cast_to_object.ets rename to plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/non_generic_cast_to_object.ets diff --git a/plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/non_generic_cast_to_superclass.ets b/plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/non_generic_cast_to_superclass.ets similarity index 100% rename from plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/non_generic_cast_to_superclass.ets rename to plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/non_generic_cast_to_superclass.ets diff --git a/plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/non_generic_superinterface.ets b/plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/non_generic_superinterface.ets similarity index 100% rename from plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/non_generic_superinterface.ets rename to plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_class_and_interface_types/non_generic_superinterface.ets diff --git a/plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_primitive_types/primitive_types_cast.ets b/plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_primitive_types/primitive_types_cast.ets similarity index 100% rename from plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_primitive_types/primitive_types_cast.ets rename to plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_primitive_types/primitive_types_cast.ets diff --git a/plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_primitive_types/primitive_types_cast.params.yaml b/plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_primitive_types/primitive_types_cast.params.yaml similarity index 100% rename from plugins/ets/tests/ets-templates/14.semantic_rules/01.subtyping/subtyping_among_primitive_types/primitive_types_cast.params.yaml rename to plugins/ets/tests/ets-templates/15.semantic_rules/01.subtyping/subtyping_among_primitive_types/primitive_types_cast.params.yaml diff --git a/plugins/ets/tests/ets-templates/15.semantic_rules/02.least_upper_bound/negative_cases.ets b/plugins/ets/tests/ets-templates/15.semantic_rules/02.least_upper_bound/negative_cases.ets new file mode 100644 index 000000000..cf19b3b91 --- /dev/null +++ b/plugins/ets/tests/ets-templates/15.semantic_rules/02.least_upper_bound/negative_cases.ets @@ -0,0 +1,15 @@ +{% for c in cases %} +/*--- +desc: >- + The notion of the least upper bound (LUB) is used where a single type must be found that is a common supertype for + a set of reference types. +tags: [compile-only, negative] +params: '{{c.decl}}' +---*/ + +{{c.decl}} + +function main(): int { + return 0; +} +{% endfor %} diff --git a/plugins/ets/tests/ets-templates/15.semantic_rules/02.least_upper_bound/negative_cases.params.yaml b/plugins/ets/tests/ets-templates/15.semantic_rules/02.least_upper_bound/negative_cases.params.yaml new file mode 100644 index 000000000..89a106fd9 --- /dev/null +++ b/plugins/ets/tests/ets-templates/15.semantic_rules/02.least_upper_bound/negative_cases.params.yaml @@ -0,0 +1,12 @@ +--- +cases: + - decl: |- + class A {} + class B {} + let lub: A[] = [ new A(), new B() ] + - decl: |- + interface A {} + class B implements A {} + class C {} + let lub: A[] = [ new B(), new C() ] + diff --git a/plugins/ets/tests/ets-templates/15.semantic_rules/02.least_upper_bound/positive_cases.ets b/plugins/ets/tests/ets-templates/15.semantic_rules/02.least_upper_bound/positive_cases.ets new file mode 100644 index 000000000..04a9dfc23 --- /dev/null +++ b/plugins/ets/tests/ets-templates/15.semantic_rules/02.least_upper_bound/positive_cases.ets @@ -0,0 +1,15 @@ +{% for c in cases %} +/*--- +desc: >- + The notion of the least upper bound (LUB) is used where a single type must be found that is a common supertype for + a set of reference types. +tags: [compile-only] +params: '{{c.decl}}' +---*/ + +{{c.decl}} + +function main(): int { + return 0; +} +{% endfor %} diff --git a/plugins/ets/tests/ets-templates/15.semantic_rules/02.least_upper_bound/positive_cases.params.yaml b/plugins/ets/tests/ets-templates/15.semantic_rules/02.least_upper_bound/positive_cases.params.yaml new file mode 100644 index 000000000..f5e5cf3ef --- /dev/null +++ b/plugins/ets/tests/ets-templates/15.semantic_rules/02.least_upper_bound/positive_cases.params.yaml @@ -0,0 +1,22 @@ +--- +cases: + - decl: |- + class X {} + class Y {} + class Z {} + let lub: Object[] = [ new X(), new Y(), new Z() ] + - decl: |- + class A {} + class B extends A {} + class C extends B {} + let lub: A[] = [ new A(), new B(), new C() ] + - decl: |- + interface A {} + class B implements A {} + class C extends B {} + let lub: A[] = [ new B(), new C() ] + - decl: |- + let lub: Object[] = [ new Int(), new String(), new Date(), new Object[1] ] + - decl: |- + let lub: Object[] = [ "string", [0, 1, 2], 2 ] + diff --git a/plugins/ets/tests/ets-templates/14.semantic_rules/03.override_equivalent_signatures/neg.ets b/plugins/ets/tests/ets-templates/15.semantic_rules/03.override_equivalent_signatures/neg.ets similarity index 100% rename from plugins/ets/tests/ets-templates/14.semantic_rules/03.override_equivalent_signatures/neg.ets rename to plugins/ets/tests/ets-templates/15.semantic_rules/03.override_equivalent_signatures/neg.ets diff --git a/plugins/ets/tests/ets-templates/14.semantic_rules/03.override_equivalent_signatures/neg.params.yaml b/plugins/ets/tests/ets-templates/15.semantic_rules/03.override_equivalent_signatures/neg.params.yaml similarity index 100% rename from plugins/ets/tests/ets-templates/14.semantic_rules/03.override_equivalent_signatures/neg.params.yaml rename to plugins/ets/tests/ets-templates/15.semantic_rules/03.override_equivalent_signatures/neg.params.yaml diff --git a/plugins/ets/tests/ets-templates/14.semantic_rules/03.override_equivalent_signatures/pos.ets b/plugins/ets/tests/ets-templates/15.semantic_rules/03.override_equivalent_signatures/pos.ets similarity index 100% rename from plugins/ets/tests/ets-templates/14.semantic_rules/03.override_equivalent_signatures/pos.ets rename to plugins/ets/tests/ets-templates/15.semantic_rules/03.override_equivalent_signatures/pos.ets diff --git a/plugins/ets/tests/ets-templates/14.semantic_rules/03.override_equivalent_signatures/pos.params.yaml b/plugins/ets/tests/ets-templates/15.semantic_rules/03.override_equivalent_signatures/pos.params.yaml similarity index 100% rename from plugins/ets/tests/ets-templates/14.semantic_rules/03.override_equivalent_signatures/pos.params.yaml rename to plugins/ets/tests/ets-templates/15.semantic_rules/03.override_equivalent_signatures/pos.params.yaml diff --git a/tests/tests-u-runner/runner/plugins/ets/ets-cts-ignored.txt b/tests/tests-u-runner/runner/plugins/ets/ets-cts-ignored.txt index 63e4c0c49..0d383a8b5 100644 --- a/tests/tests-u-runner/runner/plugins/ets/ets-cts-ignored.txt +++ b/tests/tests-u-runner/runner/plugins/ets/ets-cts-ignored.txt @@ -1707,7 +1707,7 @@ 17.experimental_features/05.statements/05.function_overloading/fn_overloading_30.ets 04.names_declarations_and_scopes/08.function_declarations/02.parameter_list/param_list_12.ets 04.names_declarations_and_scopes/08.function_declarations/02.parameter_list/param_list_7.ets -14.semantic_rules/03.override_equivalent_signatures/pos_1.ets +15.semantic_rules/03.override_equivalent_signatures/pos_1.ets 04.names_declarations_and_scopes/08.function_declarations/03.optional_parameters/opt_param_0.ets 04.names_declarations_and_scopes/08.function_declarations/03.optional_parameters/opt_param_1.ets 04.names_declarations_and_scopes/08.function_declarations/03.optional_parameters/opt_param_10.ets @@ -1719,7 +1719,7 @@ 04.names_declarations_and_scopes/08.function_declarations/03.optional_parameters/opt_param_9.ets 05.generics/05.parameterized_declarations/type_arguments_of_parameterized_declarations/class_args_22.ets 05.generics/05.parameterized_declarations/type_arguments_of_parameterized_declarations/class_args_25.ets -14.semantic_rules/03.override_equivalent_signatures/pos_6.ets +15.semantic_rules/03.override_equivalent_signatures/pos_6.ets 04.names_declarations_and_scopes/08.function_declarations/06.return_type/ret_type_5.ets 04.names_declarations_and_scopes/08.function_declarations/06.return_type/ret_type_6.ets 04.names_declarations_and_scopes/08.function_declarations/06.return_type/ret_type_7.ets -- Gitee