From 601c84108fa32bdba558c011f0874d70e6386eca Mon Sep 17 00:00:00 2001 From: tanglizhen Date: Sat, 27 May 2023 16:07:17 +0800 Subject: [PATCH 01/18] Ts test cases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issues: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/I78HJU?from=project-issue Signed-off-by: tanglizhen --- es2panda/test/ts_extra_tests/package.json | 6 + es2panda/test/ts_extra_tests/run_ts_case.py | 173 +++++++++++++ es2panda/test/ts_extra_tests/suite/assert.ts | 68 +++++ .../ts_extra_tests/suite/assertionError.ts | 24 ++ .../abstract_properties_and_accessors.ts | 36 +++ ...icate_identifiers_across_declarations_1.ts | 45 ++++ .../control_flow_based_type_analysis1.ts | 44 ++++ .../control_flow_based_type_analysis2.ts | 33 +++ .../control_flow_based_type_analysis3.ts | 36 +++ .../dotted_names_in_type_guards_1.ts | 62 +++++ .../expression_operators_1.ts | 40 +++ .../expression_operators_2.ts | 37 +++ .../implicit_index_signatures.ts | 39 +++ ...le_identifiers_allow_for_js_extension_1.ts | 26 ++ .../test_js_extension.ts | 22 ++ .../module_resolution_enhancements_1.ts | 28 ++ .../module_resolution_enhancements_2.ts | 29 +++ .../module_resolution_enhancements_3.ts | 31 +++ .../non_null_assertion_operator.ts | 30 +++ .../optional_class_properties.ts | 52 ++++ .../optional_parameters_and_properties.ts | 36 +++ .../private_and_protected_constructor.ts | 38 +++ ...ad-only_properties_and_index_signatures.ts | 40 +++ .../hot-new-module.ts | 21 ++ ...shorthand_ambient_module_declarations_1.ts | 29 +++ ...ifying_the_type_of_this_for_functions_1.ts | 28 ++ ...ifying_the_type_of_this_for_functions_2.ts | 44 ++++ .../math-lib.ts | 29 +++ .../support_for_UMD_module_definitions_1.ts | 26 ++ .../tagged_union_types_1.ts | 83 ++++++ .../ts_extra_tests/test/2.0/test_base_url.ts | 21 ++ .../view1.ts | 17 ++ .../view2.ts | 22 ++ .../better_inference_for_literal_types_1.ts | 43 +++ .../better_inference_for_literal_types_2.ts | 47 ++++ .../better_inference_for_literal_types_3.ts | 48 ++++ .../downlevel_async_functions_1.ts | 42 +++ .../improved_any_inference_1.ts | 34 +++ .../improved_any_inference_2.ts | 38 +++ .../keyof_and_lookup_types_1.ts | 59 +++++ .../keyof_and_lookup_types_2.ts | 43 +++ .../test/2.1/mapped_types/mapped_types_1.ts | 66 +++++ .../test/2.1/mapped_types/mapped_types_2.ts | 50 ++++ .../test/2.1/mapped_types/mapped_types_3.ts | 44 ++++ .../test/2.1/mapped_types/mapped_types_4.ts | 58 +++++ .../object_spread_and_rest_1.ts | 51 ++++ .../object_spread_and_rest_2.ts | 38 +++ .../object_spread_and_rest_3.ts | 37 +++ ...turned_values_from_super_call_as_this_1.ts | 42 +++ ..._for_types_with_string_index_signatures.ts | 33 +++ .../test/2.2/object_type/object_type.ts | 31 +++ .../support_for_mix_in_classes_1.ts | 75 ++++++ .../support_for_mix_in_classes_2.ts | 51 ++++ .../support_for_new.target_1.ts | 53 ++++ .../support_for_new.target_2.ts | 42 +++ .../async_generators/async_generators.ts | 71 +++++ .../async_iterators/async_iterators_1.ts | 68 +++++ .../async_iterators/async_iterators_2.ts | 35 +++ .../generators/generators_1.ts | 44 ++++ .../generators/generators_2.ts | 44 ++++ .../iterators/iterators_1.ts | 52 ++++ .../iterators/iterators_2.ts | 40 +++ .../generic_parameter_defaults_1.ts | 38 +++ .../generic_parameter_defaults_2.ts | 57 ++++ .../generic_parameter_defaults_3.ts | 34 +++ .../1_dynamic_import_expressions.ts | 31 +++ .../2.4/1_dynamic_import_expressions/lib.ts | 19 ++ .../test/2.4/2_string_enums/string_enums_1.ts | 30 +++ .../3_improved_inference_for_generics.ts | 48 ++++ ..._contravariance_for_callback_parameters.ts | 41 +++ .../5_weak_type_detection.ts | 59 +++++ .../2.5/1_optional_catch_clause_variables.ts | 29 +++ ...rs_in_ts_files_using_ts_ignore_comments.ts | 35 +++ .../10_numeric_separators.ts | 30 +++ .../1_constant_named_properties.ts | 53 ++++ .../2.7/2_unique_symbol/2_unique_symbol.ts | 42 +++ .../3_strict_class_initialization.ts | 43 +++ .../4_definite_assignment_assertions.ts | 39 +++ .../5_fixed_length_tuples.ts | 45 ++++ ...oved_type_inference_for_object_literals.ts | 35 +++ .../7_improved_handling.ts | 76 ++++++ ...8_Type_guards_inferred_from_in_operator.ts | 49 ++++ .../Improved_keyof_with_intersection_types.ts | 64 +++++ .../test/2.8/conditional_types.ts | 50 ++++ .../2.8/distributive_conditional_types.ts | 71 +++++ .../test/2.8/filter_union_types.ts | 39 +++ ...oved_control_over_mapped_type_modifiers.ts | 55 ++++ .../test/2.8/predefined_conditional_types.ts | 67 +++++ .../test/2.8/prototype_assignment.ts | 33 +++ .../ts_extra_tests/test/2.8/type_inference.ts | 68 +++++ .../1_support_number_and_symbol_nam_1.ts | 57 ++++ .../1_support_number_and_symbol_nam_2.ts | 41 +++ .../1_support_number_and_symbol_nam_3.ts | 81 ++++++ .../2.9/3_generic_type_arguments_in_tt.ts | 45 ++++ .../ts_extra_tests/test/2.9/4_import_types.ts | 34 +++ .../test/ts_extra_tests/test/2.9/module.ts | 19 ++ .../new_unknown_top_type.ts | 116 +++++++++ .../test/3.0/reference_lib/reference_lib.ts | 26 ++ .../generic_rest_parameters.ts | 44 ++++ .../optional_elements_in_tuple_types.ts | 36 +++ .../rest_elements_in_tuple_types.ts | 43 +++ .../rest_parameters_with_tuple_types.ts | 35 +++ .../spread_expressions_with_tuple_types.ts | 39 +++ .../mapped_types_on_tuples_and_arrays_1.ts | 46 ++++ .../properties_declarations_on_functions_1.ts | 61 +++++ .../test/3.2/bigint/bigint_1.ts | 47 ++++ .../test/3.2/bigint/bigint_2.ts | 32 +++ .../test/3.2/bigint/bigint_3.ts | 39 +++ ...ic_object_rest_variables_and_parameters.ts | 35 +++ ...spread_expressions_in_object_literals_1.ts | 32 +++ ...spread_expressions_in_object_literals_2.ts | 37 +++ ...spread_expressions_in_object_literals_3.ts | 43 +++ .../non-unit_types_as_union_discriminants.ts | 51 ++++ ...proved_behavior_for_calling_union_types.ts | 62 +++++ .../test/3.4/const_assertions.ts | 29 +++ .../test/3.4/higher_order_type_inference.ts | 48 ++++ .../ts_extra_tests/test/3.4/readonly_array.ts | 47 ++++ .../test/3.5/higher_order_type_inference.ts | 55 ++++ .../test/3.5/omit_helper_type.ts | 43 +++ .../test/3.5/smarter_union_type_checking.ts | 42 +++ ...etter_unicode_support_for_identifiers_1.ts | 27 ++ ...ssors_are_allowed_in_ambient_contexts_1.ts | 29 +++ .../test.ts | 21 ++ .../more_accurate_array_spread_1.ts | 30 +++ .../stricter_generators_1.ts | 39 +++ .../stricter_generators_2.ts | 65 +++++ .../stricter_generators_3.ts | 41 +++ .../stricter_generators_4.ts | 34 +++ .../stricter_generators_5.ts | 44 ++++ .../assertion_functions_1.ts | 32 +++ .../nullish_coalescing_1.ts | 33 +++ .../nullish_coalescing_2.ts | 31 +++ .../optional_chaining/optional_chaining_1.ts | 33 +++ .../optional_chaining/optional_chaining_2.ts | 32 +++ .../optional_chaining/optional_chaining_3.ts | 33 +++ .../optional_chaining/optional_chaining_4.ts | 34 +++ .../optional_chaining/optional_chaining_5.ts | 34 +++ .../recursive_type_aliases_1.ts | 43 +++ .../ts_nocheck_in_typescript_files.ts | 37 +++ .../3.8/1_type_only_imports_and_export.ts | 29 +++ .../2_ecmsscript_private_fields_1.ts | 39 +++ .../2_ecmsscript_private_fields_2.ts | 44 ++++ .../2_ecmsscript_private_fields_3.ts | 41 +++ .../test/3.8/3_which_should_i_use.ts | 33 +++ .../test/3.8/4_export_star_as_ns_syntax.ts | 27 ++ .../ts_extra_tests/test/3.8/export_star.ts | 17 ++ .../test/ts_extra_tests/test/3.8/my_module.ts | 18 ++ .../ts_extra_tests/test/3.8/some_module.ts | 19 ++ ...provements_in_inference_and_Promise.all.ts | 44 ++++ .../ts-expect-error_comments.ts | 37 +++ ..._property_Inference_from_constructors_1.ts | 67 +++++ .../labeled_tuple_elements_1.ts | 37 +++ .../labeled_tuple_elements_2.ts | 31 +++ .../labeled_tuple_elements_3.ts | 32 +++ .../labeled_tuple_elements_4.ts | 31 +++ ...short_circuiting_assignment_operators_1.ts | 70 +++++ ...short_circuiting_assignment_operators_2.ts | 31 +++ ...short_circuiting_assignment_operators_3.ts | 36 +++ .../unknow_on_catch_clause_bindings_1.ts | 33 +++ .../unknow_on_catch_clause_bindings_2.ts | 39 +++ .../variadic_tuple_types_1.ts | 40 +++ .../variadic_tuple_types_2.ts | 52 ++++ .../variadic_tuple_types_3.ts | 42 +++ .../variadic_tuple_types_4.ts | 43 +++ .../variadic_tuple_types_5.ts | 40 +++ .../variadic_tuple_types_6.ts | 54 ++++ ...bstract_members_can_not_be_marked_async.ts | 43 +++ ...known_are_propagated_in_falsy_positions.ts | 33 +++ ...al_spreads_create_optional_properties_1.ts | 52 ++++ .../key_remapping_in_mapped_types_1.ts | 47 ++++ .../key_remapping_in_mapped_types_2.ts | 34 +++ .../recursive_conditional_types.ts | 41 +++ ...ters_are_no_longer_optional_in_promises.ts | 28 ++ .../template_literal_types_1.ts | 35 +++ .../template_literal_types_2.ts | 52 ++++ .../template_literal_types_3.ts | 46 ++++ .../abstract_construct_signatures.ts | 94 +++++++ .../abstract_construct_signatures_1.ts | 43 +++ .../abstract_construct_signatures_3.ts | 47 ++++ ...ng_middle_rest_elements_in_tuple_types1.ts | 31 +++ ...ng_middle_rest_elements_in_tuple_types2.ts | 39 +++ ...ng_middle_rest_elements_in_tuple_types3.ts | 39 +++ .../smarter_type_alias_preservation1.ts | 33 +++ .../smarter_type_alias_preservation2.ts | 32 +++ .../always-truthy_promise_checks.ts | 39 +++ ...uctorParameters_works_on_abstract_class.ts | 36 +++ .../separate_write_types_on_properties_1.ts | 52 ++++ .../static_index_signatures.ts | 59 +++++ .../template_string_type_improvements_1.ts | 43 +++ .../template_string_type_improvements_2.ts | 38 +++ .../template_string_type_improvements_3.ts | 41 +++ .../template_string_type_improvements_4.ts | 51 ++++ ...cannot_be_compared_to_arbitrary_numbers.ts | 63 +++++ ..._aliased_conditions_and_discriminants_1.ts | 58 +++++ ..._aliased_conditions_and_discriminants_2.ts | 51 ++++ ..._aliased_conditions_and_discriminants_3.ts | 38 +++ ..._aliased_conditions_and_discriminants_4.ts | 38 +++ ...o_the_unknown_type_in_catch_variables_1.ts | 40 +++ ...o_the_unknown_type_in_catch_variables_2.ts | 40 +++ ...o_the_unknown_type_in_catch_variables_3.ts | 38 +++ .../exact_optional_property_types_1.ts | 41 +++ ...lates_string_pattern_index_signatures_1.ts | 35 +++ ...lates_string_pattern_index_signatures_2.ts | 30 +++ ...lates_string_pattern_index_signatures_3.ts | 39 +++ ...lates_string_pattern_index_signatures_4.ts | 37 +++ ...lates_string_pattern_index_signatures_5.ts | 45 ++++ .../4.5/disabling_import_elision/animal.ts | 28 ++ .../disabling_import_elision_1.ts | 27 ++ .../private_field_presence_checks_1.ts | 40 +++ ...rsion_elimination_on_conditional_types1.ts | 29 +++ ...rsion_elimination_on_conditional_types2.ts | 40 +++ ...emplate_string_types_as_discriminants_1.ts | 60 +++++ ...awaited_type_and_promise_improvements_1.ts | 47 ++++ .../some-module.ts | 22 ++ .../type_modifiers_on_import_names_1.ts | 36 +++ .../4.6/1_allowing_code_in_constructors.ts | 45 ++++ .../test/4.6/2_control_flow_analysis.ts | 82 ++++++ .../4.6/3_improved_recursion_depth_checks.ts | 50 ++++ ...4_indexed_access_inference_improvements.ts | 48 ++++ ..._flow_analysis_for_dependent_parameters.ts | 36 +++ ...w_analysis_for_bracketed_element_access.ts | 36 +++ ...nds_constraints_on_infer_type_variables.ts | 57 ++++ ...nction_inference_in_objects_and_methods.ts | 63 +++++ .../instantiation_expressions.ts | 41 +++ ...ariance_annotations_for_type_parameters.ts | 34 +++ ..._tuples_have_a_readonly_length_property.ts | 29 +++ ...or_infer_types_in_template_string_types.ts | 44 ++++ .../auto_accessors_in_classes.ts | 51 ++++ .../checks_for_equality_on_NaN.ts | 31 +++ .../the_satisfies_operator.ts | 45 ++++ ...property_narrowing_with_the_in_operator.ts | 73 ++++++ .../ambient_function_declarations.ts | 50 ++++ .../ambient_namespace_declarations.ts | 36 +++ .../ambient_module_declarations_1.ts | 34 +++ .../ambient_module_declarations_3.ts | 44 ++++ .../declarations/declarations_1.ts | 41 +++ .../declarations/declarations_2.ts | 59 +++++ .../computed_property_names_1.ts | 48 ++++ .../names/property_names/property_names_1.ts | 45 ++++ .../any_cannot_be_type_name_2.ts | 25 ++ .../boolean_cannot_be_type_name_2.ts | 25 ++ .../number_cannot_be_type_name_2.ts | 25 ++ .../string_cannot_be_type_name_2.ts | 25 ++ .../symbol_cannot_be_type_name_2.ts | 25 ++ .../abstract_is_valid_identifier_1.ts | 25 ++ .../abstract_is_valid_identifier_2.ts | 27 ++ .../abstract_is_valid_identifier_3.ts | 34 +++ .../abstract_is_valid_identifier_4.ts | 34 +++ .../as_is_valid_identifier_1.ts | 25 ++ .../as_is_valid_identifier_2.ts | 27 ++ .../as_is_valid_identifier_3.ts | 34 +++ .../as_is_valid_identifier_4.ts | 34 +++ .../async_is_valid_identifier_1.ts | 25 ++ .../async_is_valid_identifier_2.ts | 27 ++ .../async_is_valid_identifier_3.ts | 34 +++ .../async_is_valid_identifier_4.ts | 34 +++ .../constructor_is_valid_identifier_1.ts | 25 ++ .../constructor_is_valid_identifier_2.ts | 27 ++ .../constructor_is_valid_identifier_3.ts | 34 +++ .../constructor_is_valid_identifier_4.ts | 34 +++ .../declare_is_valid_identifier_1.ts | 25 ++ .../declare_is_valid_identifier_2.ts | 27 ++ .../declare_is_valid_identifier_3.ts | 34 +++ .../declare_is_valid_identifier_4.ts | 34 +++ .../from_is_valid_identifier_1.ts | 25 ++ .../from_is_valid_identifier_2.ts | 27 ++ .../from_is_valid_identifier_3.ts | 34 +++ .../from_is_valid_identifier_4.ts | 34 +++ .../get_is_valid_identifier_1.ts | 25 ++ .../get_is_valid_identifier_2.ts | 27 ++ .../get_is_valid_identifier_3.ts | 34 +++ .../get_is_valid_identifier_4.ts | 34 +++ .../is_is_valid_identifier_1.ts | 25 ++ .../is_is_valid_identifier_2.ts | 27 ++ .../is_is_valid_identifier_3.ts | 34 +++ .../is_is_valid_identifier_4.ts | 34 +++ .../module_is_valid_identifier_1.ts | 25 ++ .../module_is_valid_identifier_2.ts | 29 +++ .../module_is_valid_identifier_3.ts | 39 +++ .../module_is_valid_identifier_4.ts | 34 +++ .../namespace_is_valid_identifier_1.ts | 25 ++ .../namespace_is_valid_identifier_2.ts | 27 ++ .../namespace_is_valid_identifier_3.ts | 34 +++ .../namespace_is_valid_identifier_4.ts | 34 +++ .../of_is_valid_identifier_1.ts | 25 ++ .../of_is_valid_identifier_2.ts | 27 ++ .../of_is_valid_identifier_3.ts | 34 +++ .../of_is_valid_identifier_4.ts | 34 +++ .../require_is_valid_identifier_1.ts | 34 +++ .../set_is_valid_identifier_1.ts | 25 ++ .../set_is_valid_identifier_2.ts | 27 ++ .../set_is_valid_identifier_3.ts | 34 +++ .../set_is_valid_identifier_4.ts | 34 +++ .../type_is_valid_identifier_1.ts | 25 ++ .../type_is_valid_identifier_2.ts | 27 ++ .../type_is_valid_identifier_3.ts | 34 +++ .../type_is_valid_identifier_4.ts | 34 +++ .../spec/basic_concepts/scopes/let_scope.ts | 37 +++ .../spec/basic_concepts/scopes/namespace.ts | 36 +++ .../spec/basic_concepts/scopes/var_scope.ts | 35 +++ .../class_body/class_body.ts | 77 ++++++ .../class_heritage_specification_1.ts | 68 +++++ .../class_heritage_specification_2.ts | 66 +++++ .../class_heritage_specification_3.ts | 64 +++++ .../class_heritage_specification_4.ts | 35 +++ .../class_heritage_specification_5.ts | 46 ++++ .../class_heritage_specification_6.ts | 43 +++ .../automatic_constructors_1.ts | 42 +++ .../automatic_constructors_2.ts | 59 +++++ .../automatic_constructors_3.ts | 45 ++++ .../constructor_parameters_1.ts | 55 ++++ .../constructor_parameters_2.ts | 48 ++++ .../constructor_parameters_3.ts | 47 ++++ .../constructor_parameters_4.ts | 32 +++ .../constructor_parameters_5.ts | 36 +++ .../super_calls/super_calls.ts | 41 +++ .../index_member_declarations.ts | 38 +++ .../members/accessibility/accessibility_1.ts | 41 +++ .../members/accessibility/accessibility_2.ts | 37 +++ .../members/accessibility/accessibility_3.ts | 45 ++++ .../members/class_types/class_types.ts | 61 +++++ .../constructor_function_types_1.ts | 34 +++ .../constructor_function_types_2.ts | 42 +++ .../constructor_function_types_3.ts | 35 +++ .../constructor_function_types_4.ts | 53 ++++ .../constructor_function_types_5.ts | 40 +++ .../inheritance_and_overriding_1.ts | 38 +++ .../inheritance_and_overriding_2.ts | 44 ++++ .../inheritance_and_overriding_3.ts | 43 +++ .../inheritance_and_overriding_4.ts | 52 ++++ .../instance_and_static_members_1.ts | 32 +++ .../instance_and_static_members_2.ts | 50 ++++ .../instance_and_static_members_3.ts | 44 ++++ .../member_accessor_declarations.ts | 47 ++++ .../member_function_declarations_1.ts | 39 +++ .../member_function_declarations_2.ts | 35 +++ .../member_function_declarations_3.ts | 36 +++ .../member_function_declarations_4.ts | 42 +++ .../member_function_declarations_5.ts | 41 +++ .../member_variable_declarations_1.ts | 44 ++++ .../member_variable_declarations_2.ts | 43 +++ .../member_variable_declarations_3.ts | 47 ++++ .../member_variable_declarations_4.ts | 42 +++ .../member_variable_declarations_5.ts | 39 +++ .../constant_enum_declarations.ts | 51 ++++ .../declaration_merging_1.ts | 51 ++++ .../declaration_merging_2.ts | 49 ++++ .../enum_declarations/enum_declarations_1.ts | 46 ++++ .../enum_declarations/enum_declarations_2.ts | 34 +++ .../enum_declarations/enum_declarations_3.ts | 49 ++++ .../spec/enums/enum_members/enum_members_1.ts | 48 ++++ .../array_literals/array_literal_1.ts | 34 +++ .../array_literals/array_literal_2.ts | 34 +++ .../array_literals/array_literal_3.ts | 30 +++ .../array_literals/array_literal_4.ts | 33 +++ .../array_literals/array_literal_5.ts | 29 +++ .../array_literals/array_literal_6.ts | 32 +++ .../arrow_function/arrow_function_1.ts | 36 +++ .../arrow_function/arrow_function_2.ts | 48 ++++ .../arrow_function/arrow_function_3.ts | 31 +++ .../assignment_operator_1.ts | 30 +++ .../assignment_operator_2.ts | 49 ++++ .../assignment_operator_3.ts | 31 +++ .../destructing_assignment_1.ts | 29 +++ .../destructing_assignment_2.ts | 35 +++ .../destructing_assignment_3.ts | 34 +++ .../destructing_assignment_4.ts | 42 +++ .../destructing_assignment_5.ts | 42 +++ .../destructing_assignment_6.ts | 30 +++ .../destructing_assignment_7.ts | 32 +++ .../destructing_assignment_8.ts | 35 +++ .../the_add_operator/the_add_operator_1.ts | 54 ++++ .../the_add_operator/the_add_operator_2.ts | 43 +++ .../the_add_operator/the_add_operator_3.ts | 28 ++ .../the_and_operator/the_and_operator.ts | 65 +++++ .../the_in_operator/the_in_operator.ts | 40 +++ .../the_instanceof_operator.ts | 57 ++++ .../the_mul_div_operators/the_and_operator.ts | 42 +++ .../the_division_method_operator.ts | 42 +++ .../the_left_shift_operator.ts | 42 +++ .../the_multiplication_operator.ts | 42 +++ .../the_mul_div_operators/the_or_operator.ts | 42 +++ .../the_remainder_operator.ts | 42 +++ .../the_right_shift_operator.ts | 42 +++ .../the_subtraction_operator.ts | 42 +++ .../the_unsigned_shift_to_the_right.ts | 42 +++ .../the_mul_div_operators/the_xor_operator.ts | 42 +++ .../the_operators/the_congruence_operator.ts | 32 +++ .../the_operators/the_equal_operator.ts | 32 +++ .../the_operators/the_greater_operator.ts | 32 +++ .../the_greater_or_equal_operator.ts | 32 +++ .../the_incongruence_operator.ts | 32 +++ .../the_operators/the_less_operator.ts | 32 +++ .../the_less_or_equal_operator.ts | 32 +++ .../the_operators/the_unequal_operator.ts | 32 +++ .../the_or_operator/the_or_operator_1.ts | 66 +++++ .../the_or_operator/the_or_operator_2.ts | 33 +++ .../class_expressions/class_expressions_1.ts | 58 +++++ .../contextually_typed_expressions_1.ts | 48 ++++ .../contextually_typed_expressions_10.ts | 38 +++ .../contextually_typed_expressions_11.ts | 30 +++ .../contextually_typed_expressions_12.ts | 38 +++ .../contextually_typed_expressions_13.ts | 33 +++ .../contextually_typed_expressions_14.ts | 37 +++ .../contextually_typed_expressions_15.ts | 29 +++ .../contextually_typed_expressions_16.ts | 31 +++ .../contextually_typed_expressions_2.ts | 30 +++ .../contextually_typed_expressions_3.ts | 31 +++ .../contextually_typed_expressions_4.ts | 47 ++++ .../contextually_typed_expressions_5.ts | 39 +++ .../contextually_typed_expressions_6.ts | 35 +++ .../contextually_typed_expressions_7.ts | 49 ++++ .../contextually_typed_expressions_8.ts | 42 +++ .../contextually_typed_expressions_9.ts | 39 +++ .../grammar_ambiguities.ts | 46 ++++ .../overload_resolution_1.ts | 44 ++++ .../overload_resolution_2.ts | 41 +++ .../overload_resolution_3.ts | 38 +++ .../overload_resolution_4.ts | 41 +++ .../type_argument_inference_1.ts | 32 +++ .../type_argument_inference_2.ts | 41 +++ .../type_argument_inference_3.ts | 34 +++ .../type_argument_inference_4.ts | 38 +++ .../function_expressions_1.ts | 36 +++ .../function_expressions_2.ts | 34 +++ .../function_expressions_3.ts | 39 +++ .../spec/expressions/identifiers/class.ts | 35 +++ .../test/spec/expressions/identifiers/enum.ts | 31 +++ .../spec/expressions/identifiers/function.ts | 27 ++ .../expressions/identifiers/name_space.ts | 43 +++ .../spec/expressions/identifiers/parameter.ts | 35 +++ .../spec/expressions/identifiers/variable.ts | 29 +++ .../test/spec/expressions/literals/boolean.ts | 25 ++ .../test/spec/expressions/literals/null.ts | 26 ++ .../test/spec/expressions/literals/number.ts | 25 ++ .../test/spec/expressions/literals/regexp.ts | 25 ++ .../test/spec/expressions/literals/string.ts | 26 ++ .../object_literal/object_literal_3.ts | 41 +++ .../object_literal/object_literal_4.ts | 41 +++ .../object_literal/object_literal_5.ts | 39 +++ .../object_literal/object_literal_6.ts | 36 +++ .../object_literal/object_literal_7.ts | 40 +++ .../expressions/parentheses/parentheses.ts | 44 ++++ .../property_access/object_access_2.ts | 51 ++++ .../property_access/object_any_1.ts | 35 +++ .../property_access/object_any_type_6.ts | 46 ++++ .../property_access/object_apprent_5.ts | 37 +++ .../property_access/object_index_4.ts | 41 +++ .../property_access/object_string_number_3.ts | 49 ++++ .../property_access/property_access_1.ts | 33 +++ .../property_access/property_access_2.ts | 32 +++ .../the_comma_operator/the_comma_operator.ts | 31 +++ .../the_conditional_operator_1.ts | 36 +++ .../the_conditional_operator_2.ts | 33 +++ .../the_new_operator/new_operator_1.ts | 30 +++ .../the_new_operator/new_operator_2.ts | 42 +++ .../the_new_operator/new_operator_3.ts | 37 +++ .../the_new_operator/new_operator_4.ts | 54 ++++ .../super_calls/arguments.ts | 37 +++ .../super_calls/gengric_extends.ts | 40 +++ .../super_calls/super_calls.ts | 56 ++++ .../derived_class_access.ts | 41 +++ .../static_member_access.ts | 39 +++ .../this_key_word/this_key_word_1.ts | 57 ++++ .../type_assertion/type_assertion_1.ts | 38 +++ .../type_assertion/type_assertion_2.ts | 43 +++ .../type_assertion/type_assertion_3.ts | 33 +++ .../expressions/type_guards/type_guards_1.ts | 35 +++ .../expressions/type_guards/type_guards_10.ts | 55 ++++ .../expressions/type_guards/type_guards_11.ts | 36 +++ .../expressions/type_guards/type_guards_12.ts | 36 +++ .../expressions/type_guards/type_guards_13.ts | 41 +++ .../expressions/type_guards/type_guards_14.ts | 41 +++ .../expressions/type_guards/type_guards_15.ts | 53 ++++ .../expressions/type_guards/type_guards_2.ts | 35 +++ .../expressions/type_guards/type_guards_3.ts | 35 +++ .../expressions/type_guards/type_guards_4.ts | 31 +++ .../expressions/type_guards/type_guards_5.ts | 31 +++ .../expressions/type_guards/type_guards_6.ts | 30 +++ .../expressions/type_guards/type_guards_7.ts | 31 +++ .../expressions/type_guards/type_guards_8.ts | 57 ++++ .../expressions/type_guards/type_guards_9.ts | 37 +++ .../unary_operators/the_!_operator.ts | 34 +++ .../the_++_and_--_operators.ts | 44 ++++ .../unary_operators/the_+_and_~_operators.ts | 34 +++ .../unary_operators/the_delete_operator.ts | 35 +++ .../unary_operators/the_typeof_operator.ts | 29 +++ .../unary_operators/the_void_operator.ts | 28 ++ .../asynchronous_functions_1.ts | 75 ++++++ .../destructuring_parameter_declarations_1.ts | 54 ++++ .../destructuring_parameter_declarations_2.ts | 43 +++ .../destructuring_parameter_declarations_3.ts | 43 +++ .../destructuring_parameter_declarations_4.ts | 58 +++++ .../destructuring_parameter_declarations_5.ts | 41 +++ .../destructuring_parameter_declarations_6.ts | 47 ++++ .../destructuring_parameter_declarations_7.ts | 33 +++ .../function_declarations_1.ts | 45 ++++ .../function_declarations_2.ts | 43 +++ .../function_implementations_1.ts | 33 +++ .../function_implementations_2.ts | 47 ++++ .../function_implementations_3.ts | 42 +++ .../function_implementations_4.ts | 45 ++++ .../function_implementations_5.ts | 39 +++ .../function_overloads_1.ts | 42 +++ .../generator_functions_1.ts | 35 +++ .../generator_functions_2.ts | 44 ++++ .../generic_functions/generic_functions_1.ts | 31 +++ .../generic_functions/generic_functions_2.ts | 34 +++ .../type_guard_functions_1.ts | 69 +++++ .../test/spec/grammar/classes/classes.ts | 64 +++++ .../test/spec/grammar/enums/enums.ts | 41 +++ .../spec/grammar/expressions/expressions.ts | 58 +++++ .../test/spec/grammar/functions/functions.ts | 35 +++ .../spec/grammar/interfaces/interfaces.ts | 47 ++++ .../spec/grammar/namespaces/namespaces.ts | 76 ++++++ .../spec/grammar/statements/statements.ts | 65 +++++ .../test/spec/grammar/types/types.ts | 131 ++++++++++ .../interface_declarations_1.ts | 74 ++++++ .../interface_declarations_2.ts | 73 ++++++ .../interface_declarations_3.ts | 51 ++++ .../declaration_merging_1.ts | 58 +++++ .../declaration_merging_2.ts | 77 ++++++ .../interfaces_extending_classes_1.ts | 45 ++++ .../interfaces_extending_classes_2.ts | 50 ++++ .../dynamic_type_checks_1.ts | 50 ++++ .../declaration_merging_1_1.ts | 26 ++ .../declaration_merging_1_2.ts | 26 ++ .../declaration_merging_1_3.ts | 30 +++ .../declaration_merging_2.ts | 91 +++++++ .../export_declarations_1.ts | 33 +++ .../export_declarations_2.ts | 39 +++ .../export_declarations_3.ts | 37 +++ .../import_alias_declarations_1.ts | 43 +++ .../import_alias_declarations_3.ts | 81 ++++++ .../namespace_body/namespace_body.ts | 75 ++++++ .../namespace_declarations_1.ts | 43 +++ .../namespace_declarations_2.ts | 52 ++++ .../namespace_declarations_3.ts | 53 ++++ .../namespace_declarations_4.ts | 36 +++ .../1_programs_and_source_files/source_1.ts | 19 ++ .../1_programs_and_source_files/source_10.ts | 21 ++ .../1_programs_and_source_files/source_2.ts | 19 ++ .../1_programs_and_source_files/source_3.ts | 18 ++ .../1_programs_and_source_files/source_4.ts | 19 ++ .../1_programs_and_source_files/source_5.ts | 21 ++ .../1_programs_and_source_files/source_6.ts | 21 ++ .../1_programs_and_source_files/source_7.ts | 27 ++ .../1_programs_and_source_files/source_8.ts | 17 ++ .../1_programs_and_source_files/source_9.ts | 25 ++ .../2_modules/modules_1.ts | 28 ++ .../import_declarations_1.ts | 28 ++ .../import_declarations_2.ts | 30 +++ .../import_declarations_3.ts | 31 +++ .../import_declarations_4.ts | 31 +++ .../import_require_declarations_1.ts | 29 +++ .../export_default_declarations_1.ts | 27 ++ .../export_default_declarations_2.ts | 27 ++ .../export_default_declarations_3.ts | 26 ++ .../export_default_declarations_4.ts | 27 ++ .../export_default_declarations_5.ts | 27 ++ .../export_assignments_1.ts | 30 +++ .../7_commonJS_modules/commonJS_modules_1.ts | 30 +++ .../7_commonJS_modules/commonJS_modules_2.ts | 30 +++ .../if_do_and_while_Statements_1.ts | 56 ++++ .../if_do_and_while_Statements_2.ts | 51 ++++ .../test/spec/statements/blocks/blocks_1.ts | 41 +++ .../test/spec/statements/blocks/blocks_2.ts | 36 +++ .../test/spec/statements/blocks/blocks_3.ts | 41 +++ .../break_statements/break_statements.ts | 50 ++++ .../continue_statements.ts | 54 ++++ .../for_in_statements/for_in_statements.ts | 64 +++++ .../for_of_statements/for_of_statements.ts | 42 +++ .../for_statements/for_statements.ts | 29 +++ .../let_and_const_declarations.ts | 37 +++ .../return_statements/return_statements.ts | 40 +++ .../switch_statements/switch_statements.ts | 76 ++++++ .../throw_statements/throw_statements.ts | 71 +++++ .../try_statements/try_statements.ts | 44 ++++ .../simple_variable_declarations_1.ts | 69 +++++ .../simple_variable_declarations_2.ts | 49 ++++ .../simple_variable_declarations_3.ts | 28 ++ .../destructuring_variable_declarations_1.ts | 41 +++ .../destructuring_variable_declarations_2.ts | 57 ++++ .../destructuring_variable_declarations_3.ts | 52 ++++ .../3_implied_type/implied_type.ts | 60 +++++ .../Intersection_types_1.ts | 88 +++++++ .../intersection_types_2.ts | 42 +++ .../spec/types/named_types/named_types_1.ts | 50 ++++ .../spec/types/named_types/named_types_2.ts | 47 ++++ .../spec/types/named_types/named_types_3.ts | 42 +++ .../spec/types/named_types/named_types_4.ts | 55 ++++ .../object_types/array_types/array_types_1.ts | 44 ++++ .../object_types/array_types/array_types_2.ts | 29 +++ .../object_types/array_types/array_types_3.ts | 37 +++ .../constructor_types/constructor_types_1.ts | 48 ++++ .../constructor_types/constructor_types_2.ts | 55 ++++ .../constructor_types/constructor_types_3.ts | 56 ++++ .../function_types/function_types.ts | 42 +++ .../types/object_types/members/members_1.ts | 54 ++++ .../types/object_types/members/members_2.ts | 40 +++ .../named_type_reference.ts | 54 ++++ .../object_types/tuple_types/tuple_types_1.ts | 34 +++ .../object_types/tuple_types/tuple_types_2.ts | 36 +++ .../object_types/tuple_types/tuple_types_3.ts | 34 +++ .../the_boolean_type/the_boolean_type_1.ts | 61 +++++ .../the_boolean_type/the_boolean_type_2.ts | 53 ++++ .../the_boolean_type/the_boolean_type_3.ts | 27 ++ .../the_enum_type/the_enum_type_1.ts | 38 +++ .../the_null_type/the_null_type_1.ts | 29 +++ .../the_number_type/the_number_type_1.ts | 48 ++++ .../the_number_type/the_number_type_2.ts | 58 +++++ .../the_number_type/the_number_type_3.ts | 40 +++ .../the_string_literal_type_1.ts | 32 +++ .../the_string_literal_type_2.ts | 36 +++ .../the_string_literal_type_3.ts | 36 +++ .../the_string_type/the_string_type_1.ts | 27 ++ .../the_string_type/the_string_type_2.ts | 29 +++ .../the_string_type/the_string_type_3.ts | 43 +++ .../the_symbol_type/the_symbol_type_1.ts | 31 +++ .../the_symbol_type/the_symbol_type_2.ts | 46 ++++ .../the_symbol_type/the_symbol_type_3.ts | 32 +++ .../the_undefined_type_1.ts | 25 ++ .../the_void_type/the_void_type_1.ts | 29 +++ .../the_void_type/the_void_type_2.ts | 33 +++ .../the_void_type/the_void_type_3.ts | 32 +++ .../parameter_list/parameter_list_1.ts | 42 +++ .../parameter_list/parameter_list_2.ts | 35 +++ .../parameter_list/parameter_list_3.ts | 33 +++ .../parameter_list/parameter_list_4.ts | 33 +++ .../parameter_list/parameter_list_5.ts | 37 +++ .../parameter_list/parameter_list_6.ts | 59 +++++ .../return_type/return_type_1.ts | 49 ++++ .../return_type/return_type_2.ts | 36 +++ .../return_type/return_type_3.ts | 42 +++ .../specialized_signatures_1.ts | 54 ++++ .../type_parameters/type_parameters_1.ts | 43 +++ .../type_parameters/type_parameters_2.ts | 34 +++ .../construct_signatures.ts | 62 +++++ .../index_signatures/index_signatures.ts | 64 +++++ .../method_signatures/method_signatures_1.ts | 54 ++++ .../method_signatures/method_signatures_2.ts | 49 ++++ .../property_signatures.ts | 45 ++++ .../array_type_literals_1.ts | 29 +++ .../array_type_literals_2.ts | 28 ++ .../array_type_literals_3.ts | 35 +++ .../array_type_literals_4.ts | 37 +++ .../function_type_literals_3.ts | 39 +++ .../intersection_type_literals.ts | 30 +++ .../object_type_literals.ts | 48 ++++ .../predefined_types/predefined_types.ts | 36 +++ .../specifying_types/specifying_types_1.ts | 44 ++++ .../specifying_types/specifying_types_2.ts | 32 +++ .../this_type_references_1.ts | 38 +++ .../this_type_references_2.ts | 38 +++ .../tuple_type_literals.ts | 29 +++ .../type_queries/type_queries_1.ts | 34 +++ .../type_queries/type_queries_2.ts | 33 +++ .../type_references/type_references_1.ts | 41 +++ .../type_references/type_references_2.ts | 51 ++++ .../type_references/type_references_3.ts | 59 +++++ .../union_type_literals.ts | 30 +++ .../spec/types/the_any_type/any_type_1.ts | 35 +++ .../spec/types/the_any_type/any_type_2.ts | 50 ++++ .../spec/types/the_any_type/any_type_3.ts | 35 +++ .../spec/types/type_aliases/type_aliases_1.ts | 40 +++ .../spec/types/type_aliases/type_aliases_2.ts | 37 +++ .../spec/types/type_aliases/type_aliases_3.ts | 40 +++ .../type_parameters/this_types/this_types.ts | 54 ++++ .../this_types/this_types_1.ts | 44 ++++ .../this_types/this_types_2.ts | 54 ++++ .../type_argument_lists_1.ts | 32 +++ .../type_argument_lists_2.ts | 35 +++ .../type_argument_lists_3.ts | 46 ++++ .../type_argument_lists_4.ts | 31 +++ .../type_parameter_lists_1.ts | 56 ++++ .../type_parameter_lists_2.ts | 34 +++ .../type_parameter_lists_3.ts | 47 ++++ .../type_parameter_lists_4.ts | 30 +++ .../type_parameter_lists_5.ts | 31 +++ .../type_parameter_lists_6.ts | 39 +++ .../apparent_members/apparent_members_1.ts | 34 +++ .../apparent_members/apparent_members_2.ts | 34 +++ .../apparent_members/apparent_members_3.ts | 46 ++++ .../apparent_members/apparent_members_4.ts | 43 +++ .../apparent_members/apparent_members_5.ts | 43 +++ .../apparent_members/apparent_members_6.ts | 43 +++ .../apparent_members/apparent_members_7.ts | 43 +++ .../apparent_members/apparent_members_8.ts | 29 +++ .../assignment_compatibility_1.ts | 35 +++ .../assignment_compatibility_10.ts | 43 +++ .../assignment_compatibility_11.ts | 34 +++ .../assignment_compatibility_12.ts | 48 ++++ .../assignment_compatibility_13.ts | 46 ++++ .../assignment_compatibility_14.ts | 39 +++ .../assignment_compatibility_15.ts | 42 +++ .../assignment_compatibility_16.ts | 42 +++ .../assignment_compatibility_17.ts | 35 +++ .../assignment_compatibility_18.ts | 33 +++ .../assignment_compatibility_2.ts | 32 +++ .../assignment_compatibility_3.ts | 35 +++ .../assignment_compatibility_4.ts | 29 +++ .../assignment_compatibility_5.ts | 34 +++ .../assignment_compatibility_6.ts | 30 +++ .../assignment_compatibility_7.ts | 46 ++++ .../assignment_compatibility_8.ts | 45 ++++ .../assignment_compatibility_9.ts | 41 +++ .../contextual_signature_instantiation.ts | 37 +++ .../excess_properties/excess_properties_1.ts | 36 +++ .../excess_properties/excess_properties_2.ts | 40 +++ .../excess_properties/excess_properties_3.ts | 33 +++ .../recursive_types/recursive_types.ts | 44 ++++ .../subtypes_and_supertypes_1.ts | 46 ++++ .../subtypes_and_supertypes_10.ts | 50 ++++ .../subtypes_and_supertypes_11.ts | 35 +++ .../subtypes_and_supertypes_12.ts | 54 ++++ .../subtypes_and_supertypes_13.ts | 47 ++++ .../subtypes_and_supertypes_14.ts | 40 +++ .../subtypes_and_supertypes_15.ts | 41 +++ .../subtypes_and_supertypes_16.ts | 29 +++ .../subtypes_and_supertypes_2.ts | 46 ++++ .../subtypes_and_supertypes_3.ts | 47 ++++ .../subtypes_and_supertypes_4.ts | 47 ++++ .../subtypes_and_supertypes_5.ts | 36 +++ .../subtypes_and_supertypes_6.ts | 32 +++ .../subtypes_and_supertypes_7.ts | 31 +++ .../subtypes_and_supertypes_8.ts | 50 ++++ .../subtypes_and_supertypes_9.ts | 31 +++ .../type_inference/type_inference_1.ts | 38 +++ .../type_inference/type_inference_2.ts | 35 +++ .../type_inference/type_inference_3.ts | 31 +++ .../type_inference/type_inference_4.ts | 60 +++++ .../type_inference/type_inference_5.ts | 37 +++ .../type_inference/type_inference_6.ts | 36 +++ .../type_inference/type_inference_7.ts | 31 +++ .../spec/types/union_types/union_types_1.ts | 38 +++ .../spec/types/union_types/union_types_2.ts | 35 +++ .../spec/types/union_types/union_types_3.ts | 72 +++++ .../spec/types/union_types/union_types_4.ts | 64 +++++ .../spec/types/union_types/union_types_5.ts | 59 +++++ .../spec/types/union_types/union_types_6.ts | 30 +++ .../spec/types/union_types/union_types_7.ts | 41 +++ .../spec/types/widend_types/widend_types_1.ts | 27 ++ .../spec/types/widend_types/widend_types_2.ts | 29 +++ .../spec/types/widend_types/widend_types_3.ts | 32 +++ .../test/ts_extra_tests/tool/test_helper.py | 101 ++++++++ es2panda/test/ts_extra_tests/tool/testcfg.py | 245 ++++++++++++++++++ 746 files changed, 30662 insertions(+) create mode 100644 es2panda/test/ts_extra_tests/package.json create mode 100644 es2panda/test/ts_extra_tests/run_ts_case.py create mode 100644 es2panda/test/ts_extra_tests/suite/assert.ts create mode 100644 es2panda/test/ts_extra_tests/suite/assertionError.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/allow_duplicate_identifiers_across_declarations/allow_duplicate_identifiers_across_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis2.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis3.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/dotted_names_in_type_guards/dotted_names_in_type_guards_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/expression_operators/expression_operators_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/expression_operators/expression_operators_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/implicit_index_signatures/implicit_index_signatures.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/module_identifiers_allow_for_js_extension/module_identifiers_allow_for_js_extension_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/module_identifiers_allow_for_js_extension/test_js_extension.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/module_resolution_enhancements/module_resolution_enhancements_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/module_resolution_enhancements/module_resolution_enhancements_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/module_resolution_enhancements/module_resolution_enhancements_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/non_null_assertion_operator/non_null_assertion_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/optional_class_properties/optional_class_properties.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/optional_parameters_and_properties/optional_parameters_and_properties.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/private_and_protected_constructor/private_and_protected_constructor.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/read-only_properties_and_index_signatures/read-only_properties_and_index_signatures.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/shorthand_ambient_module_declarations/hot-new-module.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/shorthand_ambient_module_declarations/shorthand_ambient_module_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/support_for_UMD_module_definitions/math-lib.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/support_for_UMD_module_definitions/support_for_UMD_module_definitions_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/tagged_union_types/tagged_union_types_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/test_base_url.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/test_virtual_directories_with_rootDirs/view1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.0/test_virtual_directories_with_rootDirs/view2.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.1/better_inference_for_literal_types/better_inference_for_literal_types_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.1/better_inference_for_literal_types/better_inference_for_literal_types_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.1/better_inference_for_literal_types/better_inference_for_literal_types_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.1/downlevel_async_functions/downlevel_async_functions_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.1/improved_any_inference/improved_any_inference_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.1/improved_any_inference/improved_any_inference_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.1/keyof_and_lookup_types/keyof_and_lookup_types_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.1/keyof_and_lookup_types/keyof_and_lookup_types_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.1/object_spread_and_rest/object_spread_and_rest_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.1/object_spread_and_rest/object_spread_and_rest_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.1/object_spread_and_rest/object_spread_and_rest_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.1/use_returned_values_from_super_call_as_this/use_returned_values_from_super_call_as_this_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.2/dotted_property_for_types_with_string_index_signatures/dotted_property_for_types_with_string_index_signatures.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.2/object_type/object_type.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.2/support_for_mix_in_classes/support_for_mix_in_classes_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.2/support_for_mix_in_classes/support_for_mix_in_classes_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.2/support_for_new.target/support_for_new.target_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.2/support_for_new.target/support_for_new.target_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.3/async_iteration/async_generators/async_generators.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.3/async_iteration/async_iterators/async_iterators_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.3/async_iteration/async_iterators/async_iterators_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.3/generic_parameter_defaults/generic_parameter_defaults_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.3/generic_parameter_defaults/generic_parameter_defaults_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.3/generic_parameter_defaults/generic_parameter_defaults_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.4/1_dynamic_import_expressions/1_dynamic_import_expressions.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.4/1_dynamic_import_expressions/lib.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.4/2_string_enums/string_enums_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.4/4_strict_contravariance_for_callback_parameters/4_strict_contravariance_for_callback_parameters.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.4/5_weak_type_detection/5_weak_type_detection.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.5/1_optional_catch_clause_variables.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.6/suppress_errors_in_ts_files_using_ts_ignore_comments/suppress_errors_in_ts_files_using_ts_ignore_comments.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.7/10_numeric_separators/10_numeric_separators.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.7/1_constant_named_properties/1_constant_named_properties.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.7/2_unique_symbol/2_unique_symbol.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.7/3_strict_class_initialization/3_strict_class_initialization.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.7/4_definite_assignment_assertions/4_definite_assignment_assertions.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.7/5_fixed_length_tuples/5_fixed_length_tuples.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.7/6_improved_type_inference_for_object_literals/6_improved_type_inference_for_object_literals.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.7/7_improved_handling/7_improved_handling.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.7/8_Type_guards_inferred_from_in_operator/8_Type_guards_inferred_from_in_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.8/Improved_keyof_with_intersection_types.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.8/conditional_types.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.8/distributive_conditional_types.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.8/filter_union_types.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.8/improved_control_over_mapped_type_modifiers.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.8/predefined_conditional_types.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.8/prototype_assignment.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.8/type_inference.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.9/3_generic_type_arguments_in_tt.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.9/4_import_types.ts create mode 100644 es2panda/test/ts_extra_tests/test/2.9/module.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.0/new_unknown_top_type/new_unknown_top_type.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.0/reference_lib/reference_lib.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/generic_rest_parameters/generic_rest_parameters.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_elements_in_tuple_types/rest_elements_in_tuple_types.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/spread_expressions_with_tuple_types/spread_expressions_with_tuple_types.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.1/mapped_types_on_tuples_and_arrays/mapped_types_on_tuples_and_arrays_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.1/properties_declarations_on_functions/properties_declarations_on_functions_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.2/bigint/bigint_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.2/bigint/bigint_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.2/bigint/bigint_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.2/generic_object_rest_variables_and_parameters/generic_object_rest_variables_and_parameters.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.2/non-unit_types_as_union_discriminants/non-unit_types_as_union_discriminants.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.3/improved_behavior_for_calling_union_types.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.4/const_assertions.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.4/higher_order_type_inference.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.4/readonly_array.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.5/higher_order_type_inference.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.5/omit_helper_type.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.5/smarter_union_type_checking.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.6/better_unicode_support_for_identifiers/better_unicode_support_for_identifiers_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/get_and_set_accessors_are_allowed_in_ambient_contexts_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/test.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.6/more_accurate_array_spread/more_accurate_array_spread_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.7/assertion_functions/assertion_functions_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.7/nullish_coalescing/nullish_coalescing_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.7/nullish_coalescing/nullish_coalescing_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.7/recursive_type_aliases/recursive_type_aliases_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.7/ts_nocheck_in_typescript_files/ts_nocheck_in_typescript_files.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.8/1_type_only_imports_and_export.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.8/3_which_should_i_use.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.8/4_export_star_as_ns_syntax.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.8/export_star.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.8/my_module.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.8/some_module.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.9/improvements_in_inference_and_Promise.all/improvements_in_inference_and_Promise.all.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.9/ts-expect-error_comments/ts-expect-error_comments.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.0/class_property_Inference_from_constructors/class_property_Inference_from_constructors_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_6.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.1/abstract_members_can_not_be_marked_async/abstract_members_can_not_be_marked_async.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.1/any_or_unknown_are_propagated_in_falsy_positions/any_or_unknown_are_propagated_in_falsy_positions.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.1/conditional_spreads_create_optional_properties/conditional_spreads_create_optional_properties_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.1/recursive_conditional_types/recursive_conditional_types.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.1/resolvers_parameters_are_no_longer_optional_in_promises/resolves_parameters_are_no_longer_optional_in_promises.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.1/template_literal_types/template_literal_types_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.1/template_literal_types/template_literal_types_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.1/template_literal_types/template_literal_types_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types2.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types3.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation2.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.3/always-truthy_promise_checks/always-truthy_promise_checks.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.3/constructorParameters_works_on_abstract_class/constructorParameters_works_on_abstract_class.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.3/separate_write_types_on_properties/separate_write_types_on_properties_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.3/static_index_signatures/static_index_signatures.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.3/union_enums_cannot_be_compared_to_arbitrary_numbers/union_enums_cannot_be_compared_to_arbitrary_numbers.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.4/exact_optional_property_types/exact_optional_property_types_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.5/disabling_import_elision/animal.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.5/disabling_import_elision/disabling_import_elision_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.5/private_field_presence_checks/private_field_presence_checks_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.5/template_string_types_as_discriminants/template_string_types_as_discriminants_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.5/the_awaited_type_and_promise_improvements/the_awaited_type_and_promise_improvements_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.5/type_modifiers_on_import_names/some-module.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.6/1_allowing_code_in_constructors.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.6/2_control_flow_analysis.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.6/3_improved_recursion_depth_checks.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.6/4_indexed_access_inference_improvements.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.6/5_control_flow_analysis_for_dependent_parameters.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.7/extends_constraints_on_infer_type_variables/extends_constraints_on_infer_type_variables.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.7/improved_function_inference_in_objects_and_methods/improved_function_inference_in_objects_and_methods.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.7/instantiation_expressions/instantiation_expressions.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.7/optional_variance_annotations_for_type_parameters/optional_variance_annotations_for_type_parameters.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.7/readonly_tuples_have_a_readonly_length_property/readonly_tuples_have_a_readonly_length_property.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.8/improved_inference_for_infer_types_in_template_string_types/improved_inference_for_infer_types_in_template_string_types.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.9/auto_accessors_in_classes/auto_accessors_in_classes.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.9/checks_for_equality_on_NaN/checks_for_equality_on_NaN.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.9/the_satisfies_operator/the_satisfies_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.9/unlisted_property_narrowing_with_the_in_operator/unlisted_property_narrowing_with_the_in_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/ambients/ambient_declarations/ambient_namespace_declarations/ambient_namespace_declarations.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/ambients/ambient_module_declarations/ambient_module_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/declarations/declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/declarations/declarations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/computed_property_names/computed_property_names_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/property_names/property_names_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/require_is_valid_identifier_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/let_scope.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/namespace.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/var_scope.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_body/class_body.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_6.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/super_calls/super_calls.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/index_member_declarations/index_member_declarations.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_accessor_declarations/member_accessor_declarations.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/enums/constant_enum_declarations/constant_enum_declarations.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/enums/declaration_merging/declaration_merging_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/enums/declaration_merging/declaration_merging_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/enums/enum_declarations/enum_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/enums/enum_declarations/enum_declarations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/enums/enum_declarations/enum_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/enums/enum_members/enum_members_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_6.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/assignment_operators/assignment_operator_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/assignment_operators/assignment_operator_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_6.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_7.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_8.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_instanceof_operator/the_instanceof_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_and_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_division_method_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_left_shift_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_multiplication_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_or_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_remainder_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_right_shift_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_subtraction_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_unsigned_shift_to_the_right.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_xor_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_congruence_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_equal_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_greater_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_greater_or_equal_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_incongruence_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_less_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_less_or_equal_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_unequal_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_or_operator/the_or_operator_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/class_expressions/class_expressions_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_10.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_11.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_13.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_15.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_16.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_6.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_9.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/class.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/enum.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/function.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/name_space.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/parameter.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/variable.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/literals/boolean.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/literals/null.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/literals/number.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/literals/regexp.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/literals/string.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_6.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_7.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/parentheses/parentheses.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_access_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_any_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_any_type_6.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_apprent_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_index_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_string_number_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/property_access/property_access_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/property_access/property_access_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/the_comma_operator/the_comma_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/the_conditional_operator/the_conditional_operator_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_calls/arguments.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_calls/super_calls.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_property_access/derived_class_access.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_property_access/static_member_access.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/this_key_word/this_key_word_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/type_assertion/type_assertion_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/type_assertion/type_assertion_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/type_assertion/type_assertion_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_10.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_11.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_12.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_13.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_14.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_15.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_6.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_7.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_8.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_9.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_!_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_++_and_--_operators.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_+_and_~_operators.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_delete_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_typeof_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_void_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_6.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/function_declarations/function_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/function_declarations/function_declarations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/function_overloads/function_overloads_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/generator_functions/generator_functions_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/generator_functions/generator_functions_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/generic_functions/generic_functions_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/generic_functions/generic_functions_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/type_guard_functions/type_guard_functions_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/grammar/classes/classes.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/grammar/enums/enums.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/grammar/expressions/expressions.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/grammar/functions/functions.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/grammar/interfaces/interfaces.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/grammar/namespaces/namespaces.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/grammar/statements/statements.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/grammar/types/types.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/interfaces/1_interface_declarations/interface_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/interfaces/1_interface_declarations/interface_declarations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/interfaces/1_interface_declarations/interface_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/interfaces/2_declaration_merging/declaration_merging_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/interfaces/2_declaration_merging/declaration_merging_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/interfaces/4_dynamic_type_checks/dynamic_type_checks_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_1_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_1_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_1_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/namespaces/export_declarations/export_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/namespaces/export_declarations/export_declarations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/namespaces/export_declarations/export_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/namespaces/import_alias_declarations/import_alias_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/namespaces/import_alias_declarations/import_alias_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_body/namespace_body.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_10.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_6.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_7.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_8.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_9.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/2_modules/modules_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/4_import_require_declarations/import_require_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/6_export_assignments/export_assignments_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/break_statements/break_statements.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/continue_statements/continue_statements.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/for_in_statements/for_in_statements.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/for_of_statements/for_of_statements.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/for_statements/for_statements.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/let_and_const_declarations/let_and_const_declarations.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/return_statements/return_statements.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/switch_statements/switch_statements.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/throw_statements/throw_statements.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/try_statements/try_statements.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/3_implied_type/implied_type.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/Intersection_Types/Intersection_types_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/Intersection_Types/intersection_types_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/object_types/function_types/function_types.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/object_types/members/members_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/object_types/members/members_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/object_types/named_type_reference/named_type_reference.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_enum_type/the_enum_type_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_null_type/the_null_type_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_undefined_type/the_undefined_type_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_6.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/specialized_signatures/specialized_signatures_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_members/construct_signatures/construct_signatures.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_members/index_signatures/index_signatures.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_members/method_signatures/method_signatures_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_members/method_signatures/method_signatures_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_members/property_signatures/property_signatures.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_types/function_type_literals/function_type_literals_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_types/intersection_type_literals/intersection_type_literals.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_types/object_type_literals/object_type_literals.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_types/predefined_types/predefined_types.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_types/specifying_types_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_types/specifying_types_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_types/this_type_references/this_type_references_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_types/this_type_references/this_type_references_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_types/tuple_type_literals/tuple_type_literals.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_queries/type_queries_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_queries/type_queries_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/specifying_types/union_type_literals/union_type_literals.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_aliases/type_aliases_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_aliases/type_aliases_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_aliases/type_aliases_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_parameters/this_types/this_types.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_parameters/this_types/this_types_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_parameters/this_types/this_types_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_6.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_6.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_7.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_8.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_10.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_11.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_12.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_13.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_14.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_15.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_16.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_17.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_18.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_6.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_7.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_8.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_9.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/contextual_signature_instantiation/contextual_signature_instantiation.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/excess_properties/excess_properties_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/excess_properties/excess_properties_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/excess_properties/excess_properties_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/recursive_types/recursive_types.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_10.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_11.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_12.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_13.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_14.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_15.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_16.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_6.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_7.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_8.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_9.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_6.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_7.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_6.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_7.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/widend_types/widend_types_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/widend_types/widend_types_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/widend_types/widend_types_3.ts create mode 100644 es2panda/test/ts_extra_tests/tool/test_helper.py create mode 100644 es2panda/test/ts_extra_tests/tool/testcfg.py diff --git a/es2panda/test/ts_extra_tests/package.json b/es2panda/test/ts_extra_tests/package.json new file mode 100644 index 0000000000..33830f776a --- /dev/null +++ b/es2panda/test/ts_extra_tests/package.json @@ -0,0 +1,6 @@ +{ + "type": "module", + "devDependencies": { + "@types/node": "^18.15.11" + } +} diff --git a/es2panda/test/ts_extra_tests/run_ts_case.py b/es2panda/test/ts_extra_tests/run_ts_case.py new file mode 100644 index 0000000000..1cda104e93 --- /dev/null +++ b/es2panda/test/ts_extra_tests/run_ts_case.py @@ -0,0 +1,173 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# importing required modules +import argparse +import os +import shutil +import tempfile + +from tool.test_helper import get_path_file, get_disable_list, is_disable_case +from tool.testcfg import TestCase + + +TEST_PATH = './' +TEST_TMP_PATH = '/testTmp4/' +TEMP_PATH = os.getcwd() + TEST_TMP_PATH + +if os.path.exists(TEMP_PATH): + shutil.rmtree(TEMP_PATH) + + +if (os.path.exists(TEMP_PATH) == False): + os.mkdir(TEMP_PATH) + +total_case = 0 +failed_case = 0 +TestCase.temp_path = TEMP_PATH +def is_testcase_exist(parser, arg): + if not os.path.isabs(arg): + arg = TEST_PATH + arg + if not os.path.exists(arg): + parser.error("The directory or file '%s' does not exist" % arg) + return os.path.abspath(arg) + +def is_file(parser, arg): + if not os.path.isfile(arg): + parser.error("The file '%s' does not exist" % arg) + + return os.path.abspath(arg) + +def is_directory(parser, arg): + if not os.path.isdir(arg): + parser.error("The directory '%s' does not exist" % arg) + + return os.path.abspath(arg) + +def parse_and_execute(path, arkruntime = False, skip_negative = True): + if path.endswith(".ts"): + test_case = TestCase(path) + if not test_case.is_test_case: + return False, False + # check test case declare + if not test_case.check_declaration(): + print(test_case.path, test_case.detail_result, sep='\t') + return True, True + if skip_negative and test_case.is_negative(): + return False, False + else: + test_case.execute(arkruntime) + if test_case.fail: + print('TESTCASE Fail! Fail reason is coming:') + print(test_case.path, test_case.detail_result, sep='\t') + return True, True + return True, False + +# create a parser object +parser = argparse.ArgumentParser(description = "TypeScript Spec&Feature Test Tool") + +# files or command +parser.add_argument("release", nargs = '*', metavar = "release", type = lambda arg: is_testcase_exist(parser, arg), + help = "All test case in the release will be execute") + +parser.add_argument("-a", "--arkruntime", action="store_true", default=False, help= "test on arkruntime") + +parser.add_argument("-s", "--skip-abnormal-case", action="store_true", default=False, help= "skip abnormal test case") + +parser.add_argument("-v", "--version", dest='limit_version', default=None, help= "version limit") + +# skip list +parser.add_argument("-d", "--disable-list", type= lambda arg: is_file(parser, arg), default=None, + help= "path to the file that contains test to skip") + +parser.add_argument( + '--js-runtime', dest='js_runtime_path', default=None, type=lambda arg: is_directory(parser, arg), + help='the path of js vm runtime') +parser.add_argument( + '--LD_LIBRARY_PATH', dest='ld_library_path', default=None, help='LD_LIBRARY_PATH') + +parser.add_argument( + '--es2abc', dest='es2abc', default=None, help='ES2ABC_PATH') + +# parse the arguments from standard input +args = parser.parse_args() +if args.js_runtime_path: + TestCase.js_runtime_path = args.js_runtime_path +if args.ld_library_path: + TestCase.ld_library_path = args.ld_library_path +if args.es2abc: + TestCase.es2abc = args.es2abc + +disable_list = [] +if args.disable_list: + disable_list = get_disable_list(args.disable_list) + +# tsc + node / es2abc +print("TEST CASE", "FAIL REASON", "FAIL LINE", sep="\t") + +for file_path in args.release: + root = file_path + # gen abc file + if args.arkruntime: + for file_paths in get_path_file("suite", None, True): + if file_paths.endswith(".ts"): + test_case = TestCase(file_paths) + if not test_case.is_test_case: + test_case.create_abc(file_paths) + + for file_paths in get_path_file("test", None, True): + if file_paths.endswith(".ts"): + test_case = TestCase(file_paths) + if not test_case.is_test_case: + test_case.create_abc(file_paths) + + if is_disable_case(file_path, disable_list): + continue + if os.path.isfile(file_path): + is_test_count, failed = parse_and_execute(file_path, args.arkruntime, args.skip_abnormal_case) + if is_test_count: + total_case += 1 + if failed: + failed_case += 1 + continue + for file_path in get_path_file(file_path, None, True, args.limit_version): + # continue + if False == file_path.endswith(".ts"): + continue + if is_disable_case(file_path, disable_list): + continue + is_test_count , failed = parse_and_execute(file_path, args.arkruntime, args.skip_abnormal_case) + if is_test_count: + total_case += 1 + if failed : + failed_case += 1 + + # delete abc files + if args.arkruntime: + for file_paths in get_path_file("suite", None, True): + if file_paths.endswith(".ts"): + test_case = TestCase(file_paths) + if not test_case.is_test_case: + test_case.create_abc(file_paths) + + for file_paths in get_path_file("test", None, True): + if file_paths.endswith(".abc"): + if os.path.exists(file_paths): + os.remove(file_paths) + +print("TOTAL CASE COUNT:%d" % total_case) +print("FAILED CASE COUNT:%d" % failed_case) +# delete temp dir +if os.path.exists(TEMP_PATH): + shutil.rmtree(TEMP_PATH) diff --git a/es2panda/test/ts_extra_tests/suite/assert.ts b/es2panda/test/ts_extra_tests/suite/assert.ts new file mode 100644 index 0000000000..503047c090 --- /dev/null +++ b/es2panda/test/ts_extra_tests/suite/assert.ts @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +import { AssertionError } from "./assertionError.js" + +export class Assert { + private static defaultMessage(actual: any, expect: any, flag: boolean = true) { + if (flag == true) { + return "expected '" + expect + "' ,but was '" + actual + "'."; + } else { + return "expected not '" + expect + "' ,but was '" + actual + "'."; + } + + } + static equal(actual: any, expect: any, msg?: string) { + if (actual != expect) { + throw new AssertionError(msg ? msg : this.defaultMessage(actual, expect)); + } + } + static notEqual(actual: any, expect: any, msg?: string) { + if (actual == expect) { + throw new AssertionError(msg ? msg : this.defaultMessage(actual, expect, false)); + } + } + static isTrue(actual: any, msg?: string) { + this.equal(actual, true, msg); + } + static isFalse(flag: any, msg?: string) { + this.equal(flag, false, msg); + } + static isNumber(x: any, msg?: string) { + this.equal(typeof x, "number", msg); + } + static isString(s: any, msg?: string) { + this.equal(typeof s, "string", msg); + } + static isBoolean(s: any, msg?: string) { + this.equal(typeof s, "boolean", msg); + } + static isSymbol(actual: any, msg?: string) { + this.equal(typeof actual, "symbol", msg); + } + static isFunction(fun: any, msg?: string) { + this.equal(typeof fun, "function", msg); + } + static notNULL(v: any, msg?: string) { + this.notEqual(v, null, msg); + } + static isUndefined(actual: any, msg?: string) { + this.equal(actual, undefined, msg); + } + static isObject(obj: any, msg?: string) { + this.equal(typeof obj, "object", msg); + } +} \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/suite/assertionError.ts b/es2panda/test/ts_extra_tests/suite/assertionError.ts new file mode 100644 index 0000000000..b1447b867d --- /dev/null +++ b/es2panda/test/ts_extra_tests/suite/assertionError.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export class AssertionError extends Error { + protected msg: string | undefined = ""; + + constructor(msg: string | undefined) { + super(); + this.msg = msg; + } +} diff --git a/es2panda/test/ts_extra_tests/test/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts b/es2panda/test/ts_extra_tests/test/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts new file mode 100644 index 0000000000..ef52977f0a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: > + An abstract class can declare abstract properties and/or accessors. Any sub class will need to declare the abstract + properties or be marked as abstract. Abstract properties cannot have an initializer. Abstract accessors cannot have bodies. +module: ESNext +isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +abstract class Skill { + name: string; + damage:number; +} +class Divied extends Skill { + name = "derived"; + damage = 128; +} +let d = new Divied(); +Assert.equal(d.name, "derived"); +Assert.equal(d.damage, 128); diff --git a/es2panda/test/ts_extra_tests/test/2.0/allow_duplicate_identifiers_across_declarations/allow_duplicate_identifiers_across_declarations_1.ts b/es2panda/test/ts_extra_tests/test/2.0/allow_duplicate_identifiers_across_declarations/allow_duplicate_identifiers_across_declarations_1.ts new file mode 100644 index 0000000000..18da4923d1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/allow_duplicate_identifiers_across_declarations/allow_duplicate_identifiers_across_declarations_1.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: TypeScript 2.0 relaxes this constraint and allows duplicate identifiers across blocks, as long as they have identical types. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" + +interface Weapon { + damage?: number; +} + +interface Skill { + skillName?: string; + damageType?: string; + damage?: number; +} + +let sa: Weapon = { + damage: 1024, +}; + +let sb: Skill = { + skillName: "XOMissile", + damageType: "XO", + damage: 128, +}; + +Assert.equal(sa.damage, 1024); +Assert.equal(sb.damage, 128); diff --git a/es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis1.ts b/es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis1.ts new file mode 100644 index 0000000000..4d6ebc8304 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis1.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the type checker analyses all possible flows of control in statements and expressions to produce the most specific type possible (the narrowed type) at any given location for a local variable or parameter that is declared to have a union type. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" + +function fun01(x: string | number | boolean): void { + if (typeof x === "string") { + x; + Assert.equal(typeof x, "string"); + x = 1; + x; + } + x; +} + +function fun02(x: string | number): void { + if (typeof x === "number") { + Assert.equal(typeof x, "number"); + return; + } + x; +} + +fun01("hello"); +fun02(1024); diff --git a/es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis2.ts b/es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis2.ts new file mode 100644 index 0000000000..52ec8dab1d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis2.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Control flow based type analysis is particularly relevant in strictNullChecks mode because nullable types are represented using union types. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" + +function testFun(x: string | null): void { + if (x === null) { + Assert.equal(typeof x, "object"); + return; + } + x; +} + +testFun(null); diff --git a/es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis3.ts b/es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis3.ts new file mode 100644 index 0000000000..84cf6671d2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis3.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In strictNullChecks mode, control flow based type analysis includes definite assignment analysis for local variables of types that don’t permit the value undefined. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" + +// Compiled with --strictNullChecks +function tFun(c: boolean): void { + let x: number; + if (c) { + x = 1; + Assert.equal(x, 1); + } + x = 2; + Assert.equal(x, 2); +} + +tFun(true); diff --git a/es2panda/test/ts_extra_tests/test/2.0/dotted_names_in_type_guards/dotted_names_in_type_guards_1.ts b/es2panda/test/ts_extra_tests/test/2.0/dotted_names_in_type_guards/dotted_names_in_type_guards_1.ts new file mode 100644 index 0000000000..6891d01249 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/dotted_names_in_type_guards/dotted_names_in_type_guards_1.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Type guards now support checking “dotted names” consisting of a variable or parameter name followed one or more property accesses. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" + +type StrObj = + | { + strobj?: { + str1?: string; + str2?: string; + }; + } + | undefined; + +function funSO(so?: StrObj): string | void { + if (so && so.strobj && so.strobj.str1) { + const x: string = so.strobj.str1; + Assert.isString(x); + return x; + } else if (so && so.strobj && so.strobj.str2) { + const x: string = so.strobj.str2; + Assert.isString(x); + return x; + } else { + if (so && so.strobj && so.strobj.str1 === undefined) { + return "so.strobj.str1 === undefined"; + } else if (so && so.strobj && so.strobj.str2 === undefined) { + return "so.strobj.str2 === undefined"; + } else if (so !== undefined && so.strobj === undefined) { + return "so.strobj === undefined"; + } else if (so === undefined) { + return "so === undefined"; + } + } +} + +let so: StrObj = undefined; +Assert.equal(funSO(so), "so === undefined"); +so = {}; +Assert.equal(funSO(so), "so.strobj === undefined"); +so = { strobj: {} }; +Assert.equal(funSO(so), "so.strobj.str1 === undefined"); +so = { strobj: { str1: "str1" } }; +Assert.equal(funSO(so), "str1"); diff --git a/es2panda/test/ts_extra_tests/test/2.0/expression_operators/expression_operators_1.ts b/es2panda/test/ts_extra_tests/test/2.0/expression_operators/expression_operators_1.ts new file mode 100644 index 0000000000..2c83991d27 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/expression_operators/expression_operators_1.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Expression operators permit operand types to include null and/or undefined but always produce values of non-null and non-undefined types. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +function sum(a: number, b: number) { + return a + b; +} +sum(3, 5); + +interface Entity { + name: string; +} + +function getEntityName(e: Entity): string { + return e.name; +} +Assert.equal(getEntityName({ name: "caihua" }), "caihua"); + +let x: (e: Entity) => string = getEntityName; +let s: (e: Entity) => string = x; +let y: (e: Entity) => string = x || { name: "test" }; diff --git a/es2panda/test/ts_extra_tests/test/2.0/expression_operators/expression_operators_2.ts b/es2panda/test/ts_extra_tests/test/2.0/expression_operators/expression_operators_2.ts new file mode 100644 index 0000000000..859c348ace --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/expression_operators/expression_operators_2.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The && operator adds null and/or undefined to the type of the right operand depending on which are present in the type of the left operand, and the || operator removes both null and undefined from the type of the left operand in the resulting union type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +interface Entity { + name: string; +} +// Compiled with --strictNullChecks +function getEntityName(e: Entity): string { + return e.name; +} +Assert.equal(getEntityName({ name: "caihua" }), "caihua"); + +let x: (e: Entity) => string = getEntityName; +let s: (e: Entity) => string = x; +let y: (e: Entity) => string = x || { name: "test" }; + +Assert.equal(x.name, "getEntityName"); diff --git a/es2panda/test/ts_extra_tests/test/2.0/implicit_index_signatures/implicit_index_signatures.ts b/es2panda/test/ts_extra_tests/test/2.0/implicit_index_signatures/implicit_index_signatures.ts new file mode 100644 index 0000000000..65ebc007fd --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/implicit_index_signatures/implicit_index_signatures.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + An object literal type is now assignable to a type with an index signature if all known properties in the + object literal are assignable to that index signature. This makes it possible to pass a variable that was initialized with an object literal as parameter to a function that expects a map or dictionary: + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +function httpService(path: string, headers: { [x: string]: string }) { + return JSON.stringify(headers); +} +const headers = { + "Content-Type": "application/x-www-form-urlencoded", +}; +let s1: string = httpService("", { + "Content-Type": "application/x-www-form-urlencoded", +}); +Assert.equal(s1, '{"Content-Type":"application/x-www-form-urlencoded"}'); + +// Now ok, previously wasn't +let s2: string = httpService("", headers); +Assert.equal(s2, '{"Content-Type":"application/x-www-form-urlencoded"}'); diff --git a/es2panda/test/ts_extra_tests/test/2.0/module_identifiers_allow_for_js_extension/module_identifiers_allow_for_js_extension_1.ts b/es2panda/test/ts_extra_tests/test/2.0/module_identifiers_allow_for_js_extension/module_identifiers_allow_for_js_extension_1.ts new file mode 100644 index 0000000000..b5716d30ff --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/module_identifiers_allow_for_js_extension/module_identifiers_allow_for_js_extension_1.ts @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: With TypeScript 2.0, the compiler will look up definition of "moduleA.js" in ./moduleA.ts or ./moduleA.d.t. +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" +import { HelloWorld } from "./test_js_extension.js" + +let world = new HelloWorld("HelloWorld.txt"); +Assert.equal(world.txt, "HelloWorld.txt"); diff --git a/es2panda/test/ts_extra_tests/test/2.0/module_identifiers_allow_for_js_extension/test_js_extension.ts b/es2panda/test/ts_extra_tests/test/2.0/module_identifiers_allow_for_js_extension/test_js_extension.ts new file mode 100644 index 0000000000..f9b155f734 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/module_identifiers_allow_for_js_extension/test_js_extension.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export class HelloWorld { + txt: string; + constructor(name: string) { + this.txt = name; + } +}; diff --git a/es2panda/test/ts_extra_tests/test/2.0/module_resolution_enhancements/module_resolution_enhancements_1.ts b/es2panda/test/ts_extra_tests/test/2.0/module_resolution_enhancements/module_resolution_enhancements_1.ts new file mode 100644 index 0000000000..0f57862551 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/module_resolution_enhancements/module_resolution_enhancements_1.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: > + test base url import,the tsc command needs to be executed in the 2.0 file directory. + tsconfig.json file url: testing-framework\test\2.0\tsconfig.json. +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" +import { ADD, flag } from "../test_base_url.js" + +Assert.equal(ADD(50, 75), 125); +Assert.equal(flag, "baseurl"); diff --git a/es2panda/test/ts_extra_tests/test/2.0/module_resolution_enhancements/module_resolution_enhancements_2.ts b/es2panda/test/ts_extra_tests/test/2.0/module_resolution_enhancements/module_resolution_enhancements_2.ts new file mode 100644 index 0000000000..567be71b56 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/module_resolution_enhancements/module_resolution_enhancements_2.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: > + The TypeScript compiler supports the declaration of such mappings using paths property in tsconfig.json files, + Path mapping. + The tsc command needs to be executed in the 2.0 file directory. + tsconfig.json file url: testing-framework\test\2.0\tsconfig.json. +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" +import { Directions } from "../test_virtual_directories_with_rootDirs/view2.js" + +Assert.equal(Directions.Up, 0); diff --git a/es2panda/test/ts_extra_tests/test/2.0/module_resolution_enhancements/module_resolution_enhancements_3.ts b/es2panda/test/ts_extra_tests/test/2.0/module_resolution_enhancements/module_resolution_enhancements_3.ts new file mode 100644 index 0000000000..a7c264d3ea --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/module_resolution_enhancements/module_resolution_enhancements_3.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: > + Using ‘rootDirs’, you can inform the compiler of the roots making up this “virtual” directory; + and thus the compiler can resolve relative modules imports within these “virtual” directories + as if they were merged together in one directory. + The tsc command needs to be executed in the 2.0 file directory. + tsconfig.json file url: testing-framework\test\2.0\tsconfig.json. +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' +import '../test_virtual_directories_with_rootDirs/view2.js' +import { Directions } from '../test_virtual_directories_with_rootDirs/view2.js' + +Assert.equal(Directions.Left, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.0/non_null_assertion_operator/non_null_assertion_operator.ts b/es2panda/test/ts_extra_tests/test/2.0/non_null_assertion_operator/non_null_assertion_operator.ts new file mode 100644 index 0000000000..608a13b8bf --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/non_null_assertion_operator/non_null_assertion_operator.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: > + A new ! post-fix expression operator may be used to assert that its operand is non-null and non-undefined in contexts where the type checker is unable to conclude that fact. +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" + +function hwfStr(x?: string, y?: number | string): string { + let z: number | string = x! + y!; + return z; +} +Assert.equal(hwfStr("A"), "Aundefined"); +Assert.equal(hwfStr("B", 5), "B5"); diff --git a/es2panda/test/ts_extra_tests/test/2.0/optional_class_properties/optional_class_properties.ts b/es2panda/test/ts_extra_tests/test/2.0/optional_class_properties/optional_class_properties.ts new file mode 100644 index 0000000000..95fff8a358 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/optional_class_properties/optional_class_properties.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Optional properties and methods can now be declared in classes, similar to what is already permitted in interfaces. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +class Class0000 { + a: number = 0; + b?: number; + f() { + return this.a; + } + // Body of optional method can be omitted + g?(): number; + h?() { + return this.b; + } +} +let c0000 = new Class0000(); +c0000.a = 1024; +c0000.b = 1408; +Assert.equal(c0000.f(), 1024); + +if (c0000.h) { + Assert.equal(c0000.h(), 1408); +} + +c0000.g = () => { + if (c0000.b !== undefined) { + return c0000.a + c0000.b; + } else { + return c0000.a; + } +} +Assert.equal(c0000.g(), 2432); diff --git a/es2panda/test/ts_extra_tests/test/2.0/optional_parameters_and_properties/optional_parameters_and_properties.ts b/es2panda/test/ts_extra_tests/test/2.0/optional_parameters_and_properties/optional_parameters_and_properties.ts new file mode 100644 index 0000000000..1b2e6da560 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/optional_parameters_and_properties/optional_parameters_and_properties.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Optional parameters and properties automatically have undefined added to their types, even when their type annotations don’t specifically include undefined. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js"; + +function printPoint(a: number, b: number, c?: number): string { + let obj: { a: number, b: number, c?: number }; + if (c !== undefined) { + obj = { a, b, c }; + Assert.isNumber(c); + } else { + obj = { a, b }; + Assert.isUndefined(c); + } + return JSON.stringify(obj); +} +Assert.equal(printPoint(1, 3, 5), '{"a":1,"b":3,"c":5}'); +Assert.equal(printPoint(1, 1), '{"a":1,"b":1}'); diff --git a/es2panda/test/ts_extra_tests/test/2.0/private_and_protected_constructor/private_and_protected_constructor.ts b/es2panda/test/ts_extra_tests/test/2.0/private_and_protected_constructor/private_and_protected_constructor.ts new file mode 100644 index 0000000000..cb5f793ac3 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/private_and_protected_constructor/private_and_protected_constructor.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: A class constructor may be marked private or protected. A class with private constructor cannot be instantiated outside the class body, and cannot be extended. A class with protected constructor cannot be instantiated outside the class body, but can be extended. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +class Box { + [x: string]: any; + private static subBox: Box = { + cname: "Box", + }; + private constructor() { } + static getSubBos() { + if (!Box.subBox) { + Box.subBox = new Box(); + } + return Box.subBox; + } +} +let v: Box = Box.getSubBos(); +Assert.equal(v.cname, "Box"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.0/read-only_properties_and_index_signatures/read-only_properties_and_index_signatures.ts b/es2panda/test/ts_extra_tests/test/2.0/read-only_properties_and_index_signatures/read-only_properties_and_index_signatures.ts new file mode 100644 index 0000000000..4e73b5088e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/read-only_properties_and_index_signatures/read-only_properties_and_index_signatures.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A property or index signature can now be declared with the readonly modifier is considered read-only. + Read-only properties may have initializers and may be assigned to in constructors within the same class declaration, but otherwise assignments to read-only properties are disallowed + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +interface Point { + readonly x: number; + readonly y: number; +} +var p1: Point = { x: 10, y: 20 }; +var p2 = { x: 1, y: 1 }; + +var p3: Point = p2; +Assert.equal(JSON.stringify(p3), '{"x":1,"y":1}'); + +p2.x = 5; + +let a: Array = [0, 1, 2, 3, 4]; +let b: ReadonlyArray = a; +Assert.equal(JSON.stringify(b), '[0,1,2,3,4]'); diff --git a/es2panda/test/ts_extra_tests/test/2.0/shorthand_ambient_module_declarations/hot-new-module.ts b/es2panda/test/ts_extra_tests/test/2.0/shorthand_ambient_module_declarations/hot-new-module.ts new file mode 100644 index 0000000000..13cc016851 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/shorthand_ambient_module_declarations/hot-new-module.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export default function hwexpNumAdd15(a: number) { + return a + 15; +} + +export const y = 10; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.0/shorthand_ambient_module_declarations/shorthand_ambient_module_declarations_1.ts b/es2panda/test/ts_extra_tests/test/2.0/shorthand_ambient_module_declarations/shorthand_ambient_module_declarations_1.ts new file mode 100644 index 0000000000..14787aa358 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/shorthand_ambient_module_declarations/shorthand_ambient_module_declarations_1.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: > + If you don’t want to take the time to write out declarations before using a new module, + you can now just use a shorthand declaration to get started quickly. +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" +import hwexpNumAdd15, { y } from "./hot-new-module.js" + +hwexpNumAdd15(y); + +Assert.equal(typeof hwexpNumAdd15, "function"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_1.ts b/es2panda/test/ts_extra_tests/test/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_1.ts new file mode 100644 index 0000000000..ea3bcc2501 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_1.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: You can provide an explicit this parameter. this parameters are fake parameters that come first in the parameter list of a function. +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" + +function fun_this(this: any) { + Assert.equal(this, undefined); +} + +fun_this(); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_2.ts b/es2panda/test/ts_extra_tests/test/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_2.ts new file mode 100644 index 0000000000..33992f5262 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_2.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: > + this parameters in callbacks.Libraries can also use this parameters to declare how callbacks will be invoked. + this: void means that addClickListener expects onclick to be a function that does not require a this type. +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" + +interface WebElement { + Click(onclick: (this: void, e: Event) => void): void; +} + +class NetLink { + info: string; + constructor(info: string) { + this.info = info; + } + onClickGood(this: void, e: Event) { + Assert.equal(this, undefined); + } +} + +let webElement: WebElement = { + Click(Onclick: (this: void, e: Event) => void) { } +}; +let onAir = new NetLink("OnAir"); +webElement.Click(onAir.onClickGood); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.0/support_for_UMD_module_definitions/math-lib.ts b/es2panda/test/ts_extra_tests/test/2.0/support_for_UMD_module_definitions/math-lib.ts new file mode 100644 index 0000000000..5a1e8dc778 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/support_for_UMD_module_definitions/math-lib.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export function isPrime(x: number): boolean; + +export function isPrime(x: number): boolean { + if (x < 2) { + return false; + } + for (let i = 2; i <= x / 2; i++) { + if (x % i == 0) { + return false; + } + } + return true; +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.0/support_for_UMD_module_definitions/support_for_UMD_module_definitions_1.ts b/es2panda/test/ts_extra_tests/test/2.0/support_for_UMD_module_definitions/support_for_UMD_module_definitions_1.ts new file mode 100644 index 0000000000..0ee5f11177 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/support_for_UMD_module_definitions/support_for_UMD_module_definitions_1.ts @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: > + These UMD libraries can be accessed through either an import. +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" +import { isPrime } from "./math-lib.js"; + +Assert.equal(isPrime(2), true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.0/tagged_union_types/tagged_union_types_1.ts b/es2panda/test/ts_extra_tests/test/2.0/tagged_union_types/tagged_union_types_1.ts new file mode 100644 index 0000000000..1f6d3c69ba --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/tagged_union_types/tagged_union_types_1.ts @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: The TS compiler now support type guards that narrow union types based on tests of a discriminant property and furthermore extend that capability to switch statements. +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" + +interface Color { + name: "Color"; + rgb: [number, number, number]; +} + +interface Point { + name: "Point"; + point: [number, number]; +} + +interface Level { + name: "Level"; + level: number; +} + +type ColorPoint = Color | Point | Level; + +function area(s: ColorPoint) { + switch (s.name) { + case "Color": + return s.rgb; + case "Point": + return s.point; + case "Level": + return s.level; + } +} + +function test1(s: ColorPoint) { + if (s.name === "Color") { + return s; + } + return s; +} + +function test2(s: ColorPoint) { + if (s.name === "Color" || s.name === "Point") { + return; + } + return s; +} + +let color: Color = { + name: "Color", + rgb: [255, 0, 0] +}; + +let point: Point = { + name: "Point", + point: [0, 0] +}; + +let level: Level = { + name: "Level", + level: 10 +}; + +Assert.equal(JSON.stringify(area(color)), '[255,0,0]'); +Assert.equal(test1(point).name, 'Point'); +Assert.equal(test2(level)?.level, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.0/test_base_url.ts b/es2panda/test/ts_extra_tests/test/2.0/test_base_url.ts new file mode 100644 index 0000000000..8d0e09479a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/test_base_url.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +function add(a: number, b: number): number { + return a + b; +} +let flag: string = "baseurl"; +export { add as ADD, flag }; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.0/test_virtual_directories_with_rootDirs/view1.ts b/es2panda/test/ts_extra_tests/test/2.0/test_virtual_directories_with_rootDirs/view1.ts new file mode 100644 index 0000000000..8ae0a9a186 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/test_virtual_directories_with_rootDirs/view1.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +import './module_resolution_enhancements_3.js' \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.0/test_virtual_directories_with_rootDirs/view2.ts b/es2panda/test/ts_extra_tests/test/2.0/test_virtual_directories_with_rootDirs/view2.ts new file mode 100644 index 0000000000..58d9a6f69e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.0/test_virtual_directories_with_rootDirs/view2.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export enum Directions { + Up, + Down, + Left, + Right +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.1/better_inference_for_literal_types/better_inference_for_literal_types_1.ts b/es2panda/test/ts_extra_tests/test/2.1/better_inference_for_literal_types/better_inference_for_literal_types_1.ts new file mode 100644 index 0000000000..30dc59cd9a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.1/better_inference_for_literal_types/better_inference_for_literal_types_1.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The type inferred for a const variable or readonly property without a type annotation is the type of the literal initializer. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +const a = 1; +let aa: typeof a = 1; +const b = false; +let bb: typeof b = false; +const c = "hello"; +let cc: typeof c = "hello"; + +class Test { + static readonly age = 12; + static readonly isJob = false; + static readonly nickName = "wangcai"; +} + +let age: typeof Test.age = 12; +Assert.equal(typeof age, "number"); +let isJob: typeof Test.isJob = false; +Assert.equal(typeof isJob, "boolean"); +let nickName: typeof Test.nickName = "wangcai"; +Assert.equal(typeof nickName, "string"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.1/better_inference_for_literal_types/better_inference_for_literal_types_2.ts b/es2panda/test/ts_extra_tests/test/2.1/better_inference_for_literal_types/better_inference_for_literal_types_2.ts new file mode 100644 index 0000000000..42f7f24585 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.1/better_inference_for_literal_types/better_inference_for_literal_types_2.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The type inferred for a let variable, var variable, parameter, or non-readonly property with an initializer + and no type annotation is the widened literal type of the initializer. + where the widened type for a string literal type is string, number for numeric literal types, boolean for true or false + and the containing enum for enum literal types. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +let a = 1; +let aa: typeof a = 12; +Assert.isNumber(aa); + +var b = 1; +var bb: typeof b = 12; +Assert.isNumber(bb); + +function test(a = true) { + return a; +} +let tt: ReturnType = false; +Assert.isBoolean(tt); + +class Test { + static job = "coder"; +} + +let cc: typeof Test.job = "driver"; +Assert.isString(cc); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.1/better_inference_for_literal_types/better_inference_for_literal_types_3.ts b/es2panda/test/ts_extra_tests/test/2.1/better_inference_for_literal_types/better_inference_for_literal_types_3.ts new file mode 100644 index 0000000000..244e9c3875 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.1/better_inference_for_literal_types/better_inference_for_literal_types_3.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Literal type widening can be controlled through explicit type annotations. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +const c1 = "hello"; + +let v1 = c1; +v1 = "world"; +const c2: "hello" = "hello"; +let v2 = c2; +Assert.equal(v2, "hello"); + +const c3 = 1; +let c4 = c3; +c4 = 10; +Assert.equal(c4, 10); +const c5: 1 = 1; +let c6 = c5; +c6 = 1; +Assert.equal(c6, 1); + +const c7 = false; +let c8 = c7; +c8 = true; +Assert.equal(c8, true); +const c9: false = false; +let c10 = c9; +c10 = false; +Assert.equal(c10, false); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.1/downlevel_async_functions/downlevel_async_functions_1.ts b/es2panda/test/ts_extra_tests/test/2.1/downlevel_async_functions/downlevel_async_functions_1.ts new file mode 100644 index 0000000000..d588b47e8a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.1/downlevel_async_functions/downlevel_async_functions_1.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + This feature was supported before TypeScript 2.1, + but only when targeting ES6/ES2015. + TypeScript 2.1 brings the capability to ES3 and ES5 run-times. + options: + lib:dom,es5,es2015.promise + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function delayTime(milliseconds: number) { + return new Promise((resolve) => { + setTimeout(resolve, milliseconds); + }); +} +async function showMsg(a: number, b: string) { + Assert.equal(a, 12); + for (let i = 0; i < 3; i++) { + await delayTime(500); + Assert.equal(b, "New"); + } + Assert.equal(b, "New"); +} +showMsg(12, "New"); diff --git a/es2panda/test/ts_extra_tests/test/2.1/improved_any_inference/improved_any_inference_1.ts b/es2panda/test/ts_extra_tests/test/2.1/improved_any_inference/improved_any_inference_1.ts new file mode 100644 index 0000000000..b67e71a8db --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.1/improved_any_inference/improved_any_inference_1.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript2.1 will infer types based on what you end up assigning later on. + This is only enabled if noImplicitAny is set. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +let x; +x = (a: number) => a + 1; + +let y = x; +Assert.equal(y(12), 13); + +x = "abc"; +Assert.isString(x); +Assert.equal(x.toUpperCase(), "ABC"); diff --git a/es2panda/test/ts_extra_tests/test/2.1/improved_any_inference/improved_any_inference_2.ts b/es2panda/test/ts_extra_tests/test/2.1/improved_any_inference/improved_any_inference_2.ts new file mode 100644 index 0000000000..c3800f7fa0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.1/improved_any_inference/improved_any_inference_2.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A variable declared with no type annotation and an initial value of [] is considered an implicit any[] variable. + However, each subsequent x.push(value), x.unshift(value) or x[n] = value operation evolves the type of the variable + in accordance with what elements are added to it. + This is only enabled if noImplicitAny is set. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' +function func() { + let arr = []; + arr[0] = 0; + arr.push("true"); + arr.unshift("abc"); + return arr; +} + +type c = ReturnType; + +let cc: c = ["hello", 12]; +Assert.equal(JSON.stringify(cc), '["hello",12]'); diff --git a/es2panda/test/ts_extra_tests/test/2.1/keyof_and_lookup_types/keyof_and_lookup_types_1.ts b/es2panda/test/ts_extra_tests/test/2.1/keyof_and_lookup_types/keyof_and_lookup_types_1.ts new file mode 100644 index 0000000000..5ea94a09aa --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.1/keyof_and_lookup_types/keyof_and_lookup_types_1.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + An indexed type query keyof T yields the type of permitted property names for T. + A keyof T type is considered a subtype of string. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +class TestPerson { + name: string; + age: number; + private job: string; + constructor(name: string, age: number, job: string) { + this.name = name; + this.age = age; + this.job = job; + } +} +type TestName = Pick; +let nn: TestName = { + name: "nn", +}; +Assert.notEqual(nn.name, undefined); + +type TestAge = Pick; +let aa: TestAge = { + age: 20, +}; +Assert.notEqual(aa.age, undefined); + +type Test = Pick; +let cc: Test = { + name: "cc", + age: 15, +}; +Assert.notEqual(cc.name, undefined); +Assert.notEqual(cc.age, undefined); + +type TestString = keyof { [x: string]: number }; + +let str: TestString = "abc"; +Assert.isString(str); diff --git a/es2panda/test/ts_extra_tests/test/2.1/keyof_and_lookup_types/keyof_and_lookup_types_2.ts b/es2panda/test/ts_extra_tests/test/2.1/keyof_and_lookup_types/keyof_and_lookup_types_2.ts new file mode 100644 index 0000000000..110f5e6669 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.1/keyof_and_lookup_types/keyof_and_lookup_types_2.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: indexed access types, also called lookup types. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +class TestPerson { + name: string; + age: number; + constructor(name: string, age: number, job: string) { + this.name = name; + this.age = age; + } +} + +type TestName = TestPerson["name"]; +let test1: TestName = ""; +Assert.equal(typeof test1, "string"); +Assert.notEqual(typeof test1, "number"); +Assert.notEqual(typeof test1, "boolean"); + +type TestAge = TestPerson["age"]; +let test2: TestAge = 0; +Assert.equal(typeof test2, "number"); +Assert.notEqual(typeof test2, "string"); +Assert.notEqual(typeof test2, "boolean"); diff --git a/es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_1.ts b/es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_1.ts new file mode 100644 index 0000000000..4d943d2a04 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_1.ts @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Partial + Constructs a type with all properties of Type set to optional. + This utility will return a type that represents all subsets of a given type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +interface PersonTest { + name: string; + age: number; + location: string; +} +type PersonType = Partial; + +let pt1: PersonTest = { + name: "caihua", + age: 20, + location: "earth", +}; + +let pt2: PersonType; +pt2 = {}; +Assert.equal(pt2.name, undefined); +Assert.equal(pt2.age, undefined); +Assert.equal(pt2.location, undefined); +pt2 = { name: "caihua" }; +Assert.equal(pt2.name, "caihua"); +Assert.equal(pt2.age, undefined); +Assert.equal(pt2.location, undefined); +pt2 = { age: 20 }; +Assert.equal(pt2.name, undefined); +Assert.equal(pt2.age, 20); +Assert.equal(pt2.location, undefined); +pt2 = { location: "earth" }; +Assert.equal(pt2.name, undefined); +Assert.equal(pt2.age, undefined); +Assert.equal(pt2.location, "earth"); +pt2 = { name: "caihua", age: 20 }; +Assert.equal(pt2.name, "caihua"); +Assert.equal(pt2.age, 20); +Assert.equal(pt2.location, undefined); +pt2 = { name: "caihua", location: "earth" }; +pt2 = { age: 20, location: "earth" }; +pt2 = { name: "caihua", age: 20, location: "earth" }; +Assert.equal(pt2.name, "caihua"); +Assert.equal(pt2.age, 20); +Assert.equal(pt2.location, "earth"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_2.ts b/es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_2.ts new file mode 100644 index 0000000000..18f8158bb7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_2.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Readonly + Constructs a type with all properties of Type set to readonly, + meaning the properties of the constructed type cannot be reassigned. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +interface PersonTest { + name: string; + age: number; + location: string; +} +type PersonType = Readonly; + +let pt1: PersonTest = { + name: "caihua", + age: 20, + location: "earth", +}; +pt1.name = "caihua1"; +Assert.notEqual(pt1.name, "caihua"); +pt1.age = 15; +Assert.notEqual(pt1.age, 20); +pt1.location = "Mars"; +Assert.notEqual(pt1.location, "earth"); + +let pt2: PersonType = { + name: "caihua", + age: 20, + location: "earth", +}; diff --git a/es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_3.ts b/es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_3.ts new file mode 100644 index 0000000000..ea6ef38b4c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_3.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Record + Constructs an object type whose property keys are Keys and whose property values are Type. + This utility can be used to map the properties of a type to another type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +interface CatInfoTest { + age: number; + breed: string; +} + +type CatNameType = "miffy" | "boris" | "mordred"; + +const cats: Record = { + miffy: { age: 10, breed: "Persian" }, + boris: { age: 5, breed: "Maine Coon" }, + mordred: { age: 16, breed: "British Shorthair" }, +}; +Assert.equal(cats.miffy.age, 10); +Assert.equal(cats.boris.age, 5); +Assert.equal(cats.mordred.age, 16); +Assert.equal(cats.miffy.breed, "Persian"); +Assert.equal(cats.boris.breed, "Maine Coon"); +Assert.equal(cats.mordred.breed, "British Shorthair"); diff --git a/es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_4.ts b/es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_4.ts new file mode 100644 index 0000000000..af235985d8 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_4.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Pick + Constructs a type by picking the set of properties Keys (string literal or union of string literals) from Type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +interface TodoInter { + title: string; + description: string; + completed: boolean; +} + +type TodoTitle = Pick; +type TodoTitleOrCompleted = Pick; +type TodoAll = Pick; + +const title: TodoTitle = { + title: "Clean room", +}; +Assert.equal("title" in title, true); +Assert.equal("description" in title, false); +Assert.equal("completed" in title, false); + +const titleAndCompleted: TodoTitleOrCompleted = { + title: "Clean room", + completed: false, +}; +Assert.equal("title" in titleAndCompleted, true); +Assert.equal("completed" in titleAndCompleted, true); +Assert.equal("description" in titleAndCompleted, false); + +const testAll: TodoAll = { + title: "Clean room", + description: "clean the whole room", + completed: false, +}; +Assert.equal("title" in testAll, true); +Assert.equal("description" in testAll, true); +Assert.equal("completed" in testAll, true); diff --git a/es2panda/test/ts_extra_tests/test/2.1/object_spread_and_rest/object_spread_and_rest_1.ts b/es2panda/test/ts_extra_tests/test/2.1/object_spread_and_rest/object_spread_and_rest_1.ts new file mode 100644 index 0000000000..a8893a0a0a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.1/object_spread_and_rest/object_spread_and_rest_1.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: spreading an object can be handy to get a shallow copy. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +let humen = { + name: "caihua", + age: 20, +}; +let job = { job: "stu" }; +let data = { + location: "mars", + pets: { + type: "dog", + name: "ahuang", + }, +}; + +let copy = { ...humen, ...job, ...data }; + +Assert.equal(copy.name, humen.name); +Assert.equal(copy.age, humen.age); +Assert.equal(copy.job, job.job); +Assert.equal(copy.location, data.location); +Assert.equal(copy.pets.name, data.pets.name); +Assert.equal(copy.pets.type, data.pets.type); +Assert.equal(copy.name == humen.name, true); +Assert.equal(copy.age == humen.age, true); +Assert.equal(copy.job == job.job, true); +Assert.equal(copy.location == data.location, true); +Assert.equal(copy.pets == data.pets, true); +Assert.equal(copy.pets.type == data.pets.type, true); +Assert.equal(copy.pets.name == data.pets.name, true); diff --git a/es2panda/test/ts_extra_tests/test/2.1/object_spread_and_rest/object_spread_and_rest_2.ts b/es2panda/test/ts_extra_tests/test/2.1/object_spread_and_rest/object_spread_and_rest_2.ts new file mode 100644 index 0000000000..0e3ed3045c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.1/object_spread_and_rest/object_spread_and_rest_2.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + override existing properties and add new ones + The order of specifying spread operations determines what properties end up in the resulting object; + properties in later spreads "win out" over previously created properties. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +let humen = { + name: "caihua", + age: 20, +}; + +let copy = { ...humen, name: "huahua", job: "teacher" }; + +Assert.equal(copy.age, humen.age); +Assert.equal(copy.age == humen.age, true); +Assert.equal(copy.name != humen.name, true); + +Assert.equal(copy.job != undefined, true); diff --git a/es2panda/test/ts_extra_tests/test/2.1/object_spread_and_rest/object_spread_and_rest_3.ts b/es2panda/test/ts_extra_tests/test/2.1/object_spread_and_rest/object_spread_and_rest_3.ts new file mode 100644 index 0000000000..2c1b6c21d0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.1/object_spread_and_rest/object_spread_and_rest_3.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + override existing properties and add new ones + The order of specifying spread operations determines what properties end up in the resulting object; + properties in later spreads "win out" over previously created properties. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +let humen = { + name: "caihua", + age: 20, +}; + +let copy = { ...humen, name: "huahua", job: "teacher" }; + +let { job, ...restProperties } = copy; +Assert.equal(job, copy.job); +Assert.equal(restProperties.age, copy.age); +Assert.equal(restProperties.name, copy.name); diff --git a/es2panda/test/ts_extra_tests/test/2.1/use_returned_values_from_super_call_as_this/use_returned_values_from_super_call_as_this_1.ts b/es2panda/test/ts_extra_tests/test/2.1/use_returned_values_from_super_call_as_this/use_returned_values_from_super_call_as_this_1.ts new file mode 100644 index 0000000000..6f43f2be59 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.1/use_returned_values_from_super_call_as_this/use_returned_values_from_super_call_as_this_1.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In ES2015, constructors which return an object implicitly substitute the value of this for any callers of super(). + it is necessary to capture any potential return value of super() and replace it with this. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +class Test { + x: number; + constructor(x: number) { + this.x = x; + return { + x: 1, + }; + } +} +class Test_sub extends Test { + constructor(x: number) { + super(x); + } +} +let cc = new Test_sub(12); +Assert.equal(cc.x, 1); +Assert.notEqual(cc.x, 12); diff --git a/es2panda/test/ts_extra_tests/test/2.2/dotted_property_for_types_with_string_index_signatures/dotted_property_for_types_with_string_index_signatures.ts b/es2panda/test/ts_extra_tests/test/2.2/dotted_property_for_types_with_string_index_signatures/dotted_property_for_types_with_string_index_signatures.ts new file mode 100644 index 0000000000..2fcfb0a992 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.2/dotted_property_for_types_with_string_index_signatures/dotted_property_for_types_with_string_index_signatures.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + types with a string index signature can be indexed using the "[]" notation, but were not allowed to use the ".". Starting with TypeScript 2.2 using either should be allowed. + this only apply to types with an explicit string index signature. It is still an error to access unknown properties on a type using "." notation. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +interface StringArrIndex { + [x: string]: T; +} +var strArr: StringArrIndex = {}; +strArr["ATP"] = 0x00; +strArr.NARC = 0x01; +Assert.equal(strArr.ATP, 0x00); +Assert.equal(strArr["NARC"], 0x01); diff --git a/es2panda/test/ts_extra_tests/test/2.2/object_type/object_type.ts b/es2panda/test/ts_extra_tests/test/2.2/object_type/object_type.ts new file mode 100644 index 0000000000..1961d02258 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.2/object_type/object_type.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + typeScript did not have a type that represents the non-primitive type, i.e. any thing that is not number, string, + boolean, symbol, null, or undefined. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +var obj1 = { num: 0, str: "string", bool: false, null: null, undefined: undefined }; +Assert.isNumber(obj1.num); +Assert.isString(obj1.str); +Assert.isBoolean(obj1.bool); +Assert.equal(obj1.null, null); +Assert.equal(obj1.undefined, undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.2/support_for_mix_in_classes/support_for_mix_in_classes_1.ts b/es2panda/test/ts_extra_tests/test/2.2/support_for_mix_in_classes/support_for_mix_in_classes_1.ts new file mode 100644 index 0000000000..b8c15597b7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.2/support_for_mix_in_classes/support_for_mix_in_classes_1.ts @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + typeScript 2.2 adds support for the ECMAScript 2015 mixin class pattern as well as rules for combining mixin construct signatures with regular construct signatures in intersection types. + a mixin constructor type refers to a type that has a single construct signature with a single rest argument of type any[] and an object-like return type. + a mixin class is a class declaration or expression that extends an expression of a type parameter type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +class PointXY { + public x: number; + public y: number; + constructor(x: number = 0, y: number = 0) { + this.x = x; + this.y = y; + } + toString() { + return `(${this.x}, ${this.y})`; + } +} +type MIXType = new (...args: any[]) => T; +function mixC>(Base: T) { + return class extends Base { + constructor(...args: any[]) { + super(...args); + } + public pname: string = ""; + setPname(pname: string) { + this.pname = pname; + } + getPname() { + return this.pname; + } + }; +} +const PointMix = mixC(PointXY); +var a = new PointMix(4, 4); +var b = new PointMix(); +a.setPname("A"); +b.setPname("B"); +Assert.equal(a.toString(), "(4, 4)"); +Assert.equal(b.getPname(), "B"); + +class PointMixCopy extends mixC(PointXY) { + public occupied: boolean = false; + setOccupied(occupied: boolean) { + this.occupied = occupied; + } + getOccupied() { + return this.occupied; + } +} +var c = new PointMixCopy(5, 5); +c.setPname("C"); +c.setOccupied(true); +Assert.equal(c.toString(), "(5, 5)"); +Assert.equal(c.getPname(), "C"); +Assert.equal(c.getOccupied(), true); diff --git a/es2panda/test/ts_extra_tests/test/2.2/support_for_mix_in_classes/support_for_mix_in_classes_2.ts b/es2panda/test/ts_extra_tests/test/2.2/support_for_mix_in_classes/support_for_mix_in_classes_2.ts new file mode 100644 index 0000000000..f0a4830425 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.2/support_for_mix_in_classes/support_for_mix_in_classes_2.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + mixin classes can constrain the types of classes they can mix into by specifying a construct signature return type in the constraint for the type parameter. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +class Color { + public Red: number; + public Green: number; + public Blue: number; + constructor(red: number = 0x00, green: number = 0x00, blue: number = 0x00) { + this.Red = red; + this.Green = green; + this.Blue = blue; + } + toString() { + return `Color(${this.Red}, ${this.Green}, ${this.Blue})`; + } +} +type MIXTypeCopy = new (...args: any[]) => T; +function ColorClassMix>(Base: T) { + return class extends Base { + getColors(): [number, number, number] { + return [this.Red, this.Green, this.Blue]; + } + } +} + +const ColorMix = ColorClassMix(Color); +var color = new ColorMix(255, 255, 255); +Assert.equal(color.toString(), "Color(255, 255, 255)"); +Assert.equal(color.getColors()[0], 255); + diff --git a/es2panda/test/ts_extra_tests/test/2.2/support_for_new.target/support_for_new.target_1.ts b/es2panda/test/ts_extra_tests/test/2.2/support_for_new.target/support_for_new.target_1.ts new file mode 100644 index 0000000000..2d348065ea --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.2/support_for_new.target/support_for_new.target_1.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the new.target meta-property is new syntax introduced in ES2015. When an instance of a constructor is created via new, the value of new.target is set to be a reference to the constructor function initially used to allocate the instance. + if a function is called rather than constructed via new, new.target is set to undefined. + options: + lib: es2015 + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +class A { + public cname: string; + constructor() { + this.cname = new.target.name; + } +} + +class B extends A { constructor() { super(); } } + +var na = new A(); +Assert.equal(na.cname, "A"); +var nb = new B(); +Assert.equal(nb.cname, "B"); + +class C { + public data: any; + constructor() { + this.data = new.target; + } +} +class D extends C { constructor() { super(); } } + +var nc = new C(); +Assert.equal(nc.data.name, "C"); +var nd = new D(); +Assert.equal(nd.data.name, "D"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.2/support_for_new.target/support_for_new.target_2.ts b/es2panda/test/ts_extra_tests/test/2.2/support_for_new.target/support_for_new.target_2.ts new file mode 100644 index 0000000000..bce50c3003 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.2/support_for_new.target/support_for_new.target_2.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the new.target meta-property is new syntax introduced in ES2015. When an instance of a constructor is created via new, the value of new.target is set to be a reference to the constructor function initially used to allocate the instance. + if a function is called rather than constructed via new, new.target is set to undefined. + options: + lib: es2015 + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +var gstr: string = ""; +function newTarget(): void { + if (new.target === undefined) { + gstr = "The function is called without \"new\""; + } else { + gstr = "The function is called with \"new\""; + } +} +newTarget(); +var ntf1: string = gstr; +Assert.equal(ntf1, "The function is called without \"new\""); + +new (newTarget as any)(); +var ntf2: string = gstr; +Assert.equal(ntf2, "The function is called with \"new\""); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.3/async_iteration/async_generators/async_generators.ts b/es2panda/test/ts_extra_tests/test/2.3/async_iteration/async_generators/async_generators.ts new file mode 100644 index 0000000000..d9cd289bce --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.3/async_iteration/async_generators/async_generators.ts @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the Async Iteration proposal introduces "Async Generators", which are async functions that also can be used to yield partial computation results. Async Generators can also delegate calls via yield* to either an iterable or async iterable. + as with Generators, Async Generators can only be function declarations, function expressions, or methods of classes or object literals. Arrow functions cannot be Async Generators. Async Generators require a valid, global Promise implementation (either native or an ES2015-compatible polyfill), in addition to a valid Symbol.asyncIterator reference. + options: + lib: es2018 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +async function* ag() { + let i = 0; + let c = 0; + yield* [0, 0, 0, 0]; + while (true) { + if (i % 3 == 0) { + yield c -= 1; + } else { + yield c += 1; + } + i++; + if (i > 30) { + break; + } + } +} +function newArray() { + let arr: number[] = [0, 0, 0, 0]; + let i = 0; + let c = 0; + while (true) { + if (i % 3 == 0) { + c -= 1; + arr[i + 4] = c; + } else { + c += 1; + arr[i + 4] = c; + } + i++; + if (i > 30) { + break; + } + } + return arr; +} +let arr = ag(); +async function showAsyncGenerator(arr: AsyncGenerator) { + let i = 0; + for await (let x of arr) { + Assert.equal(x as number, arr2[i++]); + } +} +let arr2 = newArray(); +showAsyncGenerator(arr); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.3/async_iteration/async_iterators/async_iterators_1.ts b/es2panda/test/ts_extra_tests/test/2.3/async_iteration/async_iterators/async_iterators_1.ts new file mode 100644 index 0000000000..4985109519 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.3/async_iteration/async_iterators/async_iterators_1.ts @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the Async Iteration introduces an AsyncIterator, which is similar to Iterator. The difference lies in the fact that the next, return, and throw methods of an AsyncIterator return a Promise for the iteration result, rather than the result itself. + this allows the caller to enlist in an asynchronous notification for the time at which the AsyncIterator has advanced to the point of yielding a value. + options: + lib: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface AsyncIterator { + next(value?: any): Promise>; + return?(value?: any): Promise>; + throw?(e?: any): Promise>; +} +function createAsyncInterator(arr: any[]): AsyncIterator { + let index = 0; + let len = arr.length; + return { + async next() { + return new Promise((resolve, reject) => { + if (index < len) { + resolve({ value: arr[index++], done: false }); + } else { + resolve({ value: undefined, done: true }); + } + }); + }, + }; +} + +let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]; + +async function exp(arr: any[]) { + let asy = createAsyncInterator(arr); + let i = 0; + let fg; + while (true) { + if (fg == true) { + break; + } + await asy.next().then((v) => { + if (v.done == true) { + fg = true; + } + Assert.equal(v.value, arr[i++]); + return; + }); + } +} +exp(arr); diff --git a/es2panda/test/ts_extra_tests/test/2.3/async_iteration/async_iterators/async_iterators_2.ts b/es2panda/test/ts_extra_tests/test/2.3/async_iteration/async_iterators/async_iterators_2.ts new file mode 100644 index 0000000000..5ffde8c1a8 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.3/async_iteration/async_iterators/async_iterators_2.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + an object that supports async iteration is said to be "iterable" if it has a Symbol.asyncIterator method that returns an AsyncIterator object. + options: + lib: es2018 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +async function asc(arr: any[]) { + let i = 0; + for await (let x of arr) { + Assert.equal(x, arr[i]); + i++ + } +} +let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]; +asc(arr); diff --git a/es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_1.ts b/es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_1.ts new file mode 100644 index 0000000000..d62a1d01cc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_1.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + es2015 also introduced "Generators", which are functions that can be used to yield partial computation results via the Iterator interface and the yield keyword. + options: + lib: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function* generators() { + var i = 0; + while (true) { + yield i += 3; + if (i > 33) { + break; + } + } +} +let gen = generators(); +let c = 0; +while (true) { + let next = gen.next(); + if (next.done == true) { + break; + } + Assert.equal(next.value, c += 3); +} diff --git a/es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_2.ts b/es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_2.ts new file mode 100644 index 0000000000..5a529605fb --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_2.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + generators can also internally delegate calls to another iterable through yield *. + options: + lib: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let arr2 = ["A", "B", "C", "D", "E", "F"]; +function* generators2() { + yield* arr2; + let s = arr2[arr2.length - 1].charCodeAt(0); + for (let i = 0; i < 20; i++) { + s++; + yield String.fromCharCode(s); + } +} +let gen2 = generators2(); +let c = 65; +while (true) { + let next = gen2.next(); + if (next.done == true) { + break; + } + Assert.equal(next.value, String.fromCharCode(c++)); +}; diff --git a/es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_1.ts b/es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_1.ts new file mode 100644 index 0000000000..1e21d398f7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_1.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + es2015 introduced Iterator, which is an object that exposes three methods, next, return, and throw. + options: + lib: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface Iterator { + next(value?: any): IteratorResult; + return?(value?: any): IteratorResult; + throw?(e?: any): IteratorResult; +} +function createInterator(arr: any[]): Iterator { + let index = 0; + let len = arr.length; + return { + next() { + return index < len + ? { value: arr[index++], done: false } + : { value: undefined, done: true } + } + } +} +var arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]; +var iterator = createInterator(arr); +let i = 0; +while (true) { + let n = iterator.next(); + if (n.done == true) { + break; + } + Assert.equal(n.value, arr[i++]); +}; diff --git a/es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_2.ts b/es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_2.ts new file mode 100644 index 0000000000..1b4b1622d2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_2.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + es2015 introduced Iterator, which is an object that exposes three methods, next, return, and throw. + options: + lib: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let arr: string[] = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]; +let iter = arr[Symbol.iterator](); +let i = 0; +while (true) { + let n = iter.next(); + if (n.done == true) { + break; + } + Assert.equal(n.value, arr[i++]); +} +i = 0; +for (let x of arr) { + Assert.equal(x, arr[i++]); +}; diff --git a/es2panda/test/ts_extra_tests/test/2.3/generic_parameter_defaults/generic_parameter_defaults_1.ts b/es2panda/test/ts_extra_tests/test/2.3/generic_parameter_defaults/generic_parameter_defaults_1.ts new file mode 100644 index 0000000000..81461a48fd --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.3/generic_parameter_defaults/generic_parameter_defaults_1.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + typescript 2.3 adds support for declaring defaults for generic type parameters. + a type parameter is deemed optional if it has a default.Required type parameters must not follow optional type parameters. + when specifying type arguments, you are only required to specify type arguments for the required type parameters. Unspecified type parameters will resolve to their default types.If a default type is specified and inference cannot choose a candidate, the default type is inferred. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +type ALL = string | number | boolean | object; +function fun1(v: V, t: T) { + return JSON.stringify({ v, t }); +} +let f1 = fun1(1, [1, 0]); +Assert.equal(f1, "{\"v\":1,\"t\":[1,0]}") + +let f2 = fun1("A", 0); +Assert.equal(f2, "{\"v\":\"A\",\"t\":0}"); + +let f3 = fun1("A", [1, "A"]); +Assert.equal(f3, "{\"v\":\"A\",\"t\":[1,\"A\"]}"); diff --git a/es2panda/test/ts_extra_tests/test/2.3/generic_parameter_defaults/generic_parameter_defaults_2.ts b/es2panda/test/ts_extra_tests/test/2.3/generic_parameter_defaults/generic_parameter_defaults_2.ts new file mode 100644 index 0000000000..de7f4fb640 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.3/generic_parameter_defaults/generic_parameter_defaults_2.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + typescript 2.3 adds support for declaring defaults for generic type parameters. + a class or interface declaration that merges with an existing class or interface declaration may introduce a default for an existing type parameter. + a class or interface declaration that merges with an existing class or interface declaration may introduce a new type parameter as long as it specifies a default. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +class CA{ + ca0: V; + ca1: T; + ca2: U; + constructor(ca0: V, ca1: T, ca2: U) { this.ca0 = ca0; this.ca1 = ca1; this.ca2 = ca2; } + creatOBJ() { + let a = this.ca0; + let b = this.ca1; + let c = this.ca2; + return { a, b, c }; + } + toJSON() { + return JSON.stringify(this.creatOBJ()); + } +} +class CCA extends CA{ } +let cca1 = new CCA(0, [0, 0], "[0]"); +Assert.equal(cca1.toJSON(), "{\"a\":0,\"b\":[0,0],\"c\":\"[0]\"}"); +let cca2 = new CCA("A", ["A"], [["A"], ["B"]]); +Assert.equal(cca2.toJSON(), "{\"a\":\"A\",\"b\":[\"A\"],\"c\":[[\"A\"],[\"B\"]]}"); + +interface IB { + ia: V; + ib: T; + ic: U; +} +interface CIB extends IB { } +let cib1: CIB = { ia: 0, ib: [0], ic: [[0], [1, 2]] }; +Assert.equal(JSON.stringify(cib1), "{\"ia\":0,\"ib\":[0],\"ic\":[[0],[1,2]]}"); +let cib2: CIB = { ia: "A", ib: ["A", "B"], ic: [["A"], ["B", "C"]] }; +Assert.equal(JSON.stringify(cib2), "{\"ia\":\"A\",\"ib\":[\"A\",\"B\"],\"ic\":[[\"A\"],[\"B\",\"C\"]]}"); diff --git a/es2panda/test/ts_extra_tests/test/2.3/generic_parameter_defaults/generic_parameter_defaults_3.ts b/es2panda/test/ts_extra_tests/test/2.3/generic_parameter_defaults/generic_parameter_defaults_3.ts new file mode 100644 index 0000000000..2fcb7540ac --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.3/generic_parameter_defaults/generic_parameter_defaults_3.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + typescript 2.3 adds support for declaring defaults for generic type parameters. + default types for a type parameter must satisfy the constraint for the type parameter, if it exists. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +interface Length { + length: number; +} +type STRS = string | string[] +function fun3(s: T) { + return s.length; +} +Assert.equal(fun3("ABC"), 3); +Assert.equal(fun3([1, 2, 3, 4]), 4); diff --git a/es2panda/test/ts_extra_tests/test/2.4/1_dynamic_import_expressions/1_dynamic_import_expressions.ts b/es2panda/test/ts_extra_tests/test/2.4/1_dynamic_import_expressions/1_dynamic_import_expressions.ts new file mode 100644 index 0000000000..74feec7a4b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.4/1_dynamic_import_expressions/1_dynamic_import_expressions.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: Dynamic import expressions are a new feature and part of ECMAScript that allows users to asynchronously request a module at any arbitrary point in your program. +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' +async function getSumAsyn(x: number, y: number): Promise { + const add = await import("./lib.js"); + const sum = add.add(x, y); + return sum; +} + +getSumAsyn(10, 20).then((sum) => { + Assert.equal(30, sum); +}); diff --git a/es2panda/test/ts_extra_tests/test/2.4/1_dynamic_import_expressions/lib.ts b/es2panda/test/ts_extra_tests/test/2.4/1_dynamic_import_expressions/lib.ts new file mode 100644 index 0000000000..8fca6c85ac --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.4/1_dynamic_import_expressions/lib.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export function add(x: number, y: number) { + return x + y; +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.4/2_string_enums/string_enums_1.ts b/es2panda/test/ts_extra_tests/test/2.4/2_string_enums/string_enums_1.ts new file mode 100644 index 0000000000..25f9be8420 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.4/2_string_enums/string_enums_1.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: TypeScript 2.4 now allows enum members to contain string initializers. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +enum Option { + END = "End", + START = "Start", + STOP = "BLUE" +}; + +Assert.equal(Option.END, "End"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts b/es2panda/test/ts_extra_tests/test/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts new file mode 100644 index 0000000000..73714c39a5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: TypeScript 2.4 introduces a few wonderful changes around the way generics are inferred. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +function arrayGen(f: (x: T) => U): (a: T[]) => U[] { + return a => a.map(f); +} + +const len: (a: string[]) => number[] = arrayGen(s => s.length); +Assert.equal(1, len(["s", "ss", "sss"])[0]); +Assert.equal(2, len(["s", "ss", "sss"])[1]); +Assert.equal(3, len(["s", "ss", "sss"])[2]); + + +type A = (x: T, y: U) => [T, U]; +type B = (x: S, y: S) => [S, S]; + +function f(a: A, b: B) { + b = a; + Assert.isTrue(true); +} + +let a: A = function funA(x: T, y: U): [T, U] { + return [x, y]; +} +let b: B = function funB(x: S, y: S): [S, S] { + return [x, x]; +} +f(a, b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.4/4_strict_contravariance_for_callback_parameters/4_strict_contravariance_for_callback_parameters.ts b/es2panda/test/ts_extra_tests/test/2.4/4_strict_contravariance_for_callback_parameters/4_strict_contravariance_for_callback_parameters.ts new file mode 100644 index 0000000000..dc2b02c130 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.4/4_strict_contravariance_for_callback_parameters/4_strict_contravariance_for_callback_parameters.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: TypeScript 2.4 introduces tightens this up when relating two callback types. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +interface TestI { + add_10(t: T): T; +} + +class CA implements TestI { + add_10(n: number) { + return n += 10; + } +} + +let a: TestI; +let b: TestI; + +a = new CA(); + +b = a; + +Assert.equal(20, b.add_10(10)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.4/5_weak_type_detection/5_weak_type_detection.ts b/es2panda/test/ts_extra_tests/test/2.4/5_weak_type_detection/5_weak_type_detection.ts new file mode 100644 index 0000000000..1d8aa346e4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.4/5_weak_type_detection/5_weak_type_detection.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: TypeScript 2.4 introduces the concept of "weak types". Any type that contains nothing but a set of all-optional properties is considered to be weak. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +interface Options { + data?: string; + type?: number; + value?: number; +} + +function check(options: Options) { + if (options !== undefined && options !== null) { + return true; + } else { + return false; + } +} + +const opts1 = { + str: "hello world!", + retryOnFail: true +}; + + +const opts2 = { + data: "hello world!" +}; +Assert.isTrue(check(opts2)); + + +const opts3: { + [index: string]: { data: string }; +} = {}; +Assert.isTrue(check(opts3)); + +const opts4 = { + payload: "hello world!", + retryOnFail: true +} as Options; +Assert.isTrue(check(opts4)); diff --git a/es2panda/test/ts_extra_tests/test/2.5/1_optional_catch_clause_variables.ts b/es2panda/test/ts_extra_tests/test/2.5/1_optional_catch_clause_variables.ts new file mode 100644 index 0000000000..2b36499517 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.5/1_optional_catch_clause_variables.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: TypeScript 2.5 implements a new ECMAScript feature that allows users to omit the variable in catch clauses. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../suite/assert.js' + +let input: string = "Error!"; +try { + JSON.parse(input); +} catch { + Assert.equal("Error!", input); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.6/suppress_errors_in_ts_files_using_ts_ignore_comments/suppress_errors_in_ts_files_using_ts_ignore_comments.ts b/es2panda/test/ts_extra_tests/test/2.6/suppress_errors_in_ts_files_using_ts_ignore_comments/suppress_errors_in_ts_files_using_ts_ignore_comments.ts new file mode 100644 index 0000000000..455e574f5b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.6/suppress_errors_in_ts_files_using_ts_ignore_comments/suppress_errors_in_ts_files_using_ts_ignore_comments.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A // @ts-ignore comment suppresses all errors that originate on the following line. + It is recommended practice to have the remainder of the comment following @ts-ignore explain which error is being suppressed. + Please note that this comment only suppresses the error reporting, and we recommend you use this comments very sparingly. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function addString(str: string, str2: string): string { + str += ""; + str2 += ""; + return str + str2; +} +// @ts-ignore +let n: number = addString(114, 514); +Assert.isString(n); +Assert.equal(n, "114514"); diff --git a/es2panda/test/ts_extra_tests/test/2.7/10_numeric_separators/10_numeric_separators.ts b/es2panda/test/ts_extra_tests/test/2.7/10_numeric_separators/10_numeric_separators.ts new file mode 100644 index 0000000000..4e1a4e3a17 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.7/10_numeric_separators/10_numeric_separators.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: TypeScript 2.7 brings support for ES Numeric Separators. Numeric literals can now be separated into segments using _. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +const num999 = 999_999_999; +const xnum = 0xFF_00_FF; +const bnum = 0b10_01; + +Assert.equal(999999999, num999); +Assert.equal(0xFF00FF, xnum); +Assert.equal(9, bnum); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.7/1_constant_named_properties/1_constant_named_properties.ts b/es2panda/test/ts_extra_tests/test/2.7/1_constant_named_properties/1_constant_named_properties.ts new file mode 100644 index 0000000000..ccfa8d5d3b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.7/1_constant_named_properties/1_constant_named_properties.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: TypeScript 2.7 adds support for declaring const-named properties on types including ECMAScript symbols. +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" + +const SERIALIZE = Symbol("serialize-method-key"); +interface Test { + [SERIALIZE](obj: {}): string; +} + +class JSONTest implements Test { + [SERIALIZE](obj: {}) { + return JSON.stringify(obj); + } +} +var obj = new JSONTest(); +Assert.equal('"test open harmony"', obj[SERIALIZE]("test open harmony")); +Assert.equal(123456, obj[SERIALIZE](123456)); + + +// This also applies to numeric and string literals. +const test01 = "test01"; +const test02 = "test02"; + +let x = { + [test01]: 100, + [test02]: "hello" +}; + + +let a = x[test01]; + +let b = x[test02]; +Assert.equal(100, a); +Assert.equal("hello", b); diff --git a/es2panda/test/ts_extra_tests/test/2.7/2_unique_symbol/2_unique_symbol.ts b/es2panda/test/ts_extra_tests/test/2.7/2_unique_symbol/2_unique_symbol.ts new file mode 100644 index 0000000000..601b31e3c5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.7/2_unique_symbol/2_unique_symbol.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: To enable treating symbols as unique literals a new type unique symbol is available. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + + +declare const usym: unique symbol; + +const test03: unique symbol = Symbol(); +const test04: unique symbol = Symbol.for("Bar2"); + +// Works - refers to a unique symbol, but its identity is tied to 'Foo'. +// in order to reference a specific unique symbol, you’ll have to use the typeof operator. +let t01: typeof test03 = test03; +let t02: typeof test04 = test04; + +// Also works. +class C { + static readonly StaticSymbol: unique symbol = Symbol(); +} + +Assert.isTrue('symbol' === typeof t01); +Assert.isTrue('symbol' === typeof t02); +Assert.isTrue('symbol' === typeof C.StaticSymbol); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.7/3_strict_class_initialization/3_strict_class_initialization.ts b/es2panda/test/ts_extra_tests/test/2.7/3_strict_class_initialization/3_strict_class_initialization.ts new file mode 100644 index 0000000000..f47984ee0d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.7/3_strict_class_initialization/3_strict_class_initialization.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: TypeScript 2.7 introduces a new flag called strictPropertyInitialization. This flag performs checks to ensure that each instance property of a class gets initialized in the constructor body, or by a property initializer. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +class C { + t01: number = 1; + t02!: number; + t03 = "hello"; + t04: boolean = true; + + constructor() { + this.initialize(); + } + + initialize() { + this.t02 = 2; + } +} + +let c = new C(); +Assert.equal(1, c.t01); +Assert.equal(2, c.t02); +Assert.equal('hello', c.t03); +Assert.isTrue(c.t04); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.7/4_definite_assignment_assertions/4_definite_assignment_assertions.ts b/es2panda/test/ts_extra_tests/test/2.7/4_definite_assignment_assertions/4_definite_assignment_assertions.ts new file mode 100644 index 0000000000..eb382bd4c6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.7/4_definite_assignment_assertions/4_definite_assignment_assertions.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The definite assignment assertion is a feature that allows a ! to be placed after instance property and variable declarations to relay to TypeScript that a variable is indeed assigned for all intents and purposes, even if TypeScript's analyses cannot detect so. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +// With definite assignment assertions, we can assert that x is really assigned by appending an ! to its declaration +let x!: number; + +// In a sense, the definite assignment assertion operator is the dual of the non-null assertion operator (in which expressions are post-fixed with a !) +let y = x! + x!; + +Assert.isTrue(Number.isNaN(y)); +initialize(); + +// No error! +let z = x + x; +function initialize() { + x = 10; +} + +Assert.equal(20, z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.7/5_fixed_length_tuples/5_fixed_length_tuples.ts b/es2panda/test/ts_extra_tests/test/2.7/5_fixed_length_tuples/5_fixed_length_tuples.ts new file mode 100644 index 0000000000..f909db53a0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.7/5_fixed_length_tuples/5_fixed_length_tuples.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: tuple types now encode their arity into the type of their respective length property. This is accomplished by leveraging numeric literal types, which now allow tuples to be distinct from tuples of different arities. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +interface NumStrTuple extends Array { + 0: number; + 1: string; + length: 2; +} + +const numstr01: NumStrTuple = [1, "string"]; + +interface NumStr extends Array { + 0: number; + 1: string; +} + +const numstr02: NumStr = [2, "string", 3, "string2"]; + + +Assert.equal(1, numstr01[0]); +Assert.equal("string", numstr01[1]); +Assert.equal(2, numstr02[0]); +Assert.equal("string", numstr02[1]); +Assert.equal(3, numstr02[2]); +Assert.equal("string2", numstr02[3]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.7/6_improved_type_inference_for_object_literals/6_improved_type_inference_for_object_literals.ts b/es2panda/test/ts_extra_tests/test/2.7/6_improved_type_inference_for_object_literals/6_improved_type_inference_for_object_literals.ts new file mode 100644 index 0000000000..220f864a12 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.7/6_improved_type_inference_for_object_literals/6_improved_type_inference_for_object_literals.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: TypeScript 2.7 improves type inference for multiple object literals occurring in the same context. When multiple object literal types contribute to a union type, we now normalize the object literal types such that all properties are present in each constituent of the union type. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +let obj1 = [{ a: 1, b: 2 }, { a: "abc" }, {}][0]; + + +function fun(...items: T[]): T { + return items[1]; +}; +let obj2 = fun({ a: 1, b: 2 }, { a: "abc", b: "ABC" }, {}); + +Assert.equal(1, obj1.a); +Assert.equal(2, obj1.b); +Assert.equal("abc", obj2.a); +Assert.equal("ABC", obj2.b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.7/7_improved_handling/7_improved_handling.ts b/es2panda/test/ts_extra_tests/test/2.7/7_improved_handling/7_improved_handling.ts new file mode 100644 index 0000000000..0b8f8a5b24 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.7/7_improved_handling/7_improved_handling.ts @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript 2.7 improves the handling of structurally identical classes in union types and instanceof expressions: + Structurally identical, but distinct, class types are now preserved in union types (instead of eliminating all but one). + Union type subtype reduction only removes a class type if it is a subclass of and derives from another class type in the union. + Type checking of the instanceof operator is now based on whether the type of the left operand derives from the type indicated by the right operand (as opposed to a structural subtype check). + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +class HWA { } +class HWB extends HWA { } +class HWC extends HWA { } +class HWD extends HWA { } +class HWE extends HWD { } + + +let x1 = !true ? new HWA() : new HWB(); + +let x2 = !true ? new HWB() : new HWC(); + +let x3 = !true ? new HWC() : new HWD(); +Assert.isTrue(x1 instanceof HWB); +Assert.isTrue(x2 instanceof HWC); +Assert.isTrue(x3 instanceof HWD); + + +let a1 = [new HWA(), new HWB(), new HWC(), new HWD(), new HWE()]; + +let a2 = [new HWB(), new HWC(), new HWD(), new HWE()]; + +Assert.isTrue(a1[0] instanceof HWA); +Assert.isTrue(a1[1] instanceof HWB); +Assert.isTrue(a1[2] instanceof HWC); +Assert.isTrue(a1[3] instanceof HWD); +Assert.isTrue(a1[4] instanceof HWE); + + +Assert.isTrue(a2[0] instanceof HWB); +Assert.isTrue(a2[1] instanceof HWC); +Assert.isTrue(a2[2] instanceof HWD); +Assert.isTrue(a2[3] instanceof HWE); + + +function fun(x: HWB | HWC | HWD) { + if (x instanceof HWB) { + Assert.isTrue(x instanceof HWB); + } else if (x instanceof HWC) { + Assert.isTrue(x instanceof HWC); + } else { + Assert.isFalse(x instanceof HWB); + Assert.isFalse(x instanceof HWC); + } +} + +fun(new HWA()); +fun(new HWB()); +fun(new HWC()); +fun(new HWD()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.7/8_Type_guards_inferred_from_in_operator/8_Type_guards_inferred_from_in_operator.ts b/es2panda/test/ts_extra_tests/test/2.7/8_Type_guards_inferred_from_in_operator/8_Type_guards_inferred_from_in_operator.ts new file mode 100644 index 0000000000..501d95fe1d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.7/8_Type_guards_inferred_from_in_operator/8_Type_guards_inferred_from_in_operator.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The in operator now acts as a narrowing expression for types. + For a n in x expression, where n is a string literal or string literal type and x is a union type, the “true” branch narrows to types which have an optional or required property n, and the “false” branch narrows to types which have an optional or missing property n. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +interface HWX { + a: number; +} +interface HWY { + b: string; +} + +function fun(x: HWX | HWY) { + if ("a" in x) { + return x.a; + } + return x.b; +} + +let a1: HWX = { + a: 1 +} + +let b1: HWY = { + b: 'this is a string' +} + +Assert.equal(1, fun(a1)); +Assert.equal('this is a string', fun(b1)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.8/Improved_keyof_with_intersection_types.ts b/es2panda/test/ts_extra_tests/test/2.8/Improved_keyof_with_intersection_types.ts new file mode 100644 index 0000000000..d4042482d6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.8/Improved_keyof_with_intersection_types.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + With TypeScript 2.8 keyof applied to an intersection type is transformed to a union of keyof applied to each intersection constituent. + In other words, types of the form keyof (A & B) are transformed to be keyof A | keyof B. This change should address inconsistencies with inference from keyof expressions. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../suite/assert.js" + +type A = { a: string }; +type B = { b: number }; + +type TAB = keyof (A & B); +let tab: TAB; +tab = "a"; +tab = "b"; + +type TTB = keyof (T & B); +let ttb: TTB; +ttb = "b"; +ttb = "valueOf"; + +type TAU = keyof (A & U); +let tau: TAU; +tau = "a"; +tau = "charCodeAt"; + +type TTU = keyof (T & U); +let ttu: TTU; +ttu = "charAt"; +ttu = "toString"; + +type IsEqual = + (() => T extends X ? 1 : 2) extends + (() => T extends Y ? 1 : 2) ? true : false + + +let f1: IsEqual = true; +Assert.isTrue(f1); + +let f2: IsEqual, keyof boolean | keyof B> = true; +Assert.isTrue(f2); + +let f3: IsEqual, keyof A | keyof string> = true; +Assert.isTrue(f3); + +let f4: IsEqual, keyof number | keyof string> = true; +Assert.isTrue(f4); diff --git a/es2panda/test/ts_extra_tests/test/2.8/conditional_types.ts b/es2panda/test/ts_extra_tests/test/2.8/conditional_types.ts new file mode 100644 index 0000000000..2b1471bb27 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.8/conditional_types.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: > + Conditional Types. +module: ESNext +isCurrent: true + ---*/ + + +import { Assert } from "../../suite/assert.js" +type TypeGather = + T extends string ? string : + T extends number ? number : + T extends boolean ? boolean : + T extends undefined ? undefined : + T extends Function ? Function : + object; + +type T0 = TypeGather; +type T1 = TypeGather<"a">; +type T2 = TypeGather; +type T3 = TypeGather<() => void>; +type T4 = TypeGather; + + +let a: T0 = "string"; +let b: T1 = 'string'; +let c: T2 = true; +let d: T3 = (() => { }); +let e: T4 = {}; + + +Assert.equal(typeof a, 'string'); +Assert.equal(typeof b, 'string'); +Assert.equal(typeof c, 'boolean'); +Assert.equal(typeof d, 'function'); +Assert.equal(typeof e, 'object'); diff --git a/es2panda/test/ts_extra_tests/test/2.8/distributive_conditional_types.ts b/es2panda/test/ts_extra_tests/test/2.8/distributive_conditional_types.ts new file mode 100644 index 0000000000..85ecfbd659 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.8/distributive_conditional_types.ts @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: > + Distributive conditional types +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from "../../suite/assert.js" +type TypeGather = + T extends string ? string : + T extends number ? number : + T extends boolean ? boolean : + T extends undefined ? undefined : + T extends Function ? Function : + object; + + +type T0 = TypeGather void)>; +type T2 = TypeGather; +type T1 = TypeGather; + +type GatherValue = { value: T }; +type GatherArray = { array: T[] }; +type Gather = T extends any[] ? GatherArray : GatherValue; + +type T20 = Gather; +type T21 = Gather; +type T22 = Gather; + +let a: T0 = 's'; +let b: T0 = (() => { +}); +let c: T2 = 's'; +let d: T2 = ['s']; +let e: T2 = undefined; +let f: T1 = ['s']; +let g: T1 = [1]; +let h: T20 = { value: "s" }; +let i: T21 = { array: [1] }; +let j: T22 = { value: "s" }; +let k: T22 = { array: [1] }; + +Assert.equal(typeof a, 'string'); +Assert.equal(typeof b, 'function'); +Assert.equal(typeof c, 'string'); +Assert.equal(typeof d, 'object'); +Assert.equal(typeof e, 'undefined'); +Assert.equal(typeof f, 'object'); +Assert.equal(typeof g, 'object'); +Assert.equal(typeof h, 'object'); +Assert.equal(typeof i, 'object'); +Assert.equal(typeof j, 'object'); +Assert.equal(typeof k, 'object'); + + + diff --git a/es2panda/test/ts_extra_tests/test/2.8/filter_union_types.ts b/es2panda/test/ts_extra_tests/test/2.8/filter_union_types.ts new file mode 100644 index 0000000000..18ba9b10f9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.8/filter_union_types.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The distributive property of conditional types can conveniently be used to filter union types + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../suite/assert.js' + +{ + type TA = T extends U ? never : T; + type TB = T extends U ? T : never; + + type T0 = TA; + type T1 = TB; + + let a: T0 = 'b'; + let b: T0 = true; + let c: T1 = 1; + + Assert.equal(typeof a, 'string'); + Assert.equal(typeof b, 'boolean'); + Assert.equal(typeof c, 'number'); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.8/improved_control_over_mapped_type_modifiers.ts b/es2panda/test/ts_extra_tests/test/2.8/improved_control_over_mapped_type_modifiers.ts new file mode 100644 index 0000000000..a85c7796be --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.8/improved_control_over_mapped_type_modifiers.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Improved control over mapped type modifiers + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../suite/assert.js' + +{ + type OA = { a: string }; + type OB = { b: string }; + + + type T1 = keyof (OA & OB); + + type T2 = keyof (T & OB); + + type T3 = keyof (OA & U); + + type T4 = keyof (T & U); + + type T5 = T2; + + type T6 = T3; + + type T7 = T4; + + let a: T1 = 'a'; + let b: T1 = "b"; + let c: T5 = "a"; + let d: T6 = "a"; + let e: T7 = "a"; + + Assert.equal(a, 'a'); + Assert.equal(b, 'b'); + Assert.equal(c, 'a'); + Assert.equal(d, 'a'); + Assert.equal(e, 'a'); +}; diff --git a/es2panda/test/ts_extra_tests/test/2.8/predefined_conditional_types.ts b/es2panda/test/ts_extra_tests/test/2.8/predefined_conditional_types.ts new file mode 100644 index 0000000000..0d99bebb58 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.8/predefined_conditional_types.ts @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Predefined conditional types + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../suite/assert.js' + +{ + + type TypeA = Exclude<"a" | "b" | "c" | "d", "a" | "c" | "f">; + + type TypeB = Extract<"a" | "b" | "c" | "d", "a" | "c" | "f">; + + + type TypeC = Exclude void), Function>; + + type TypeD = Extract void), Function>; + + function fun(s: string) { + return { a: 1, b: s }; + } + + class C { + x = 0; + y = 0; + } + + + type TypeE = ReturnType; + + type TypeF = InstanceType; + + let a: TypeA = "b"; + let b: TypeA = "d"; + let c: TypeB = "a"; + let d: TypeB = "c"; + let e: TypeC = "c"; + let f: TypeD = ((): string => { return 's' }); + let x: TypeE = { a: 1, b: 's' } + let y: TypeF = { x: 1, y: 2 } + + Assert.equal(a, 'b'); + Assert.equal(b, 'd'); + Assert.equal(c, 'a'); + Assert.equal(d, 'c'); + Assert.equal(e, 'c'); + Assert.equal(typeof f, "function"); + Assert.equal(x.a, 1); + Assert.equal(y.x, 1); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.8/prototype_assignment.ts b/es2panda/test/ts_extra_tests/test/2.8/prototype_assignment.ts new file mode 100644 index 0000000000..4f041e19a8 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.8/prototype_assignment.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + You can assign an object literal directly to the prototype property. Individual prototype assignments still work too. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../suite/assert.js" + +let q: number = 0; +let c: any = function (p: number) { q = p; } +c.sub = { + m() { + Assert.equal(q, 5); + } +} +c(5); +c.sub.m(); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.8/type_inference.ts b/es2panda/test/ts_extra_tests/test/2.8/type_inference.ts new file mode 100644 index 0000000000..001e1052ff --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.8/type_inference.ts @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Type inference in conditional types + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../suite/assert.js' + +{ + type Type00 = + T extends (infer U)[] ? U : + T extends (...args: any[]) => infer U ? U : + T extends Promise ? U : + T; + + // string + type Type0 = Type00; + // string + type Type1 = Type00; + // string + type Type2 = Type00<() => string>; + // string + type Type3 = Type00>; + // string + type Type4 = Type00[]>>; + + let a: Type0 = 's'; + let b: Type1 = 's'; + let c: Type2 = 's'; + let d: Type3 = 's'; + let e: Type4 = 's'; + + Assert.equal(typeof a, 'string'); + Assert.equal(typeof b, 'string'); + Assert.equal(typeof c, 'string'); + Assert.equal(typeof d, 'string'); + Assert.equal(typeof e, 'string'); + + type F = T extends { a: infer U, b: infer U } ? U : never; + // string + type Type5 = F<{ a: string, b: string }>; + // string | number + type Type6 = F<{ a: string, b: number }>; + + let f: Type5 = 's'; + let g: Type6 = 's'; + let h: Type6 = 1; + + Assert.equal(typeof f, 'string'); + Assert.equal(typeof g, 'string'); + Assert.equal(typeof h, 'number'); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts b/es2panda/test/ts_extra_tests/test/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts new file mode 100644 index 0000000000..da0b45084e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: TypeScript 2.9 adds support for number and symbol named properties in index types and mapped types. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +const str = "c"; +const num = 10; +const sym = Symbol(); +const bool = true; + +const enum ABC { A, B, C } +const enum ABCStr { A = "A", B = "B", C = "C" } + + +type TypeObj = { + a: string; + 5: string; + + [str]: string; + [num]: string; + [sym]: string; + + [ABC.A]: string; + [ABCStr.A]: string; +} + + +type KEY1 = keyof TypeObj; +type KEY2 = Extract; +type KEY3 = Extract; +type KEY4 = Extract; + + +let key1: KEY1 = 'c'; +let key2: KEY2 = ABCStr.A; +let key3: KEY3 = 10; +Assert.equal("c", key1); +Assert.equal(ABCStr.A, key2); +Assert.equal(10, key3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts b/es2panda/test/ts_extra_tests/test/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts new file mode 100644 index 0000000000..1d422f73fe --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Since keyof now reflects the presence of a numeric index signature by including type number in the key type, mapped types such as Partial and Readonly work correctly when applied to object types with numeric index signatures. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +type ArrayAny = { + length: number; + [x: number]: T; +} + +type RAA = Readonly>; + +let arr: RAA = { + [1]: "b", + [2]: "a", + length: 2, +}; + + +let len = arr.length; +let x = arr[1]; +Assert.equal(2, len); +Assert.equal("b", x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_3.ts b/es2panda/test/ts_extra_tests/test/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_3.ts new file mode 100644 index 0000000000..144fa4fa88 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_3.ts @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implie d. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: with the keyof operator's support for number and symbol named keys, it is now possible to abstract over access to properties of objects that are indexed by numeric literals (such as numeric enum types) and unique symbols. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +const enum Enum { + A, + B, + C, +} + +const ets = { + [Enum.A]: "Name A", + [Enum.B]: "Name B", + [Enum.C]: "Name C", +}; + +const sym1 = Symbol(); +const sym2 = Symbol(); +const sym3 = Symbol(); + +const etn = { + [sym1]: 1, + [sym2]: 2, + [sym3]: 3, +}; + +type KE = keyof typeof ets; +type KS = keyof typeof etn; + +function getValue(obj: T, key: K): T[K] { + return obj[key]; +} + +let x1 = getValue(ets, Enum.C); +let x2 = getValue(etn, sym3); +Assert.equal("Name C", x1); +Assert.equal(3, x2); + + + +function useKey1>(o: T, k: K) { + var name: string = k; + return name; +} + +const stringMap = { + a: "mystring" +}; +let x3 = useKey1(stringMap, "a"); +Assert.equal("a", x3); + + +function useKey2(o: T, k: K) { + var name: string | number | symbol = k; + return name; +} +const uniteMap = { + a: "mystring", + b: 1 +}; +let x4 = useKey2(uniteMap, "b"); +Assert.equal("b", x4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.9/3_generic_type_arguments_in_tt.ts b/es2panda/test/ts_extra_tests/test/2.9/3_generic_type_arguments_in_tt.ts new file mode 100644 index 0000000000..ae8784c1cc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.9/3_generic_type_arguments_in_tt.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: TypeScript 2.9 allows passing generic type arguments to tagged template strings. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../suite/assert.js' + +let jianbing = '煎饼' + +function kitchen(strings: TemplateStringsArray, value: string) { + Assert.equal(2, strings.length); +} + +let zaocan = kitchen`今天的早餐是${jianbing}!`; + + + +function tag(strs: TemplateStringsArray, args: T): T { + Assert.equal(2, strs.length); + return args; +}; + + +let a = tag `今天的午餐是${jianbing}!`; +Assert.equal("煎饼", a); + +let b = tag `今天的午餐是${"dessert"}!`; + +Assert.equal("dessert", b); diff --git a/es2panda/test/ts_extra_tests/test/2.9/4_import_types.ts b/es2panda/test/ts_extra_tests/test/2.9/4_import_types.ts new file mode 100644 index 0000000000..3b4dcefe25 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.9/4_import_types.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Modules can import types declared in other modules. But non-module global scripts cannot access types declared in modules. Enter import types. + Using import("mod") in a type annotation allows for reaching in a module and accessing its exported declaration without importing it. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../suite/assert.js' + +function hw_adopt(p: import("./module").Pet) { + Assert.equal('puppy', `${p.name}`); + Assert.equal('puppy', p.name); +} + +let p: import("./module.js").Pet = { + name: "puppy", +}; +hw_adopt(p); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.9/module.ts b/es2panda/test/ts_extra_tests/test/2.9/module.ts new file mode 100644 index 0000000000..381a7f8836 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/2.9/module.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export declare class Pet { + name: string; +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.0/new_unknown_top_type/new_unknown_top_type.ts b/es2panda/test/ts_extra_tests/test/3.0/new_unknown_top_type/new_unknown_top_type.ts new file mode 100644 index 0000000000..f86cf6ca25 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.0/new_unknown_top_type/new_unknown_top_type.ts @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + typescript 3.0 introduces a new top type unknown. unknown is the type-safe counterpart of any. + anything is assignable to unknown, but unknown isn't assignable to anything but itself and any without a type assertion or a control flow based narrowing. + likewise, no operations are permitted on an unknown without first asserting or narrowing to a more specific type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +type HWT00 = unknown & null; +type HWT01 = unknown & undefined; +type HWT02 = unknown & null & undefined; +type HWT03 = unknown & string; +type HWT04 = unknown & string[]; +type HWT05 = unknown & unknown; +type HWT06 = unknown & any; + +type HWT10 = unknown | null; +type HWT11 = unknown | undefined; +type HWT12 = unknown | null | undefined; +type HWT13 = unknown | string; +type HWT14 = unknown | string[]; +type HWT15 = unknown | unknown; +type HWT16 = unknown | any; + +type HWT20 = T & {}; +type HWT21 = T | {}; +type HWT22 = T & unknown; +type HWT23 = T | unknown; + +type HWT30 = unknown extends T ? true : false; +type HWT31 = T extends unknown ? true : false; +type HWT32 = never extends T ? true : false; +type HWT33 = T extends never ? true : false; + +type HWT40 = keyof any; +type HWT41 = keyof unknown; + +function hwfun01(x: unknown): unknown { + x = 10; + return x; +} +Assert.equal(hwfun01(0), 10); + +declare function isFunction(x: unknown): x is Function; + +function hwfun02(x: unknown) { + return typeof x; +} +Assert.equal(hwfun02("N"), "string"); + +type HWT50 = { [P in keyof T]: number }; +type HWT51 = HWT50; +type HWT52 = HWT50; + +function hwfun03(pAny: any, pundefined: undefined, pT: T) { + let x: unknown; + x = 123; + Assert.isNumber(x); + x = "hello"; + Assert.isString(x); + x = [1, 2, 3]; + x = new Error(); + x = x; + x = pAny; + x = pundefined; + x = pT; +} +hwfun03(1024, undefined, "A"); + +function hwfun04(x: unknown) { + let v1: any = x; + let v2: unknown = x; +} +hwfun04(1024); + +function hwfun05(x: { [x: string]: unknown }) { + x = {}; + x = { a: 5 }; +} + +function hwfun06() { + let x: unknown; + let y = x; +} + +function hwfun07(): unknown { + let x: unknown; + return x; +} + +class C1 { + a: string = ""; + b: unknown; + c: any; +} + +let x: number = 1024; +(x as unknown as string).length; diff --git a/es2panda/test/ts_extra_tests/test/3.0/reference_lib/reference_lib.ts b/es2panda/test/ts_extra_tests/test/3.0/reference_lib/reference_lib.ts new file mode 100644 index 0000000000..906ce35a04 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.0/reference_lib/reference_lib.ts @@ -0,0 +1,26 @@ +/// +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript adds a new triple-slash-reference directive (/// ), allowing a file to explicitly include an existing built-in lib file. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js"; +let sym: symbol = Symbol("es2015"); +Assert.isSymbol(sym); diff --git a/es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/generic_rest_parameters/generic_rest_parameters.ts b/es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/generic_rest_parameters/generic_rest_parameters.ts new file mode 100644 index 0000000000..57f4e4e1c9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/generic_rest_parameters/generic_rest_parameters.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + a rest parameter is permitted to have a generic type that is constrained to an array type, and type inference can infer tuple types for such generic rest parameters. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function hwfun01(f: (x: T, ...args: U) => V): (...args: U) => V { + function frm(...args: U) { let json = JSON.stringify(args); return json as unknown as V; } + return frm; +}; +function getArrJson(x: number, y: string, z: boolean): string { + let a: any[] = [x, y, z]; + let json = JSON.stringify(a); + return json; +} +let a = getArrJson(5, "A", true); +let gf1 = hwfun01(getArrJson); +let b = gf1("B", true); +let gf2 = hwfun01(gf1); +let c = gf2(true); +let gf3 = hwfun01(gf2); +let d = gf3(); +Assert.equal(a, "[5,\"A\",true]"); +Assert.equal(b, "[\"B\",true]"); +Assert.equal(c, "[true]"); +Assert.equal(d, "[]"); diff --git a/es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts b/es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts new file mode 100644 index 0000000000..217ce6100f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + tuple types now permit a ? postfix on element types to indicate that the element is optional.In strictNullChecks mode, a ? modifier automatically includes undefined in the element type, similar to optional parameters. + a tuple type permits an element to be omitted if it has a postfix ? modifier on its type and all elements to the right of it also have ? modifiers. + The length property of a tuple type with optional elements is a union of numeric literal types representing the possible lengths. For example, the type of the length property in the tuple type [number, string?, boolean?] is 1 | 2 | 3. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let test: [number, string?, boolean?]; +test = [1024, "hello", true]; +Assert.equal(JSON.stringify(test), "[1024,\"hello\",true]"); +Assert.equal(test.length, 3); +test = [1408, "N"]; +Assert.equal(JSON.stringify(test), "[1408,\"N\"]"); +Assert.equal(test.length, 2); +test = [0]; +Assert.equal(JSON.stringify(test), "[0]"); +Assert.equal(test.length, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_elements_in_tuple_types/rest_elements_in_tuple_types.ts b/es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_elements_in_tuple_types/rest_elements_in_tuple_types.ts new file mode 100644 index 0000000000..e5f29f6cd7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_elements_in_tuple_types/rest_elements_in_tuple_types.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the last element of a tuple type can be a rest element of the form ...X, where X is an array type. A rest element indicates that the tuple type is open-ended and may have zero or more additional elements of the array element type. + the type of the length property of a tuple type with a rest element is number. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function test(...args: T): T { + return args; +} +function getArrayOfNumbers0_10() { + let arr: number[] = []; + for (let i = 0; i <= 10; i++) { + arr.push(i); + } + return arr; +} +const numbers: number[] = getArrayOfNumbers0_10(); +const t1 = test("AAA", 1, true); +const t2 = test("BBB", ...numbers); +const t3 = ["A", true, ...numbers, false]; +Assert.equal(JSON.stringify(t1), "[\"AAA\",1,true]"); +Assert.equal(JSON.stringify(t2), "[\"BBB\",0,1,2,3,4,5,6,7,8,9,10]"); +Assert.equal(JSON.stringify(t3), "[\"A\",true,0,1,2,3,4,5,6,7,8,9,10,false]"); +Assert.isNumber(t1.length); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts b/es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts new file mode 100644 index 0000000000..d27c87f499 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + when a rest parameter has a tuple type, the tuple type is expanded into a sequence of discrete parameters. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function rfun1(...v: [number, string, boolean]) { + return { number: v[0], string: v[1], boolean: v[2] }; +} +function rfun2(v1: number, v2: string, v3: boolean) { + return { number: v1, string: v2, boolean: v3 }; +} +var r1 = rfun1(1, "rfun", true); +var r2 = rfun2(1, "rfun", true); +var jr1 = JSON.stringify(r1); +var jr2 = JSON.stringify(r2); +Assert.equal(jr1, jr2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/spread_expressions_with_tuple_types/spread_expressions_with_tuple_types.ts b/es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/spread_expressions_with_tuple_types/spread_expressions_with_tuple_types.ts new file mode 100644 index 0000000000..8e0d0559dd --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/spread_expressions_with_tuple_types/spread_expressions_with_tuple_types.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + when a function call includes a spread expression of a tuple type as the last argument, the spread expression corresponds to a sequence of discrete arguments of the tuple element types. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function sfun(...v: [number, string, boolean]) { + return { number: v[0], string: v[1], boolean: v[2] }; +} +const args: [number, string, boolean] = [42, "hello", true]; +var v1 = sfun(...args); +var v2 = sfun(args[0], args[1], args[2]); +var v3 = sfun(42, "hello", true); +var jv1 = JSON.stringify(v1); +var jv2 = JSON.stringify(v2); +var jv3 = JSON.stringify(v3); +var flag = false; +if (jv1 === jv2 && jv2 === jv3 && jv3 === jv1) { + flag = true; +} +Assert.isTrue(flag); diff --git a/es2panda/test/ts_extra_tests/test/3.1/mapped_types_on_tuples_and_arrays/mapped_types_on_tuples_and_arrays_1.ts b/es2panda/test/ts_extra_tests/test/3.1/mapped_types_on_tuples_and_arrays/mapped_types_on_tuples_and_arrays_1.ts new file mode 100644 index 0000000000..a43204ead9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.1/mapped_types_on_tuples_and_arrays/mapped_types_on_tuples_and_arrays_1.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In TypeScript 3.1, mapped object types over tuples and arrays now produce new tuples/arrays, + rather than creating a new type where members like push(), pop(), and length are converted. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +type Test = { + [k in keyof T]: Array; +}; +type tupleTest = [number, string, boolean]; +type tt = Test; +let cc: tt = [ + [0, 1, 2, 3], + ["a", "b", "c", "d"], + [false, true], +]; +Assert.equal(Array.isArray(cc), true); +Assert.equal(cc.length, 3); +cc.push([1, 2, 3]); +cc.push([false, false]); +cc.push(["hello", "world"]); +Assert.equal(cc.length, 6); +// pop +let vv: any = cc.pop(); +Assert.equal(vv[0], "hello"); +Assert.equal(vv[1], "world"); +Assert.equal(cc.length, 5); diff --git a/es2panda/test/ts_extra_tests/test/3.1/properties_declarations_on_functions/properties_declarations_on_functions_1.ts b/es2panda/test/ts_extra_tests/test/3.1/properties_declarations_on_functions/properties_declarations_on_functions_1.ts new file mode 100644 index 0000000000..f18d78287b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.1/properties_declarations_on_functions/properties_declarations_on_functions_1.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript 3.1 brings the ability to define properties on function declarations and const-declared functions, + simply by assigning to properties on these functions in the same scope. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function add(a: T, b: K) { + if (typeof a == "number" && typeof b == "number") { + return a + b; + } else { + return `${a}${b}`; + } +} + +add.description = "this"; +add.aa = 0; +add.bb = false; + +Assert.equal(add.description, "this"); +Assert.equal(add.aa, 0); +Assert.equal(add.bb, false); + +add.showInfo = () => { + return 1; +}; +Assert.equal(add.showInfo(), 1); + + +const link = () => { + return 11; +}; + +link.aa = 0; +link.bb = false; +link.cc = "this"; +link.showInfo = () => { + return 1; +}; +Assert.equal(link.cc, "this"); +Assert.equal(link.aa, 0); +Assert.equal(link.bb, false); +Assert.equal(link.showInfo(), 1); diff --git a/es2panda/test/ts_extra_tests/test/3.2/bigint/bigint_1.ts b/es2panda/test/ts_extra_tests/test/3.2/bigint/bigint_1.ts new file mode 100644 index 0000000000..a772f413f2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.2/bigint/bigint_1.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + BigInts are part of an upcoming proposal in ECMAScript that allow us to model theoretically arbitrarily large integers. + Brings type-checking for BigInts, as well as support for emitting BigInt literals when targeting esnext. + BigInt support in TypeScript introduces a new primitive type called the 'bigint' (all lowercase). + You can get a bigint by calling the BigInt() function or by writing out a BigInt literal by adding an n to the end of any integer numeric litera. + options: + target: es2020 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +let bi01: bigint = BigInt(100); +Assert.equal(bi01, 100n) + +let bi02: bigint = 100n; +Assert.equal(bi02, 100n) + +function hwfun(n: bigint) { + let a = 1n; + for (let x = 0n, i = 0n; i < n; i++) { + const y = a; + a += x; + x = y; + } + return a; +} + +let a = hwfun(100n); +Assert.equal(a, 573147844013817084101n); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.2/bigint/bigint_2.ts b/es2panda/test/ts_extra_tests/test/3.2/bigint/bigint_2.ts new file mode 100644 index 0000000000..a2f5c2267d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.2/bigint/bigint_2.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + As specified in ECMAScript, mixing numbers and bigints in arithmetic operations is an error. + You'll have to explicitly convert values to BigInts. + options: + target: es2020 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +var x: number = 10; +var bi: bigint = 100n; + +var y = BigInt(x) * bi; +Assert.equal(y, 1000n); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.2/bigint/bigint_3.ts b/es2panda/test/ts_extra_tests/test/3.2/bigint/bigint_3.ts new file mode 100644 index 0000000000..db0c1ad380 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.2/bigint/bigint_3.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + bigints produce a new string when using the typeof operator: the string "bigint". + Thus, TypeScript correctly narrows using typeof as you’d expect. + options: + target: es2020 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function num_or_bigint(x: number | bigint) { + if (typeof x === "bigint") { + return x; + } + else { + return x + 1; + } +} +var a = num_or_bigint(10); +var b = num_or_bigint(10n); +Assert.equal(a, 11); +Assert.equal(b, 10n); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.2/generic_object_rest_variables_and_parameters/generic_object_rest_variables_and_parameters.ts b/es2panda/test/ts_extra_tests/test/3.2/generic_object_rest_variables_and_parameters/generic_object_rest_variables_and_parameters.ts new file mode 100644 index 0000000000..5c704caaf3 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.2/generic_object_rest_variables_and_parameters/generic_object_rest_variables_and_parameters.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Allows destructuring a rest binding from a generic variable. + This is achieved by using the predefined Pick and Exclude helper types from lib.d.ts, + and using the generic type in question as well as the names of the other bindings in the destructuring pattern. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +function hwfun(obj: T) { + let { tag, ...rest } = obj; + return rest; +} + +const point = { x: 10, y: 20, tag: "point" }; +const p = hwfun(point); + +Assert.equal(JSON.stringify(p), '{"x":10,"y":20}'); diff --git a/es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_1.ts b/es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_1.ts new file mode 100644 index 0000000000..3835682e9d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_1.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Object literals now allow generic spread expressions which now produce intersection types, + similar to the Object.assign function and JSX literals. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +function cObj(obj: T, tag: U) { + return { ...obj, tag }; +} + +let x = cObj({ x: 10, y: 20 }, "point"); + +Assert.equal(JSON.stringify(x), '{"x":10,"y":20,"tag":"point"}'); diff --git a/es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts b/es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts new file mode 100644 index 0000000000..a052b02f17 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Property assignments and non-generic spread expressions are merged to the greatest extent possible on either side of a generic spread expression. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +function hwFun(t: T, obj1: { a: string }, obj2: { b: string }) { + var arr = { ...obj1, x: 1, ...t, ...obj2, y: 2 }; + return arr; +} +let o1 = { + a: "a", +}; +let o2 = { + b: "b", +}; +var f = hwFun("s", o1, o2); + +Assert.equal(JSON.stringify(f), '{"0":"s","a":"a","x":1,"b":"b","y":2}'); diff --git a/es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_3.ts b/es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_3.ts new file mode 100644 index 0000000000..05030d9c8d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_3.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Non-generic spread expressions continue to be processed as before: Call and construct signatures are stripped, + only non-method properties are preserved, and for properties with the same name, the type of the rightmost property is used. + This contrasts with intersection types which concatenate call and construct signatures, + preserve all properties, and intersect the types of properties with the same name. + Thus, spreads of the same types may produce different results when they are created through instantiation of generic types + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +function hwfun3(t: T, u: U) { + return { ...t, ...u }; +} + +let x: { a: string; b: number } = { a: "a", b: 1 }; +let y: { b: string; c: boolean } = { b: "b", c: true }; + +let s1 = { ...x, ...y }; +Assert.equal(typeof s1, "object"); +let s2 = hwfun3(x, y); +Assert.equal(typeof s2, "object"); +let b1 = s1.b; +Assert.isString(b1); +let b2 = s2.b; +Assert.isString(b2); diff --git a/es2panda/test/ts_extra_tests/test/3.2/non-unit_types_as_union_discriminants/non-unit_types_as_union_discriminants.ts b/es2panda/test/ts_extra_tests/test/3.2/non-unit_types_as_union_discriminants/non-unit_types_as_union_discriminants.ts new file mode 100644 index 0000000000..32bfb03d7c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.2/non-unit_types_as_union_discriminants/non-unit_types_as_union_discriminants.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Common properties of unions are now considered discriminants as long as they contain some singleton type, + and they contain no generics. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +type R = { error: Error; data: null } | { error: null; data: T }; + +function hwfun(result: R) { + if (result.error) { + throw result.error; + } + return result.data; +} + +var a = { + error: null, + data: null, +}; +var b = hwfun(a); +let f = false; +if (b == null) { + f = true; +} +Assert.isTrue(f); + +var c = { + error: null, + data: 10, +}; +var d = hwfun(c); +Assert.equal(d, "10"); diff --git a/es2panda/test/ts_extra_tests/test/3.3/improved_behavior_for_calling_union_types.ts b/es2panda/test/ts_extra_tests/test/3.3/improved_behavior_for_calling_union_types.ts new file mode 100644 index 0000000000..6eff873669 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.3/improved_behavior_for_calling_union_types.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Improved behavior for calling union types. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../suite/assert.js' + +{ + type DamageType = "XO" | "EXP"; + type Color = "red" | "green" | "blue"; + + type ATK = (atk: DamageType) => number; + + let s: ATK = (atk: DamageType) => 1; + + type ColorConsumer = (color: Color) => string; + + let sp: ColorConsumer = (color: Color) => 'good'; + + Assert.equal(s("XO"), 1) + Assert.equal(sp("green"), 'good') + + interface Dog { + kind: "dog"; + dogProp: any; + } + + interface Cat { + kind: "cat"; + catProp: any; + } + + const petArray: Dog[] | Cat[] = [{ kind: "dog", dogProp: 1 }, { kind: "dog", dogProp: 2 }]; + let ex: number[] = []; + petArray.forEach((animal: Dog | Cat) => { + if (animal.kind === "dog") { + ex.push(animal.dogProp); + } else if (animal.kind === "cat") { + ex.push(animal.catProp); + } + }); + + Assert.equal(ex[0], 1); + Assert.equal(ex[1], 2); +}; diff --git a/es2panda/test/ts_extra_tests/test/3.4/const_assertions.ts b/es2panda/test/ts_extra_tests/test/3.4/const_assertions.ts new file mode 100644 index 0000000000..31e3f100d5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.4/const_assertions.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript 3.4 introduces a new construct for literal values called const assertions. Its syntax is a type assertion with const in place of the type name (e.g. 123 as const). + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../suite/assert.js" +let a = 1408 as const; +Assert.equal(a, 1408); +let b = 'NARC' as const; +Assert.equal(b, 'NARC'); +let c = [255, 0, 0] as const; +Assert.equal(JSON.stringify(c), '[255,0,0]'); diff --git a/es2panda/test/ts_extra_tests/test/3.4/higher_order_type_inference.ts b/es2panda/test/ts_extra_tests/test/3.4/higher_order_type_inference.ts new file mode 100644 index 0000000000..3fb489b573 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.4/higher_order_type_inference.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Higher order type inference from generic functions. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../suite/assert.js' + +function hwfun01(f: (arg: A) => B, g: (arg: B) => C): (arg: A) => C { + return (x) => g(f(x)); +} + +interface A { + value: T; +} + +function hwfun02(x: T): T[] { + return [x]; +} + +function hwfun03(value: U): A { + return { value }; +} + +// has type '(arg: {}) => Box<{}[]>' +const hw00 = hwfun01( + hwfun02, + hwfun03, +) + + +Assert.equal(hw00("hello").value[0].toUpperCase(), 'HELLO'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.4/readonly_array.ts b/es2panda/test/ts_extra_tests/test/3.4/readonly_array.ts new file mode 100644 index 0000000000..5ecc29daa7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.4/readonly_array.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Improvements for ReadonlyArray and readonly tuples. + const assertions. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../suite/assert.js" + + + let hw_arr: ReadonlyArray = ["1", "2"]; + let hw_rsa: readonly string[] = ["1", "2"]; + + Assert.equal(hw_arr[1], "2"); + Assert.equal(hw_rsa[1], "2"); + + function hwfun() { + let result = [ + { kind: "circle", radius: 100 }, + { kind: "square", sideLength: 50 }, + ] as const; + return result; + } + for (const shape of hwfun()) { + if (shape.kind === "circle") { + Assert.equal(shape.radius, 100); + } else { + Assert.equal(shape.sideLength, 50); + } + } + diff --git a/es2panda/test/ts_extra_tests/test/3.5/higher_order_type_inference.ts b/es2panda/test/ts_extra_tests/test/3.5/higher_order_type_inference.ts new file mode 100644 index 0000000000..c6315bb15a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.5/higher_order_type_inference.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In TypeScript 3.4, we improved inference for when generic functions that return functions. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../suite/assert.js' + +{ + class A { + value: T; + + constructor(value: T) { + this.value = value; + } + } + + class B { + value: U; + + constructor(value: U) { + this.value = value; + } + } + + function hwfun( + F: new (x: T) => U, + G: new (y: U) => V + ): (x: T) => V { + return x => new G(new F(x)); + } + + + let f = hwfun(A, B); + + let a = f(1024); + + Assert.equal(a.value.value, 1024); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.5/omit_helper_type.ts b/es2panda/test/ts_extra_tests/test/3.5/omit_helper_type.ts new file mode 100644 index 0000000000..425d7fa6ea --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.5/omit_helper_type.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript 3.5 introduces the new Omit helper type, which creates a new type with some properties dropped from the original. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../suite/assert.js' + +{ + type TA = { + a: string; + b: number; + c: string; + }; + type TB = Omit; + let s: TB = { + a: 'string', + b: 1, + } + let s1: TA = { + a: 'string', + b: 1, + c: 'string' + } + Assert.isFalse("c" in s) + Assert.isTrue("c" in s1) +} \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.5/smarter_union_type_checking.ts b/es2panda/test/ts_extra_tests/test/3.5/smarter_union_type_checking.ts new file mode 100644 index 0000000000..4e3bce0250 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.5/smarter_union_type_checking.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Smarter union type checking. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../suite/assert.js' + +{ + type PointData = { + x: number; + y: number; + name: string; + }; + + type Data = { + name: string; + }; + + const point: PointData | Data = { + x: 0, + y: 0, + name: 'name' + } + Assert.equal(point.name, 'name') +} \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.6/better_unicode_support_for_identifiers/better_unicode_support_for_identifiers_1.ts b/es2panda/test/ts_extra_tests/test/3.6/better_unicode_support_for_identifiers/better_unicode_support_for_identifiers_1.ts new file mode 100644 index 0000000000..67e00fb71d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.6/better_unicode_support_for_identifiers/better_unicode_support_for_identifiers_1.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: TypeScript 3.6 contains better support for Unicode characters in identifiers when emitting to ES2015 and later targets. + options: + target:es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +const 𝓱𝓮𝓵𝓵𝓸 = "world"; +Assert.equal(𝓱𝓮𝓵𝓵𝓸, "world"); diff --git a/es2panda/test/ts_extra_tests/test/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/get_and_set_accessors_are_allowed_in_ambient_contexts_1.ts b/es2panda/test/ts_extra_tests/test/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/get_and_set_accessors_are_allowed_in_ambient_contexts_1.ts new file mode 100644 index 0000000000..fb45c459c7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/get_and_set_accessors_are_allowed_in_ambient_contexts_1.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: users can write getters and setters in ambient contexts in TypeScript 3.6 and later. +module: ESNext +isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" +import { HWC } from "./test.js" + +let hw: HWC = { x: 1 }; + +Assert.equal(1, hw.x); + + diff --git a/es2panda/test/ts_extra_tests/test/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/test.ts b/es2panda/test/ts_extra_tests/test/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/test.ts new file mode 100644 index 0000000000..118f9b77d4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/test.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +declare class HWC { + get x(): number; + set x(val: number); +} +export { HWC }; diff --git a/es2panda/test/ts_extra_tests/test/3.6/more_accurate_array_spread/more_accurate_array_spread_1.ts b/es2panda/test/ts_extra_tests/test/3.6/more_accurate_array_spread/more_accurate_array_spread_1.ts new file mode 100644 index 0000000000..d6dd3e1f0c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.6/more_accurate_array_spread/more_accurate_array_spread_1.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: More Accurate Array Spread. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +const t1 = { name: "John", age: 30 }; +const t2 = ["javascript", "typescript", "react"]; +const t3 = { ...t1, skills: t2 }; +Assert.equal("name" in t3, true); +Assert.equal("age" in t3, true); +Assert.equal("skills" in t3, true); +Assert.equal("isJob" in t3, false); diff --git a/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_1.ts b/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_1.ts new file mode 100644 index 0000000000..6a81093741 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_1.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: In TypeScript 3.6, the checker now knows that the correct type for iter.next().value + options: + lib:es2015 + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +function* hwtest() { + yield 100; + yield "Finished!"; + return false; +} +let t1 = hwtest(); +let t2 = t1.next(); +Assert.isNumber(t2.value); +t2 = t1.next(); +Assert.isString(t2.value); +t2 = t1.next(); +Assert.isBoolean(t2.value); +t2 = t1.next(); +Assert.equal(t2.done, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_2.ts b/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_2.ts new file mode 100644 index 0000000000..70c6ab2480 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_2.ts @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The Iterator type now allows users to specify the yielded type, the returned type, and the type that next can accept. + To allow differentiation between returned values and yielded values, + TypeScript 3.6 converts the IteratorResult type to a discriminated union type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +class HWC1 { + name: string; + age: number; + isJob: boolean; + constructor(name: string, age: number, isJob: boolean) { + this.name = name; + this.age = age; + this.isJob = isJob; + } +} + +let c1 = new HWC1("caihua", 12, false); + +const keys = Object.keys(c1); +var nextIndex = 0; +let x: Iterator = { + next() { + return nextIndex < keys.length + ? { + value: keys[nextIndex++], + done: false, + } + : { value: 0, done: true }; + }, +}; + +let dd = x.next(); +Assert.isString(dd.value); +Assert.isBoolean(dd.done); +Assert.equal(dd.value, "name"); +Assert.equal(dd.done, false); +x.next(); +x.next(); + +dd = x.next(); +Assert.isNumber(dd.value); +Assert.isBoolean(dd.done); +Assert.equal(dd.value, 0); +Assert.equal(dd.done, true); diff --git a/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_3.ts b/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_3.ts new file mode 100644 index 0000000000..743a45cd1e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_3.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: the new Generator type is an Iterator that always has both the return and throw methods present, and is also iterable. + options: + lib:es2017 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function* hwtest3(): Generator { + let i = 0; + while (true) { + if (yield i++) { + break; + } + } + return "done!"; +} + +let t1 = hwtest3(); +let t2 = t1.next(); +while (!t2.done) { + Assert.equal(typeof t2.value, "number"); + t2 = t1.next(typeof t2.value == "number"); +}; diff --git a/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_4.ts b/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_4.ts new file mode 100644 index 0000000000..a2aa88bd55 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_4.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + To correctly represent the types that can be passed in to a generator from calls to next(), + TypeScript 3.6 also infers certain uses of yield within the body of a generator function. + options: + lib:es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function* hwtest4() { + let x: number = yield; + Assert.isNumber(x); +} +let x = hwtest4(); +x.next(); +x.next(1); diff --git a/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_5.ts b/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_5.ts new file mode 100644 index 0000000000..5286318135 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_5.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + To correctly represent the types that can be passed in to a generator from calls to next(), + TypeScript 3.6 also infers certain uses of yield within the body of a generator function. + options: + lib:es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function* hwtest5(): Generator { + let i = 0; + while (true) { + let cc = yield i++; + Assert.isBoolean(cc); + if (cc) { + break; + } + } + return "done!"; +} + +var t1 = hwtest5(); +var t2 = t1.next(); +while (!t2.done) { + t2 = t1.next(t2.value === 5); +}; diff --git a/es2panda/test/ts_extra_tests/test/3.7/assertion_functions/assertion_functions_1.ts b/es2panda/test/ts_extra_tests/test/3.7/assertion_functions/assertion_functions_1.ts new file mode 100644 index 0000000000..a27ad9d52c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.7/assertion_functions/assertion_functions_1.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: > + Assertions in JavaScript are often used to guard against improper types being passed in. +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" + + +function hwtest(x: any, y: any) { + Assert.equal(typeof x, "number"); + Assert.equal(typeof y, "number"); + + return x * y; +} +Assert.equal(typeof hwtest(6, 8), "number"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.7/nullish_coalescing/nullish_coalescing_1.ts b/es2panda/test/ts_extra_tests/test/3.7/nullish_coalescing/nullish_coalescing_1.ts new file mode 100644 index 0000000000..8368cd3d74 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.7/nullish_coalescing/nullish_coalescing_1.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: > + We can think of this feature - the ?? operator - as a way to "fall back" to a default value when dealing with null or undefined. +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" +let nn: number | null; +nn = 1408; +let str: string = "NARC"; +let x = nn ?? str; + +nn = null; +let y = nn ?? str; + +Assert.equal(typeof x, "number"); +Assert.equal(typeof y, "string"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.7/nullish_coalescing/nullish_coalescing_2.ts b/es2panda/test/ts_extra_tests/test/3.7/nullish_coalescing/nullish_coalescing_2.ts new file mode 100644 index 0000000000..14a5192cd2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.7/nullish_coalescing/nullish_coalescing_2.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: > + The ?? operator can replace uses of || when trying to use a default value. +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" + +let n = 0; +function hwtset() { + n = n ?? 0.5; + return n; +} + +Assert.equal(hwtset(), 0); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_1.ts b/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_1.ts new file mode 100644 index 0000000000..65a25df529 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_1.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: > + The star of the show in optional chaining is the new ?. operator for optional property accesses. +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" + +const hwobj = { + x: { + y: 'NARC' + } +}; + +let str = hwobj?.x.y; + +Assert.equal(str, "NARC"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_2.ts b/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_2.ts new file mode 100644 index 0000000000..94e06d6a37 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_2.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: > + You might find yourself using ?. to replace a lot of code that performs repetitive nullish checks using the && operator. +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" +const hwobj = { + x: { + y: 'e2' + } +}; + +if (hwobj?.x?.y) { + Assert.equal(hwobj?.x?.y, "e2", "true"); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_3.ts b/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_3.ts new file mode 100644 index 0000000000..ab21496c7e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_3.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: > + One use of optional chain is optional element access, which acts similarly to optional property accesses, but allows us to access non-identifier properties (e.g. arbitrary strings, numbers). +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" + +function hwtset(arr?: T[]) { + return arr?.[0]; +} + +const arr: number[] = [1, 25, 8]; +Assert.equal(hwtset(arr), 1, "true"); + +const arrStr: string[] = ["flower", "xian"]; +Assert.equal(hwtset(arrStr), "flower", "true"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_4.ts b/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_4.ts new file mode 100644 index 0000000000..20ca32f9eb --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_4.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + There's also optional call, which allows us to conditionally call expressions if they’re not null or undefined. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +async function hwtest(url: string, log?: (msg: string) => void) { + log?.(`Request started at ${new Date().toISOString()}`); + const result = ((await fetch(url)).json()); + log?.(`Request finished at ${new Date().toISOString()}`); + return result; +} +hwtest("https://www.typescriptlang.org/").then(res => { + Assert.equal(typeof res, "object"); +}).catch(err => { +}); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_5.ts b/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_5.ts new file mode 100644 index 0000000000..5be370ece0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_5.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The "short-circuiting" behavior that optional chains have is limited property accesses, calls, element accesses - it doesn't expand any further out from these expressions. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +const hwobjnum = { + n1: { + n2: 10 + } +}; +function hwfun(divisor: number) { + return divisor + 4; +} +let result = hwobjnum?.n1?.n2 / hwfun(1); +Assert.equal(typeof result, "number"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.7/recursive_type_aliases/recursive_type_aliases_1.ts b/es2panda/test/ts_extra_tests/test/3.7/recursive_type_aliases/recursive_type_aliases_1.ts new file mode 100644 index 0000000000..101a620ca9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.7/recursive_type_aliases/recursive_type_aliases_1.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + That's exactly what TypeScript 3.7 introduces. At the "top level" of a type alias, TypeScript will defer resolving type arguments to permit these patterns. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +type JSONType = + | string + | number + | boolean + | null + | HWJsonObject + | JsonArray; + +interface HWJsonObject { + [property: string]: JSONType; +} + +interface JsonArray extends Array { } +const myJson: JSONType = ["a", 2, true, null, { + "Damage": 1024, + "DamageType": "XO", +}, []]; + +Assert.equal(typeof myJson, "object"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.7/ts_nocheck_in_typescript_files/ts_nocheck_in_typescript_files.ts b/es2panda/test/ts_extra_tests/test/3.7/ts_nocheck_in_typescript_files/ts_nocheck_in_typescript_files.ts new file mode 100644 index 0000000000..47db4dd102 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.7/ts_nocheck_in_typescript_files/ts_nocheck_in_typescript_files.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript 3.7 allows us to add // @ts-nocheck comments to the top of TypeScript files to disable semantic checks. Historically this comment was only respected in JavaScript source files in the presence of checkJs, but we’ve expanded support to TypeScript files to make migrations easier for all users. + module: ESNext + isCurrent: true +---*/ + + +// @ts-nocheck + +import { Assert } from "../../../suite/assert.js"; + +function add(a, b) { + let s = a + b; + return s; +} +Assert.isTrue(isNaN(add())); +Assert.equal(add("NARC"), "NARCundefined"); +Assert.isTrue(isNaN(add(1408))); +Assert.equal(add(1, 2), 3); +Assert.equal(add('A', 'B'), "AB"); +Assert.equal(add(10, "false"), "10false"); +Assert.equal(add(10, true), 11); diff --git a/es2panda/test/ts_extra_tests/test/3.8/1_type_only_imports_and_export.ts b/es2panda/test/ts_extra_tests/test/3.8/1_type_only_imports_and_export.ts new file mode 100644 index 0000000000..4e561a3a1a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.8/1_type_only_imports_and_export.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: TypeScript 3.8 adds a new syntax for type-only imports and exports. +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from "../../suite/assert.js"; +import type { SomeThing } from "./some_module.js"; + +export type { SomeThing }; + +let sth: SomeThing = { legs: 5 }; + +Assert.equal(5, sth.legs); diff --git a/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_1.ts b/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_1.ts new file mode 100644 index 0000000000..d2ae798caf --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_1.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: TypeScript 3.8 brings support for ECMAScript’s private fields + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +class HWC { + #name: string; + + constructor(name: string) { + this.#name = name; + } + + getName(): string { + return this.#name; + } +} + +let c = new HWC("NARC"); + +Assert.equal("NARC", c.getName()); + diff --git a/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_2.ts b/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_2.ts new file mode 100644 index 0000000000..34540e0d89 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_2.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: With private fields, each field name is unique to the containing class. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +class HWC { + #x = 10; + + getX() { + return this.#x; + } +} + +class HWD extends HWC { + #y = 20; + + getY() { + return this.#y; + } +} + +let d = new HWD(); + +Assert.equal(10, d.getX()); + +Assert.equal(20, d.getY()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_3.ts b/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_3.ts new file mode 100644 index 0000000000..6ccf904d78 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_3.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Accessing a private field on any other type will result in a TypeError! + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +class HWS { + #len: number; + + constructor(len: number) { + this.#len = len; + } + + equals(other: any) { + return this.#len === other.#len; + } +} + +const a = new HWS(100); +const b = { len: 100 }; +const c = new HWS(100); + + +Assert.isTrue(a.equals(c)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.8/3_which_should_i_use.ts b/es2panda/test/ts_extra_tests/test/3.8/3_which_should_i_use.ts new file mode 100644 index 0000000000..e94fca21b4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.8/3_which_should_i_use.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: the difference between private and # + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../suite/assert.js' + +class HWC { + private x = 10; +} + + +class HWD { + #x = 10; +} + +Assert.equal(10, new HWC()["x"]); diff --git a/es2panda/test/ts_extra_tests/test/3.8/4_export_star_as_ns_syntax.ts b/es2panda/test/ts_extra_tests/test/3.8/4_export_star_as_ns_syntax.ts new file mode 100644 index 0000000000..4e0cb9b799 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.8/4_export_star_as_ns_syntax.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: ECMAScript 2020 recently added a new syntax to support this pattern! +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from "../../suite/assert.js" +import { NUMX } from "./export_star.js" + +Assert.equal(1024, NUMX.x); +Assert.equal("STRING", NUMX.getX("STRING")); + diff --git a/es2panda/test/ts_extra_tests/test/3.8/export_star.ts b/es2panda/test/ts_extra_tests/test/3.8/export_star.ts new file mode 100644 index 0000000000..9c768b7b42 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.8/export_star.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export * as NUMX from "./my_module.js"; diff --git a/es2panda/test/ts_extra_tests/test/3.8/my_module.ts b/es2panda/test/ts_extra_tests/test/3.8/my_module.ts new file mode 100644 index 0000000000..55187964d7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.8/my_module.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export let x = 1024; +export function getX(x: string) { return x; }; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.8/some_module.ts b/es2panda/test/ts_extra_tests/test/3.8/some_module.ts new file mode 100644 index 0000000000..7f32b745bc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.8/some_module.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +const cat: any = { legs: 4 }; + +export type SomeThing = typeof cat; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.9/improvements_in_inference_and_Promise.all/improvements_in_inference_and_Promise.all.ts b/es2panda/test/ts_extra_tests/test/3.9/improvements_in_inference_and_Promise.all/improvements_in_inference_and_Promise.all.ts new file mode 100644 index 0000000000..cbb0dd3bf9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.9/improvements_in_inference_and_Promise.all/improvements_in_inference_and_Promise.all.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + recrent versions of TypeScript (around 3.7) have had updates to the declarations of functions like Promise.all and Promise.race. + unfortunately, that introduced a few regressions, especially when mixing in values with null or undefined. + this issue has now been fixed. + options: + lib: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +interface HW_Lion { + roar(): void; +} + +interface HW_Seal { + visit(): void; +} + +async function zoo( + lionExhibit: Promise, + sealExhibit: Promise +) { + let [lion, seal] = await Promise.all([lionExhibit, sealExhibit]); + lion.roar(); +} +Assert.isString("The \"lion.roar()\" in the above example was incorrectly reported as having the value \"undefined\" and has now been fixed."); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.9/ts-expect-error_comments/ts-expect-error_comments.ts b/es2panda/test/ts_extra_tests/test/3.9/ts-expect-error_comments/ts-expect-error_comments.ts new file mode 100644 index 0000000000..4f4396aff6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.9/ts-expect-error_comments/ts-expect-error_comments.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + when a line is preceded by a // @ts-expect-error comment, TypeScript will suppress that error from being reported; but if there’s no error, TypeScript will report that // @ts-expect-error wasn’t necessary. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function toASCIICode(s: string) { + s += ""; + let arr: number[] = []; + let char: string[] = s.split(''); + for (let i = 0; i < s.length; i++) { + arr[i] = char[i].charCodeAt(0); + } + return arr; +} +// @ts-expect-error +let json = JSON.stringify(toASCIICode(123)); + +Assert.equal(json, "[49,50,51]"); diff --git a/es2panda/test/ts_extra_tests/test/4.0/class_property_Inference_from_constructors/class_property_Inference_from_constructors_1.ts b/es2panda/test/ts_extra_tests/test/4.0/class_property_Inference_from_constructors/class_property_Inference_from_constructors_1.ts new file mode 100644 index 0000000000..2bfe3fc36d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.0/class_property_Inference_from_constructors/class_property_Inference_from_constructors_1.ts @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript 4.0 can now use control flow analysis to determine the types of properties in classes when noImplicitAny is enabled. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +class HWP { + name: string; + age: number | undefined; + constructor(name: string) { + this.name = name; + } + setAge(age: number) { + if (age >= 0) { + this.age = age; + } + } +} +const W = new HWP("tom"); +Assert.equal(W.name, "tom"); + +class HWSD { + area: number | undefined; + + sideLength: number | undefined; + constructor(sideLength: number) { + this.sideLength = sideLength; + this.area = sideLength * 2; + } +} +const D = new HWSD(6); +Assert.equal(D.area, 12); + +class HWS { + sideLength!: number; + constructor(sideLength: number) { + this.initialize(sideLength); + } + + initialize(sideLength: number) { + this.sideLength = sideLength; + } + + get area() { + return this.sideLength ** 2; + } +} +const b = new HWS(8); +Assert.equal(b.area, 64); diff --git a/es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_1.ts b/es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_1.ts new file mode 100644 index 0000000000..f759ab47bf --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_1.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + function foo(...args: [string, number]): void { + // ...} + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function hwtest01(...args: [string, number]): void { + const newArr = [args[0].toUpperCase(), args[1] * 2]; + Assert.equal(newArr[0], "HELLO"); + Assert.equal(newArr[1], 10); +} +hwtest01("hello", 5); +function hwtest02(arg0: string, arg1: number): void { + const Arrb = [arg0.toUpperCase(), arg1 * 2]; + Assert.equal(Arrb[0], "HELLO"); + Assert.equal(Arrb[1], 10); +} +hwtest02("hello", 5); diff --git a/es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_2.ts b/es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_2.ts new file mode 100644 index 0000000000..4538478934 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_2.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + To deepen the connection between parameter lists and tuple types, + the syntax for rest elements and optional elements mirrors the syntax for parameter lists. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +type HWT = [first: number, second?: string, ...rest: any[]]; +let arr: HWT = [42, "Hello", true, { foo: "bar" }]; + +Assert.equal(arr[0], 42); +Assert.equal(arr[1], "Hello"); +Assert.equal(arr[2], true); diff --git a/es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_3.ts b/es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_3.ts new file mode 100644 index 0000000000..fc23def7cf --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_3.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + There are a few rules when using labeled tuples. + For one, when labeling a tuple element, all other elements in the tuple must also be labeled. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +type A01 = [name: string, age: number]; +type A02 = [name?: string, age?: number]; + +const t: [string, number, boolean] = ["hello", 123, true]; +Assert.equal(t[0], "hello"); +Assert.equal(t[1], 123); +Assert.equal(t[2], true); diff --git a/es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_4.ts b/es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_4.ts new file mode 100644 index 0000000000..67f70f611a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_4.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + It’s worth noting - labels don’t require us to name our variables differently when destructuring. + They’re purely there for documentation and tooling. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function hwtest01(x: [first: string, second: number]) { + const [a, b] = x; + Assert.equal(a, "hello"); + Assert.equal(b, 42); +} +hwtest01(["hello", 42]); diff --git a/es2panda/test/ts_extra_tests/test/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_1.ts b/es2panda/test/ts_extra_tests/test/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_1.ts new file mode 100644 index 0000000000..f63de617e9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_1.ts @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + JavaScript, and a lot of other languages, support a set of operators called compound assignment operators. + Compound assignment operators apply an operator to two arguments, + and then assign the result to the left side. You may have seen these before: + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +let a: number = 1; +let b: number = 2; +a += b; +Assert.equal(a, 3); + +let c: number = 4; +let d: number = 3; +c -= d; +Assert.equal(c, 1); + +let e: number = 5; +let f: number = 6; +e *= f; +Assert.equal(e, 30); + +let g: number = 7; +let h: number = 8; +g /= h; +Assert.equal(g, 0.875); + +let j: number = 2; +let k: number = 3; +j **= k; +Assert.equal(j, 8); + +let m: number = 20; +let n: number = 30; +m <<= n; +Assert.equal(m, 0); + +let o: number = 4; +let p: number = 5; +o = o && p; +Assert.equal(o, 5); + +let s: number = 7; +let t: number = 8; +s = s || t; +Assert.equal(s, 7); + +let u: number = 10; +let v: number = 20; +u = u ?? v; +Assert.equal(u, 10); diff --git a/es2panda/test/ts_extra_tests/test/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_2.ts b/es2panda/test/ts_extra_tests/test/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_2.ts new file mode 100644 index 0000000000..4c7bad2308 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_2.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + There are even some patterns we’ve seen (or, uh, written ourselves) to lazily initialize values, only if they’ll be needed. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +let arrStr: string[]; + +(arrStr ??= []).push("hello"); +(arrStr ??= []).push("world"); + +Assert.equal(arrStr[0], "hello"); +Assert.equal(arrStr[1], "world"); diff --git a/es2panda/test/ts_extra_tests/test/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_3.ts b/es2panda/test/ts_extra_tests/test/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_3.ts new file mode 100644 index 0000000000..a4d820977b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_3.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + On the rare case that you use getters or setters with side-effects, it’s worth noting that these operators only perform assignments if necessary. + In that sense, not only is the right side of the operator “short-circuited” - the assignment itself is too. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +const obj = { + get prop() { + return true; + }, + set prop(_val: boolean) { }, +}; +function hwtest01() { + return true; +} +obj.prop = obj.prop || hwtest01(); +Assert.equal(obj.prop, true); diff --git a/es2panda/test/ts_extra_tests/test/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_1.ts b/es2panda/test/ts_extra_tests/test/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_1.ts new file mode 100644 index 0000000000..ca84854f2b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_1.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Since the beginning days of TypeScript, catch clause variables have always been typed as any. + This meant that TypeScript allowed you to do anything you wanted with them. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function hw_throwError(): never { + throw new Error("An error occurred"); +} +try { + hw_throwError(); +} catch (error: any) { + Assert.equal(error.message, "An error occurred"); +}; diff --git a/es2panda/test/ts_extra_tests/test/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_2.ts b/es2panda/test/ts_extra_tests/test/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_2.ts new file mode 100644 index 0000000000..8d6ca59910 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_2.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The above has some undesirable behavior if we’re trying to prevent more errors from happening in our error-handling code! + Because these variables have the type any by default, they lack any type-safety which could have errored on invalid operations. + That’s why TypeScript 4.0 now lets you specify the type of catch clause variables as unknown instead. + unknown is safer than any because it reminds us that we need to perform some sorts of type-checks before operating on our values. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function hw_throwError(): never { + throw new Error("An error occurred"); +} +try { + hw_throwError(); +} catch (error: unknown) { + if (error instanceof Error) { + Assert.equal(error.message, "An error occurred"); + } else { + let errString = "An unknow error occurred"; + } +}; diff --git a/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_1.ts b/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_1.ts new file mode 100644 index 0000000000..2f28c933ba --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_1.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Consider a function in JavaScript called concat that takes two array or tuple types and concatenates them together to make a new array. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function hwtest01(arr1: any, arr2: any) { + return [...arr1, ...arr2]; +} +const arrA: any = [1, 2, 3]; +const arrB: any = [4, 5, 6]; +let len01 = hwtest01(arrA, arrB).length; +Assert.equal(len01, 6); + +function hwtest02(arg: any) { + const [_, ...result] = arg; + return result; +} + +const arrC: any = [1, 2, 3, 4, 5]; +let len02 = hwtest02(arrC).length; +Assert.equal(len02, 4); diff --git a/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_2.ts b/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_2.ts new file mode 100644 index 0000000000..c09e8c33a5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_2.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + How would we type either of these in TypeScript? + For concat, the only valid thing we could do in older versions of the language was to try and write some overloads. + function concat(arr1: [A, B, C, D, E, F], arr2: []): [A, B, C, D, E, F]; + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function hwtest01(arr1: [T1, T2], arr2: []): [T1, T2]; +function hwtest01(arr1: T[], arr2: T[]): T[] { + return arr1.concat(arr2); +} +const t0: [] = []; +const tns: [number, string] = hwtest01([1, "a"], t0); +Assert.equal(tns[0], 1); +Assert.equal(tns[1], "a"); + +const arr1: [number, string, boolean, number[], object, string] = [ + 1, + "NARC", + true, + [2, 3], + { name: "Rose" }, + "AAAA", +]; +const arr2: [] = []; +function hwtest02( + arr1: [A, B, C, D, E, F], + arr2: [] +): [A, B, C, D, E, F] { + return [...arr1, ...arr2]; +} +const result = hwtest02(arr1, arr2); +Assert.equal(result.length, 6); diff --git a/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_3.ts b/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_3.ts new file mode 100644 index 0000000000..8911aea129 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_3.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + This is another case of what we like to call “death by a thousand overloads”, and it doesn’t even solve the problem generally. + It only gives correct types for as many overloads as we care to write. + If we wanted to make a catch-all case, we’d need an overload like the following: + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function hwtest01(arr1: T[], arr2: U[]): Array { + return [...arr1, ...arr2] +} +const arr1: string[] = ["hello", "world"]; +const arr2: number[] = [1, 2, 3]; +const arrsn: Array = hwtest01(arr1, arr2); +function hwtest02(arg: any) { + const [_, ...result] = arg; + return result; +} +const myTuple: any = [1, 2, 3, 4] as const; +const newArr: any = ["hello", "world"]; +const r1 = hwtest02(myTuple); +const r2 = hwtest02([...myTuple, ...newArr] as const); +const Arrlength = r2.length; +Assert.equal(Arrlength, 5); diff --git a/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_4.ts b/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_4.ts new file mode 100644 index 0000000000..6d137c2dcc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_4.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Uh…okay, that’s…seven overloads for when the second array is always empty. Let’s add some for when arr2 has one argument. + function concat(arr1: [A1, B1, C1, D1, E1, F1], arr2: [A2]): [A1, B1, C1, D1, E1, F1, A2]; + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +function hwtest01( + arr1: [A1, B1, C1, D1, E1, F1, A2], + arr2: [A3] +): [A1, B1, C1, D1, E1, F1, A2, A3] { + return [...arr1, ...arr2]; +} +const arr1: [string, number, boolean, number, null, undefined, string] = [ + "hello", + 12, + true, + 45, + null, + undefined, + "tom", +]; +const arr2: [string] = ["world"]; +const result = hwtest01(arr1, arr2); +Assert.equal(result.length, 8); diff --git a/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_5.ts b/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_5.ts new file mode 100644 index 0000000000..6c37bdbd4e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_5.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The first change is that spreads in tuple type syntax can now be generic. + This means that we can represent higher-order operations on tuples and arrays even when we don’t know the actual types we’re operating over. + When generic spreads are instantiated (or, replaced with a real type) in these tuple types, they can produce other sets of array and tuple types + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function hwtest01(arr: readonly [any, ...T]) { + const [_ignored, ...rest] = arr; + return rest; +} +const anum = [1, 2, 3, 4] as const; +const astr = ["hello", "world"]; +const r1 = hwtest01(anum); +const r2 = hwtest01([...anum, ...astr] as const); +Assert.equal(r2.length, 5); +Assert.equal(r2[0], 2); +Assert.equal(r2[1], 3); +Assert.equal(r2[2], 4); +Assert.equal(r2[3], "hello"); +Assert.equal(r2[4], "world"); diff --git a/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_6.ts b/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_6.ts new file mode 100644 index 0000000000..b732f41dd5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_6.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The second change is that rest elements can occur anywhere in a tuple - not just at the end! + TypeScript 4.0 improves the inference process for rest parameters and rest tuple elements so that we can type this and have it “just work”. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +type ArrStr = [string, string]; +type ArrNum = number[]; +type ASN = [...ArrStr, ...ArrNum, boolean]; +const asn: ASN = ["hello", "world", 1, 2, true]; +Assert.equal(asn.length, 5); +type Arr = readonly any[]; +function hwtest01(arr1: T, arr2: U): [...T, ...U] { + return [...arr1, ...arr2]; +} +const arr1 = [1, 2, 3]; +const arr2 = ["a", "b", "c"]; +const arr3 = hwtest01(arr1, arr2); +Assert.equal(arr3.length, 6); + + +type Arry = readonly unknown[]; + +function hwtest02( + f: (...args: [...T, ...U]) => R, + ...headArgs: T +) { + return (...tailArgs: U) => f(...headArgs, ...tailArgs); +} +function hwtest03(a: number, b: number, c: number): number { + return a + b + c; +} +const add2And3 = hwtest02(hwtest03, 2, 3); +const result = add2And3(4); +Assert.equal(result, 9); diff --git a/es2panda/test/ts_extra_tests/test/4.1/abstract_members_can_not_be_marked_async/abstract_members_can_not_be_marked_async.ts b/es2panda/test/ts_extra_tests/test/4.1/abstract_members_can_not_be_marked_async/abstract_members_can_not_be_marked_async.ts new file mode 100644 index 0000000000..2b2d5d5d6b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.1/abstract_members_can_not_be_marked_async/abstract_members_can_not_be_marked_async.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Members marked as abstract can no longer be marked as async. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +abstract class Animal { + abstract name: string; + abstract eat(): number; + run(): void { } +} +class Dog extends Animal { + name: string = "dog"; + gender: string; + constructor(gender: string) { + super(); + this.gender = gender; + } + eat(): number { + return 1; + } +} +let dog = new Dog("male"); +Assert.equal(dog.eat(), 1); +Assert.equal(dog.name, "dog"); diff --git a/es2panda/test/ts_extra_tests/test/4.1/any_or_unknown_are_propagated_in_falsy_positions/any_or_unknown_are_propagated_in_falsy_positions.ts b/es2panda/test/ts_extra_tests/test/4.1/any_or_unknown_are_propagated_in_falsy_positions/any_or_unknown_are_propagated_in_falsy_positions.ts new file mode 100644 index 0000000000..eb023e6b93 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.1/any_or_unknown_are_propagated_in_falsy_positions/any_or_unknown_are_propagated_in_falsy_positions.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Since nothing is known about the type on the left side of the &&, + we propagate any and unknown outward instead of the type on the right side. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +let unk: unknown; +declare let hwobj: { someProp: string }; +let anyx = unk && hwobj; +function isThing(x: any): boolean { + return x && typeof x === "object" && x.blah === "foo"; +} +let y = isThing(anyx); +Assert.isUndefined(y); diff --git a/es2panda/test/ts_extra_tests/test/4.1/conditional_spreads_create_optional_properties/conditional_spreads_create_optional_properties_1.ts b/es2panda/test/ts_extra_tests/test/4.1/conditional_spreads_create_optional_properties/conditional_spreads_create_optional_properties_1.ts new file mode 100644 index 0000000000..da625e1bfa --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.1/conditional_spreads_create_optional_properties/conditional_spreads_create_optional_properties_1.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the returned type sometimes uses all-optional properties. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +interface HWPerson { + name: string; + age: number; + location: string; +} +interface HWAnimal { + name: string; + owner: HWPerson; +} +function hwtest01(pet?: HWAnimal) { + return { + ...(pet && pet.owner), + otherStuff: 123, + }; +} +let pet: HWAnimal = { + name: "qiqi", + owner: { + name: "owner", + age: 11, + location: "qingdao", + }, +}; +let pet2 = hwtest01(pet); +Assert.equal(pet2.age, 11); +Assert.equal(pet2.name, "owner"); +Assert.equal(pet2.location, "qingdao"); +Assert.equal(pet2.otherStuff, 123); diff --git a/es2panda/test/ts_extra_tests/test/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_1.ts b/es2panda/test/ts_extra_tests/test/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_1.ts new file mode 100644 index 0000000000..8c35c30de0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_1.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + allows you to re-map keys in mapped types with a new as clause. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +type HWGetters = { + [K in keyof T as `get${Capitalize}`]: () => T[K]; +}; +interface HWPerson { + name: string; + age: number; + location: string; +} +type HWPersonType = HWGetters; +let k1: HWPersonType = { + getName() { + return "honny"; + }, + getAge() { + return 22; + }, + getLocation() { + return "qingdao"; + }, +}; +Assert.equal(k1.getName(), "honny"); +Assert.equal(k1.getAge(), 22); +Assert.equal(k1.getLocation(), "qingdao"); diff --git a/es2panda/test/ts_extra_tests/test/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_2.ts b/es2panda/test/ts_extra_tests/test/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_2.ts new file mode 100644 index 0000000000..ac77c09fc5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_2.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + you can even filter out keys by producing never + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +type HWRemoveKindField = { + [K in keyof T as Exclude]: T[K]; +}; +interface Circle { + kind: "circle"; + radius: number; +} +type HWKindlessCircle = HWRemoveKindField; +let k: HWKindlessCircle = { radius: 10 }; +Assert.equal(k.radius, 10); diff --git a/es2panda/test/ts_extra_tests/test/4.1/recursive_conditional_types/recursive_conditional_types.ts b/es2panda/test/ts_extra_tests/test/4.1/recursive_conditional_types/recursive_conditional_types.ts new file mode 100644 index 0000000000..c6193f36c4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.1/recursive_conditional_types/recursive_conditional_types.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + conditional types can now immediately reference themselves within their branches + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +type HWElementType = T extends ReadonlyArray ? HWElementType : T; + +function hwtest01(x: T): HWElementType[] { + return []; +} +let d1 = hwtest01([1, 2, 3]); +type typeofx = typeof d1; +let nx1: typeofx = [1, 2, 3]; +Assert.isNumber(nx1[0]); +let d2 = hwtest01([[1], [2, 3]]); +type typeofx2 = typeof d2; +let nx2: typeofx2 = [4, 5, 6]; +Assert.isNumber(nx2[0]); +let d3 = hwtest01([[1], [[2]], [[[3]]]]); +type typeofx3 = typeof d3; +let nx3: typeofx3 = [7, 8, 9]; +Assert.isNumber(nx3[0]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.1/resolvers_parameters_are_no_longer_optional_in_promises/resolves_parameters_are_no_longer_optional_in_promises.ts b/es2panda/test/ts_extra_tests/test/4.1/resolvers_parameters_are_no_longer_optional_in_promises/resolves_parameters_are_no_longer_optional_in_promises.ts new file mode 100644 index 0000000000..e445c585ce --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.1/resolvers_parameters_are_no_longer_optional_in_promises/resolves_parameters_are_no_longer_optional_in_promises.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + resolve’s Parameters Are No Longer Optional in Promises + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +var p = Promise.resolve(); +var count: number = 1; + +Assert.equal(count, 1); diff --git a/es2panda/test/ts_extra_tests/test/4.1/template_literal_types/template_literal_types_1.ts b/es2panda/test/ts_extra_tests/test/4.1/template_literal_types/template_literal_types_1.ts new file mode 100644 index 0000000000..9e8d9661f2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.1/template_literal_types/template_literal_types_1.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + String literal types in TypeScript allow us to model functions and APIs that expect a set of specific strings. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function getnum(location: "top" | "middle" | "bottom") { + if (location == "top") return 1; + else if (location == "middle") return 2; + else if (location == "bottom") return 3; +} +let num1 = getnum("top"); +let num2 = getnum("middle"); +let num3 = getnum("bottom"); +Assert.equal(num1, 1); +Assert.equal(num2, 2); +Assert.equal(num3, 3); diff --git a/es2panda/test/ts_extra_tests/test/4.1/template_literal_types/template_literal_types_2.ts b/es2panda/test/ts_extra_tests/test/4.1/template_literal_types/template_literal_types_2.ts new file mode 100644 index 0000000000..4c40cd23f1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.1/template_literal_types/template_literal_types_2.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + template literal string type has the same syntax as template literal strings in JavaScript, but is used in type positions. + When you use it with concrete literal types, it produces a new string literal type by concatenating the contents. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +type World = "world"; +type Greeting = `hello ${World}`; +function helloworld(w: World | Greeting) { + if (w == "world") return 1; + else if (w == "hello world") return 2; +} +let saying1 = helloworld("world"); +Assert.equal(saying1, 1); +let saying2 = helloworld("hello world"); +Assert.equal(saying2, 2); +type Color = "red" | "blue"; +type Quantity = "one" | "two"; +type SeussFish = `${Quantity | Color} fish`; +function getfish(fish: SeussFish) { + if (fish == "one fish") return 1; + else if (fish == "two fish") return 2; + else if (fish == "red fish") return "red"; + else if (fish == "blue fish") return "blue"; +} +let fish1 = getfish("one fish"); +Assert.equal(fish1, 1); +let fish2 = getfish("two fish"); +Assert.equal(fish2, 2); +let fish3 = getfish("red fish"); +Assert.equal(fish3, "red"); +let fish4 = getfish("blue fish"); +Assert.equal(fish4, "blue"); diff --git a/es2panda/test/ts_extra_tests/test/4.1/template_literal_types/template_literal_types_3.ts b/es2panda/test/ts_extra_tests/test/4.1/template_literal_types/template_literal_types_3.ts new file mode 100644 index 0000000000..f71571fefc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.1/template_literal_types/template_literal_types_3.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The new type aliases are Uppercase, Lowercase, Capitalize and Uncapitalize. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +type UpperHello = `${Uppercase}`; +type LowerHello = `${Lowercase}`; +type CapHello = `${Capitalize}`; +type UncapHello = `${Uncapitalize}`; +type HELLO = UpperHello<"hello">; +type hello = LowerHello<"HEllO">; +type Hello = CapHello<"hello">; +type hELLO = UncapHello<"HELLO">; +function gethello(hi: HELLO | hello | Hello | hELLO) { + if (hi == "HELLO") return 1; + else if (hi == "hello") return 2; + else if (hi == "Hello") return 3; + else if (hi == "hELLO") return 4; +} +let hi1 = gethello("HELLO"); +Assert.equal(hi1, 1); +let hi2 = gethello("hello"); +Assert.equal(hi2, 2); +let hi3 = gethello("Hello"); +Assert.equal(hi3, 3); +let hi4 = gethello("hELLO"); +Assert.equal(hi4, 4); diff --git a/es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures.ts b/es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures.ts new file mode 100644 index 0000000000..dae3a27a2c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures.ts @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript allows us to mark a class as abstract. This tells TypeScript that the class is only meant to be extended from, and that certain members need to be filled in by any subclass to actually create an instance. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +abstract class Color { + abstract red: number; + abstract green: number; + abstract blue: number; + protected abstract rgb: [number, number, number]; + + abstract getRGB(): [number, number, number]; +} + +class ColorCopy extends Color { + red: number = 0; + green: number = 0; + blue: number = 0; + protected rgb: [number, number, number] = [0, 0, 0]; + getRGB(): [number, number, number] { + this.rgb = [this.red, this.green, this.blue] + return this.rgb; + } + constructor(r: number, g: number, b: number) { + super(); + this.red = r; + this.green = g; + this.blue = b; + this.getRGB(); + } +} + +let color: ColorCopy = new ColorCopy(255, 0, 0); +Assert.equal(JSON.stringify(color.getRGB()), '[255,0,0]'); + +abstract class Point { + abstract a: number; + abstract b: number; + abstract getPoint(): [number, number]; +} + +type MIX = abstract new (...args: any[]) => T + +function mixClass>(Ctor: T) { + abstract class CPColor extends Ctor { + abstract red: number; + abstract green: number; + abstract blue: number; + abstract getColor(): [number, number, number]; + } + return CPColor; +} + +class ColorPoint extends mixClass(Point) { + red: number = 0; + green: number = 0; + blue: number = 0; + a: number = 0; + b: number = 0; + getColor(): [number, number, number] { + return [this.red, this.green, this.blue]; + } + getPoint(): [number, number] { + return [this.a, this.b]; + } + constructor(red: number = 0, green: number = 0, blue: number = 0, a: number = 0, b: number = 0) { + super(); + this.a = a; this.b = b; + this.red = red; this.green = green; this.blue = blue; + } +} + +let cp = new ColorPoint(0, 255, 0, 25, 25); +Assert.equal(JSON.stringify(cp.getColor()), '[0,255,0]'); +Assert.equal(JSON.stringify(cp.getPoint()), '[25,25]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures_1.ts b/es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures_1.ts new file mode 100644 index 0000000000..e3fecca282 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures_1.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Assign an abstract class to anything that expects a construct signature is the right thing in case we intend to run code. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +abstract class myClass { + abstract getMy(): number; +} +interface myInter { + getMy(): number; +} + +function func(myCode: new () => myInter) { + let test = new myCode(); + return test.getMy(); +} + +class my_C extends myClass { + getMy(): number { + return 10; + } +} + +Assert.equal(func(my_C), 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures_3.ts b/es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures_3.ts new file mode 100644 index 0000000000..5f796a4af2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures_3.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The feature allows us to write mixin factories in a way that supports abstract classes. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +abstract class myClass { + abstract h_method(): number; + func() { }; +} + +type myType = abstract new (...args: any[]) => T; + +function myFunc>(value: T) { + abstract class myC extends value { + getS() { + }; + } + return myC; +} + +class h_C extends myFunc(myClass) { + h_method(): number { + return 10; + } +} + +let test = new h_C(); +Assert.equal(test.h_method(), 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types1.ts b/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types1.ts new file mode 100644 index 0000000000..e209c494d1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types1.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In TypeScript, tuple types are meant to model arrays with specific lengths and element types. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + + +let a: [number, number] = [1, 2]; + +let b: [string, number, boolean] = ["hello", 42, true]; + +Assert.equal(JSON.stringify(a), "[1,2]"); +Assert.equal(JSON.stringify(b), "[\"hello\",42,true]"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types2.ts b/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types2.ts new file mode 100644 index 0000000000..97c8d7dd96 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types2.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + they can have optional elements and rest elements, and can even have labels for tooling and readability. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + + +let c: [string, string?] = ["hello"]; +c = ["hello", "world"]; + +let d: [first: string, second?: string] = ["hello"]; +d = ["hello", "world"]; + +let e: [string, string, ...boolean[]]; + +e = ["hello", "world"]; +e = ["hello", "world", false]; +e = ["hello", "world", true, false, true]; + +Assert.equal(JSON.stringify(c), "[\"hello\",\"world\"]"); +Assert.equal(JSON.stringify(e), "[\"hello\",\"world\",true,false,true]"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types3.ts b/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types3.ts new file mode 100644 index 0000000000..5eacd58fc4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types3.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In prior versions, TypeScript only allowed ...rest elements at the very last position of a tuple type.However, now rest elements can occur anywhere within a tuple - with only a few restrictions. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +let f: [...string[], number]; + +f = [123]; +f = ['hello', 123]; +f = ['hello!', 'hello!', 'hello!', 123]; + +let g: [boolean, ...string[], boolean]; + +g = [true, false]; +g = [true, 'some text', false]; +g = [true, 'some', 'separated', 'text', false]; + +Assert.equal(JSON.stringify(f), "[\"hello!\",\"hello!\",\"hello!\",123]"); +Assert.equal(JSON.stringify(g), "[true,\"some\",\"separated\",\"text\",false]"); + diff --git a/es2panda/test/ts_extra_tests/test/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation1.ts b/es2panda/test/ts_extra_tests/test/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation1.ts new file mode 100644 index 0000000000..5af91e419e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation1.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript has always used a set of rules and guesses for when to reuse type aliases when printing out types. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +type NumStrBool = number | string | boolean; + +function hwtest01(value: NumStrBool): NumStrBool { + let x = value; + return x; +} + +let arr = [1, "hello", false]; +Assert.equal(typeof hwtest01(arr[0]), "number"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation2.ts b/es2panda/test/ts_extra_tests/test/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation2.ts new file mode 100644 index 0000000000..d443f765f2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation2.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If we hover our mouse over x in an editor like Visual Studio, Visual Studio Code, or the TypeScript Playground, we’ll get a quick info panel that shows the type BasicPrimitive. Likewise, if we get the declaration file output (.d.ts output) for this file, TypeScript will say that doStuff returns BasicPrimitive. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +type NumStrBool = number | string | boolean; + +function hwtest02(value: NumStrBool) { + return value; +} + +let arr = [10, "hello", false]; +Assert.equal(typeof hwtest02(arr[0]), "number"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.3/always-truthy_promise_checks/always-truthy_promise_checks.ts b/es2panda/test/ts_extra_tests/test/4.3/always-truthy_promise_checks/always-truthy_promise_checks.ts new file mode 100644 index 0000000000..91902ee008 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.3/always-truthy_promise_checks/always-truthy_promise_checks.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Under strictNullChecks, checking whether a Promise is 'truthy' in a conditional will trigger an error. + options: + lib: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +async function getFalse(): Promise { + return false; +} + +async function hwtest(): Promise { + if (!getFalse()) { + return 'false'; + } + return 'true'; +} + +var b = hwtest(); +Assert.equal(b, '[object Promise]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.3/constructorParameters_works_on_abstract_class/constructorParameters_works_on_abstract_class.ts b/es2panda/test/ts_extra_tests/test/4.3/constructorParameters_works_on_abstract_class/constructorParameters_works_on_abstract_class.ts new file mode 100644 index 0000000000..8bd39f4b19 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.3/constructorParameters_works_on_abstract_class/constructorParameters_works_on_abstract_class.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The ConstructorParameters type helper now works on abstract classes. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +abstract class HWC { + a: string; + b: number; + constructor(a: string, b: number) { + this.a = a; + this.b = b; + } +} + +type TypeC = ConstructorParameters; +var c: TypeC = ["s", 10]; +Assert.equal(JSON.stringify(c), '["s",10]'); diff --git a/es2panda/test/ts_extra_tests/test/4.3/separate_write_types_on_properties/separate_write_types_on_properties_1.ts b/es2panda/test/ts_extra_tests/test/4.3/separate_write_types_on_properties/separate_write_types_on_properties_1.ts new file mode 100644 index 0000000000..689e771181 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.3/separate_write_types_on_properties/separate_write_types_on_properties_1.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript 4.3 allows to specify types for reading and writing to properties. + When considering how two properties with the same name relate to each other, TypeScript will only use the "reading" type. + "Writing" types are only considered when directly writing to a property. + options: + target: es2015 + lib: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +class HWC { + #size = 0; + get size(): number { + return this.#size; + } + set size(value: string | number | boolean) { + let num = Number(value); + if (!Number.isFinite(num)) { + this.#size = 0; + return; + } + this.#size = num; + } +} + +let c = new HWC(); + +c.size = "hello"; +c.size = 42; +c.size = true; + +let n: number = c.size; +Assert.equal(typeof n, "number"); diff --git a/es2panda/test/ts_extra_tests/test/4.3/static_index_signatures/static_index_signatures.ts b/es2panda/test/ts_extra_tests/test/4.3/static_index_signatures/static_index_signatures.ts new file mode 100644 index 0000000000..a150462843 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.3/static_index_signatures/static_index_signatures.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Index signatures allow us set more properties on a value than a type explicitly declares, + And index signatures can now be declared as static. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +class HWC { + hello = "hello"; + world = "1213"; + [propName: string]: string | number | undefined; +} + +let hwc = new HWC(); +hwc["whatever"] = 42; +Assert.equal(hwc["whatever"], 42); + +let x = hwc["something"]; +x = undefined; +Assert.isUndefined(x); +x = 20; +Assert.equal(x, 20); +x = "x"; +Assert.equal(x, "x"); + +class HWB { + static hello = "hello"; + static world = 1342; + static [propName: string]: string | number | undefined; +} + +HWB["whatever"] = 42; +Assert.equal(HWB["whatever"], 42); + +let y = HWB["something"]; +y = "y"; +Assert.equal(y, "y"); +y = 10; +Assert.equal(y, 10); +y = undefined; +Assert.isUndefined(y); diff --git a/es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_1.ts b/es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_1.ts new file mode 100644 index 0000000000..bc330388c6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_1.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Template string types are types that either construct new string-like types by concatenating, + or match patterns of other string-like types. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +type Color = "red" | "blue"; +type Num = "one" | "two"; + +type Fish1 = `${Num | Color} fish`; +type Fish2 = "one fish" | "two fish" | "red fish" | "blue fish"; +var fish1: Fish1 = "blue fish"; +var fish2: Fish2 = fish1; +fish1 = "one fish"; +fish2 = fish1; +fish1 = "red fish"; +fish2 = fish1; +fish1 = "two fish"; +fish2 = fish1; + +let s1: `${number}-${number}-${number}`; +let s2: `1-2-3` = `1-2-3`; +s1 = s2; +Assert.equal(s1, "1-2-3"); diff --git a/es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_2.ts b/es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_2.ts new file mode 100644 index 0000000000..503181dcf6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_2.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When a template string is contextually typed by a string-literal-like type it will try to give that expression a template type. + This also kicks in when inferring types, and the type parameter extends string. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +function hwtest(s: string): `hello ${string}` { + // Previously an error, now works + return `hello ${s}`; +} +var b = hwtest("s"); +Assert.equal(b, "hello s"); + +let s: string = "s"; +function f(x: T): T { + return x; +} +let x: `hello ${string}` = f(`hello ${s}`); +Assert.equal(x, "hello s"); diff --git a/es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_3.ts b/es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_3.ts new file mode 100644 index 0000000000..87d00e6a13 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_3.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript can now better-relate, and infer between, different template string types. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +let sn1: `${number}-${number}-${number}`; +let sn2: `1-2-3` = `1-2-3`; +let sn3: `${number}-2-3` = `${4}-2-3`; +let sn4: `1-${number}-3` = `1-${5}-3`; +let sn5: `1-2-${number}` = `1-2-${6}`; +let sn6: `${number}-2-${number}` = `${7}-2-${8}`; + +sn1 = sn2; +Assert.equal(sn1, "1-2-3"); +sn1 = sn3; +Assert.equal(sn1, "4-2-3"); +sn1 = sn4; +Assert.equal(sn1, "1-5-3"); +sn1 = sn5; +Assert.equal(sn1, "1-2-6"); +sn1 = sn6; +Assert.equal(sn1, "7-2-8"); diff --git a/es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_4.ts b/es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_4.ts new file mode 100644 index 0000000000..e08e6ea8f1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_4.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript add better inference capabilities + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +function hwtest01(arg: `*${V}*`): `*${V}*` { + return arg; +} +function hwtest02(s: string, n: number, b: boolean, t: T) { + let x1 = hwtest01("*hello*"); + Assert.equal(x1, "*hello*"); + + let x2 = hwtest01("**hello**"); + Assert.equal(x2, "**hello**"); + + let x3 = hwtest01(`*${s}*` as const); + Assert.equal(x3, "*s*"); + + let x4 = hwtest01(`*${n}*` as const); + Assert.equal(x4, "*5*"); + + let x5 = hwtest01(`*${b}*` as const); + Assert.equal(x5, "*true*"); + + let x6 = hwtest01(`*${t}*` as const); + Assert.equal(x6, "*t*"); + + let x7 = hwtest01(`**${s}**` as const); + Assert.equal(x7, "**s**"); +} + +hwtest02("s", 5, true, "t"); diff --git a/es2panda/test/ts_extra_tests/test/4.3/union_enums_cannot_be_compared_to_arbitrary_numbers/union_enums_cannot_be_compared_to_arbitrary_numbers.ts b/es2panda/test/ts_extra_tests/test/4.3/union_enums_cannot_be_compared_to_arbitrary_numbers/union_enums_cannot_be_compared_to_arbitrary_numbers.ts new file mode 100644 index 0000000000..31df78ced9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.3/union_enums_cannot_be_compared_to_arbitrary_numbers/union_enums_cannot_be_compared_to_arbitrary_numbers.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If a value with a union enum type is compared with a numeric literal that it could never be equal to, + then the type-checker will issue an error. + As a workaround, you can re-write an annotation to include the appropriate literal type. + You can also use a type-assertion on the value. + Alternatively, you can re-declare your enum to have a non-trivial initializer so that any number is both assignable and comparable to that enum. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +enum AB { + A = 0, + B = 1, +} + +function hwtest01(x: AB | -1) { + if (x === -1) { + return -1; + } + return 1; +} +Assert.equal(hwtest01(-1), -1); +Assert.equal(hwtest01(AB.A), 1); + +function hwtest02(x: AB) { + if ((x as number) === -1) { + return x; + } + return x + 1; +} +Assert.equal(hwtest02(AB.A), 1); + +enum ab { + A = +0, + B = 1, +} +function hwtest03(x: ab) { + if (x === 1) { + return x; + } + return x + 2; +} + +Assert.equal(hwtest03(ab.A), 2); +Assert.equal(hwtest03(ab.B), 1); diff --git a/es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_1.ts b/es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_1.ts new file mode 100644 index 0000000000..1ad37b10ed --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_1.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When TypeScript sees that we are testing a constant value, it will do a little bit of extra work to see if it contains a type guard. + If that type guard operates on a const, a readonly property, or an un-modified parameter, + then TypeScript is able to narrow that value appropriately. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function hwtest01(arg: unknown) { + const argIsString = typeof arg === "string"; + if (argIsString) { + Assert.equal(arg.toUpperCase(), "C"); + } +} +hwtest01("c"); + +interface HWTestType { + readonly name: "caihua"; +} +function hwtest02() { + let tt: HWTestType = { name: "caihua" }; + let res = tt.name === "caihua"; + if (res) { + Assert.isNumber(tt.name.length); + Assert.equal(tt.name[0], "c"); + } +} +hwtest02(); + +function hwtest03(a: number, b = "function" as const) { + let cc = typeof b === "function"; + if (cc) { + Assert.isNumber(b.length); + Assert.equal(b[0], "f"); + Assert.equal(cc, true); + } else { + Assert.equal(cc, false); + } +} +hwtest03(12); diff --git a/es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_2.ts b/es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_2.ts new file mode 100644 index 0000000000..50b5b48a74 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_2.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Different sorts of type guard conditions are preserved. For example, checks on discriminated unions + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +type T1 = { kind: "circle"; radius: number }; +type T2 = { kind: "square"; sideLength: number }; +type T3 = T1 | T2; + +let c: T1 = { kind: "circle", radius: 2 }; +let s: T2 = { kind: "square", sideLength: 2 }; + +function hwtest01(shape: T3): number { + const isCircle = shape.kind === "circle"; + if (isCircle) { + return Math.PI * shape.radius ** 2; + } else { + return shape.sideLength ** 2; + } +} +Assert.equal(Math.round(hwtest01(c)), 13); +Assert.equal(hwtest01(s), 4); + +function hwtest02(shape: T3): number { + const { kind } = shape; + if (kind === "circle") { + return Math.PI * shape.radius ** 2; + } else { + return shape.sideLength ** 2; + } +} +Assert.equal(Math.round(hwtest02(c)), 13); +Assert.equal(hwtest02(s), 4); diff --git a/es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_3.ts b/es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_3.ts new file mode 100644 index 0000000000..c58f82364d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_3.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Different sorts of type guard conditions are preserved. + As another example, here’s a function that checks whether two of its inputs have contents. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function hwtest01(a: string | undefined, b: number | undefined, c: boolean) { + const res = a && b && c; + if (res) { + Assert.equal(a.toLowerCase(), "abc"); + Assert.equal(b, 1); + Assert.equal(c, true); + return 1; + } else { + return 0; + } +} +Assert.equal(hwtest01("abc", 1, true), 1); +Assert.equal(hwtest01("abc", undefined, true), 0); diff --git a/es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_4.ts b/es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_4.ts new file mode 100644 index 0000000000..4a965a94e1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_4.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + One neat feature here is that this analysis works transitively. + TypeScript will hop through constants to understand what sorts of checks you’ve already performed. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function isBool(x: string | number | boolean) { + const isString = typeof x === "string"; + const isNumber = typeof x === "number"; + const isStringOrNumber = isString || isNumber; + if (isStringOrNumber) { + return 0; + } else { + return 1; + } +} +Assert.equal(isBool(false), 1); +Assert.equal(isBool("false"), 0); +Assert.equal(isBool(12), 0); diff --git a/es2panda/test/ts_extra_tests/test/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_1.ts b/es2panda/test/ts_extra_tests/test/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_1.ts new file mode 100644 index 0000000000..95ad76c567 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_1.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript 4.4 introduces a new flag called useUnknownInCatchVariables. + This flag changes the default type of catch clause variables from any to unknown. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function hwtest(a: any) { + if (typeof a === "number") { + } else { + throw new Error("type error"); + } +} + +try { + hwtest("string"); +} catch (err) { + Assert.equal(err instanceof Error, true); + if (err instanceof Error) { + Assert.equal(err.message, "type error"); + } +}; diff --git a/es2panda/test/ts_extra_tests/test/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_2.ts b/es2panda/test/ts_extra_tests/test/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_2.ts new file mode 100644 index 0000000000..1257509f4c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_2.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + useUnknownInCatchVariables flag is enabled under the strict family of options. + That means that if you check your code using strict, this option will automatically be turned on + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function hwtest(a: any) { + if (typeof a === "number") { + } else { + throw new Error("type error"); + } +} + +try { + hwtest("string"); +} catch (err) { + Assert.equal(err instanceof Error, true); + if (err instanceof Error) { + Assert.equal(err.message, "type error"); + } +}; diff --git a/es2panda/test/ts_extra_tests/test/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_3.ts b/es2panda/test/ts_extra_tests/test/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_3.ts new file mode 100644 index 0000000000..57673d1968 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_3.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In cases where we don’t want to deal with an unknown variable in a catch clause, + we can always add an explicit : any annotation so that we can opt out of stricter types. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function hwtest(a: any) { + if (typeof a === "number") { + } else { + throw new Error("type error"); + } +} + +try { + hwtest("string"); +} catch (err: any) { + Assert.equal(err instanceof Error, true); + Assert.equal(err.message, "type error"); +}; diff --git a/es2panda/test/ts_extra_tests/test/4.4/exact_optional_property_types/exact_optional_property_types_1.ts b/es2panda/test/ts_extra_tests/test/4.4/exact_optional_property_types/exact_optional_property_types_1.ts new file mode 100644 index 0000000000..1c71d7ec00 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.4/exact_optional_property_types/exact_optional_property_types_1.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In TypeScript 4.4, the new flag exactOptionalPropertyTypes specifies that optional property types + should be interpreted exactly as written, meaning that | undefined is not added to the type + This flag needs to be turned on explicitly. It also requires strictNullChecks to be enabled as well. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +interface HWPerson { + name: string; + age?: number; +} +const p: HWPerson = { + name: "Daniel", +}; +const keys = Object.keys(p); +Assert.equal(keys.indexOf("age"), -1); +Assert.equal(typeof p.age, "undefined"); +Assert.notEqual(typeof p.age, "number"); + +p.age = 12; +Assert.equal(typeof p.age, "number"); +Assert.notEqual(typeof p.age, "undefined"); diff --git a/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_1.ts b/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_1.ts new file mode 100644 index 0000000000..1e76b73f88 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_1.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript lets us describe objects where every property has to have a certain type using index signatures. + This allows us to use these objects as dictionary-like types, where we can use string keys to index into them with square brackets. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +interface HWTest { + [key: string]: any; +} +let t: HWTest = {}; +t["1"] = 1; +t["2"] = "1"; +const keys = Object.keys(t); +keys.forEach((item) => { + Assert.isString(item); +}); diff --git a/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_2.ts b/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_2.ts new file mode 100644 index 0000000000..f35585ecd5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_2.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Array already defines a number index signature that lets us insert/retrieve values of type T + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +let arr: Array = []; +arr[0] = "a"; +Assert.equal(arr[0], "a"); +Assert.isString(arr[0]); +arr[1] = 12; +Assert.equal(arr[1], 12); +Assert.isNumber(arr[1]); diff --git a/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_3.ts b/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_3.ts new file mode 100644 index 0000000000..14aa9339f1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_3.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: TypeScript 4.4 allows index signatures for symbols and template string patterns. + options: + lib:es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +interface HWColor { + [keys: number]: any; +} +const red = Symbol("red"); +const green = Symbol("green"); +const blue = Symbol("blue"); + +let c: HWColor = {}; +c[red] = 0xff0000; +c[green] = 0x00ff00; +c[blue] = 0x0000ff; +Assert.isNumber(c[red]); + + diff --git a/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_4.ts b/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_4.ts new file mode 100644 index 0000000000..c754460623 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_4.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: we can write an index signature with template string pattern type + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +interface HWI1 { + name: string; + age: number; +} +interface HWI2 extends HWI1 { + [optName: number]: any; +} +let a: HWI2 = { + name: "wangcai", + age: 20 +}; +Assert.isString(a.name); +Assert.isNumber(a.age); + diff --git a/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_5.ts b/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_5.ts new file mode 100644 index 0000000000..cea4503d47 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_5.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + index signatures now permit union types,as long as they’re a union of infinite-domain primitive types + specifically:string,number,symbol,template string patterns + An index signature whose argument is a union of these types will de-sugar into several different index signatures. + options: + lib:es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +interface HWDI1 { + [key: number ]: any; +} +interface HWDI2 { + + [key: number]: any; +} +interface HWDI3 extends HWDI2 { + [key: number]: any; +} +const one = Symbol(1); +let a: HWDI1 = {}; +let b: HWDI3 = {}; +b[one] = 1; +a = b; +Assert.equal(a[one], 1); + diff --git a/es2panda/test/ts_extra_tests/test/4.5/disabling_import_elision/animal.ts b/es2panda/test/ts_extra_tests/test/4.5/disabling_import_elision/animal.ts new file mode 100644 index 0000000000..6e8b68ee43 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.5/disabling_import_elision/animal.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export class Animal { + color: string; + age: number; + gender: string; + constructor(color: string, age: number, gender: string) { + this.color = color; + this.age = age; + this.gender = gender; + } +} + +export { Animal as animal }; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.5/disabling_import_elision/disabling_import_elision_1.ts b/es2panda/test/ts_extra_tests/test/4.5/disabling_import_elision/disabling_import_elision_1.ts new file mode 100644 index 0000000000..22a16b12f0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.5/disabling_import_elision/disabling_import_elision_1.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript 4.5, you can enable a new flag called preserveValueImports to prevent TypeScript + from stripping out any imported values from your JavaScript outputs. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js"; +import { animal } from "./animal.js"; + +Assert.isFunction(animal); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.5/private_field_presence_checks/private_field_presence_checks_1.ts b/es2panda/test/ts_extra_tests/test/4.5/private_field_presence_checks/private_field_presence_checks_1.ts new file mode 100644 index 0000000000..cf7f2ca6c2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.5/private_field_presence_checks/private_field_presence_checks_1.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + You can now write a class with a #private field member and see whether another object has the same field by using the in operator. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +class HWP { + #name: string; + constructor(name: string) { + this.#name = name; + } + + equals(other: any) { + return other && + typeof other === "object" && + this.#name === other.#name; + } +} + +const men = new HWP('jack'); +const women = new HWP('marry'); +Assert.equal(women.equals(men), false); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types1.ts b/es2panda/test/ts_extra_tests/test/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types1.ts new file mode 100644 index 0000000000..d02f72e2ed --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types1.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + As long as one branch of a conditional type is simply another conditional type, TypeScript can avoid intermediate instantiations. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" + +type HWT1 = T extends ` ${infer Rest}` ? HWT1 : T; + +type HWT2 = HWT1<" oops">; +var t: HWT2 = "oops"; +Assert.equal(t, "oops"); diff --git a/es2panda/test/ts_extra_tests/test/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts b/es2panda/test/ts_extra_tests/test/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts new file mode 100644 index 0000000000..1cf1fc96fe --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The following type won't be optimized, since it uses the result of a conditional type by adding it to a union. + You can introduce a helper that takes an "accumulator" type parameter to make it tail-recursive + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" + +type HWGetChars = S extends `${infer Char}${infer Rest}` + ? Char | HWGetChars + : never; +type gc = HWGetChars<" getChar">; +var g1: gc = "e"; +Assert.isString(g1); + +type HWGetChars1 = HWGetCharsHelper; +type HWGetCharsHelper = S extends `${infer Char}${infer Rest}` + ? HWGetCharsHelper + : Acc; + +type gch = HWGetCharsHelper; +var g2: gch = 10; +Assert.isNumber(g2); diff --git a/es2panda/test/ts_extra_tests/test/4.5/template_string_types_as_discriminants/template_string_types_as_discriminants_1.ts b/es2panda/test/ts_extra_tests/test/4.5/template_string_types_as_discriminants/template_string_types_as_discriminants_1.ts new file mode 100644 index 0000000000..3704a08b34 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.5/template_string_types_as_discriminants/template_string_types_as_discriminants_1.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: > + TypeScript 4.5 now can narrow values that have template string types, and also recognizes template string types as discriminants. +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" + +interface Message { + type: string; + url: string; +} + +interface SuccessMessage { + type: `${string}Success`; + body: string; +} + +interface ErrorMessage { + type: `${string}Error`; + message: string; +} + +function hwtest(r: SuccessMessage | ErrorMessage) { + if (r.type === "HttpSuccess") { + let token = r.body; + Assert.equal(r.type, "HttpSuccess"); + } else { + Assert.equal(r.type, "HttpError"); + } +} + +const successMessage: SuccessMessage = { + type: "HttpSuccess", + body: "request success" +} + +const errorMessage: ErrorMessage = { + type: "HttpError", + message: "100-continue" +} + +hwtest(successMessage); +hwtest(errorMessage); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.5/the_awaited_type_and_promise_improvements/the_awaited_type_and_promise_improvements_1.ts b/es2panda/test/ts_extra_tests/test/4.5/the_awaited_type_and_promise_improvements/the_awaited_type_and_promise_improvements_1.ts new file mode 100644 index 0000000000..489442a606 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.5/the_awaited_type_and_promise_improvements/the_awaited_type_and_promise_improvements_1.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript 4.5 introduces a new utility type called the Awaited type. + This type is meant to model operations like await in async functions, + or the .then() method on Promises - specifically, the way that they recursively unwrap Promises; + some of the problems around inference with Promise.all served as motivations for Awaited. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" + + +function MaybePromise(value: number): number | Promise | PromiseLike { + return new Promise((resolve, reject) => { + resolve(Math.random()); + }); +} + +async function doSomething(): Promise<[number, number]> { + const result = await Promise.all([MaybePromise(100), MaybePromise(200)]); + return result; +} + +let D = doSomething().then(res => { + Assert.isObject(res, "object"); +}); + +type E = Awaited>; + +let e: E; +Assert.equal(e, undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.5/type_modifiers_on_import_names/some-module.ts b/es2panda/test/ts_extra_tests/test/4.5/type_modifiers_on_import_names/some-module.ts new file mode 100644 index 0000000000..1a7b34d361 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.5/type_modifiers_on_import_names/some-module.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +let num = 5; +export let someFunc = function () { + return 10 + num; +}; + +export class BaseType { }; diff --git a/es2panda/test/ts_extra_tests/test/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts b/es2panda/test/ts_extra_tests/test/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts new file mode 100644 index 0000000000..e86a71c41d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- +description: > + That’s part of why TypeScript 4.5 allows a type modifier on individual named imports. + BaseType is always guaranteed to be erased and someFunc will be preserved under preserveValueImports. +module: ESNext +isCurrent: true +---*/ + + +import { Assert } from "../../../suite/assert.js" +import { someFunc, BaseType } from "./some-module.js" + + +export class Thing implements BaseType { + someMethod() { + someFunc(); + } +} + +const thing = new Thing(); +Assert.isFunction(Thing); +Assert.isObject(thing); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.6/1_allowing_code_in_constructors.ts b/es2panda/test/ts_extra_tests/test/4.6/1_allowing_code_in_constructors.ts new file mode 100644 index 0000000000..60b2f505fa --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.6/1_allowing_code_in_constructors.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: TypeScript 4.6 is now much more lenient in that check and permits other code to run before super()., all while still ensuring that super() occurs at the top-level before any references to this. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../suite/assert.js' + +class HWB1 { } + +class HWB2 extends HWB1 { + bool = true; + + constructor() { + super(); + this.bool = false; + } + + getBool(): boolean { + return this.bool; + } + + +} + + +let d = new HWB2(); + +Assert.equal(false, d.getBool()); + diff --git a/es2panda/test/ts_extra_tests/test/4.6/2_control_flow_analysis.ts b/es2panda/test/ts_extra_tests/test/4.6/2_control_flow_analysis.ts new file mode 100644 index 0000000000..d8fece6f5c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.6/2_control_flow_analysis.ts @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: TypeScript is able to narrow types based on what’s called a discriminant property. For example, in the following code snippet, TypeScript is able to narrow the type of action based on every time we check against the value of kind. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../suite/assert.js' + +type HWA = + | { kind: "NumberContents"; payload: number } + | { kind: "StringContents"; payload: string }; + +function hwtest01(action: HWA) { + if (action.kind === "NumberContents") { + // `action.payload` is a number here. + let num = action.payload * 2; + return num; + } else if (action.kind === "StringContents") { + // `action.payload` is a string here. + const str = action.payload.trim(); + return str; + } +} + +let action1: HWA = { + kind: "NumberContents", + payload: 1 +} + +let action2: HWA = { + kind: "StringContents", + payload: " 1234 " +} + +Assert.equal(2, hwtest01(action1)); +Assert.equal("1234", hwtest01(action2)); + + +// you might have wanted to destructure kind and payload in the the example above. +type Action2 = + | { kind: "NumberContents"; payload: number } + | { kind: "StringContents"; payload: string }; + +function hwtest02(action: Action2) { + const { kind, payload } = action; + if (kind === "NumberContents") { + let num = payload * 2; + return num; + } else if (kind === "StringContents") { + const str = payload.trim(); + return str; + } +} + + +let action3: HWA = { + kind: "NumberContents", + payload: 2 +} + +let action4: HWA = { + kind: "StringContents", + payload: " 5678 " +} + +Assert.equal(4, hwtest02(action3)); +Assert.equal("5678", hwtest02(action4)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.6/3_improved_recursion_depth_checks.ts b/es2panda/test/ts_extra_tests/test/4.6/3_improved_recursion_depth_checks.ts new file mode 100644 index 0000000000..f897799b72 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.6/3_improved_recursion_depth_checks.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Improved Recursion Depth Checks + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../suite/assert.js' + +// In a structural type system, object types are compatible based on the members they have. +interface HWA { + prop: HWA>; +} + +interface HWB { + prop: HWB>; +} + +function hwtest(source: HWA, target: HWB) { + target = source; +} + + +interface HWC { + prop: T; +} + +let x: HWC>>>>>; +let y: HWC>>>>; + + +y = { prop: { prop: { prop: { prop: { prop: "prop" } } } } } +x = { prop: y }; + +Assert.isString("x = y; this is error"); +Assert.notEqual(JSON.stringify(x), JSON.stringify(y)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.6/4_indexed_access_inference_improvements.ts b/es2panda/test/ts_extra_tests/test/4.6/4_indexed_access_inference_improvements.ts new file mode 100644 index 0000000000..4b247cc4a9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.6/4_indexed_access_inference_improvements.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: TypeScript now can correctly infer to indexed access types which immediately index into a mapped object type. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../suite/assert.js' + +interface HWI01 { + number: number; + string: string; + boolean: boolean; +} + +type HWI02

= { + [K in P]: { + kind: K; + v: HWI01[K]; + f: (p: HWI01[K]) => void; + }; +}[P]; + +function hwtest(record: HWI02) { + record.f(record.v); +} + +hwtest({ + kind: "string", + v: "hello!", + f: (val) => { + Assert.equal("HELLO!", val.toUpperCase()); + }, +}); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.6/5_control_flow_analysis_for_dependent_parameters.ts b/es2panda/test/ts_extra_tests/test/4.6/5_control_flow_analysis_for_dependent_parameters.ts new file mode 100644 index 0000000000..58072b6aaa --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.6/5_control_flow_analysis_for_dependent_parameters.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: A signature can be declared with a rest parameter whose type is a discriminated union of tuples. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../suite/assert.js' + +type HWT01 = (...args: ["a", number] | ["b", string]) => void; + +const hwf: HWT01 = (kind, payload) => { + if (kind === "a") { + Assert.equal(42, payload.toFixed()); + } + if (kind === "b") { + Assert.equal("HELLO", payload.toUpperCase()); + } +}; + +hwf("a", 42); +hwf("b", "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access.ts b/es2panda/test/ts_extra_tests/test/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access.ts new file mode 100644 index 0000000000..a8eea7425f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript 4.7 now narrows the types of element accesses when the indexed keys are literal types and unique symbols. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +const sym = Symbol(); + +const numstr = Math.random() < 0.5 ? 42 : "hello"; + +const obj = { + [sym]: numstr, +}; + +if (typeof obj[sym] === "string") { + let str = obj[sym].toUpperCase(); + Assert.equal(str, "HELLO"); +}; diff --git a/es2panda/test/ts_extra_tests/test/4.7/extends_constraints_on_infer_type_variables/extends_constraints_on_infer_type_variables.ts b/es2panda/test/ts_extra_tests/test/4.7/extends_constraints_on_infer_type_variables/extends_constraints_on_infer_type_variables.ts new file mode 100644 index 0000000000..0231ad2eb6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.7/extends_constraints_on_infer_type_variables/extends_constraints_on_infer_type_variables.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Conditional types are a bit of a power-user feature. + They allow us to match and infer against the shape of types, and make decisions based on them. + To avoid that second level of nesting, TypeScript 4.7 now allows to place a constraint on any infer type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +type FStr1 = T extends [infer S, ...unknown[]] + ? S extends string + ? S + : boolean + : boolean; + +type FStr2 = T extends [infer S extends string, ...unknown[]] ? S : boolean; + +let A1: FStr1<[string, number, number]> = "A1"; +let A2: FStr2<[string, number, number]> = "A2"; +Assert.isString(A1); +Assert.isString(A2); + +let B1: FStr1<["hello", number, number]> = "hello"; +let B2: FStr2<["hello", number, number]> = "hello"; +Assert.equal(B1, "hello"); +Assert.equal(B2, "hello"); + +let C1: FStr1<["hello" | "world", boolean]> = "hello"; +Assert.equal(C1, "hello"); +let C2: FStr2<["hello" | "world", boolean]> = "world"; +Assert.equal(C2, "world"); +C1 = "world"; +Assert.equal(C1, "world"); +C2 = "hello"; +Assert.equal(C2, "hello"); + +let D1: FStr1<[object, number, string]> = false; +Assert.isBoolean(D1); +let D2: FStr2<[object, number, string]> = false; +Assert.isBoolean(D2); diff --git a/es2panda/test/ts_extra_tests/test/4.7/improved_function_inference_in_objects_and_methods/improved_function_inference_in_objects_and_methods.ts b/es2panda/test/ts_extra_tests/test/4.7/improved_function_inference_in_objects_and_methods/improved_function_inference_in_objects_and_methods.ts new file mode 100644 index 0000000000..f32dee01f2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.7/improved_function_inference_in_objects_and_methods/improved_function_inference_in_objects_and_methods.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript 4.7 can now perform more granular inferences from functions within objects and arrays. + This allows the types of these functions to consistently flow in a left-to-right manner just like for plain arguments. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +function hwtest(arg: { + produce: (n: string) => T; + consume: (x: T) => void; +}): void { } + +var a = hwtest({ + produce: () => "hello", + consume: (x) => x.toLowerCase(), +}); +Assert.isUndefined(a); + +var b = hwtest({ + produce: (n: string) => n, + consume: (x) => x.toLowerCase(), +}); +Assert.isUndefined(b); + +var c = hwtest({ + produce: (n) => n, + consume: (x) => x.toLowerCase(), +}); +Assert.isUndefined(c); + +var d = hwtest({ + produce: function () { + return "hello"; + }, + consume: (x) => x.toLowerCase(), +}); +Assert.isUndefined(d); + +var e = hwtest({ + produce() { + return "hello"; + }, + consume: (x) => x.toLowerCase(), +}); +Assert.isUndefined(e); diff --git a/es2panda/test/ts_extra_tests/test/4.7/instantiation_expressions/instantiation_expressions.ts b/es2panda/test/ts_extra_tests/test/4.7/instantiation_expressions/instantiation_expressions.ts new file mode 100644 index 0000000000..00cb29d8fe --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.7/instantiation_expressions/instantiation_expressions.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript 4.7 allows exactly that we can now take functions and constructors and feed them type arguments directly. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +interface HWI1 { + value: T; +} +interface HWI2 { + name: string; +} +interface HWI3 { + use: string; +} +function hwtest(value: T) { + return { value }; +} + +const m1 = hwtest({ name: "hammer" }); +Assert.equal(JSON.stringify(m1), '{"value":{"name":"hammer"}}'); +const m2 = hwtest({ use: "turn the screw" }); +Assert.equal(JSON.stringify(m2), '{"value":{"use":"turn the screw"}}'); diff --git a/es2panda/test/ts_extra_tests/test/4.7/optional_variance_annotations_for_type_parameters/optional_variance_annotations_for_type_parameters.ts b/es2panda/test/ts_extra_tests/test/4.7/optional_variance_annotations_for_type_parameters/optional_variance_annotations_for_type_parameters.ts new file mode 100644 index 0000000000..7c05355af3 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.7/optional_variance_annotations_for_type_parameters/optional_variance_annotations_for_type_parameters.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + With TypeScript 4.7, we're now able to explicitly specify variance on type parameters. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + + +class Dog { + dogType: any; +} + +type Setter = (value) => void; +let animal2: Setter = (): any => { }; +let dog2: Setter= (): any => { }; +dog2 = animal2; +Assert.isTrue(dog2 == animal2); diff --git a/es2panda/test/ts_extra_tests/test/4.7/readonly_tuples_have_a_readonly_length_property/readonly_tuples_have_a_readonly_length_property.ts b/es2panda/test/ts_extra_tests/test/4.7/readonly_tuples_have_a_readonly_length_property/readonly_tuples_have_a_readonly_length_property.ts new file mode 100644 index 0000000000..ebb5869458 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.7/readonly_tuples_have_a_readonly_length_property/readonly_tuples_have_a_readonly_length_property.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A readonly tuple will now treat its length property as readonly. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function hwtest(tuple: readonly [string, string, string]) { + return tuple.length; +} +var a = hwtest(['a', 'b', 'c']); +Assert.equal(a, 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.8/improved_inference_for_infer_types_in_template_string_types/improved_inference_for_infer_types_in_template_string_types.ts b/es2panda/test/ts_extra_tests/test/4.8/improved_inference_for_infer_types_in_template_string_types/improved_inference_for_infer_types_in_template_string_types.ts new file mode 100644 index 0000000000..bc733ae4eb --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.8/improved_inference_for_infer_types_in_template_string_types/improved_inference_for_infer_types_in_template_string_types.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + typescript recently introduced a way to add extends constraints to infer type variables in conditional types. + if these infer types appear in a template string type and are constrained to a primitive type, TypeScript will now try to parse out a literal type. + this can now better convey what a library will do at runtime, and give more precise types. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +type TrySetVIfFirst = T extends [infer U extends V, ...unknown[]] ? U : never; +function setFirst(arr: any[], x: TrySetVIfFirst<[T, ...any], V>) { + arr[0] = x; + return arr; +} +let arr = ["A", "B", "C"]; +let first = setFirst(arr, 65); +Assert.equal(JSON.stringify(first), "[65,\"B\",\"C\"]"); + +type SomeNum = "100" extends `${infer U extends number}` ? U : never; +type SomeBigInt = "100" extends `${infer U extends bigint}` ? U : never; +type SomeBool = "true" extends `${infer U extends boolean}` ? U : never; +let sn: SomeNum = 100; +let sbi: SomeBigInt = 100n; +let sbool: SomeBool = true; +Assert.equal(sn, 100); +Assert.equal(sbi, 100n); +Assert.equal(sbool, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.9/auto_accessors_in_classes/auto_accessors_in_classes.ts b/es2panda/test/ts_extra_tests/test/4.9/auto_accessors_in_classes/auto_accessors_in_classes.ts new file mode 100644 index 0000000000..e34cbf1ec2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.9/auto_accessors_in_classes/auto_accessors_in_classes.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + typescript 4.9 makes the in operator a little bit more powerful when narrowing types that don’t list the property at all. + options: + target: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +class NormalClass { + #_str: string; + get str(): string { + return this.#_str; + } + set str(value: string) { + this.#_str = value; + } + constructor(str: string) { + this.#_str = str; + } +} +class AutoClass { + str: string; + constructor(str: string) { + this.str = str; + } +} + +let c1 = new NormalClass("0"); +let c2 = new AutoClass("0"); +c1.str = "NormalClass"; +Assert.equal(c1.str, "NormalClass"); +c2.str = "AutoClass"; +Assert.equal(c2.str, "AutoClass"); diff --git a/es2panda/test/ts_extra_tests/test/4.9/checks_for_equality_on_NaN/checks_for_equality_on_NaN.ts b/es2panda/test/ts_extra_tests/test/4.9/checks_for_equality_on_NaN/checks_for_equality_on_NaN.ts new file mode 100644 index 0000000000..1793962aa0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.9/checks_for_equality_on_NaN/checks_for_equality_on_NaN.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + typescript now errors on direct comparisons against NaN, and will suggest using some variation of Number.isNaN instead. + options: + lib: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +function notNaN(x: number) { + return !Number.isNaN(x); +} +Assert.isFalse(notNaN(NaN)); +Assert.isTrue(notNaN(0)); diff --git a/es2panda/test/ts_extra_tests/test/4.9/the_satisfies_operator/the_satisfies_operator.ts b/es2panda/test/ts_extra_tests/test/4.9/the_satisfies_operator/the_satisfies_operator.ts new file mode 100644 index 0000000000..243116bc2d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.9/the_satisfies_operator/the_satisfies_operator.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the new satisfies operator lets us validate that the type of an expression matches some type, without changing the resulting type of that expression. + module: es2020 + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +type Colors = "Red" | "Green" | "Blue"; +type RGB = [Red: number, Green: number, Blue: number]; +const rgbData = { + Red: [255, 0, 0], + Green: "0x00ff00", + Blue: [0, 0, 255], +}; + +const favoriteColors = { + "Red": "yes", + "Green": false, + "Blue": "kinda", +}; + +const redComponent = rgbData.Red.length; +const greenUpperCase = rgbData.Green.toUpperCase(); +const g: boolean = favoriteColors.Green; + +Assert.equal(redComponent, 3); +Assert.equal(greenUpperCase, "0X00FF00"); +Assert.isFalse(g); diff --git a/es2panda/test/ts_extra_tests/test/4.9/unlisted_property_narrowing_with_the_in_operator/unlisted_property_narrowing_with_the_in_operator.ts b/es2panda/test/ts_extra_tests/test/4.9/unlisted_property_narrowing_with_the_in_operator/unlisted_property_narrowing_with_the_in_operator.ts new file mode 100644 index 0000000000..9fb4f82aee --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.9/unlisted_property_narrowing_with_the_in_operator/unlisted_property_narrowing_with_the_in_operator.ts @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + typescript 4.9 makes the in operator a little bit more powerful when narrowing types that don’t list the property at all. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +interface RGBIN { + red: number; + green: number; + blue: number; +} + +interface HSV { + hue: number; + saturation: number; + value: number; +} + +function setColor(color: RGBIN | HSV) { + if ("hue" in color && "red" in color) { + return "RGBIN | HSV"; + } else if ("hue" in color) { + return "HSV"; + } else if ("red" in color) { + return "RGBIN"; + } +} +var c1: RGBIN = { red: 0, green: 0, blue: 0 }; +var c2: HSV = { hue: 0, saturation: 0, value: 0 }; +var c3: RGBIN | HSV = { hue: 0, saturation: 0, value: 0, red: 0, green: 0, blue: 0 }; + +Assert.equal(setColor(c1), "RGBIN"); +Assert.equal(setColor(c2), "HSV"); +Assert.equal(setColor(c3), "RGBIN | HSV"); + +interface Package { + JSON: unknown; +} + +function getPackageName(pak: Package): string { + const p:any = pak.JSON; + if (p && typeof p === "object") { + if ("name" in p && typeof p.name === "string") { + return p.name; + } + } + return "no JSON"; +} +let pak: Package = { JSON: { name: "JSON" } }; +let none: Package = { JSON: "null" }; +let out1 = getPackageName(pak); +let out2 = getPackageName(none); + +Assert.equal(out1, "JSON"); +Assert.equal(out2, "no JSON"); diff --git a/es2panda/test/ts_extra_tests/test/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts b/es2panda/test/ts_extra_tests/test/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts new file mode 100644 index 0000000000..5c835b2811 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + an ambient function declaration introduces a function in the containing declaration space. + ambient functions may be overloaded by specifying multiple ambient function declarations with the same name, but it is an error to declare multiple overloads that are considered identical or differ only in their return types. + ambient function declarations cannot specify a function bodies and do not permit default parameter values. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +declare type DF1 = () => void; +declare type DF2 = (a: string, b: string) => string; +declare type DF3 = (a: number, b?: number) => string; +declare function fun1(): void; +declare function fun2(a: number): string; +const dFun1: DF1 = () => { Assert.isString("dFun1"); } + +const dFun2: DF2 = (a: string, b: string) => { Assert.isString("dFun2"); return a + b; } + +const dFun3: DF3 = (a: number, b?: number) => { + var c: any; + if (b != undefined) { + c = a + b; + } else { + c = a; + } + c = c.toString(); + Assert.isString("dFun3"); + return "$" + c; +} + +dFun1(); +Assert.equal(dFun2("A", "B"), 'AB'); +Assert.equal(dFun3(10, 20), "$30"); diff --git a/es2panda/test/ts_extra_tests/test/spec/ambients/ambient_declarations/ambient_namespace_declarations/ambient_namespace_declarations.ts b/es2panda/test/ts_extra_tests/test/spec/ambients/ambient_declarations/ambient_namespace_declarations/ambient_namespace_declarations.ts new file mode 100644 index 0000000000..50a4a5d529 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/ambients/ambient_declarations/ambient_namespace_declarations/ambient_namespace_declarations.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + an ambient namespace declaration declares a namespace. + except for ImportAliasDeclarations, AmbientNamespaceElements always declare exported entities regardless of whether they include the optional export modifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +declare namespace AmbientNamespace { + var an1: string; + export var an2: string; + interface ColorInterface { + Red: number; + Green: number; + Blue: number; + } +} +var colorI: AmbientNamespace.ColorInterface = { Red: 0, Green: 1, Blue: 2 }; +Assert.equal(JSON.stringify(colorI), '{"Red":0,"Green":1,"Blue":2}'); diff --git a/es2panda/test/ts_extra_tests/test/spec/ambients/ambient_module_declarations/ambient_module_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/ambients/ambient_module_declarations/ambient_module_declarations_1.ts new file mode 100644 index 0000000000..2db8f0b7bc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/ambients/ambient_module_declarations/ambient_module_declarations_1.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + ambient modules are "open-ended" and ambient module declarations with the same string literal name contribute to a single module. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../../suite/assert.js" + +declare module AMD1 { + export var a1: any; + export interface AMD1IF { + a1_1: any; + a1_2: number; + } +} + +var am2: AMD1.AMD1IF = { a1_1: "am2", a1_2: 123 }; +Assert.equal(JSON.stringify(am2), '{"a1_1":"am2","a1_2":123}'); diff --git a/es2panda/test/ts_extra_tests/test/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts b/es2panda/test/ts_extra_tests/test/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts new file mode 100644 index 0000000000..877c0341d7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + if an ambient module declaration includes an export assignment, it is an error for any of the declarations within the module to specify an export modifier. + if an ambient module declaration contains no export assignment, entities declared in the module are exported regardless of whether their declarations include the optional export modifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +export declare module AMD3_1 { + interface AMD3_1IF { + a3_1: boolean; + a3_2: number; + } + var AMD2Var1: string; +} +declare module AMD3_2 { + export interface AMD3_2IF { + a3_1: boolean; + a3_2: string; + } + export var AMD2Var1: string; +} + +var am3_1: AMD3_1.AMD3_1IF = { a3_1: false, a3_2: 0 }; +var am3_2: AMD3_2.AMD3_2IF = { a3_1: true, a3_2: "T" }; +Assert.equal(JSON.stringify(am3_1), '{"a3_1":false,"a3_2":0}'); +Assert.equal(JSON.stringify(am3_2), '{"a3_1":true,"a3_2":"T"}'); diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/declarations/declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/declarations/declarations_1.ts new file mode 100644 index 0000000000..6bec3bd20b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/declarations/declarations_1.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A name that denotes a value has an associated type and can be referenced in expressions. + A name that denotes a type can be used by itself in a type reference or on the right hand side of a dot in a type reference. + A name that denotes a namespace can be used on the left hand side of a dot in a type reference. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +// name denotes a value +var X: string = "X is string"; +Assert.equal("X is string1", X + "1"); + +// name denotes a type +type X = String | Number; +var x: X = "xx"; +Assert.equal("xx", x); + +// name denotes a namespace +namespace X { + export type Y = string; +} +var y: X.Y = "ystr"; +Assert.equal("ystr", y); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/declarations/declarations_2.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/declarations/declarations_2.ts new file mode 100644 index 0000000000..681e422701 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/declarations/declarations_2.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Declarations introduce the following meanings for the name they declare: + A variable, parameter, function, generator, member variable, member function, member accessor, or enum member declaration introduces a value meaning. + An interface, type alias, or type parameter declaration introduces a type meaning. + A class declaration introduces a value meaning (the constructor function) and a type meaning (the class type). + An enum declaration introduces a value meaning (the enum instance) and a type meaning (the enum type). + A namespace declaration introduces a namespace meaning (the type and namespace container) and, if the namespace is instantiated, a value meaning (the namespace instance). + An import or export declaration introduces the meaning(s) of the imported or exported entity. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +// class declaration +class C { + x: string; + constructor(x: string) { + this.x = x; + } +} +var c: C = new C("x"); +Assert.equal(c.x, "x"); + +// enum declaration +enum WeekDay { + MON = 1, + TUE, + WEN, + THU, + FRI, + SAT, + SUN +} +type a = WeekDay; +var mon: a = WeekDay.MON; +Assert.equal(mon, 1); + +// namespace declaration +namespace N { + export let x: string = "x"; +} +Assert.equal(N.x, "x"); diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/computed_property_names/computed_property_names_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/computed_property_names/computed_property_names_1.ts new file mode 100644 index 0000000000..855ee181ed --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/computed_property_names/computed_property_names_1.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + ECMAScript 2015 permits object literals and classes to declare members with computed property names. + A computed property name specifies an expression that computes the actual property name at run-time. + options: + lib: es6 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class ComputedName { + // computed property name with a well-known symbol name have a simple literal type + aa: 1 | undefined; + // computed property name have a simple literal type + ["address"]: string; + constructor(x: string, y: 1) { + this.address = x; + if (y === 1) { + this.aa = y; + } else { + this.aa = undefined; + } + } +} +var c: ComputedName = new ComputedName("address No1", 1); +Assert.equal(1, c.aa); +Assert.equal("address No1", c.address); + +// computed property name with in object literal +var objectliteral = { ["xx" + "123".length]: 22, name: "string" }; +Assert.equal(22, objectliteral.xx3); diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/property_names/property_names_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/property_names/property_names_1.ts new file mode 100644 index 0000000000..279e16f4df --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/property_names/property_names_1.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A property name can be any identifier (including a reserved word), a string literal, a numeric literal, + or a computed property name. String literals may be used to give properties names that are not valid identifiers, + such as names containing blanks. Numeric literal property names are equivalent to string literal property names + with the string representation of the numeric literal, as defined in the ECMAScript specification. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Property { + // reserved word as property name + break: string; + // string literal as property name + "with blank": number; + // numeric literal as property name + 1: boolean; + constructor(x: string, y: number, z: boolean) { + this.break = x; + this["with blank"] = y; + this[1] = z; + } +} + +var p: Property = new Property("abc", 12, false); +Assert.equal("abc", p.break); +Assert.equal(12, p["with blank"]); +Assert.equal(false, p[1]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_2.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_2.ts new file mode 100644 index 0000000000..765a4646cd --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_2.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: any cannot be type name, but are otherwise not restricted. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +var any: string = "any"; +Assert.equal(any, "any"); diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_2.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_2.ts new file mode 100644 index 0000000000..16b81ee496 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_2.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: boolean cannot be type name, but are otherwise not restricted. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +var boolean: number = 0; +Assert.equal(boolean, 0); diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_2.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_2.ts new file mode 100644 index 0000000000..fb82eab8a2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_2.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: number cannot be type name, but are otherwise not restricted. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +var number: string = "number"; +Assert.equal(number, "number"); diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_2.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_2.ts new file mode 100644 index 0000000000..ae0243b991 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_2.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: string cannot be type name, but are otherwise not restricted. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +var string: number = 10; +Assert.equal(string, 10); diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_2.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_2.ts new file mode 100644 index 0000000000..0b2457ac18 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_2.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: symbol cannot be type name, but are otherwise not restricted. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +var symbol: string = "any"; +Assert.equal(symbol, "any"); diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_1.ts new file mode 100644 index 0000000000..f2245aa4c4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_1.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: abstract is valid identifier + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +var abstract: string = "abstract"; +Assert.equal(abstract, "abstract"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_2.ts new file mode 100644 index 0000000000..2b22fef997 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_2.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: abstract is valid identifier + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +function abstract(): string { + return "abstract"; +} +Assert.equal(abstract(), "abstract"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_3.ts new file mode 100644 index 0000000000..7ce5b7d580 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_3.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: abstract is valid identifier + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +class abstract { + name: string; + constructor(name: string) { + this.name = name; + } + getName(): string { + return this.name; + } +} +var newobj = new abstract("abstract"); +Assert.equal(newobj.getName(), "abstract"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_4.ts new file mode 100644 index 0000000000..a06c5abb67 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_4.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: abstract is valid identifier + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +interface abstruct { + name: string, + getName: () => string +} +var customer: abstruct = { + name: "abstruct", + getName(): string { + return this.name; + } +} +Assert.equal(customer.name, "abstruct"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_1.ts new file mode 100644 index 0000000000..4a0cf23f27 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_1.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: as is valid identifier + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +var as: string = "as"; +Assert.equal(as, "as"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_2.ts new file mode 100644 index 0000000000..ec61e3aa21 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_2.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: as is valid identifier + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +function as(): string { + return "as"; +} +Assert.equal(as(), "as"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_3.ts new file mode 100644 index 0000000000..b42a1fdd7d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_3.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: as is valid identifier + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +class as { + name: string; + constructor(name: string) { + this.name = name; + } + getName(): string { + return this.name; + } +} +var newobj = new as("as"); +Assert.equal(newobj.getName(), "as"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_4.ts new file mode 100644 index 0000000000..1eb01c1d3b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_4.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: as is valid identifier + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +interface as { + name: string, + getName: () => string +} +var customer: as = { + name: "as", + getName(): string { + return this.name; + } +} +Assert.equal(customer.name, "as"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_1.ts new file mode 100644 index 0000000000..676457a5b2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_1.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: async is valid identifier + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +var async: string = "async"; +Assert.equal(async, "async"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_2.ts new file mode 100644 index 0000000000..4b6e6e9b57 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_2.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: async is valid identifier + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +function async(): string { + return "async"; +} +Assert.equal(async(), "async"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_3.ts new file mode 100644 index 0000000000..fdb6480948 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_3.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: async is valid identifier + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +class async { + name: string; + constructor(name: string) { + this.name = name; + } + getName(): string { + return this.name; + } +} +var newobj = new async("async"); +Assert.equal(newobj.getName(), "async"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_4.ts new file mode 100644 index 0000000000..6c20af07d1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_4.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: async is valid identifier + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +interface async { + name: string, + getName: () => string +} +var customer: async = { + name: "async", + getName(): string { + return this.name; + } +} +Assert.equal(customer.name, "async"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_1.ts new file mode 100644 index 0000000000..34de3bf84b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_1.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'constructor' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +var constructor: string = "constructor"; +Assert.equal(constructor, "constructor"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_2.ts new file mode 100644 index 0000000000..17c7cc39a7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_2.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'constructor' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +function constructor(): string { + return "constructor"; +} +Assert.equal(constructor(), "constructor"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_3.ts new file mode 100644 index 0000000000..711349b149 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_3.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'constructor' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +class constructor { + name: string; + constructor(name: string) { + this.name = name; + } + getName(): string { + return this.name; + } +} +var newobj = new constructor("constructor"); +Assert.equal(newobj.getName(), "constructor"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_4.ts new file mode 100644 index 0000000000..a0e571e0aa --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_4.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'constructor' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +interface constructor { + name: string, + getName: () => string +} +var customer: constructor = { + name: "constructor", + getName(): string { + return this.name; + } +} +Assert.equal(customer.name, "constructor"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_1.ts new file mode 100644 index 0000000000..aac04f3d37 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_1.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'declare' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +var declare: string = "declare"; +Assert.equal(declare, "declare"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_2.ts new file mode 100644 index 0000000000..bb41f4d113 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_2.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'declare' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +function declare(): string { + return "declare"; +} +Assert.equal(declare(), "declare"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_3.ts new file mode 100644 index 0000000000..b81f44896d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_3.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'declare' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +class declare { + name: string; + constructor(name: string) { + this.name = name; + } + getName(): string { + return this.name; + } +} +var newobj = new declare("declare"); +Assert.equal(newobj.getName(), "declare"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_4.ts new file mode 100644 index 0000000000..f315768977 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_4.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'declare' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +interface declare { + name: string, + getName: () => string +} +var customer: declare = { + name: "declare", + getName(): string { + return this.name; + } +} +Assert.equal(customer.name, "declare"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_1.ts new file mode 100644 index 0000000000..f7c3ea544e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_1.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'from' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +var from: string = "from"; +Assert.equal(from, "from"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_2.ts new file mode 100644 index 0000000000..1900fe5d1b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_2.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'from' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +function from(): string { + return "from"; +} +Assert.equal(from(), "from"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_3.ts new file mode 100644 index 0000000000..c1c86b2b49 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_3.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'from' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +class from { + name: string; + constructor(name: string) { + this.name = name; + } + getName(): string { + return this.name; + } +} +var newobj = new from("from"); +Assert.equal(newobj.getName(), "from"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_4.ts new file mode 100644 index 0000000000..9862bfc8e5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_4.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'from' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +interface from { + name: string, + getName: () => string +} +var customer: from = { + name: "from", + getName(): string { + return this.name; + } +} +Assert.equal(customer.name, "from"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_1.ts new file mode 100644 index 0000000000..299b54e6cc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_1.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'get' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +var get: string = "get"; +Assert.equal(get, "get"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_2.ts new file mode 100644 index 0000000000..1ed9abdd41 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_2.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'get' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +function get(): string { + return "get"; +} +Assert.equal(get(), "get"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_3.ts new file mode 100644 index 0000000000..48ade41aea --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_3.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'get' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +class get { + name: string; + constructor(name: string) { + this.name = name; + } + getName(): string { + return this.name; + } +} +var newobj = new get("get"); +Assert.equal(newobj.getName(), "get"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_4.ts new file mode 100644 index 0000000000..7aeffc88a8 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_4.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'get' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +interface get { + name: string, + getName: () => string +} +var customer: get = { + name: "get", + getName(): string { + return this.name; + } +} +Assert.equal(customer.name, "get"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_1.ts new file mode 100644 index 0000000000..1fe4f7ea78 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_1.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'is' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +var is: string = "is"; +Assert.equal(is, "is"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_2.ts new file mode 100644 index 0000000000..bd17391c72 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_2.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'is' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +function is(): string { + return "is"; +} +Assert.equal(is(), "is"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_3.ts new file mode 100644 index 0000000000..ae9fdb3c57 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_3.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'is' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +class is { + name: string; + constructor(name: string) { + this.name = name; + } + getName(): string { + return this.name; + } +} +var newobj = new is("is"); +Assert.equal(newobj.getName(), "is"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_4.ts new file mode 100644 index 0000000000..21d321bf4f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_4.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'is' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +interface is { + name: string, + getName: () => string +} +var customer: is = { + name: "is", + getName(): string { + return this.name; + } +} +Assert.equal(customer.name, "is"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_1.ts new file mode 100644 index 0000000000..a8439b34c1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_1.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'module' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +var module2: string = "module"; +Assert.equal(module2, "module"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_2.ts new file mode 100644 index 0000000000..4931884599 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_2.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'module' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + + +function module1(): string { + return "module"; +} + +Assert.equal(module1(), "module"); diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_3.ts new file mode 100644 index 0000000000..0782ed97f8 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_3.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'module' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +{ + class module { + name: string; + + constructor(name: string) { + this.name = name; + } + + getName(): string { + return this.name; + } + } + + var newobj = new module("module"); + Assert.equal(newobj.getName(), "module"); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_4.ts new file mode 100644 index 0000000000..fe05033736 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_4.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'module' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +interface module { + name: string, + getName: () => string +} +var customer: module = { + name: "module", + getName(): string { + return this.name; + } +} +Assert.equal(customer.name, "module"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_1.ts new file mode 100644 index 0000000000..bceffbe726 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_1.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'namespace' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +var namespace: string = "namespace"; +Assert.equal(namespace, "namespace"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_2.ts new file mode 100644 index 0000000000..13b73f89b7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_2.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'namespace' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +function namespace(): string { + return "namespace"; +} +Assert.equal(namespace(), "namespace"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_3.ts new file mode 100644 index 0000000000..fa58b1e6c1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_3.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'namespace' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +class namespace { + name: string; + constructor(name: string) { + this.name = name; + } + getName(): string { + return this.name; + } +} +var newobj = new namespace("namespace"); +Assert.equal(newobj.getName(), "namespace"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_4.ts new file mode 100644 index 0000000000..3be3526411 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_4.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'namespace' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +interface namespace { + name: string, + getName: () => string +} +var customer: namespace = { + name: "namespace", + getName(): string { + return this.name; + } +} +Assert.equal(customer.name, "namespace"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_1.ts new file mode 100644 index 0000000000..d50c317607 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_1.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'of' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +var of: string = "of"; +Assert.equal(of, "of"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_2.ts new file mode 100644 index 0000000000..08ffa6cddf --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_2.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'of' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +function of(): string { + return "of"; +} +Assert.equal(of(), "of"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_3.ts new file mode 100644 index 0000000000..47d4f7a37f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_3.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'of' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +class of { + name: string; + constructor(name: string) { + this.name = name; + } + getName(): string { + return this.name; + } +} +var newobj = new of("of"); +Assert.equal(newobj.getName(), "of"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_4.ts new file mode 100644 index 0000000000..8f31d65c4f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_4.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'of' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +interface of { + name: string, + getName: () => string +} +var customer: of = { + name: "of", + getName(): string { + return this.name; + } +} +Assert.equal(customer.name, "of"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/require_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/require_is_valid_identifier_1.ts new file mode 100644 index 0000000000..d5908d19d8 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/require_is_valid_identifier_1.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'require' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +interface require { + name: string, + getName: () => string +} +var customer: require = { + name: "require", + getName(): string { + return this.name; + } +} +Assert.equal(customer.name, "require"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_1.ts new file mode 100644 index 0000000000..e0b5607cf1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_1.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'set' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +var set: string = "set"; +Assert.equal(set, "set"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_2.ts new file mode 100644 index 0000000000..65a32d4ed1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_2.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'set' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +function set(): string { + return "set"; +} +Assert.equal(set(), "set"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_3.ts new file mode 100644 index 0000000000..0ce429bfbb --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_3.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'set' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +class set { + name: string; + constructor(name: string) { + this.name = name; + } + getName(): string { + return this.name; + } +} +var newobj = new set("set"); +Assert.equal(newobj.getName(), "set"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_4.ts new file mode 100644 index 0000000000..b0279a2228 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_4.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'set' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +interface set { + name: string, + getName: () => string +} +var customer: set = { + name: "set", + getName(): string { + return this.name; + } +} +Assert.equal(customer.name, "set"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_1.ts new file mode 100644 index 0000000000..3bec40eb37 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_1.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'type' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +var type: string = "type"; +Assert.equal(type, "type"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_2.ts new file mode 100644 index 0000000000..4c9e57cc56 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_2.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'type' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +function type(): string { + return "type"; +} +Assert.equal(type(), "type"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_3.ts new file mode 100644 index 0000000000..d7ef405195 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_3.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'type' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +class type { + name: string; + constructor(name: string) { + this.name = name; + } + getName(): string { + return this.name; + } +} +var newobj = new type("type"); +Assert.equal(newobj.getName(), "type"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_4.ts new file mode 100644 index 0000000000..995036f95a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_4.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The keywords 'type' has special meaning in certain contexts, but is valid identifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +interface type { + name: string, + getName: () => string +} +var customer: type = { + name: "type", + getName(): string { + return this.name; + } +} +Assert.equal(customer.name, "type"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/let_scope.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/let_scope.ts new file mode 100644 index 0000000000..43f18b965b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/let_scope.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The scope of a local let declared immediately within a statement block is the body of that statement block. + The scope of a local let declaration declared immediately within the body of a function-like declaration is the body of that function-like declaration. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let GlobalScope = 1; + +function someFunc() { + let FunctionScope = 2; + if (true) { + let BlockScope = 3; + Assert.equal(FunctionScope, 2); + Assert.equal(BlockScope, 3); + } + Assert.equal(GlobalScope, 1); +} +someFunc(); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/namespace.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/namespace.ts new file mode 100644 index 0000000000..956317955e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/namespace.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + locally declared entities in a namespace are closer in scope than exported entities declared in other namespace declarations for the same namespace. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var num = 1; +namespace ns { + export var num = 2; + Assert.equal(num, 2); +} +namespace ns { + Assert.equal(num, 2); +} +namespace ns { + var num = 3; + Assert.equal(num, 3); +} \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/var_scope.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/var_scope.ts new file mode 100644 index 0000000000..1346a9affe --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/var_scope.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The scope of a local var name declared anywhere in the body of a function-like declaration is the body of that function-like declaration. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var GlobalScope = 1; + +function someFunc() { + var FunctionScope = 2; + if (true) { + var BlockScope = 3; + } + Assert.equal(FunctionScope, 2); + Assert.equal(BlockScope, 3); +} +Assert.equal(GlobalScope, 1); +someFunc(); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_body/class_body.ts b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_body/class_body.ts new file mode 100644 index 0000000000..65b420216b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_body/class_body.ts @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The class body consists of zero or more constructor or member declarations. + Statements are not allowed in the body of a class—they must be placed in the constructor or in members. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class P { + num1: number; + num2: number; + constructor(num1: number, num2: number) { + this.num1 = num1; + this.num2 = num2; + } + public hypot() { + return Math.sqrt(this.num1 * this.num1 + this.num2 * this.num2); + } + static initial = new P(0, 0); +} +var p: P = new P(10, 20); +Assert.equal(10, p.num1); +Assert.equal(20, p.num2); + +// zero constructor +class Circle { + radius: number = 1; +} +const c = new Circle(); +Assert.equal(c.radius, 1); + +// more constructor +type TypeSummation = { + width?: number; + height?: number; +}; +class summation { + public width: number; + public height: number; + constructor(width: number, height: number); + constructor(ParamObje_: TypeSummation); + constructor(ParamObje_Obj_: any, height_ = 0) { + if (typeof ParamObje_Obj_ === "object") { + const { width, height } = ParamObje_Obj_; + this.width = width; + this.height = height; + } else { + this.width = ParamObje_Obj_; + this.height = height_; + } + } + sunArea(): number { + return this.width * this.height; + } +} +const sun = new summation(4, 5); +Assert.equal(sun.sunArea(), 20); +const obj: TypeSummation = { width: 10, height: 2 }; +const sun2 = new summation(obj); +Assert.equal(sun2.sunArea(), 20); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts new file mode 100644 index 0000000000..4f3e141121 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A class declaration declares a class type and a constructor function: class BindingIdentifieropt TypeParametersopt ClassHeritage { ClassBody } + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class P { + constructor(public num1: number, public num2: number) { } + public hypot() { + return Math.sqrt(this.num1 * this.num1 + this.num2 * this.num2); + } + static initial = new P(0, 0); +} + +var p: P = new P(10, 20); +Assert.equal(10, p.num1); +Assert.equal(20, p.num2); + +class ChildP extends P { + constructor(public x: number, public y: number) { + super(x, y); + } + public move() { + this.x += 1; + this.y += 1; + } +} + +var pChild: ChildP = new ChildP(10, 20); +pChild.move(); +Assert.equal(11, pChild.x); +Assert.equal(21, pChild.y); +class MyClass { + field: T; + constructor(field: T) { + this.field = field; + } + + public getFieldName(): T { + return this.field; + } +} +let mc: MyClass = new MyClass("a"); +Assert.equal("a", mc.field); +let mc2: MyClass = new MyClass(1); +Assert.equal(1, mc2.field); +let mc3: MyClass = new MyClass(false); +Assert.equal(false, mc3.field); +let mc4: MyClass = new MyClass(pChild); +Assert.isTrue(mc4.field instanceof ChildP); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts new file mode 100644 index 0000000000..2eda0a2895 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The heritage specification of a class consists of optional extends and implements clauses. + The extends clause specifies the base class of the class + and the implements clause specifies a set of interfaces for which to validate the class provides an implementation. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class P { + constructor(public num1: number, public num2: number) { } + public hypot() { + return Math.sqrt(this.num1 * this.num1 + this.num2 * this.num2); + } + static initial = new P(0, 0); +} + +var p: P = new P(10, 20); +Assert.equal(10, p.num1); +Assert.equal(20, p.num2); +// the extends +class ChildP extends P { + constructor(public x: number, public y: number) { + super(x, y); + } + public move() { + this.x += 1; + this.y += 1; + } +} +var pChild: ChildP = new ChildP(10, 20); +pChild.move(); +Assert.equal(11, pChild.x); +Assert.equal(21, pChild.y); +// the implements +interface InterP { + x: number; + y: number; +} +class P2 implements InterP { + x = 1; + y = 1; + setarea(x: number, y: number) { + return x * y; + } +} +var ipoint = new P2(); +Assert.equal(1, ipoint.x); +Assert.equal(1, ipoint.y); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts new file mode 100644 index 0000000000..90b7b218b2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The this-type (section 3.6.3) of the declared class + must be assignable (section 3.11.4) to the base type reference + and each of the type references listed in the implements clause. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Point { + constructor(public x: number = 0) { } + public add(): this { + this.x++; + return this; + } +} +var p: Point = new Point(10); +Assert.equal(11, p.add().x); +// the extends +class ChildPoint extends Point { + constructor(public x: number = 0) { + super(x); + } + public move(): this { + this.x++; + return this; + } +} +var pChild: ChildPoint = new ChildPoint(10); +Assert.equal(11, pChild.move().x); +var basePoint: Point = pChild.move(); +Assert.equal(13, basePoint.add().x); +// the implements +interface InterPoint { + x: number; +} +class Point2 implements InterPoint { + x = 1; + setadd(): this { + this.x++; + return this; + } +} +var ipoint = new Point2(); +Assert.equal(2, ipoint.setadd().x); +var interpoint: InterPoint = ipoint.setadd(); +Assert.equal(3, interpoint.x); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts new file mode 100644 index 0000000000..8446e99901 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + as is the case with every object type, type references (section 3.3.1) to the class + will appear to have the members of the global interface type named 'Object' + unless those members are hidden by members with the same name in the class. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class P { + constructor(public num1: number, public num2: number) { } + public hypot() { } + static initial = new P(0, 0); +} + +let p = new P(1, 2); +let obj = new Object(); +Assert.equal(p.toString(), obj.toString()); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_5.ts b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_5.ts new file mode 100644 index 0000000000..fe2cbfd833 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_5.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A class may optionally have type parameters. A class with type parameters is called a generic class. + The type parameters of a generic class declaration are in scope in the entire declaration and may be referenced in the ClassHeritage and ClassBody. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class MyClass{ + myArry: T[] = []; + add(num: T): void { + this.myArry.push(num); + } + max(): T { + var mNum = this.myArry[0]; + for (var i = 0; i < this.myArry.length; i++) { + if (mNum < this.myArry[i]) { + mNum = this.myArry[i]; + } + } + return mNum; + } +} +var h_m = new MyClass(); +h_m.add(5); +h_m.add(4); +h_m.add(9); +h_m.add(15); +Assert.equal(h_m.max(), 15); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_6.ts b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_6.ts new file mode 100644 index 0000000000..6a9d96087a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_6.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A class that includes an extends clause is called a derived class, + and the class specified in the extends clause is called the base class of the derived class. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Person { + name: string; + age: number; + constructor(name: string, age: number) { + this.name = name; + this.age = age; + } + introduce() { + return 'I am a college student'; + } +} +class Student extends Person { + constructor(name: string, age: number) { + super(name, age); + } +} +var m_C = new Student('xiao', 18); +Assert.equal(m_C.introduce(), 'I am a college student'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_1.ts b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_1.ts new file mode 100644 index 0000000000..ff4aea69c4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_1.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If a class omits a constructor declaration, an automatic constructor is provided. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class A { + x: number = 1; + y: string = "go"; +} +let a = new A(); +Assert.equal(a.x, 1); +Assert.equal(a.y, "go"); +class B { + x: number; + y: string; + constructor(x: number = 1, y: string = "go") { + this.x = x; + this.y = y; + } +} +let b = new B(); +Assert.equal(a.x, 1); +Assert.equal(a.y, "go"); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_2.ts b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_2.ts new file mode 100644 index 0000000000..44f4e7b5db --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_2.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a derived class, the automatic constructor has the same parameter list (and possibly overloads) as the base class constructor. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Point1 { + x: string; + y: string; + constructor(x: string, y: string) { + this.x = x; + this.y = y; + } + toString() { + return this.x + " " + this.y; + } +} +class ColorPoint extends Point1 { + color: string; + constructor(x: string, y: string, color: string) { + super(x, y); + this.color = color; + } + toString() { + return this.color + " " + super.toString(); + } +} +let co = new ColorPoint("A", "B", "blue"); +Assert.equal(co.x, "A"); +Assert.equal(co.y, "B"); +Assert.equal(co.color, "blue"); +Assert.equal(co.toString(), "blue A B"); +class ColorPoint2 extends Point1 { + constructor(x: string, y: string) { + super(x, y); + } +} +let co2 = new ColorPoint2("a", "b"); +Assert.equal(co2.x, "a"); +Assert.equal(co2.y, "b"); +Assert.equal(co2.toString(), "a b"); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_3.ts b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_3.ts new file mode 100644 index 0000000000..4c6e6d93f1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_3.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a class with no extends clause, the automatic constructor has no parameters + and performs no action other than executing the instance member variable initializers (section 8.4.1), if any. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Foo { + constructor(public x: number = 1, public y: string = "go") { + this.x = x; + this.y = y; + } +} +let foo = new Foo(); +Assert.equal(foo.x, 1); +Assert.equal(foo.y, "go"); +class Foo2 { + x: number; + y: string; + constructor(x: number, y: string) { + this.x = x; + this.y = y; + } +} +let foo2 = new Foo2(2, "go"); +Assert.equal(foo2.x, 2); +Assert.equal(foo2.y, "go"); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts new file mode 100644 index 0000000000..a2b1b75a0f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Constructor declarations that specify a body are called constructor implementations and + constructor declarations without a body are called constructor overloads. + It is possible to specify multiple constructor overloads in a class, + but a class can have at most one constructor implementation. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Animal1 { + name: string | undefined; + age: number | undefined; + constructor(); + constructor(name: string); + constructor(age: number); + constructor(name: string, age: number); + constructor(nameorage?: string | number, age?: number) { + if (typeof nameorage == "number") { + this.age = nameorage; + } + if (typeof nameorage == "string") { + this.name = nameorage; + } + if (age) { + this.age = age; + } + } +} +let tt1 = new Animal1(); +let tt2 = new Animal1("caihua2", 12); +Assert.equal(tt2.name, "caihua2"); +Assert.equal(tt2.age, 12); +let tt3 = new Animal1("caihua3"); +Assert.equal(tt3.name, "caihua3"); +let tt4 = new Animal1(1230); +Assert.equal(tt4.age, 1230); + diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts new file mode 100644 index 0000000000..7160740278 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A parameter of a ConstructorImplementation may be prefixed with a public, private, or protected modifier. + This is called a parameter property declaration and is shorthand for declaring a property with the same name as the parameter + and initializing it with the value of the parameter. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class P1 { + constructor(public num1: number, private num2: number = 1) { } + get foo(): number { + return this.num2; + } +} +class Point2 { + public num1: number; + protected num2: number; + constructor(num1: number, num2: number) { + this.num1 = num1; + this.num2 = num2; + } + get foo(): number { + return this.num2; + } +} +let p1 = new P1(1, 2); +Assert.equal(p1.num1, 1); +Assert.equal(p1.foo, 2); +let p2 = new Point2(3, 4); +Assert.equal(p2.foo, 4); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_3.ts b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_3.ts new file mode 100644 index 0000000000..2c0cd465a8 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_3.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The function body of a constructor is permitted to contain return statements. If return statements specify expressions, + those expressions must be of types that are assignable to the this-type of the class. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + + +class myClass1 { + num: number; + constructor(num: number) { + this.num = num + return; + } +} + +var myTest1 = new myClass1(5); +Assert.equal(myTest1.num, 5); + +class myClass2 { + num: number; + constructor(num: number) { + this.num = num + return { num: 10 }; + } +} + +var myTest2 = new myClass2(5); +Assert.equal(myTest2.num, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_4.ts b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_4.ts new file mode 100644 index 0000000000..cca29f29f0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_4.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The type parameters of a generic class are in scope and accessible in a constructor declaration. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class myClass{ + num: T; + constructor(num: T) { + this.num = num; + } +} +var myTest = new myClass(10); +Assert.isNumber(myTest.num); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_5.ts b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_5.ts new file mode 100644 index 0000000000..6852182d4d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_5.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A parameter property declaration may declare an optional parameter, + but the property introduced by such a declaration is always considered a required property. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class myClass { + constructor(public num1: number, public num2?: number, public num3: number = 10) { + this.num1 = num1; + this.num2 = num2; + this.num3 = num3; + } +} +var myTest = new myClass(3); +Assert.equal(myTest.num1, 3); +Assert.isUndefined(myTest.num2); +Assert.equal(myTest.num3, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/super_calls/super_calls.ts b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/super_calls/super_calls.ts new file mode 100644 index 0000000000..c1488a9aa0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/super_calls/super_calls.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Super calls (section 4.9.1) are used to call the constructor of the base class. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class P { + public num1: number; + public num2: number; + constructor(num1: number, num2: number) { + this.num1 = num1; + this.num2 = num2; + } +} +class HueP extends P { + constructor(num1: number, num2: number, public hue: string) { + super(num1, num2); + } +} +let p1 = new HueP(1, 2, "red"); +Assert.equal(p1.num1, 1); +Assert.equal(p1.num2, 2); +Assert.equal(p1.hue, "red"); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/index_member_declarations/index_member_declarations.ts b/es2panda/test/ts_extra_tests/test/spec/classes/index_member_declarations/index_member_declarations.ts new file mode 100644 index 0000000000..b721607bcf --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/index_member_declarations/index_member_declarations.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + All instance property members of a class must satisfy + the constraints implied by the index members of the class as specified in section 3.9.4. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class ind { + name: string; + [index: string]: number | string; + constructor(name: string) { + this.name = name; + } +} +let a = new ind("aa"); +a.name = "pig"; +a.age = 12; +Assert.equal(a.age, 12); +a.add = "qindao"; +Assert.equal(a.add, "qindao"); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_1.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_1.ts new file mode 100644 index 0000000000..efbeb274c2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_1.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Public property members can be accessed everywhere without restrictions. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Base { + public a: number = 2; +} + +class Derived extends Base { + public b() { + return this.a; + } +} +const derived = new Derived(); +let a = derived.a; +Assert.equal(a, 2); +let b = derived.b(); +Assert.equal(b, 2); +const base = new Base(); +a = base.a; +Assert.equal(a, 2); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_2.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_2.ts new file mode 100644 index 0000000000..aff50e9204 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_2.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Private property members can be accessed only within their declaring class. Specifically, + a private member M declared in a class C can be accessed only within the class body of C. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Base { + private x: number = 1; + add() { + this.x++; + } + get foo() { + return this.x; + } +} +const a: Base = new Base(); +a.add(); +Assert.equal(a.foo, 2); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_3.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_3.ts new file mode 100644 index 0000000000..5b798caaea --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_3.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Protected property members can be accessed only within their declaring class and classes derived from their declaring class, + and a protected instance property member must be accessed through an instance of the enclosing class or a subclass thereof. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Base { + protected x: number = 1; + add() { + this.x++; + } + get foo() { + return this.x; + } +} +class Derived extends Base { + get foo() { + return this.x; + } +} +const a: Base = new Base(); +a.add(); +Assert.equal(a.foo, 2); +const b: Derived = new Derived(); +b.add(); +Assert.equal(b.foo, 2); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types.ts new file mode 100644 index 0000000000..e6832615d9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A class declaration declares a new named type called a class type. + Within the constructor and instance member functions of a class, the type of this is the this-type of that class type + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class h_A { + public h_x: number; + public h_f() { } + public h_g(h_a: any): any { + return undefined; + } + constructor(h_x: number) { + this.h_x = h_x; + } + static h_s: string; +} +let h_a = new h_A(1); +class h_B extends h_A { + public h_y: number; + public h_g(h_b: boolean) { return false; } + constructor(h_x: number, h_y: number) { + super(h_x); + this.h_y = h_y; + } +} +let h_b = new h_B(1, 2); +interface h_C { + h_x: number; + h_f: () => void; + h_g: (h_a: any) => any; +} +let h_c: h_C = h_a; +Assert.equal(h_c.h_g(1), undefined); +interface h_D { + h_x: number; + h_y: number; + h_f: () => void; + h_g: (h_b: boolean) => boolean; +} +let h_d: h_D = h_b; +Assert.isFalse(h_d.h_g(true)); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_1.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_1.ts new file mode 100644 index 0000000000..1d0b696a3c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_1.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the class contains no constructor declaration and has no base class, + a single construct signature with no parameters, + having the same type parameters as the class (if any) + and returning an instantiation of the class type with those type parameters passed as type arguments. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class A { + a: number = 0; + b: number = 0; + constructor() { } +} +let a = new A(); +Assert.equal(a.a, 0); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_2.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_2.ts new file mode 100644 index 0000000000..84aea38fb7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_2.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the class contains no constructor declaration and has a base class, + a set of construct signatures with the same parameters as those of the base class constructor function type + following substitution of type parameters with the type arguments specified in the base class type reference, + all having the same type parameters as the class. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class A1 { + public num: number; + constructor(a: number) { + this.num = a; + } +} +class B1 extends A1 { + public numb: number; + constructor(a: number, b: number) { + super(a); + this.numb = b; + } +} +const b = new B1(2, 2); +Assert.equal(b.num, 2); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_3.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_3.ts new file mode 100644 index 0000000000..b954cb847f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_3.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the class contains a constructor declaration with no overloads, + a construct signature with the parameter list of the constructor implementation, + having the same type parameters as the class (if any) + and returning an instantiation of the class type with those type parameters passed as type arguments. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class A { + r: number; + constructor(r: number) { + this.r = r; + } +} +let a = new A(1); +Assert.equal(a.r, 1); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_4.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_4.ts new file mode 100644 index 0000000000..3b586b165e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_4.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the class contains a constructor declaration with overloads, a set of construct signatures + with the parameter lists of the overloads, all having the same type parameters as the class (if any) + and returning an instantiation of the class type with those type parameters passed as type arguments. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +type TypeSummation = { + width?: number; + height?: number; +}; +class summation { + public width; + public height; + constructor(width: number, height: number); + constructor(ParamObje_: TypeSummation); + constructor(ParamObje_Obj_: any, height_ = 0) { + if (typeof ParamObje_Obj_ === "object") { + const { width, height } = ParamObje_Obj_; + this.width = width; + this.height = height; + } else { + this.width = ParamObje_Obj_; + this.height = height_; + } + } + sunArea(): number { + return this.width * this.height; + } +} +const sun = new summation(4, 5); +Assert.equal(sun.sunArea(), 20); +const obj: TypeSummation = { width: 10, height: 20 }; +Assert.equal(new summation(obj).sunArea(), 200); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts new file mode 100644 index 0000000000..4e0c13e613 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Every class automatically contains a static property member named 'prototype', + the type of which is the containing class with type Any substituted for each type parameter. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class P { + constructor(public pro1: T1, public pro2: T2) { } +} +class TwoArrays extends P { } +let x: number = 1; +let y: number = 2; +let p = new P(x, y); +Assert.equal(p.pro1, 1); +let x2: string = "one"; +let y2: string = "two"; +let p2 = new P(x2, y2); +Assert.equal(p2.pro1, "one"); +let x3: boolean = true; +let p3 = new P(x3, y); +Assert.isBoolean(p3.pro1); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_1.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_1.ts new file mode 100644 index 0000000000..500e6eb8ad --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_1.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A derived class inherits all members from its base class it doesn't override. + Inheritance means that a derived class implicitly contains all non-overridden members of the base class. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Shape { + color: string = "black"; + switchColor() { + this.color = this.color === "black" ? "white" : "black"; + } +} +class Circle extends Shape { } +const circle = new Circle(); +let a = circle.color; +Assert.equal(a, "black"); +circle.switchColor(); +let b = circle.color; +Assert.equal(b, "white"); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_2.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_2.ts new file mode 100644 index 0000000000..aa3105f80f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_2.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A property member in a derived class is said to override a property member in a base class + when the derived class property member has the same name and kind (instance or static) as the base class property member. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Shape { + color: string = "black"; + switchColor() { + this.color = this.color === "black" ? "white" : "black"; + } +} +class Circle extends Shape { + color: string = "red"; + + switchColor() { + this.color = this.color === "red" ? "green" : "red"; + } +} +const circle = new Circle(); +let a = circle.color; +Assert.equal(a, "red"); +circle.switchColor(); +let b = circle.color; +Assert.equal(b, "green"); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_3.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_3.ts new file mode 100644 index 0000000000..288514a9b5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_3.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Base class static property members can be overridden by derived class static property members + of any kind as long as the types are compatible, as described above. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Shape { + static color: string = "black"; + static switchColor() { + this.color = this.color === "black" ? "white" : "black"; + } +} +class Circle extends Shape { + static color: string = "red"; + + static switchColor() { + this.color = this.color === "red" ? "green" : "red"; + } +} +let a = Circle.color; +Assert.equal(a, "red"); +Circle.switchColor(); +let b = Circle.color; +Assert.equal(b, "green"); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_4.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_4.ts new file mode 100644 index 0000000000..c1abb4f2e9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_4.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Base class instance member variables and accessors can be overridden by derived class instance member variables and accessors. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class MyClass { + num: number = 20; + constructor(num: number) { + this.num = num; + } + get() { + return this.num + } + set(num: number) { + this.num = num; + } +} +class myClass extends MyClass { + constructor(num: number) { + super(num); + this.num = num; + } + get() { + return 10 + } + set(num: number) { + this.num = num; + } +} + +let myTest = new myClass(5); +Assert.equal(myTest.num, 5); +Assert.equal(myTest.get(), 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_1.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_1.ts new file mode 100644 index 0000000000..c4b2200b96 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_1.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Members are either instance members or static members. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Person { + name: string = "rain"; + static age: number = 0; + constructor() { } +} +const per = new Person(); +Assert.equal(per.name, "rain"); +Assert.equal(Person.age, 0); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts new file mode 100644 index 0000000000..69c27e181b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Instance members are members of the class type and its associated this-type. Within constructors, + instance member functions, and instance member accessors, + the type of this is the this-type of the class. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Counter { + private count: number = 0; + constructor(count_: number) { + this.count = count_; + } + public add(): this { + this.count++; + return this; + } + public subtract(): this { + this.count--; + return this; + } + + public getResult(): number { + return this.count; + } +} +const counter = new Counter(1); +counter.add(); +Assert.equal(counter.getResult(), 2); +counter.add(); +counter.subtract(); +Assert.equal(counter.getResult(), 2); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts new file mode 100644 index 0000000000..4d988e93f1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Static members are declared using the static modifier and are members of the constructor function type. + Within static member functions and static member accessors, + the type of this is the constructor function type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Person { + static n2: number = 20; + tool(): number { + return 30; + } + static tool2() { + return this.n2; + } + static get foo() { + return this.n2; + } +} +let a: number = Person.n2; +Assert.equal(a, 20); +let b: number = Person.tool2(); +Assert.equal(b, 20); +let c: number = Person.foo; +Assert.equal(c, 20); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_accessor_declarations/member_accessor_declarations.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_accessor_declarations/member_accessor_declarations.ts new file mode 100644 index 0000000000..a0713729af --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_accessor_declarations/member_accessor_declarations.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A member accessor declaration declares an instance member accessor or a static member accessor. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class A { + private _foo: number = 0; + get foo(): number { + return this._foo; + } + set foo(value: number) { + this._foo = value; + } + private static a: number = 0; + static get aa(): number { + return this.a; + } + static set aa(value: number) { + this.a = value; + } +} +let x = new A(); +Assert.equal(x.foo, 0); +x.foo = 10; +Assert.equal(x.foo, 10); +Assert.equal(A.aa, 0); +A.aa = 20; +Assert.equal(A.aa, 20); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts new file mode 100644 index 0000000000..b97a731c9b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A member function declaration declares an instance member function or a static member function. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Point { + constructor(public x: number, public y: number) { } + public distance(p: Point) { + var dx = this.x - p.x; + var dy = this.y - p.y; + return Math.sqrt(dx * dx + dy * dy); + } + static distance(p1: Point, p2: Point) { + return p1.distance(p2); + } +} +var p1: Point = new Point(2, 2); +var p2: Point = new Point(1, 1); +Assert.equal(p1.distance(p2), Math.sqrt(2)); +Assert.equal(Point.distance(p1, p2), Math.sqrt(2)); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_2.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_2.ts new file mode 100644 index 0000000000..d0eb468760 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_2.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In the body of an instance member function declaration, this is of the this-type (section 3.6.3) of the class. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Circle { + radius: number = 1; + area(): number { + return Math.PI * this.radius * this.radius; + } +} +let c = new Circle(); +Assert.equal(c.radius, 1); +Assert.equal(c.area(), Math.PI); +c.radius = 2; +Assert.equal(c.area(), Math.PI * 4); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts new file mode 100644 index 0000000000..3d48544ea3 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In the body of a static member function declaration, the type of this is the constructor function type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Point { + constructor(public x: number = 3, public y: number = 3) { } + static z: number; + static pro() { + return this.prototype; + } + static returnz() { + this.z; + } +} +Assert.equal(Point.pro(), "[object Object]"); +Assert.equal(Point.returnz(), undefined); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts new file mode 100644 index 0000000000..61f21a1b9a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A member function can access overridden base class members using a super property access (section 4.9.2). + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Point { + constructor(public x: number, public y: number) { } + public toString() { + return "x=" + this.x + " y=" + this.y; + } +} +class ColoredPoint extends Point { + constructor(x: number, y: number, public color: string) { + super(x, y); + } + public toString() { + return super.toString() + " color=" + this.color; + } +} +let cp = new ColoredPoint(1, 2, "red"); +Assert.equal(cp.color, "red"); +Assert.equal(cp.x, 1); +Assert.equal(cp.y, 2); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts new file mode 100644 index 0000000000..182f9a898c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a static member function,a call to 'new this()' may actually invoke a derived class constructor + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class A { + constructor(public a: number = 1) { } + static create() { + return new this(); + } +} +class B extends A { + constructor(public b: number = 2) { + super(); + } +} +// new A() +var x = A.create(); +// new B() +var y = B.create(); +Assert.equal(x.a, 1); +Assert.equal(y.a, 1); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts new file mode 100644 index 0000000000..73b409830b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Member declarations with a static modifier are called static member declarations. + it is possible to have instance and static property members with the same name. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Point { + constructor(public x: number, public y: number) { } + public distance(p: Point) { + var dx = this.x - p.x; + var dy = this.y - p.y; + return Math.sqrt(dx * dx + dy * dy); + } + static origin = new Point(0, 0); + static distance(p1: Point, p2: Point) { + return p1.distance(p2); + } + static x: number = 10; +} +var p1: Point = new Point(2, 2); +var p2: Point = new Point(1, 1); +Assert.equal(p1.distance(p2), Math.sqrt(2)); +Assert.equal(Point.distance(p1, p2), Math.sqrt(2)); +Assert.equal(p1.distance(Point.origin), Math.sqrt(8)); +Assert.equal(Point.x, 10); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_2.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_2.ts new file mode 100644 index 0000000000..b3d35d834a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_2.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Every class automatically contains a static property member named 'prototype' + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Point { + public x: number; + public y: number; + constructor(x: number, y: number) { + this.x = x; + this.y = y; + } + static origin = new Point(0, 0); +} +class ColoredPoint extends Point { + constructor(x: number, y: number, public color: string) { + super(x, y); + } +} +Assert.equal(ColoredPoint.prototype.color, undefined); +Assert.equal(ColoredPoint.prototype.x, undefined); +Assert.equal(ColoredPoint.prototype.y, undefined); +Assert.equal(Point.prototype.x, undefined); +Assert.equal(Point.prototype.y, undefined); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts new file mode 100644 index 0000000000..1b7743d93e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A member variable declaration declares an instance member variable or a static member variable. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Point { + public x: number; + public y: number; + constructor(x: number, y: number) { + this.x = x; + this.y = y; + } + static z: number = 3; +} +class ColoredPoint extends Point { + constructor(x: number, y: number, public color: string) { + super(x, y); + } + static r: number = 10; +} +let p = new Point(1, 2); +Assert.equal(p.x, 1); +Assert.equal(p.y, 2); +Assert.equal(Point.z, 3); +let cp = new ColoredPoint(4, 5, "red"); +Assert.equal(cp.x, 4); +Assert.equal(cp.y, 5); +Assert.equal(ColoredPoint.r, 10); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts new file mode 100644 index 0000000000..89d71c8a10 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Instance member variable initializers are equivalent to assignments to properties of this in the constructor + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Staff1 { + constructor(public name: string, public place: string, public work = false) { } +} +class Staff2 { + public name: string; + public place: string; + public work: boolean; + constructor(name: string, place: string, work: boolean = false) { + this.name = name; + this.place = place; + this.work = work; + } +} +let em1 = new Staff1("name", "qindao", false); +let em2 = new Staff2("name", "qingdao", true); +Assert.equal(em1.work, false); +Assert.equal(em2.work, true); + diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_5.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_5.ts new file mode 100644 index 0000000000..ca5218be5b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_5.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The declaration spaces of instance and static property members are separate. + Thus, it is possible to have instance and static property members with the same name. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../../../suite/assert.js" + +class myClass { + public x: number; + public y: number; + constructor(x: number, y: number) { + this.x = x; + this.y = y; + } + static x: number = 3; +} + +let myTest = new myClass(1, 2); +Assert.equal(myTest.x, 1); +Assert.equal(myTest.y, 2); +Assert.equal(myClass.x, 3); diff --git a/es2panda/test/ts_extra_tests/test/spec/enums/constant_enum_declarations/constant_enum_declarations.ts b/es2panda/test/ts_extra_tests/test/spec/enums/constant_enum_declarations/constant_enum_declarations.ts new file mode 100644 index 0000000000..9642e89210 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/enums/constant_enum_declarations/constant_enum_declarations.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + in a constant enum declaration, all members must have constant values and it is an error for a member declaration to specify an expression that isn't classified as a constant enum expression. + it is an error to reference a constant enum object in any other context than a property access that selects one of the enum's members. + the only permitted references to the enum object are those that are replaced with an enum member value. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +const enum CED { + None = -1, + False, + True = 1, + DEF = 1024, +} +Assert.equal(CED.None, -1); +Assert.equal(CED.False, 0); +Assert.equal(CED.True, 1); +Assert.equal(CED.DEF, 1024); +Assert.equal(CED["None"], -1); +Assert.equal(CED["False"], 0); +Assert.equal(CED["True"], 1); +Assert.equal(CED["DEF"], 1024); + +enum CED_COPY { + None = -1, + False, + True = 1, + DEF = 1024, +} +Assert.equal(CED_COPY[-1], "None"); +Assert.equal(CED_COPY[0], "False"); +Assert.equal(CED_COPY[1], "True"); +Assert.equal(CED_COPY[1024], "DEF"); diff --git a/es2panda/test/ts_extra_tests/test/spec/enums/declaration_merging/declaration_merging_1.ts b/es2panda/test/ts_extra_tests/test/spec/enums/declaration_merging/declaration_merging_1.ts new file mode 100644 index 0000000000..4e2ac9a503 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/enums/declaration_merging/declaration_merging_1.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + enums are "open-ended" and enum declarations with the same qualified name relative to a common root define a single enum type and contribute to a single enum object. + it isn't possible for one enum declaration to continue the automatic numbering sequence of another, and when an enum type has multiple declarations, only one declaration is permitted to omit a value for the first member. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +enum A { + A1, + A2, +} +enum A { + A3 = 3, + A4, +} +Assert.equal(A.A1, 0); +Assert.equal(A.A2, 1); +Assert.equal(A.A3, 3); +Assert.equal(A.A4, 4); +namespace NSP { + export enum A { + A1, + A2, + } + export enum A { + A3 = 2, + A4, + } +} +Assert.equal(NSP.A.A1, 0); +Assert.equal(NSP.A.A2, 1); +Assert.equal(NSP.A.A3, 2); +Assert.equal(NSP.A.A4, 3); diff --git a/es2panda/test/ts_extra_tests/test/spec/enums/declaration_merging/declaration_merging_2.ts b/es2panda/test/ts_extra_tests/test/spec/enums/declaration_merging/declaration_merging_2.ts new file mode 100644 index 0000000000..dc03af4393 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/enums/declaration_merging/declaration_merging_2.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + when enum declarations are merged, they must either all specify a const modifier or all specify no const modifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +const enum T1 { + Tex0, + Tex1, +} +const enum T1 { + Tex2 = 2, + Tex3, +} +Assert.equal(T1.Tex0, 0); +Assert.equal(T1.Tex1, 1); +Assert.equal(T1.Tex2, 2); +Assert.equal(T1.Tex3, 3); + +enum T2 { + Tex0, + Tex1, +} +enum T2 { + Tex2 = 2, + Tex3, +} +Assert.equal(T2.Tex0, 0); +Assert.equal(T2.Tex1, 1); +Assert.equal(T2.Tex2, 2); +Assert.equal(T2.Tex3, 3); diff --git a/es2panda/test/ts_extra_tests/test/spec/enums/enum_declarations/enum_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/enums/enum_declarations/enum_declarations_1.ts new file mode 100644 index 0000000000..95a0b14894 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/enums/enum_declarations/enum_declarations_1.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + an EnumDeclaration introduces a named type and a named value in the containing declaration space. + The enum type is a distinct subtype of the Number primitive type. + the enum object is a value of an anonymous object type containing a set of properties, + all of the enum type, corresponding to the values declared for the enum type in the body of the declaration. + The enum object's type furthermore includes a numeric index signature with the signature '[x: number]: string'. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +enum Colour { + Red = 0xff0000, + Green = 0x00ff00, + Blue = 0x0000ff, +} +Assert.isString(Colour[0xff0000]); +Assert.equal(Colour[0x00ff00], "Green"); +Assert.isNumber(Colour.Blue); + +enum TypeABC { + A, + B, + C, +} +var index = TypeABC.A; +Assert.equal(TypeABC.A, 0); +Assert.equal(TypeABC.B, index + 1); +Assert.equal(TypeABC.C, index + 2); diff --git a/es2panda/test/ts_extra_tests/test/spec/enums/enum_declarations/enum_declarations_2.ts b/es2panda/test/ts_extra_tests/test/spec/enums/enum_declarations/enum_declarations_2.ts new file mode 100644 index 0000000000..aba1af9ae1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/enums/enum_declarations/enum_declarations_2.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the numeric index signature reflects a "reverse mapping" that is automatically generated in every enum object. + the reverse mapping provides a convenient way to obtain the string representation of an enum value + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +enum Colour { + Red = 0xff0000, + Green = 0x00ff00, + Blue = 0x0000ff, +} +var c = Colour.Green; +Assert.isNumber(c); +Assert.isString(Colour[c]); +Assert.equal("Green", Colour[c]); diff --git a/es2panda/test/ts_extra_tests/test/spec/enums/enum_declarations/enum_declarations_3.ts b/es2panda/test/ts_extra_tests/test/spec/enums/enum_declarations/enum_declarations_3.ts new file mode 100644 index 0000000000..0d9081920c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/enums/enum_declarations/enum_declarations_3.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When an enum declaration includes a const modifier it is said to be a constant enum declaration. + The members of a constant enum declaration must all have constant values that can be computed at compile time. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +const enum H_Date { + Monday = 'Mon', + Tuesday = 'Tues', + Wednesday = 'Wed', + Thursday = 'Thur', + Friday = 'Fri', + Saturday = 'Satur', + Sunday = 'Sun' +} + +let h_date1 = H_Date.Monday; +Assert.equal(h_date1, 'Mon'); +let h_date2 = H_Date.Tuesday; +Assert.equal(h_date2, 'Tues'); +let h_date3 = H_Date.Wednesday; +Assert.equal(h_date3, 'Wed'); +let h_date4 = H_Date.Thursday; +Assert.equal(h_date4, 'Thur'); +let h_date5 = H_Date.Friday; +Assert.equal(h_date5, 'Fri'); +let h_date6 = H_Date.Saturday; +Assert.equal(h_date6, 'Satur'); +let h_date7 = H_Date.Sunday; +Assert.equal(h_date7, 'Sun'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/enums/enum_members/enum_members_1.ts b/es2panda/test/ts_extra_tests/test/spec/enums/enum_members/enum_members_1.ts new file mode 100644 index 0000000000..a1e648d870 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/enums/enum_members/enum_members_1.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + if the member declaration specifies no value, the member is considered a constant enum member. + If the member is the first member in the enum declaration, it is assigned the value zero. + Otherwise, it is assigned the value of the immediately preceding member plus one, and an error occurs if the immediately preceding member is not a constant enum member. + if the member declaration specifies a value that can be classified as a constant enum expression, + the member is considered a constant enum member.otherwise, the member is considered a computed enum member. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +enum ABCList { + A, + B, + C = "string".length, + D = 10, + E, + F = ~17, + G = 0x0f << 0x02, + H = 0xff & 0xaa, + I = E | F, +} +Assert.equal(ABCList.A, 0); +Assert.equal(ABCList.B, 1); +Assert.equal(ABCList.C, 6); +Assert.equal(ABCList.D, 10); +Assert.equal(ABCList.E, 11); +Assert.equal(ABCList.F, -18); +Assert.equal(ABCList.G, 60); +Assert.equal(ABCList.H, 170); +Assert.equal(ABCList.I, -17); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_1.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_1.ts new file mode 100644 index 0000000000..4eb081a6e4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_1.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.23) + by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, + the element expression is contextually typed by the type of that property. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface MyArray { + 0: number; + 1: string; + length: 2; +} +const myArray: MyArray = [42, "hello"]; +Assert.isNumber(myArray[0]); +Assert.isString(myArray[1]); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_2.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_2.ts new file mode 100644 index 0000000000..135558a50a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_2.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the array literal is contextually typed by a type T with a numeric index signature, + the element expression is contextually typed by the type of the numeric index signature + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var MyArray: { + [0]: number; + [1]: string; + [2]: string; +} = [1, "aaa", "bbb"]; + +Assert.isNumber(MyArray[0]); +Assert.isString(MyArray[1]); +Assert.isString(MyArray[2]); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_3.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_3.ts new file mode 100644 index 0000000000..bc7e8b9a23 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_3.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the array literal is empty, the resulting type is an array type with the element type Undefined. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +const emptyArray: any[] = []; + +const emptyStringArray: string[] = emptyArray; +const emptyNumberArray: number[] = emptyArray; + +Assert.isUndefined(emptyArray[0]); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_4.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_4.ts new file mode 100644 index 0000000000..66154b81b3 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_4.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the array literal contains no spread elements and is contextually typed by a tuple-like type (section 3.3.3), + the resulting type is a tuple type constructed from the types of the element expressions + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let myTuple: [string, number] = ["hello", 42]; +Assert.isString(myTuple[0]); +Assert.isNumber(myTuple[1]); + +function foo(pair: [string, number]) { + return pair +} +Assert.equal(JSON.stringify(foo(["hello", 42])), '["hello",42]'); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_5.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_5.ts new file mode 100644 index 0000000000..eb4daa9801 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_5.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.21.1), + the resulting type is a tuple type constructed from the types of the element expressions. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let [x, y]: [string, number] = ["hello", 42]; + +Assert.isString(x); +Assert.isNumber(y); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_6.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_6.ts new file mode 100644 index 0000000000..08e40223f0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_6.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The resulting type is an array type with an element type that is the union of the types of + the non-spread element expressions and the numeric index signature types of the spread element expressions. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let arr = [1, 2, ...["three", "four"], 5]; + +Assert.isNumber(arr[0]); +Assert.isNumber(arr[1]); +Assert.isString(arr[2]); +Assert.isString(arr[3]); +Assert.isNumber(arr[4]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_1.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_1.ts new file mode 100644 index 0000000000..659c79a89d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_1.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Arrow functions are extended from JavaScript to optionally include parameter and return type annotations. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +const addNumbers = (num1: number, num2: number): number => { + return num1 + num2; +}; + +const result1 = addNumbers(5, 10); +Assert.equal(result1, 15); + +const greet = (name: string) => { + return name; +}; +const result2 = greet("Alice"); +Assert.equal(result2, "Alice"); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_2.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_2.ts new file mode 100644 index 0000000000..09c28ac84f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_2.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + 1.( ... ) => expr is exactly equivalent to ( ... ) => { return expr ; } + 2.id => { ... } id => expr are exactly equivalent to + ( id ) => { ... } ( id ) => expr + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +const myFunctionA = (num: string): string => { + return num; +}; +const resultA = myFunctionA("hello,world"); +Assert.equal(resultA, "hello,world"); + +const myFunctionB: () => string = () => "hello,world"; +const resultB = myFunctionB(); +Assert.equal(resultB, "hello,world"); + +let getTempItem = (id: any) => ({ id: id, name: "Temp" }); +const TempAResult = getTempItem(123); +Assert.equal(TempAResult.id, 123); + +var getTempItemB = function (id: any) { + return { + id: id, + name: "Temp", + }; +}; +const TempBResult = getTempItemB(123); +Assert.equal(TempBResult.id, 123); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_3.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_3.ts new file mode 100644 index 0000000000..96cefe3ddd --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_3.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When an arrow function with an expression body and no return type annotation is contextually typed + by a function type T and a contextual signature S can be extracted from T, + the expression body is contextually typed by the return type of S. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let myFunction = (h_x: number, h_y: number) => { return h_x + h_y; } +function myFunc(myValue: (x: number, y: number) => number) { + return myValue; +} +Assert.isFunction(myFunc(myFunction)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts new file mode 100644 index 0000000000..3d3e893eb2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + An assignment of the form 'v = expr' requires v to be classified as a reference or as an assignment pattern. + The expr expression is contextually typed by the type of v, and the type of expr must be assignable to the type of v, + or otherwise a compile-time error occurs. The result is a value with the type of expr. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var sum: Function = function (x: number, y: number) { + return x + y +} +Assert.equal(typeof sum, 'function'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/assignment_operators/assignment_operator_2.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/assignment_operators/assignment_operator_2.ts new file mode 100644 index 0000000000..5a32e54a54 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/assignment_operators/assignment_operator_2.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A compound assignment of the form 'v ??= expr' where '??=' is one of the compound assignment operators, + is subject to the same requirements, and produces a value of the same type, as the corresponding non-compound operation. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var x: number = 10 +var y: number = 20 +x *= y +Assert.isNumber(x) +x /= y +Assert.isNumber(x) +x %= y +Assert.isNumber(x) +x += y +Assert.isNumber(x) +x -= y +Assert.isNumber(x) +x <<= y +Assert.isNumber(x) +x >>= y +Assert.isNumber(x) +x >>>= y +Assert.isNumber(x) +x &= y +Assert.isNumber(x) +x ^= y +Assert.isNumber(x) +x |= y +Assert.isNumber(x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/assignment_operators/assignment_operator_3.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/assignment_operators/assignment_operator_3.ts new file mode 100644 index 0000000000..025a430f02 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/assignment_operators/assignment_operator_3.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A compound assignment furthermore requires v to be classified as a reference and the type of the non-compound operation to be assignable to the type of v. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +let obj = { + name: 'xiao', + age: 18 +} +let v = obj +v.age += v.age +Assert.equal(v.age, 36); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_1.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_1.ts new file mode 100644 index 0000000000..731c9d1407 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_1.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. + An expression of type S is considered assignable to an assignment target V, if V is variable and S is assignable to the type of V. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +let arr = [1, 2] +let [first, second] = arr +Assert.equal(first, 1) +Assert.equal(second, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_2.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_2.ts new file mode 100644 index 0000000000..8555c425b6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_2.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. + An expression of type S is considered assignable to an assignment target V if V is an object assignment pattern and, + for each assignment property P in V, S is the type Any. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +let obj: any = { + a: "foo", + b: 15, + c: "bar" +} +let { a, b, c } = obj; +Assert.equal(a, 'foo') +Assert.equal(b, 15) +Assert.equal(c, 'bar'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_3.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_3.ts new file mode 100644 index 0000000000..722f536d89 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_3.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. + An expression of type S is considered assignable to an assignment target V if V is an object assignment pattern and, + for each assignment property P in V, S has an apparent property with the property name specified in P of a type that is assignable to the target given in P. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +let obj = { + a: "foo", + b: 15, + c: "bar" +} +let { a, b } = obj; +Assert.equal(a, 'foo'); +Assert.equal(b, 15); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_4.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_4.ts new file mode 100644 index 0000000000..0d12823371 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_4.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. + An expression of type S is considered assignable to an assignment target V if V is an object assignment pattern and, + for each assignment property P in V, P specifies a numeric property name and S has a numeric index signature of a type that is assignable to the target given in P. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface Foo { + [key: number]: string + 18: string + 180: string +} +let t: Foo = { + 18: 'age', + 180: 'height' +} +let v = { + 18: 'Age', + 180: 'Height' +} +v = t +Assert.equal(v[18], 'age'); +Assert.equal(v[180], 'height'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_5.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_5.ts new file mode 100644 index 0000000000..bcbbee18d3 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_5.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. + An expression of type S is considered assignable to an assignment target V if V is an object assignment pattern and, + for each assignment property P in V,S has a string index signature of a type that is assignable to the target given in P. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface Foo { + [key: string]: string + name: string + house: string +} +let t: Foo = { + name: 'xiao', + house: 'nanjing' +} +let v = { + name: '', + house: '' +} +v = t +Assert.equal(v.house, 'nanjing'); +Assert.equal(v.name, 'xiao'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_6.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_6.ts new file mode 100644 index 0000000000..10a776d67d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_6.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. + An expression of type S is considered assignable to an assignment target V if V is an array assignment pattern, + for each assignment element E in V, S is the type Any. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +let arr: any = [1, 2] +let [first, second]: [number, number] = arr +Assert.equal(first, 1) +Assert.equal(second, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_7.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_7.ts new file mode 100644 index 0000000000..b7bb0e33ea --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_7.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. + An expression of type S is considered assignable to an assignment target V if V is an array assignment pattern, + for each assignment element E in V, S is a tuple-like type with a property named N of a type that is assignable to the target given in E, + where N is the numeric index of E in the array assignment pattern. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +let s: ['0', string, number] = ['0', 'str', 10] +let [x, y, z]: [string, string, number] = s +Assert.equal(x, '0') +Assert.equal(y, 'str') +Assert.equal(z, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_8.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_8.ts new file mode 100644 index 0000000000..5fe003b1d5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_8.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. + An expression of type S is considered assignable to an assignment target V if V is an array assignment pattern, + S is the type Any or an array-like type, and, for each assignment element E in V, + S is not a tuple-like type and the numeric index signature type of S is assignable to the target given in E. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface A { + [key: number]: string +} +let a: A = ['a', 'b', 'c'] +let [x, y, z] = [a[0], a[1], a[2]] +Assert.equal(x, 'a') +Assert.equal(y, 'b') +Assert.equal(z, 'c'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts new file mode 100644 index 0000000000..d6f2c30785 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The binary + operator requires both operands to be of the Number primitive type or an enum type, + or at least one of the operands to be of type Any or the String primitive type. + Operands of an enum type are treated as having the primitive type Number. + If one operand is the null or undefined value, it is treated as having the type of the other operand. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: number = 10 +var b: number = 20 +var x = a + b +enum e1 { + A, + B, + C +} +enum e2 { + D, + E, + F +} +var c = e1.A +Assert.equal(c, 0) +var d = e2.D +Assert.equal(d, 0) +var y = c + d +Assert.equal(y, 0) +var e: any = true +Assert.isTrue(e) +var f: string = 's' +Assert.equal(f, 's') +var w = a + e +Assert.equal(w, 11) +var v = c + f +Assert.equal(v, '0s'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts new file mode 100644 index 0000000000..641ea0bb0f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The binary + operator, + If one or both operands are of the String primitive type, the result is of the String primitive type. + Otherwise, the result is of type Any. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = true +var b: any = 's' +var c: boolean = false +var d: string = 'str' +var e: number = 10 +var f: any = 20 +// the result is of type Any +var w = a + b +var v = a + f +Assert.isString(w) +Assert.isNumber(v) +var x = a + c +Assert.isNumber(x) +var y = a + d +Assert.isString(y) +var z = a + e +Assert.isNumber(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts new file mode 100644 index 0000000000..8541ba99e3 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The binary + operator, + A value of any type can converted to the String primitive type by adding an empty string. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +function getValue() { } +var s = getValue() + "" +Assert.isString(s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts new file mode 100644 index 0000000000..1cf90e27ae --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The && operator permits the operands to be of any type and produces a result of the same type as the second operand. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = 10 +var b: any = 's' +var c: boolean = false +var d: boolean = true +var e: number = 20 +var f: number = 15 +var g: string = 'a' +var h: string = 'b' +var i: undefined = undefined +var j: undefined = undefined + +var k = a && b +Assert.isString(k) +var l = c && d +Assert.isBoolean(l) +var m = e && f +Assert.isNumber(m) +var n = g && h +Assert.isString(n) +var o = i && j +Assert.isUndefined(o) +var p = a && c +Assert.isBoolean(p) +var q = a && e +Assert.isNumber(q) +var r = a && g +Assert.isString(r) +var s = a && i +Assert.isUndefined(s) +var t = c && e +Assert.isBoolean(t) +var u = c && g +Assert.isBoolean(u) +var v = c && i +Assert.isBoolean(v) +var w = e && g +Assert.isString(w) +var x = e && i +Assert.isUndefined(x) +var y = g && i +Assert.isUndefined(y); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts new file mode 100644 index 0000000000..ace7f6ebff --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, + and the right operand to be of type Any, an object type, or a type parameter type. + The result is always of the Boolean primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface A { + num: number +} +interface B { + str: string +} +function isString(k: A | B) { + if ('num' in k) { + Assert.isBoolean('num' in k) + return false + } + return true +} +isString({ num: 20 }); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_instanceof_operator/the_instanceof_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_instanceof_operator/the_instanceof_operator.ts new file mode 100644 index 0000000000..580fd1a26b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_instanceof_operator/the_instanceof_operator.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type, + and the right operand to be of type Any or a subtype of the 'Function' interface type. + The result is always of the Boolean primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface Animal { + species: string +} +class Felidae implements Animal { + kind: string + species: string + constructor(species: string, kind: string) { + this.species = species + this.kind = kind + } +} +class Canidae implements Animal { + species: string + name: string + constructor(species: string, name: string) { + this.species = species + this.name = name + } +} +const getRandomAnimal = () => { + return Math.random() < 0.5 ? + new Canidae('Canidae', 'Wolf') : + new Felidae('Felidae', 'Tiger') +} +let Animal = getRandomAnimal() +if (Animal instanceof Canidae) { + Assert.isBoolean(Animal instanceof Canidae) +} +if (Animal instanceof Felidae) { + Assert.isBoolean(Animal instanceof Felidae); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_and_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_and_operator.ts new file mode 100644 index 0000000000..85ddf4aa3f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_and_operator.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '&' operator require its operands to be of type Any, the Number primitive type, or an enum type. + Operands of an enum type are treated as having the primitive type Number. + If one operand is the null or undefined value, it is treated as having the type of the other operand. + The result is always of the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = '10' +var b: any = true +var c: number = 20 +var x = a & b +var y = a & c +Assert.isNumber(x) +Assert.isNumber(y) +enum e { + A, + B, + C +} +var d = e.A +var z = a & d +Assert.isNumber(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_division_method_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_division_method_operator.ts new file mode 100644 index 0000000000..80df8d49d7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_division_method_operator.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '/' operator require its operands to be of type Any, the Number primitive type, or an enum type. + Operands of an enum type are treated as having the primitive type Number. + If one operand is the null or undefined value, it is treated as having the type of the other operand. + The result is always of the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = '10' +var b: any = true +var c: number = 20 +var x = a / b +var y = a / c +Assert.isNumber(x) +Assert.isNumber(y) +enum e { + A, + B, + C +} +var d = e.A +var z = a / d +Assert.isNumber(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_left_shift_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_left_shift_operator.ts new file mode 100644 index 0000000000..8deb5bd73d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_left_shift_operator.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '<<' operator require its operands to be of type Any, the Number primitive type, or an enum type. + Operands of an enum type are treated as having the primitive type Number. + If one operand is the null or undefined value, it is treated as having the type of the other operand. + The result is always of the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = '10' +var b: any = true +var c: number = 20 +var x = a << b +var y = a << c +Assert.isNumber(x) +Assert.isNumber(y) +enum e { + A, + B, + C +} +var d = e.A +var z = a << d +Assert.isNumber(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_multiplication_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_multiplication_operator.ts new file mode 100644 index 0000000000..b67909d056 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_multiplication_operator.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '*' operator require its operands to be of type Any, the Number primitive type, or an enum type. + Operands of an enum type are treated as having the primitive type Number. + If one operand is the null or undefined value, it is treated as having the type of the other operand. + The result is always of the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = '10' +var b: any = true +var c: number = 20 +var x = a * b +var y = a * c +Assert.isNumber(x) +Assert.isNumber(y) +enum e { + A, + B, + C +} +var d = e.A +var z = a * d +Assert.isNumber(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_or_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_or_operator.ts new file mode 100644 index 0000000000..4458dbe61b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_or_operator.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '|' operator require its operands to be of type Any, the Number primitive type, or an enum type. + Operands of an enum type are treated as having the primitive type Number. + If one operand is the null or undefined value, it is treated as having the type of the other operand. + The result is always of the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = '10' +var b: any = true +var c: number = 20 +var x = a | b +var y = a | c +Assert.isNumber(x) +Assert.isNumber(y) +enum e { + A, + B, + C +} +var d = e.A +var z = a | d +Assert.isNumber(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_remainder_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_remainder_operator.ts new file mode 100644 index 0000000000..654e0b83cc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_remainder_operator.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '%' operator require its operands to be of type Any, the Number primitive type, or an enum type. + Operands of an enum type are treated as having the primitive type Number. + If one operand is the null or undefined value, it is treated as having the type of the other operand. + The result is always of the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = '10' +var b: any = true +var c: number = 20 +var x = a % b +var y = a % c +Assert.isNumber(x) +Assert.isNumber(y) +enum e { + A, + B, + C +} +var d = e.A +var z = a % d +Assert.isNumber(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_right_shift_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_right_shift_operator.ts new file mode 100644 index 0000000000..bba1c4ac7f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_right_shift_operator.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '>>' operator require its operands to be of type Any, the Number primitive type, or an enum type. + Operands of an enum type are treated as having the primitive type Number. + If one operand is the null or undefined value, it is treated as having the type of the other operand. + The result is always of the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = '10' +var b: any = true +var c: number = 20 +var x = a >> b +var y = a >> c +Assert.isNumber(x) +Assert.isNumber(y) +enum e { + A, + B, + C +} +var d = e.A +var z = a >> d +Assert.isNumber(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_subtraction_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_subtraction_operator.ts new file mode 100644 index 0000000000..fd4c8ae72b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_subtraction_operator.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '-' operator require its operands to be of type Any, the Number primitive type, or an enum type. + Operands of an enum type are treated as having the primitive type Number. + If one operand is the null or undefined value, it is treated as having the type of the other operand. + The result is always of the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = '10' +var b: any = true +var c: number = 20 +var x = a - b +var y = a - c +Assert.isNumber(x) +Assert.isNumber(y) +enum e { + A, + B, + C +} +var d = e.A +var z = a - d +Assert.isNumber(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_unsigned_shift_to_the_right.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_unsigned_shift_to_the_right.ts new file mode 100644 index 0000000000..bd046685b1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_unsigned_shift_to_the_right.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '>>>' operator require its operands to be of type Any, the Number primitive type, or an enum type. + Operands of an enum type are treated as having the primitive type Number. + If one operand is the null or undefined value, it is treated as having the type of the other operand. + The result is always of the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = '10' +var b: any = true +var c: number = 20 +var x = a >>> b +var y = a >>> c +Assert.isNumber(x) +Assert.isNumber(y) +enum e { + A, + B, + C +} +var d = e.A +var z = a >>> d +Assert.isNumber(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_xor_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_xor_operator.ts new file mode 100644 index 0000000000..4c3fa45c49 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_xor_operator.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '^' operator require its operands to be of type Any, the Number primitive type, or an enum type. + Operands of an enum type are treated as having the primitive type Number. + If one operand is the null or undefined value, it is treated as having the type of the other operand. + The result is always of the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = '10' +var b: any = true +var c: number = 20 +var x = a ^ b +var y = a ^ c +Assert.isNumber(x) +Assert.isNumber(y) +enum e { + A, + B, + C +} +var d = e.A +var z = a ^ d +Assert.isNumber(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_congruence_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_congruence_operator.ts new file mode 100644 index 0000000000..5a466b5eb0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_congruence_operator.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '===' operator require one or both of the operand types to be assignable to the other. + The result is always of the Boolean primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = undefined +var b: boolean = true +var c: number = 10 +var d: string = 'str' +Assert.isBoolean(a === b) +Assert.isBoolean(a === c) +Assert.isBoolean(a === d); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_equal_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_equal_operator.ts new file mode 100644 index 0000000000..5be5e1f6c1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_equal_operator.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '==' operator require one or both of the operand types to be assignable to the other. + The result is always of the Boolean primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = undefined +var b: boolean = true +var c: number = 10 +var d: string = 'str' +Assert.isBoolean(a == b) +Assert.isBoolean(a == c) +Assert.isBoolean(a == d); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_greater_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_greater_operator.ts new file mode 100644 index 0000000000..1b9295b48c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_greater_operator.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '>' operator require one or both of the operand types to be assignable to the other. + The result is always of the Boolean primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = undefined +var b: boolean = true +var c: number = 10 +var d: string = 'str' +Assert.isBoolean(a > b) +Assert.isBoolean(a > c) +Assert.isBoolean(a > d); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_greater_or_equal_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_greater_or_equal_operator.ts new file mode 100644 index 0000000000..8018af54ef --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_greater_or_equal_operator.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '>=' operator require one or both of the operand types to be assignable to the other. + The result is always of the Boolean primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = undefined +var b: boolean = true +var c: number = 10 +var d: string = 'str' +Assert.isBoolean(a >= b) +Assert.isBoolean(a >= c) +Assert.isBoolean(a >= d); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_incongruence_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_incongruence_operator.ts new file mode 100644 index 0000000000..762038e557 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_incongruence_operator.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '!==' operator require one or both of the operand types to be assignable to the other. + The result is always of the Boolean primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = undefined +var b: boolean = true +var c: number = 10 +var d: string = 'str' +Assert.isBoolean(a !== b) +Assert.isBoolean(a !== c) +Assert.isBoolean(a !== d); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_less_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_less_operator.ts new file mode 100644 index 0000000000..484705dcb8 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_less_operator.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '<' operator require one or both of the operand types to be assignable to the other. + The result is always of the Boolean primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = undefined +var b: boolean = true +var c: number = 10 +var d: string = 'str' +Assert.isBoolean(a < b) +Assert.isBoolean(a < c) +Assert.isBoolean(a < d); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_less_or_equal_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_less_or_equal_operator.ts new file mode 100644 index 0000000000..1f580108e5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_less_or_equal_operator.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '<=' operator require one or both of the operand types to be assignable to the other. + The result is always of the Boolean primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = undefined +var b: boolean = true +var c: number = 10 +var d: string = 'str' +Assert.isBoolean(a <= b) +Assert.isBoolean(a <= c) +Assert.isBoolean(a <= d); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_unequal_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_unequal_operator.ts new file mode 100644 index 0000000000..388d7b4c6f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_unequal_operator.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '!=' operator require one or both of the operand types to be assignable to the other. + The result is always of the Boolean primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = undefined +var b: boolean = true +var c: number = 10 +var d: string = 'str' +Assert.isBoolean(a != b) +Assert.isBoolean(a != c) +Assert.isBoolean(a != d); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts new file mode 100644 index 0000000000..7d0360cf06 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The || operator permits the operands to be of any type. + The type of the result is the union type of the two operand types. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = 10 +var b: any = 's' +var c: boolean = false +var d: boolean = true +var e: number = 20 +var f: number = 15 +var g: string = 'a' +var h: string = 'b' +var i: undefined = undefined +var j: undefined = undefined + +var k = a || b +Assert.isNumber(k) +var l = c || d +Assert.isBoolean(l) +var m = e || f +Assert.isNumber(m) +var n = g || h +Assert.isString(n) +var o = i || j +Assert.isUndefined(o) +var p = a || c +Assert.isNumber(p) +var q = a || e +Assert.isNumber(q) +var r = a || g +Assert.isNumber(r) +var s = a || i +Assert.isNumber(s) +var t = c || e +Assert.isNumber(t) +var u = c || g +Assert.isString(u) +var v = c || i +Assert.isUndefined(v) +var w = e || g +Assert.isNumber(w) +var x = e || i +Assert.isNumber(x) +var y = g || i +Assert.isString(y); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_or_operator/the_or_operator_2.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_or_operator/the_or_operator_2.ts new file mode 100644 index 0000000000..728fc4b74c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_or_operator/the_or_operator_2.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the || expression is contextually typed, the operands are contextually typed by the same type. + Otherwise, the left operand is not contextually typed and the right operand is contextually typed by the type of the left operand. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var sum = function (x: number, y: number) { + return x + y +} +var average = function (a: number, b: number) { + return (a + b) / 2 +} +var rela = sum || average +Assert.equal(typeof rela, 'function'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/class_expressions/class_expressions_1.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/class_expressions/class_expressions_1.ts new file mode 100644 index 0000000000..b5a715ff96 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/class_expressions/class_expressions_1.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Just as with class declarations, class expressions would create a constructor function that can be used to construct instances. + Like class declarations, you may also declare property members and index members, as well as use the constructor parameters. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var Square = class { + acreage: number; + + constructor(public h_length: number, public h_width: number) { + this.acreage = this.h_length * this.h_width; + } +}; +var square = new Square(5, 10); +Assert.equal(square.acreage, 50); + +class Reflmpl { + public readonly _v = true; + constructor(private _rawValue: T, public _shaw = false) { + this._rawValue = _rawValue; + this._shaw = this._shaw; + } + get value() { + return this._rawValue; + } + set value(newVal) { + this._rawValue = newVal; + } + get shaw() { + return this._shaw; + } + set shaw(newShaw) { + this._shaw = newShaw; + } +} + +let ref = new Reflmpl(10, true); +Assert.equal(ref.value, 10); +Assert.equal(ref._shaw, true); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts new file mode 100644 index 0000000000..6b58147511 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a variable, parameter, binding property, binding element, or member declaration, + an initializer expression is contextually typed by the type given in the declaration's type annotation. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +// In a variable +let a: number +a = 10 +Assert.isNumber(a) + +// In a parameter +function fun(x: string) { + let y = x + 'ing' + return y +} +Assert.isString(fun('str')) + +// In a member declaration +interface Obj { + name: string + age: number +} +let obj: Obj = { + name: 'xiao', + age: 18 +} +Assert.isString(obj.name) +Assert.isNumber(obj.age); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_10.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_10.ts new file mode 100644 index 0000000000..c9649d460a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_10.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a contextually typed array literal expression containing no spread elements, an element expression at index N is contextually typed by + the type of the property with the numeric name N in the contextual type, if any, or otherwise + the numeric index type of the contextual type, if any. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let arr: { + [key: number]: string +} = { + 1: 'a', + 2: 'b', + 3: 'c', + 4: 'd' +} +Assert.isString(arr[1]) +Assert.isString(arr[2]) +Assert.isString(arr[3]) +Assert.isString(arr[4]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_11.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_11.ts new file mode 100644 index 0000000000..46c0bdd684 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_11.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a contextually typed array literal expression containing one or more spread elements, + an element expression at index N is contextually typed by the numeric index type of the contextual type, if any. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let first = [1, 2] +let second = [3, 4] +let bothPlus = [0, ...first, ...second, 5] +Assert.isNumber(bothPlus[2]) +Assert.isNumber(bothPlus[4]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts new file mode 100644 index 0000000000..beea4246b1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a contextually typed parenthesized expression, the contained expression is contextually typed by the same type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var a: number = 10 +var b: number = 5 +var c = (a + b) * (a - b) +Assert.isNumber(c) + +interface Foo { + num: number + str: string +} +const x: Foo[] = [{ num: 18, str: 'hello' }, { num: 20, str: 'world' }] +Assert.isNumber(x[0].num) +Assert.isNumber(x[1].num) +Assert.isString(x[0].str) +Assert.isString(x[1].str); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_13.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_13.ts new file mode 100644 index 0000000000..b7a6cd652f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_13.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a type assertion, the expression is contextually typed by the indicated type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface Person { + name: string + age: number +} +let student = {} as Person +student.name = 'xiao' +student.age = 18 +Assert.isNumber(student.age) +Assert.isString(student.name); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts new file mode 100644 index 0000000000..7b8ddd0423 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a || operator expression, if the expression is contextually typed, the operands are contextually typed by the same type. + Otherwise, the right expression is contextually typed by the type of the left expression. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var sum = function (x: number, y: number) { + return x + y +} +var average1 = function (a: number, b: number) { + return (a + b) / 2 +} +var rela1 = sum || average1 +Assert.equal(typeof rela1, 'function') + +var average2: number = 10 +var rela2 = average2 || sum +Assert.equal(typeof rela2, 'number'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_15.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_15.ts new file mode 100644 index 0000000000..d7a649f139 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_15.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a contextually typed conditional operator expression, the operands are contextually typed by the same type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function processValue(value: number | (() => number)) { + var x = typeof value !== "number" ? value() : value + Assert.isNumber(x) +} +processValue(5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_16.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_16.ts new file mode 100644 index 0000000000..940f31181e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_16.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In an assignment expression, the right hand expression is contextually typed by the type of the left hand expression. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface A { + (a: number): void +} +const fn: A = function (a) { + Assert.isNumber(a) +} +fn(5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_2.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_2.ts new file mode 100644 index 0000000000..d24a9bad0e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_2.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a variable, parameter, binding property, binding element, or member declaration, + an initializer expression is contextually typed by for a parameter, the type provided by a contextual signature. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var f: (s: string) => string = function (x) { + Assert.isString(x) + return x.toLowerCase() +} +f('str'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_3.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_3.ts new file mode 100644 index 0000000000..b94a14a8f5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_3.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a variable, parameter, binding property, binding element, or member declaration, + an initializer expression is contextually typed by the type implied by the binding pattern in the declaration. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function f({ a = true, b = "hello", c = 1 }) { + Assert.isBoolean(a) + Assert.isString(b) + Assert.isNumber(c) +} +f({ a: false }); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts new file mode 100644 index 0000000000..35360dd5fe --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In the body of a function declaration, function expression, arrow function, method declaration, + or get accessor declaration that has a return type annotation, + return expressions are contextually typed by the type given in the return type annotation. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function add(x: number, y: number): number { + return x + y +} +let sum = add(10, 20) +Assert.isNumber(sum) + + +type Fun = (a: number, b: number) => number +function fun(fn: Fun, x: number, y: number) { + return fn(x, y) +} +function minus(a: number, b: number) { + return a - b +} +function mul(a: number, b: number) { + return a * b +} +let m = fun(minus, 15, 7) +let n = fun(mul, 3, 6) +Assert.isNumber(m) +Assert.isNumber(n); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_5.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_5.ts new file mode 100644 index 0000000000..dadabf1676 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_5.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In the body of a function expression or arrow function that has no return type annotation, + if the function expression or arrow function is contextually typed by a function type with exactly one call signature, + and if that call signature is non-generic, return expressions are contextually typed by the return type of that call signature. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +type Fun = { + description: string + (someThing: number): boolean +} +function fun1(fn: Fun) { + return fn.description + fn(100) +} +function fun2(num: number) { + Assert.equal(num, 100) + return false +} +fun2.description = 'hello' +Assert.equal(fun1(fun2), 'hellofalse'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_6.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_6.ts new file mode 100644 index 0000000000..3d70a3597e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_6.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In the body of a constructor declaration, return expressions are contextually typed by the containing class type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Person { + name: string + age: number + constructor(name: string, age: number) { + this.name = name + this.age = age + } +} +const p = new Person("xiao", 18) +Assert.isString(p.name) +Assert.isNumber(p.age); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts new file mode 100644 index 0000000000..7799d6bf1f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In the body of a get accessor with no return type annotation, + if a matching set accessor exists and that set accessor has a parameter type annotation, + return expressions are contextually typed by the type given in the set accessor's parameter type annotation. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Developer { + private _language = '' + private _tasks: string[] = [] + get language() { + return this._language + } + set language(value: string) { + this._language = value + } + get tasks() { + return this._tasks + } + set tasks(value: string[]) { + this._tasks = value + } +} + +const dev = new Developer() +dev.language = 'TS' +Assert.isString(dev.language) +dev.tasks = ['develop', 'test'] +dev.tasks.push('ship') +Assert.equal(dev.tasks, 'develop,test,ship'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts new file mode 100644 index 0000000000..0c2192e4d6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a typed function call, argument expressions are contextually typed by their corresponding parameter types. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +const state: Record = { + isPending: false, + results: ['a', 'b', 'c'] +} + +const useValue = (name: string): [T, Function] => { + const value: T = state[name] + const setValue: Function = (value: T): void => { + state[name] = value + } + return [value, setValue] +} + +const [isPending, setIsPending] = useValue('isPending') +const [results, setResults] = useValue('results') + +Assert.isBoolean(isPending) +Assert.equal(results, 'a,b,c'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_9.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_9.ts new file mode 100644 index 0000000000..e6fc7d38b7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_9.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a contextually typed object literal, each property value expression is contextually typed by + the type of the property with a matching name in the contextual type, if any, or otherwise + for a numerically named property, the numeric index type of the contextual type, if any, or otherwise + the string index type of the contextual type, if any. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface Person { + (a: number): void +} +interface B { + fn: Person +} +const obj: B = { + fn: function (a) { + Assert.isNumber(a) + } +} +obj.fn(10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts new file mode 100644 index 0000000000..a7fee45284 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The inclusion of type arguments in the Arguments production gives rise to certain ambiguities in the grammar for expressions. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +// a call to 'f' with two arguments, 'g < A' and 'B > (7)' +var h_g: number = 5 +var h_A: number = 3 +var h_B: number = 6 +function f(a: any, b?: any) { + return a +} + +Assert.isFalse(f(h_g < h_A, h_B > 7)) +Assert.isFalse(f(h_g < h_A, h_B > +(7))) + +// a call to a generic function 'g' with two type arguments and one regular argument +type A1 = number +type B1 = number +function g1(a: T) { + return a; +} +function f1(a: any, b?: any) { + return a +} + +Assert.equal(f1(g1(7)), 7); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts new file mode 100644 index 0000000000..2412ff911d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The compile-time processing of a typed function call consists, + a list of candidate signatures is constructed from the call signatures in the function type in declaration order. + A generic signature is a candidate in a function call with type arguments when the signature has the same number of type parameters + as were supplied in the type argument list, the type arguments satisfy their constraints, + and once the type arguments are substituted for their associated type parameters, + the signature is applicable with respect to the argument list of the function call. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface IFnCall { + (fn: () => T, age: number): string +} +interface IFnCall { + (func: () => T, str: string): string +} +const foo: IFnCall = function () { + return 'a' +} + +var f = foo(() => { + return 'f' +}, 10) + +Assert.equal(f, 'a'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts new file mode 100644 index 0000000000..156ff59674 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The compile-time processing of a typed function call consists, + a list of candidate signatures is constructed from the call signatures in the function type in declaration order. + A generic signature is a candidate in a function call without type arguments when type inference succeeds for each type parameter, + once the inferred type arguments are substituted for their associated type parameters, + the signature is applicable with respect to the argument list of the function call. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface IFnCall { + (fn: (name: S) => T, age: number): T +} +interface IFnCall { + (func: (str: S) => T, name: string): T +} +const foo: IFnCall = function (fn) { + return fn('xiao') +} +const res = foo((name) => { + return name +}, 10) +Assert.isString(res); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_3.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_3.ts new file mode 100644 index 0000000000..6da42897a5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_3.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + list of candidate signatures is constructed from the call signatures in the function type in declaration order. + A non-generic signature is a candidate when + the function call has no type arguments, and + the signature is applicable with respect to the argument list of the function call. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface IfnCall { + (name: string, age: number): string +} +interface IfnCall { + (str: string, num: string): string +} +const foo: IfnCall = function (name, age) { + return name + ":" + age +} +var f = foo("xiao", 18) +Assert.isString(f); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_4.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_4.ts new file mode 100644 index 0000000000..e1398bb043 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_4.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A signature is said to be an applicable signature with respect to an argument list when + the number of arguments is not less than the number of required parameters, + the number of arguments is not greater than the number of parameters, and + for each argument expression e and its corresponding parameter P, when e is contextually typed by the type of P, + no errors ensue and the type of e is assignable to the type of P. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface IfnCall { + (name: string, age?: number): string +} +const foo1: IfnCall = function (name, age) { + return name + ":" + age +} +const foo2: IfnCall = function (name) { + return name +} +var f1 = foo1("xiao", 18) +var f2 = foo2("xi") +f1 = f2 +Assert.equal(f1, f2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts new file mode 100644 index 0000000000..2620024e11 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Given a type parameter T and set of candidate types, the actual inferred type argument is determined, + if the set of candidate argument types is empty, the inferred type argument for T is T's constraint. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +type t = number | string +function select(h_x: T, h_y: T): T { + return Math.random() < 0.5 ? h_x : h_y; +} + +var x = select(10, 20); +Assert.isNumber(x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts new file mode 100644 index 0000000000..022076cc4e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Given a type parameter T and set of candidate types, the actual inferred type argument is determined, + if at least one of the candidate types is a supertype of all of the other candidate types, + let C denote the widened form of the first such candidate type. + If C satisfies T's constraint, the inferred type argument for T is C. + Otherwise, the inferred type argument for T is T's constraint. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +type c = number | undefined +type t = number | null | undefined +function select(h_x: T, h_y: T): T { + return Math.random() < 0.5 ? h_x : h_y; +} + +var y = select(10, undefined) +if (typeof y === 'number') { + Assert.isNumber(y); +} +else { + Assert.isUndefined(y); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts new file mode 100644 index 0000000000..40e5662030 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When a function expression is inferentially typed and a type assigned to a parameter in that expression references type parameters for which inferences are being made, + the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +function h_map(h_a: T[], h_f: (h_x: T) => U): U[] { + var cons: U[] = []; + for (var i = 0; i < h_a.length; i++) cons.push(h_f(h_a[i])); + return cons; +} + +var h_names = ["xiao", "xi", "xin"]; +var h_lengths = h_map(h_names, str => str.length); +Assert.equal(typeof h_lengths, 'object'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts new file mode 100644 index 0000000000..0c9f7f3b93 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If e is an expression of a function type that contains exactly one generic call signature and no other members, + and T is a function type with exactly one non-generic call signature and no other members, + then any inferences made for type parameters referenced by the parameters of T's call signature are fixed, + and e's type is changed to a function type with e's call signature instantiated in the context of T's call signature. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +function h_zip(x: S[], y: T[], group: (x: S) => (y: T) => U): U[] { + var length = Math.max(x.length, y.length); + var cons: U[] = []; + for (var i = 0; i < length; i++) cons.push(group(x[i])(y[i])); + return cons; +} + +var h_names = ["Peter", "Paul", "Mary"]; +var h_ages = [7, 9, 12]; +var h_pairs = h_zip(h_names, h_ages, str => num => ({ name: str, age: num })); +Assert.equal(typeof h_pairs, 'object'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_1.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_1.ts new file mode 100644 index 0000000000..e96d3bb579 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_1.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If T is a union type, let U be the set of element types in T that have call signatures. + If each type in U has exactly one call signature and that call signature is non-generic, and if all of the signatures are identical ignoring return types, + then S is a signature with the same parameters and a union of the return types. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +type MyUnionType = ((x: number) => string) | ((x: number) => number); +function myFunction(fn: MyUnionType, arg: number) { + return fn(arg); +} +const fn1 = (x: number): string => `Hello,${x}`; +const fn2 = (x: number): number => x * 2; +const result1 = myFunction(fn1, 123); +const result2 = myFunction(fn2, 456); +Assert.equal(result1, "Hello,123"); +Assert.equal(result2, 912); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_2.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_2.ts new file mode 100644 index 0000000000..ffa91c1630 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_2.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If T is a function type with exactly one call signature, + and if that call signature is non-generic, S is that signature. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +type MyFunctionType = (x: number, y: number) => number; +function myFunction(fn: MyFunctionType) { + return fn(2, 3); +} +const add: MyFunctionType = function (x, y) { + return x + y; +}; +const result = myFunction(add); +Assert.equal(result, 5); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_3.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_3.ts new file mode 100644 index 0000000000..34af633da7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_3.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Otherwise, no contextual signature can be extracted from T. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +type MyType = { + fn: (a: number, b: string) => boolean; +}; +function myFunction(obj: MyType) { + const { fn } = obj; + const result = fn(123, "hello"); + Assert.isTrue(result); +} + +var h_x: MyType = { + fn: function func(x: number, y: string) { + return true; + } +} +myFunction(h_x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/class.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/class.ts new file mode 100644 index 0000000000..188b7b895d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/class.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: For a class, the constructor type associated with the constructor function object. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Car { + // field + engine: string; + agelimit: number; + // Constructor function + constructor(engine: string, agelimit: number) { + this.engine = engine; + this.agelimit = agelimit; + } +} +var car = new Car("Benci", 2); +Assert.equal(car.agelimit, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/enum.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/enum.ts new file mode 100644 index 0000000000..49f197edf1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/enum.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: For an enum, the object type associated with the enum object. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +enum Direction { + up = 1, + down, + Left, + right, +} +const direction: Direction = Direction.up; +Assert.isNumber(direction); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/function.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/function.ts new file mode 100644 index 0000000000..d1513c3bf3 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/function.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: For a function, the function type associated with the function object. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function myFunction(x: number): number { + return x * 2; +} +Assert.isFunction(myFunction); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/name_space.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/name_space.ts new file mode 100644 index 0000000000..7e0c424ff4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/name_space.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When an expression is an IdentifierReference, the expression refers to the most nested namespace, class, enum, function, variable, + or parameter with that name whose scope (section 2.4) includes the location of the reference. + The type of such an expression is the type associated with the referenced entity: + For a namespace, the object type associated with the namespace instance + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +namespace MyNamespace { + export interface Person { + name: string; + age: number; + } + export function greet(person: Person) { + Assert.equal(person.name, "John"); + Assert.equal(person.age, 30); + } +} + +const person: MyNamespace.Person = { + name: "John", + age: 30, +}; +MyNamespace.greet(person); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/parameter.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/parameter.ts new file mode 100644 index 0000000000..0893470877 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/parameter.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + For a parameter, the type of the parameter. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class paramMethod { + person: string; + age: number; + constructor(person: string, age: number) { + this.person = person; + this.age = age; + Assert.isString(person); + Assert.isNumber(age); + } +} +var newparam = new paramMethod("xiaoli", 18); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/variable.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/variable.ts new file mode 100644 index 0000000000..d6af27202a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/variable.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + For a variable, the type of the variable. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let uname: string = "Runoob"; +let score1: number = 50; + +Assert.isString(uname); +Assert.isNumber(score1); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/literals/boolean.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/literals/boolean.ts new file mode 100644 index 0000000000..fb4fec1795 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/literals/boolean.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The type of the literals true and false is the Boolean primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +Assert.equal(typeof false, "boolean"); +Assert.equal(typeof true, "boolean"); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/literals/null.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/literals/null.ts new file mode 100644 index 0000000000..8878a4debc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/literals/null.ts @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The type of the null literal is the Null primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +// TODO judge the null type +Assert.isTrue(typeof null === "object"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/literals/number.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/literals/number.ts new file mode 100644 index 0000000000..070870d0f5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/literals/number.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The type of numeric literals is the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +Assert.equal(typeof 1, "number"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/literals/regexp.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/literals/regexp.ts new file mode 100644 index 0000000000..772c21d027 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/literals/regexp.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The type of regular expression literals is the global interface type 'RegExp'. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +Assert.isTrue(/hello world/ instanceof RegExp); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/literals/string.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/literals/string.ts new file mode 100644 index 0000000000..3a97e72e58 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/literals/string.ts @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The type of string literals is the String primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +Assert.isString("Hello world"); +Assert.isString("kitty"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_3.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_3.ts new file mode 100644 index 0000000000..235f41d28d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_3.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the object literal is contextually typed and the contextual type contains a string index signature, + the property assignment is contextually typed by the type of the string index signature. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let animal: { + name: String; + age: Number; + run: Number; + bark(run: Number): Number; +} = { + name: "Tom", + age: 12, + run: 23, + bark(run) { + return run; + }, +}; +Assert.equal(animal.run, 23); +animal.run = 66; +Assert.equal(animal.run, 66); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_4.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_4.ts new file mode 100644 index 0000000000..a9756ff419 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_4.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The property assignment is processed without a contextual type + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface Iperson { + name: String; + age: Number; + gender?: string; + sayName(): void; +} +const P: Iperson = { + name: "Tom", + age: 21, + gender: "male", + sayName() { + return this.name; + }, +}; +Assert.equal(P.gender, "male"); +P.gender = "female"; +Assert.equal(P.gender, "female"); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_5.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_5.ts new file mode 100644 index 0000000000..0f4a068064 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_5.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A get accessor declaration is processed in the same manner as an ordinary function declaration (section 6.1) with no parameters. + A set accessor declaration is processed in the same manner as an ordinary function declaration with a single parameter and a Void return type. + When both a get and set accessor is declared for a property: + If both accessors include type annotations, the specified types must be identical. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Example { + private _count: number = 0; + get count(): number { + return this._count; + } + set count(value: number) { + this._count = value; + } +} +const example = new Example(); +example.count = 1; +Assert.isNumber(example.count); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_6.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_6.ts new file mode 100644 index 0000000000..0559529d12 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_6.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If only one accessor includes a type annotation, the other behaves as if it had the same type annotation + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Person { + private _name: string = ""; + get name(): string { + return this._name; + } + set name(value: string) { + this._name = value; + } +} +const person = new Person(); +person.name = "john"; +Assert.isString(person.name); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_7.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_7.ts new file mode 100644 index 0000000000..63ddd93fa9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_7.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If neither accessor includes a type annotation, + the inferred return type of the get accessor becomes the parameter type of the set accessor. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class h_C { + private num: number; + constructor(num: number) { + this.num = num; + } + get() { + return this.num; + } + set() { + return this.num + } +} +var h_c = new h_C(10); +Assert.isNumber(h_c.get()) +Assert.isNumber(h_c.set()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/parentheses/parentheses.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/parentheses/parentheses.ts new file mode 100644 index 0000000000..c5d2881422 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/parentheses/parentheses.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A parenthesized expression has the same type and classification as the contained expression itself. + Specifically, if the contained expression is classified as a reference, so is the parenthesized expression. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var addparent = function (n1: number, n2: number): number { + return n1 + n2; +}; +// is equivalent to +var addnoparent = (n1: number, n2: number): number => n1 + n2; +let isCorrect = addparent(11, 22) === addnoparent(11, 22); +Assert.isTrue(isCorrect); + +let foo: string = "hello"; +let bar: string = foo; +Assert.isString(foo); +Assert.isString(bar); + +const obj = { value: "world" }; +function printValue(value: string) { + Assert.equal(value, "world"); + Assert.isString(value); +} +printValue(obj.value); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_access_2.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_access_2.ts new file mode 100644 index 0000000000..6291224769 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_access_2.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If name denotes an accessible apparent property (section 3.11.1) in the widened type (section 3.12) of object, + the property access is of the type of that property. Public members are always accessible, + but private and protected members of a class have restricted accessibility, as described in 8.2.2. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var sites = { + site1: "Runoob", + site2: "Google", + sayHello: function () { }, +}; +sites.sayHello = function () { + return "hello " + sites.site1; +}; +Assert.isString(sites.sayHello()); + +class Person { + name: string; + age: string; + constructor(name: any, age: any) { + this.name = name; + this.age = age; + } + greet() { } +} +const person1 = new Person("Alice", 30); +const person2 = { name: "Bob", age: 35 }; +person1["greet"](); +Assert.equal(person1.name, "Alice"); +Assert.equal(person2.name, "Bob"); +Assert.equal(person1.age, 30); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_any_1.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_any_1.ts new file mode 100644 index 0000000000..89bd7d7ae3 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_any_1.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If object is of type Any, any name is permitted and the property access is of type Any. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let myVariable: any = { name: "John", age: 30 }; + +Assert.isUndefined(myVariable.firstName); + +myVariable = 42; + +Assert.isUndefined(myVariable.length); + +myVariable = "Hello World"; + +Assert.isUndefined(myVariable.foo); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_any_type_6.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_any_type_6.ts new file mode 100644 index 0000000000..7591a9ebf7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_any_type_6.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If index is of type Any, the String or Number primitive type, + or an enum type, the property access is of type Any. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface MyObject { + [key: string]: number; +} + +const obj: MyObject = { + prop1: 1, + prop2: 2, + prop3: 3, +}; + +const prop = "prop2"; +const value1 = obj[prop]; +const value2 = obj[0]; +enum MyEnum { + Prop1 = "prop1", + Prop2 = "prop2", + Prop3 = "prop3", +} + +const value3 = obj[MyEnum.Prop3]; +Assert.equal(value3, 3); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_apprent_5.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_apprent_5.ts new file mode 100644 index 0000000000..8435894554 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_apprent_5.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If object has an apparent string index signature and index is of type Any, + the String or Number primitive type, or an enum type, the property access is of the type of that index signature. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface ExampleObject { + [key: string]: string; +} + +const myObject: ExampleObject = { + foo: "bar", + baz: "qux", +}; + +const myIndex: any = "foo"; +const myValue = myObject[myIndex]; +Assert.isString(myValue); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_index_4.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_index_4.ts new file mode 100644 index 0000000000..9bd3f9e7a8 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_index_4.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If object has an apparent numeric index signature and index is of type Any, + the Number primitive type, or an enum type, the property access is of the type of that index signature + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface MyObj { + [index: number]: string; +} + +const obj: MyObj = { + 0: "foo", + 1: "bar", + 2: "baz", +}; + +Assert.equal(obj[0], "foo"); +Assert.equal(obj[1], "bar"); +Assert.equal(obj[2], "baz"); +Assert.equal(obj["0"], "foo"); +Assert.equal(obj["1"], "bar"); +Assert.equal(obj["2"], "baz"); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_string_number_3.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_string_number_3.ts new file mode 100644 index 0000000000..f35f919394 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_string_number_3.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If index is a string literal or a numeric literal and object has an apparent property (section 3.11.1) with the name given by that literal + (converted to its string representation in the case of a numeric literal), the property access is of the type of that property. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +const sites = { + siteName: "Runoob", + site2: 999, + sayHello: function () { }, +}; +Assert.isString(sites["siteName"]); +Assert.isNumber(sites["site2"]); +Assert.isFunction(sites["sayHello"]); + +interface Person { + name: string; + age: number; + city: string; +} + +const person: Person = { + name: "Alice", + age: 30, + city: "New York", +}; + +Assert.equal(person["name"], "Alice"); + +Assert.equal(person["city"], "New York"); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/property_access_1.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/property_access_1.ts new file mode 100644 index 0000000000..413969cb9a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/property_access_1.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Properties are strongly typed when accessed using bracket notation with the literal representation of their name. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var myType = { + h_str: 'string', + h_bool: true +}; + +var h_s = myType['h_str']; +Assert.isString(h_s); +var h_b = myType['h_bool']; +Assert.isBoolean(h_b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/property_access_2.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/property_access_2.ts new file mode 100644 index 0000000000..3b624b2cdc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/property_access_2.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Tuple types assign numeric names to each of their elements and elements are therefore strongly typed + when accessed using bracket notation with a numeric literal. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var myArry: [number, string, boolean] = [10, 'string', true]; +var h_n = myArry[0]; +Assert.isNumber(h_n); +var h_s = myArry[1]; +Assert.isString(h_s); +var h_b = myArry[2]; +Assert.isBoolean(h_b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_comma_operator/the_comma_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/the_comma_operator/the_comma_operator.ts new file mode 100644 index 0000000000..5ad6c8dc4e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/the_comma_operator/the_comma_operator.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The comma operator permits the operands to be of any type and produces a result that is of the same type as the second operand. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let x: number = 20 +let y: boolean = true +let z: string = 'a' +let com1 = (x++, y) +let com2 = (x++, z = z + 'b') +Assert.isBoolean(com1) +Assert.isString(com2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts new file mode 100644 index 0000000000..f660174baf --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a conditional expression of the form 'test ? expr1 : expr2', the test expression may be of any type. + The type of the result is the union type of the types of expr1 and expr2. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var x: number = 10 +var y: string = '5' +// the typeof z is string | number +var z = Math.random() < 0.5 ? x + y : y && x +if (typeof z === 'number') { + z++ + Assert.equal(z, 11); +} +else { + Assert.equal(z, '105'); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_conditional_operator/the_conditional_operator_2.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/the_conditional_operator/the_conditional_operator_2.ts new file mode 100644 index 0000000000..f9a4095a63 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/the_conditional_operator/the_conditional_operator_2.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the conditional expression is contextually typed, expr1 and expr2 are contextually typed by the same type. + Otherwise, expr1 and expr2 are not contextually typed. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var sum = function (x: number, y: number) { + return x + y +} +var average = function (a: number, b: number) { + return (a + b) / 2 +} +var rela: number = Math.random() < 0.5 ? sum(5, 7) : average(6, 9) +Assert.isNumber(rela); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_1.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_1.ts new file mode 100644 index 0000000000..36d96aed31 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_1.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If C is of type Any, any argument list is permitted and the result of the operation is of type Any. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let C: any; +C = function (this: any, x: number, y: number) { + this.sum = x + y; +}; +const myObject = new C(2, 3); +Assert.equal(myObject.sum, 5); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_2.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_2.ts new file mode 100644 index 0000000000..46a0602f6f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_2.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If C has one or more apparent construct signatures (section 3.11.1), the expression is processed in the same manner as a function call, + but using the construct signatures as the initial set of candidate signatures for overload resolution. + The result type of the function call becomes the result type of the operation. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Person { + constructor(public name: string, public age: number) { } +} +interface Animal { + speak(): void; +} + +class Dog implements Animal { + speak() { + return "Woof!"; + } +} +const p = new Person("Alice", 30); +const d = new Dog(); +Assert.isString(p.name); +Assert.equal(d.speak(), "Woof!"); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_3.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_3.ts new file mode 100644 index 0000000000..5483e09f17 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_3.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If C has no apparent construct signatures but one or more apparent call signatures, the expression is processed as a function call. + A compile-time error occurs if the result of the function call is not Void. The type of the result of the operation is Any. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Person { + sayHello() { + return "Hello,world"; + } +} + +let person: Person = new Person(); +Assert.equal(person.sayHello(), "Hello,world"); + +let person2: any = new Person(); +person2.sayHello(); +Assert.equal(person2.sayHello(), "Hello,world"); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_4.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_4.ts new file mode 100644 index 0000000000..f90ab907a6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_4.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + new C + new C ( ... ) + new C < ... > ( ... ) + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class MyClass { + constructor() { + return "MyClass"; + } +} + +const myInstance = new MyClass(); + + +class Person { + name: string; + age: number; + constructor(name: string, age: number) { + this.name = name; + this.age = age; + } +} +const john = new Person("john", 30); +Assert.isString(john.name, "john"); + +class Box { + contents: T; + constructor(value: T) { + this.contents = value; + } +} +const myBox = new Box("hello"); +Assert.equal(myBox.contents, "hello"); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_calls/arguments.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_calls/arguments.ts new file mode 100644 index 0000000000..7d49a0cbfc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_calls/arguments.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Type arguments cannot be explicitly specified in a super call. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class SuperClass { + value: T; + constructor(value: T) { + this.value = value; + } +} +class SubClass extends SuperClass { + constructor(value: T) { + super(value); + } +} +const sub = new SubClass("hello"); +Assert.equal(sub.value, "hello"); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts new file mode 100644 index 0000000000..8446aea645 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the base class is a generic class, + the type arguments used to process a super call are always those specified in the extends clause that references the base class. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class BaseClass { + constructor(public value: T) { } +} +class SubClass extends BaseClass { + constructor(value: T) { + super(value); + } +} +class StringSubClass extends SubClass { + constructor() { + super("hello"); + } +} +const sub = new StringSubClass(); +Assert.equal(sub.value, "hello"); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_calls/super_calls.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_calls/super_calls.ts new file mode 100644 index 0000000000..cf8fb43cbc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_calls/super_calls.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The super keyword can be used in expressions to reference base class properties and the base class constructor. + Super calls consist of the keyword super followed by an argument list enclosed in parentheses. + Super calls are only permitted in constructors of derived classes, as described in section 8.3.2. + A super call invokes the constructor of the base class on the instance referenced by this. + A super call is processed as a function call (section 4.15) using the construct signatures of the base class constructor function type + as the initial set of candidate signatures for overload resolution. + The type of a super call expression is Void. + The JavaScript code generated for a super call is specified in section 8.7.2. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Animal { + private name: string; + constructor(name: any) { + this.name = name; + } + speak() { + return `${this.name} makes a noise`; + } +} + +class Dog extends Animal { + private breed: string; + constructor(name: any, breed: any) { + super(name); + this.breed = breed; + } + extendsSpeak() { + super.speak(); + Assert.isString(super.speak(), "Fodo makes a noise"); + return `${this.breed}`; + } +} +const d = new Dog("Fido", "Golden Retriever"); +d.extendsSpeak(); +Assert.isString(d.extendsSpeak(), "Golden Retriever"); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_property_access/derived_class_access.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_property_access/derived_class_access.ts new file mode 100644 index 0000000000..559f084c59 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_property_access/derived_class_access.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance, + a super property access is permitted and must specify a public instance member function of the base class. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class AnimalA { + public makeSound(): string { + return "the animal makes"; + } +} + +class DogA extends AnimalA { + public makeSound(): string { + super.makeSound(); + Assert.equal(super.makeSound(), "the animal makes"); + return "the dog barks"; + } +} +const myDog = new DogA(); +myDog.makeSound(); +Assert.equal(myDog.makeSound(), "the dog barks"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_property_access/static_member_access.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_property_access/static_member_access.ts new file mode 100644 index 0000000000..d7c0f1dc7a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_property_access/static_member_access.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a static member function or static member accessor where this references the constructor function object of a derived class, + a super property access is permitted and must specify a public static member function of the base class. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Base { + static greet() { + return "hello world"; + } +} +class Derived extends Base { + static greet() { + super.greet(); + Assert.equal(super.greet(), "hello world"); + return "hola,mundo"; + } +} +Derived.greet(); +Assert.equal(Derived.greet(), "hola,mundo"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/this_key_word/this_key_word_1.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/this_key_word/this_key_word_1.ts new file mode 100644 index 0000000000..10829b5ecb --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/this_key_word/this_key_word_1.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a constructor, instance member function, instance member accessor, + or instance member variable initializer, this is of the this-type (section 3.6.3) of the containing class. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +// CHECK this in constructor +class Dog { + name: string; + age: number; + constructor(name: string, age: number) { + this.name = name; + this.age = age; + } + + getName(): string { + return this.name; + } + + bark(): string { + return this.getName() + " is bark"; + } +} + +var dog = new Dog("doggy", 7); +Assert.equal(dog.age, 7); + +// CHECK this in instance member function and instance member accessor +Assert.equal("doggy is bark", dog.bark()) + +// CHECK this in instance member variable initializer +class Duck { + age: number = this.b; + constructor(private readonly b: number) { + } +} +var duck = new Duck(6); +Assert.equal(6, duck.age); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_assertion/type_assertion_1.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/type_assertion/type_assertion_1.ts new file mode 100644 index 0000000000..82c489c038 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/type_assertion/type_assertion_1.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Type assertions check for assignment compatibility in both directions. + Thus, type assertions allow type conversions that might be correct, but aren't known to be correct. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Form { } + +class Square extends Form { } + +function createForm(mold: string): Form { + if (mold === "square") { + return new Square() + } + return Square +} + +var square = createForm("square") +Assert.equal(JSON.stringify(square), '{}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_assertion/type_assertion_2.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/type_assertion/type_assertion_2.ts new file mode 100644 index 0000000000..6befd8d74f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/type_assertion/type_assertion_2.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + type assertions are not checked at run-time and it is up to the programmer to guard against errors, + for example using the instanceof operator + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Foo { + foo = 123; + common = '123' +} +class Bar { + bar = 123 + common = '123' +} +function doStuff(arg: Foo | Bar) { + if (arg instanceof Foo) { + Assert.equal(arg.foo, 123) + } else { + Assert.equal(arg.bar, 123) + } + +} +doStuff(new Foo()) +doStuff(new Bar()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_assertion/type_assertion_3.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/type_assertion/type_assertion_3.ts new file mode 100644 index 0000000000..076898c01c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/type_assertion/type_assertion_3.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a type assertion expression of the form < T > e, e is contextually typed by T and the resulting type of* e* is required to be assignable to T, + or T is required to be assignable to the widened form of the resulting type of e, or otherwise a compile-time error occurs. The type of the result is T. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function getLength(something: string | number): number { + if ((something).length) { + return (something).length + } else { + return something.toString().length + } +} +Assert.equal(getLength('length'), 6); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_1.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_1.ts new file mode 100644 index 0000000000..775be14936 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_1.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Type guards are particular expression patterns involving the 'typeof' and 'instanceof' operators + that cause the types of variables or parameters to be narrowed to more specific types. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function h_func(h_x: number | string) { + if (typeof h_x === 'string') { + Assert.isString(h_x) + } + else { + Assert.isNumber(h_x) + } +} +h_func('string') +h_func(10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_10.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_10.ts new file mode 100644 index 0000000000..087eba5420 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_10.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type guard of the form typeof x === s, where s is a string literal with any value but 'string', 'number', or 'boolean', + when true, if x is a union type, removes from the type of x all constituent types that are subtypes of the string, number, or boolean primitive type, + or when false, has no effect on the type of x. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function f1(x: string | number | undefined) { + if (typeof x === "undefined") { + return undefined + } + else { + return x + } +} +var a = f1(10) +Assert.isNumber(a) +var b = f1('s') +Assert.isString(b) +var c = f1(undefined) +Assert.isUndefined(c) + +function f2(x: string | number | boolean) { + if (typeof x === "undefined") { + return undefined + } + else { + return x + } +} +var a1 = f2(10) +Assert.isNumber(a1) +var b1 = f2('s') +Assert.isString(b1) +var c1 = f2(true) +Assert.isBoolean(c1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_11.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_11.ts new file mode 100644 index 0000000000..17dd287fe2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_11.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type guard of the form typeof x !== s, where s is a string literal, + when true, narrows the type of x by typeof x === s when false, + or when false, narrows the type of x by typeof x === s when true. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function h_func(h_x: string | number) { + if (typeof h_x !== "string") { + Assert.isNumber(h_x) + } + else { + Assert.isString(h_x) + } +} +h_func(10) +h_func('s'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_12.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_12.ts new file mode 100644 index 0000000000..e74b28969b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_12.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type guard of the form !expr, + when true, narrows the type of x by expr when false, + or when false, narrows the type of x by expr when true. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function h_func(h_x: string | number) { + if (!(typeof h_x === "string")) { + Assert.isNumber(h_x) + } + else { + Assert.isString(h_x) + } +} +h_func(10) +h_func('s'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_13.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_13.ts new file mode 100644 index 0000000000..2c176aad23 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_13.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type guard of the form expr1 && expr2, + when true, narrows the type of x by expr1 when true and then by expr2 when true, or + when false, narrows the type of x to T1 | T2, where T1 is the type of x narrowed by expr1 when false, + and T2 is the type of x narrowed by expr1 when true and then by expr2 when false. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function h_func(h_x: string | number | undefined) { + if (typeof h_x === "string" && typeof h_x === "number") { + return undefined + } + else { + return h_x + } +} +var h_a = h_func(10) +Assert.isNumber(h_a) +var h_b = h_func('s') +Assert.isString(h_b) +var h_c = h_func(undefined) +Assert.isUndefined(h_c); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_14.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_14.ts new file mode 100644 index 0000000000..57be49076b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_14.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type guard of the form expr1 || expr2, + when true, narrows the type of x to T1 | T2, where T1 is the type of x narrowed by expr1 when true, + and T2 is the type of x narrowed by expr1 when false and then by expr2 when true, or + when false, narrows the type of x by expr1 when false and then by expr2 when false. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function h_func(h_x: string | number | undefined) { + if (typeof h_x === "string" || typeof h_x === "number") { + return h_x + } + else { + return undefined + } +} +var h_a = h_func(10) +Assert.isNumber(h_a) +var h_b = h_func('s') +Assert.isString(h_b) +var h_c = h_func(undefined) +Assert.isUndefined(h_c); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_15.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_15.ts new file mode 100644 index 0000000000..76c5846f6d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_15.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type guard of any other form has no effect on the type of x. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Person { + name: string + age: number + public constructor(name: string, age: number) { + this.name = name + this.age = age + } +} +class Animal { + height: number + weight: number + public constructor(height: number, weight: number) { + this.height = height + this.weight = weight + } +} +function func(arg: Person | Animal) { + if ('age' in arg) { + Assert.isString(arg.name) + } + if ('height' in arg) { + Assert.isNumber(arg.height) + } +} + +var p = new Person('x', 18) +func(p) +var a = new Animal(200, 180) +func(a); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_2.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_2.ts new file mode 100644 index 0000000000..8379ef2e6e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_2.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In the true branch statement of an 'if' statement, + the type of a variable or parameter is narrowed by a type guard in the 'if' condition when true, + provided no part of the 'if' statement contains assignments to the variable or parameter. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function h_func(h_x: number | string) { + if (typeof h_x === 'string') { + Assert.isString(h_x) + } + else { + return h_x + 1 + } +} +h_func('string'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_3.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_3.ts new file mode 100644 index 0000000000..6631b4da40 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_3.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In the false branch statement of an 'if' statement, + the type of a variable or parameter is narrowed by a type guard in the 'if' condition when false, + provided no part of the 'if' statement contains assignments to the variable or parameter. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function h_func(h_x: number | string) { + if (!(typeof h_x === 'string')) { + Assert.isNumber(h_x) + } + else { + return h_x.length + } +} +h_func(10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_4.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_4.ts new file mode 100644 index 0000000000..c37c99bf9a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_4.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In the true expression of a conditional expression, + the type of a variable or parameter is narrowed by a type guard in the condition when true, + provided no part of the conditional expression contains assignments to the variable or parameter. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function h_process(h_value: number | (() => number)) { + var h_x = typeof h_value == "number" ? h_value : h_value() + Assert.isNumber(h_x) +} +h_process(5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_5.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_5.ts new file mode 100644 index 0000000000..672afeb88e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_5.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In the false expression of a conditional expression, + the type of a variable or parameter is narrowed by a type guard in the condition when false, + provided no part of the conditional expression contains assignments to the variable or parameter. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function h_process(h_value: number | (() => number)) { + var h_x = typeof h_value !== "number" ? h_value() : h_value + Assert.isNumber(h_x) +} +h_process(5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_6.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_6.ts new file mode 100644 index 0000000000..3a96973e1a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_6.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In the right operand of a && operation, + the type of a variable or parameter is narrowed by a type guard in the left o + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function isString(obj: any) { + typeof obj === "string" && obj.length < 10 + Assert.isString(obj) +} +isString('s'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_7.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_7.ts new file mode 100644 index 0000000000..6294a16ce0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_7.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In the right operand of a || operation, + the type of a variable or parameter is narrowed by a type guard in the left operand when false, + provided neither operand contains assignments to the variable or parameter. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function isString(obj: any) { + typeof obj === "string" || obj.length > 10 + Assert.isString(obj) +} +isString('s'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_8.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_8.ts new file mode 100644 index 0000000000..3e41132722 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_8.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type guard of the form 'x instanceof C', where x is not of type Any, + C is of a subtype of the global type 'Function', and C has a property named 'prototype', + when true, narrows the type of x to the type of the 'prototype' property in C provided it is a subtype of the type of x, + or, if the type of x is a union type, removes from the type of x all constituent types that aren't subtypes of the type of the 'prototype' property in C, + or when false, has no effect on the type of x. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Person { + height: number + age: number + public constructor(height: number, age: number) { + this.height = height + this.age = age + } +} +class Animal { + height: number + weight: number + public constructor(height: number, weight: number) { + this.height = height + this.weight = weight + } +} +function func(arg: Person | Animal) { + if (arg instanceof Person) { + return arg.age = 18 + } + if (arg instanceof Animal) { + return arg.weight = 300 + } +} + +var p = new Person(150, 18) +Assert.equal(func(p), 18) +var a = new Animal(200, 180) +Assert.equal(func(a), 300); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_9.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_9.ts new file mode 100644 index 0000000000..d6b6357491 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_9.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type guard of the form typeof x === s, where s is a string literal with the value 'string', 'number', or 'boolean', + when true, narrows the type of x to the given primitive type provided it is a subtype of the type of x, + or, if the type of x is a union type, removes from the type of x all constituent types that aren't subtypes of the given primitive type, + or when false, removes the primitive type from the type of x. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function h_func(h_x: string | number) { + if (typeof h_x === "string") { + Assert.isString(h_x) + } + else { + Assert.isNumber(h_x) + } +} +h_func(10) +h_func('s'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_!_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_!_operator.ts new file mode 100644 index 0000000000..87357beb51 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_!_operator.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The ! operator permits its operand to be of any type and produces a result of the Boolean primitive type. + Two unary ! operators in sequence can conveniently be used to convert a value of any type to the Boolean primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var num1: number = 20 +var num2: number = 90 +var res = !((num1 > 50) && (num2 > 80)) +Assert.isBoolean(res) + +function getValue(): any { +} +var b = !!getValue() +Assert.isBoolean(b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_++_and_--_operators.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_++_and_--_operators.ts new file mode 100644 index 0000000000..9b26a46dc6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_++_and_--_operators.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The ++ and -- operators in prefix or postfix form, require their operand to be of type Any, the Number primitive type, or an enum type, + and classified as a reference. They produce a result of the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var a: any = '10' +a++ +a-- +--a +++a +Assert.isNumber(a) + +enum e { + A, + B, + C, + D +} +let b = e.A +b++ +b-- +++b +--b +Assert.isNumber(b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_+_and_~_operators.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_+_and_~_operators.ts new file mode 100644 index 0000000000..299b7be551 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_+_and_~_operators.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The +, -, and ~ operators permit their operand to be of any type and produce a result of the Number primitive type. + The unary + operator can conveniently be used to convert a value of any type to the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var a: any = 'a' +a = a + 1 +a = a - 1 +a = ~a +Assert.isNumber(a) + +function getValue() { } +var n = +getValue() +Assert.isNumber(n); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_delete_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_delete_operator.ts new file mode 100644 index 0000000000..159678417b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_delete_operator.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The 'delete' operator takes an operand of any type and produces a result of the Boolean primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface Foo { + prop1?: string + prop2?: boolean + prop3?: number +} +let obj: Foo = { + prop1: 'value', + prop2: true, + prop3: 20 +} +Assert.isBoolean(delete obj.prop1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_typeof_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_typeof_operator.ts new file mode 100644 index 0000000000..d56999cb13 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_typeof_operator.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The 'typeof' operator takes an operand of any type and produces a value of the String primitive type. In positions where a type is expected, 'typeof' can also be used in a type query to produce the type of an expression. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var h_x = 5 +var h_y = typeof h_x +Assert.equal(h_y, 'number') +var h_z: typeof h_x = 10 +Assert.isNumber(h_z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_void_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_void_operator.ts new file mode 100644 index 0000000000..501fb22f61 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_void_operator.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The 'void' operator takes an operand of any type and produces the value 'undefined'. The type of the result is the Undefined type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let num: any = 10 +num = 'string' +let un = void num +Assert.isUndefined(un); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_1.ts b/es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_1.ts new file mode 100644 index 0000000000..1aeb210cd4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_1.ts @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + An Async Function is a JavaScript Function, Parameterized Arrow Function, Method that has been prefixed with the async modifier. + An Async Function must provide a return type annotation that points to a compatible Promise type. + Return type inference can only be used if there is a globally defined, compatible Promise type. + options: + lib:es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +// globally defined +let pp: Promise = Promise.resolve(1); +// Function +async function fetchTest1(): Promise { + return await pp; +} +fetchTest1().then((params) => { + Assert.equal(params, 1); +}); +// Function : No Return Type +async function fetchTest1NoReturnType() { + return await pp; +} +fetchTest1NoReturnType().then((params) => { + Assert.equal(params, 1); +}); +// Arrow Function +const fetchTest2 = async (): Promise => { + return await pp; +}; +fetchTest2().then((params) => { + Assert.equal(params, 1); +}); +// Arrow Function : No Return Type +const fetchTest2NoReturnType = async () => { + return await pp; +}; +fetchTest2NoReturnType().then((params) => { + Assert.equal(params, 1); +}); + +class Person { + // Method + async fetchTest3(): Promise { + return await pp; + } + // Method : No Return Type + async fetchTest3NoReturnType() { + return await pp; + } +} +new Person().fetchTest3().then((params) => { + Assert.equal(params, 1); +}); +new Person().fetchTest3NoReturnType().then((params) => { + Assert.equal(params, 1); +}); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_1.ts new file mode 100644 index 0000000000..10d99c7ca5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_1.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + a destructuring parameter declaration introduces zero or more named locals + and initializes them with values extracted from properties or elements of the object or array passed as an argument for the parameter. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Person { + m_name: string; + m_age: number; + constructor(name: string, age: number) { + this.m_name = name; + this.m_age = age; + } +} +let tt: Person = new Person("caihua", 12); +function showInfo({ m_name, m_age }: Person) { + Assert.isString(m_name); + Assert.equal(m_name, tt.m_name); + Assert.isNumber(m_age); + Assert.equal(m_age, tt.m_age); +} +showInfo(tt); + +let tt1: Person = new Person("caihua1", 121); +let tt2: Person = new Person("caihua2", 122); +let person_array: Person[] = [tt1, tt2]; + +function showArrayInfo(v_array: Array) { + let [tt1, tt2] = v_array; + Assert.equal(tt1.m_name, v_array[0].m_name); + Assert.equal(tt1.m_age, v_array[0].m_age); + Assert.equal(tt2.m_name, v_array[1].m_name); + Assert.equal(tt2.m_age, v_array[1].m_age); +} +showArrayInfo(person_array); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_2.ts b/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_2.ts new file mode 100644 index 0000000000..f304b84cc9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_2.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the type T associated with a destructuring parameter declaration is determined as follows + If the declaration includes a type annotation, T is that type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Person { + m_name: string; + m_age: number; + constructor(name: string, age: number) { + this.m_name = name; + this.m_age = age; + } +} +let tt: Person = new Person("caihua", 12); +function showInfo(v: Person) { + let { m_name, m_age }: { m_name: string; m_age: number } = v; + Assert.isString(m_name); + Assert.equal(m_name, "caihua"); + Assert.isNumber(m_age); + Assert.equal(m_age, 12); +} +showInfo(tt); + diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_3.ts b/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_3.ts new file mode 100644 index 0000000000..fe87d70581 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_3.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the type T associated with a destructuring parameter declaration is determined as follows + If the declaration occurs in a function expression for which a contextual signature is available, + T is the type obtained from the contextual signature. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Person { + m_name: string; + m_age: number; + constructor(name: string, age: number) { + this.m_name = name; + this.m_age = age; + } +} +let tt: Person = new Person("caihua", 12); +const showInfo: (v: Person) => void = function (v) { + let { m_name, m_age } = v; + Assert.isString(m_name); + Assert.equal(m_name, "caihua"); + Assert.isNumber(m_age); + Assert.equal(m_age, 12); +}; +showInfo(tt); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts b/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts new file mode 100644 index 0000000000..06d22b813a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the type T associated with a destructuring parameter declaration is determined as follows + if the declaration includes an initializer expression, T is the widened form of the type of the initializer expression. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +// string literal type +type testStr = "caihua"; +// number literal type +type testStrNum = 12; +class Person { + m_name: testStr | undefined; + m_age: testStrNum | undefined; + constructor(); + constructor(name?: testStr, age?: testStrNum) { + if (name && typeof name === "string") { + this.m_name = name; + } else { + this.m_name = undefined; + } + + if (age && typeof age === "number") { + this.m_age = age; + } else { + this.m_age = undefined; + } + } +} +let tt: Person = new Person(); + +function showInfo(v: Person) { + let { + m_name = "caihua", + m_age = 12, + }: { m_name: testStr | undefined; m_age: testStrNum | undefined } = v; + Assert.equal(typeof m_name === "string", true); + Assert.equal(typeof m_age === "number", true); +} +showInfo(tt); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_5.ts b/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_5.ts new file mode 100644 index 0000000000..f432223f8f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_5.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the type T associated with a destructuring parameter declaration is determined as follows + if the declaration specifies a binding pattern, T is the implied type of that binding pattern + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +type cc = { + name: string; + age: number; + isJob: boolean; +}; +// T is the implied type of that binding pattern +function showInfo({ age, name, isJob }: cc) { + Assert.isNumber(age); + Assert.isBoolean(isJob); + Assert.isString(name); +} +showInfo({ + name: "caihua", + age: 90, + isJob: true, +}); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_6.ts b/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_6.ts new file mode 100644 index 0000000000..cf1c560bfb --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_6.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Destructuring parameter declarations do not permit type annotations on the individual binding patterns, + as such annotations would conflict with the already established meaning of colons in object literals. + Type annotations must instead be written on the top-level parameter declaration. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface information { + title?: string; + place?: [number, number]; + brave?: boolean; +} + +function infor({ title, place, brave }: information) { + if (title) { + Assert.equal(typeof title == "string", true); + } + if (place) { + Assert.equal(Array.isArray(place), true); + } + if (brave) { + Assert.equal(typeof brave === "boolean", true); + } +} + +infor({ title: "title" }); +infor({ brave: false }); +infor({ place: [0, 1] }); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts b/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts new file mode 100644 index 0000000000..ee0f7341dc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the type T associated with a destructuring parameter declaration is determined as follows + if the parameter is a rest parameter, T is any[]. + Otherwise,T is any + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +// v is any[]. +function test(...v: any[]) { + Assert.isString(v[0]); + Assert.isNumber(v[1]); + Assert.isBoolean(v[2]); +} +test("caihua", 90, true); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/function_declarations/function_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/functions/function_declarations/function_declarations_1.ts new file mode 100644 index 0000000000..24c3af62ae --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/function_declarations/function_declarations_1.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Function declarations are extended to permit the function body to be omitted in overload declarations. + a function can have at most one implementation. + When a function has both overloads and an implementation, the overloads must precede the implementation + and all of the declarations must be consecutive with no intervening grammatical elements. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function add(a: number, b: number): number; +function add(a: string, b: number): string; +function add(a: string, b: string): string; +function add(arg1: string | number, arg2: string | number) { + if (typeof arg1 === "number" && typeof arg2 === "number") { + return arg1 + arg2; + } + + if (typeof arg1 === "string" || typeof arg2 === "string") { + return `${arg1}${arg2}`; + } +} +// (number, number) +Assert.equal(add(0, 1), 1); +// (string, number) +Assert.equal(add("0", 1), "01"); +// (string, string) +Assert.equal(add("0", "1"), "01"); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/function_declarations/function_declarations_2.ts b/es2panda/test/ts_extra_tests/test/spec/functions/function_declarations/function_declarations_2.ts new file mode 100644 index 0000000000..6490e33a31 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/function_declarations/function_declarations_2.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + All declarations for the same function must specify the same set of modifiers (the same combination of declare, export, and default) + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function add(a: string, b: string): string; +function add(a: number, b: number): number; +function add(a: string, b: number): string; +function add(arg1: string | number, arg2: string | number) { + if (typeof arg1 === "number" && typeof arg2 === "number") { + return arg1 + arg2; + } + + if (typeof arg1 === "string" || typeof arg2 === "string") { + return `${arg1}${arg2}`; + } +} + +// (number, number) +Assert.equal(add(0, 1), 1); +// (string, number) +Assert.equal(add("0", 1), "01"); +// (string, string) +Assert.equal(add("0", "1"), "01"); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_1.ts b/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_1.ts new file mode 100644 index 0000000000..b5c753e431 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_1.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If there are no return statements with expressions in f's function body, the inferred return type is Void. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function func(h_x: number) { + Assert.isNumber(h_x); +} +// get function's return type +type voidTest = ReturnType; +let tt1: void = undefined; +let tt2: voidTest = undefined; +Assert.equal(tt1, tt2); +Assert.equal(tt1 === tt2, true); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_2.ts b/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_2.ts new file mode 100644 index 0000000000..ee6f7d0b8d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_2.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + if f is a contextually typed function expression + the inferred return type is the union type of the types of the return statement expressions in the function body, + ignoring return statements with no expressions. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function f(x: number) { + switch (x) { + case 0: + return "hello"; + case 1: + return 1; + default: + return true; + } +} +type testType = ReturnType; + +type ttStr = testType & string; +let tt1: ttStr = "hello"; +Assert.isString(tt1); +type ttBoo = testType & boolean; +let tt2: ttBoo = true; +Assert.isBoolean(tt2); +type ttNum = testType & number; +let tt3: ttNum = 1; +Assert.isNumber(tt3); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_3.ts b/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_3.ts new file mode 100644 index 0000000000..df3bfa521a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_3.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the inferred return type is the first of the types of the return statement expressions in the function body + that is a supertype of each of the others, ignoring return statements with no expressions. + A compile-time error occurs if no return statement expression has a type that is a supertype of each of the others. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function foo(x: string | number, y: string | boolean) { + if (typeof x === "string") { + return x.toUpperCase(); + } else if (typeof x === "number") { + return x.toString(); + } else if (typeof y === "string") { + return y.toUpperCase(); + } else { + return y; + } +} +type cc = ReturnType; +let dd: cc = "string"; +Assert.isString(dd); +dd = true; +Assert.isBoolean(dd); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_4.ts b/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_4.ts new file mode 100644 index 0000000000..9a30fc41e4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_4.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In the signature of a function implementation, a parameter can be marked optional by following it with an initializer. + When a parameter declaration includes both a type annotation and an initializer, the initializer expression is contextually typed by the stated type + and must be assignable to the stated type, or otherwise a compile-time error occurs. + When a parameter declaration has no type annotation but includes an initializer, + the type of the parameter is the widened form (section 3.12) of the type of the initializer expression + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +// stated type +class Test { + a: number; + constructor(a: number) { this.a = a; } +} +function f(x: number, y: Test = { a: 1 }, z = "hello") { + // the type of the parameter is the widened + Assert.isString(z); + return { + x, + yy: y, + z: z, + }; +} +// y and z are optional +Assert.equal(f(0).yy.a, 1); +Assert.equal(f(0).z, "hello"); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_5.ts b/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_5.ts new file mode 100644 index 0000000000..2cb9debe1a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_5.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Initializer expressions are evaluated in the scope of the function body but are not permitted to reference local variables + and are only permitted to access parameters that are declared to the left of the parameter they initialize, + unless the parameter reference occurs in a nested function expression. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let a = 1; +function f(x: number, y = x * 2, z = x + y) { + let b = 12; + function g(xx = b) { + return xx; + } + let c = g(); + return { x, y, z, g: c }; +} +Assert.equal(f(1).x, 1); +Assert.equal(f(1).y, 2); +Assert.equal(f(1).z, 3); +Assert.equal(f(1).g, 12); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/function_overloads/function_overloads_1.ts b/es2panda/test/ts_extra_tests/test/spec/functions/function_overloads/function_overloads_1.ts new file mode 100644 index 0000000000..a0598bff36 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/function_overloads/function_overloads_1.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The parameter list of a function overload cannot specify default values for parameters. + In other words, an overload may use only the ? form when specifying optional parameters. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function add(): number; +function add(x: number): number; +function add(y: number): number; +function add(x: number, y: number): number; +function add(xOry?: number, y?: number): number { + let sum: number = 0; + if (xOry) { + sum += xOry; + } + if (y) { + sum += y; + } + return sum; +} +Assert.equal(add(), 0); +Assert.equal(add(1), 1); +Assert.equal(add(1, 1), 2); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/generator_functions/generator_functions_1.ts b/es2panda/test/ts_extra_tests/test/spec/functions/generator_functions/generator_functions_1.ts new file mode 100644 index 0000000000..0acef06292 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/generator_functions/generator_functions_1.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + for..of loops over an iterable object, invoking the Symbol.iterator property on the object. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let someArray = [1, "string", false]; + +for (let item of someArray) { + if (typeof item === "number") { + Assert.equal(item, 1); + } else if (typeof item === "string") { + Assert.equal(item, "string"); + } else if (typeof item === "boolean") { + Assert.equal(item, false); + } +}; diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/generator_functions/generator_functions_2.ts b/es2panda/test/ts_extra_tests/test/spec/functions/generator_functions/generator_functions_2.ts new file mode 100644 index 0000000000..010ab7c8a6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/generator_functions/generator_functions_2.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Generator Functions + options: + lib: es2015 + target: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function* generator(): IterableIterator { + yield 0; + yield 1; + yield 2; +} +const iterator = generator(); +let cc = iterator.next(); +Assert.equal(cc.value, 0); +Assert.equal(cc.done, false); +cc = iterator.next(); +Assert.equal(cc.value, 1); +Assert.equal(cc.done, false); +cc = iterator.next(); +Assert.equal(cc.value, 2); +Assert.equal(cc.done, false); +cc = iterator.next(); +Assert.equal(cc.value, undefined); +Assert.equal(cc.done, true); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/generic_functions/generic_functions_1.ts b/es2panda/test/ts_extra_tests/test/spec/functions/generic_functions/generic_functions_1.ts new file mode 100644 index 0000000000..a8968c2096 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/generic_functions/generic_functions_1.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Type parameters declared in the signature of a function implementation are + in scope in the signature and body of that function implementation. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function identity(arg: T): T { + return arg; +} +Assert.equal(identity(0), 0); +Assert.equal(identity("hello"), "hello"); +Assert.equal(identity(true), true); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/generic_functions/generic_functions_2.ts b/es2panda/test/ts_extra_tests/test/spec/functions/generic_functions/generic_functions_2.ts new file mode 100644 index 0000000000..36c9e8de0d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/generic_functions/generic_functions_2.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The type arguments of a call to a generic function may be explicitly specified in a call operation + or may, when possible, be inferred from the types of the regular arguments in the call. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function identity(arg: T): T { + return arg; +} +Assert.equal(identity(0), 0); +Assert.equal(identity(0), 0); +Assert.equal(identity("hello"), "hello"); +Assert.equal(identity("hello"), "hello"); +Assert.equal(identity(true), true); +Assert.equal(identity(true), true); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/type_guard_functions/type_guard_functions_1.ts b/es2panda/test/ts_extra_tests/test/spec/functions/type_guard_functions/type_guard_functions_1.ts new file mode 100644 index 0000000000..8b8a5cd881 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/type_guard_functions/type_guard_functions_1.ts @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: TypeScript compiler narrows the type of a variable within a type guard. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Student { + name: string; + age: number; + constructor(name: string, age: number) { + this.name = name; + this.age = age; + } +} + +class Teacher { + name: string; + age: number; + job: string; + constructor(name: string, age: number, job: string) { + this.name = name; + this.age = age; + this.job = job; + } +} + +function isTeacher(obj: Student | Teacher): obj is Teacher { + return "job" in obj; +} +function printInfo(obj: Student | Teacher) { + if ( + isTeacher(obj) && + typeof obj.age === "number" && + obj instanceof Teacher + ) { + Assert.equal(obj.name, "caihuaTeacher"); + Assert.equal(obj.age, 20); + Assert.equal(obj.job, "teacher"); + return "teacher"; + } else { + Assert.equal(obj.name, "caihuaStudent"); + Assert.equal(obj.age, 20); + return "student"; + } +} + +let tt: Teacher = new Teacher("caihuaTeacher", 20, "teacher"); +let ss: Student = new Student("caihuaStudent", 20); +Assert.equal(printInfo(tt), "teacher"); +Assert.notEqual(printInfo(tt), "student"); +Assert.equal(printInfo(ss), "student"); +Assert.notEqual(printInfo(ss), "teacher"); diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/classes/classes.ts b/es2panda/test/ts_extra_tests/test/spec/grammar/classes/classes.ts new file mode 100644 index 0000000000..f72709bc48 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/grammar/classes/classes.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + this appendix contains a summary of the grammar found in the main document. + typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface PointInterface { + x: number; + y: number; + z: number; + getPointArray(): number[]; +} +class Point implements PointInterface { + x: number = 0; + y: number = 0; + z: number = 0; + getPointArray() { + return [this.x, this.y, this.z]; + } + constructor(x: number, y: number, z: number) { + this.x = x; + this.y = y; + this.z = z; + } +} +class ColorC extends Point { + static Red: number = 0; + static Green: number = 0; + static Blue: number = 0; + static getColorArray(): number[] { + return [this.Red, this.Green, this.Blue] + } + toJSON() { + return JSON.stringify(ColorC.getColorArray()); + } + constructor(Red: number, Green: number, Blue: number, x: number = 0, y: number = 0, z: number = 0) { + super(x, y, z); + ColorC.Red = Red; + ColorC.Green = Green; + ColorC.Blue = Blue; + } +} +let colorPoint = new ColorC(255, 0, 0, 1, 1, 1); +Assert.equal(JSON.stringify(colorPoint.getPointArray()), "[1,1,1]"); +Assert.equal(colorPoint.toJSON(), "[255,0,0]"); diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/enums/enums.ts b/es2panda/test/ts_extra_tests/test/spec/grammar/enums/enums.ts new file mode 100644 index 0000000000..dbb432d691 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/grammar/enums/enums.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + this appendix contains a summary of the grammar found in the main document. + typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +const enum CED { + None = -1, + False, + True = 1, + DEF = 1024, + Ver = "1.0.1", +} +Assert.equal(CED.None, -1); +Assert.equal(CED.False, 0); +Assert.equal(CED.True, 1); +Assert.equal(CED.DEF, 1024); +Assert.equal(CED["None"], -1); +Assert.equal(CED["False"], 0); +Assert.equal(CED["True"], 1); +Assert.equal(CED["DEF"], 1024); +Assert.equal(CED.Ver, "1.0.1"); diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/expressions/expressions.ts b/es2panda/test/ts_extra_tests/test/spec/grammar/expressions/expressions.ts new file mode 100644 index 0000000000..09327519a0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/grammar/expressions/expressions.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + this appendix contains a summary of the grammar found in the main document. + typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class EXP { + cname: string; + private _ver: number = -1; + addName(ad: string) { + this.cname = this.cname + " " + ad; + return this.cname; + } + get ver() { + return this._ver; + } + set ver(v: number) { + this._ver = v; + } + constructor(cname: string) { + this.cname = cname; + } +} +let exp = new EXP("EXP"); +exp.addName("Class"); +Assert.equal(exp.cname, "EXP Class"); + +exp.ver = 1; +Assert.equal(exp.ver, 1); + +function Ax2(a: number) { + return a * 2; +} +Assert.equal(Ax2(2), 4); + +let fun1: (a: number, b: number) => number = (a: number, b: number) => { + return a + b; +} +Assert.equal(fun1(1, 2), 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/functions/functions.ts b/es2panda/test/ts_extra_tests/test/spec/grammar/functions/functions.ts new file mode 100644 index 0000000000..031c95ec63 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/grammar/functions/functions.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + this appendix contains a summary of the grammar found in the main document. + typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function addXYZ(x: number, y: number, z: number): number { + return x + y + z; +} +Assert.equal(addXYZ(1, 2, 3), 6); + +function addXY(x: number, y: number): number; +function addXY(x: number, y: number): number { + return x + y; +} +Assert.equal(addXY(1, 2), 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/interfaces/interfaces.ts b/es2panda/test/ts_extra_tests/test/spec/grammar/interfaces/interfaces.ts new file mode 100644 index 0000000000..34eebfd537 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/grammar/interfaces/interfaces.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + this appendix contains a summary of the grammar found in the main document. + typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface X { + x: number; +} +interface Y { + y: number; +} +interface Z { + z: number; +} +interface PointXYZ extends X, Y, Z { + toJSON(): string; +} +let pa: PointXYZ = { + x: 3, + y: 4, + z: 5, + toJSON() { + let pArr = [this.x, this.y, this.z]; + return JSON.stringify(pArr); + }, +} +Assert.equal(pa.toJSON(), "[3,4,5]"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/namespaces/namespaces.ts b/es2panda/test/ts_extra_tests/test/spec/grammar/namespaces/namespaces.ts new file mode 100644 index 0000000000..f272a45cb4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/grammar/namespaces/namespaces.ts @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + this appendix contains a summary of the grammar found in the main document. + typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +namespace ExampleG { + var namespace_name = "Example"; + export function exampleName(str: string): string { + return str + " " + namespace_name; + } + class Point { + x: number = 0; + y: number = 0; + } + interface PointXYZ { + x: number; + y: number; + z: number; + } + type StrNumBool = string | number | boolean; + export enum Color { + RED = 0xFF0000, + GREEN = 0x00FF00, + BLUE = 0x0000FF, + }; + namespace SubNamespace { } + declare var __TEST__: boolean; + export import EE = ExportExampleG; +} +namespace ExportExampleG { + export var namespace_name = "ExportExampleG"; + export function exampleEName(str: string): string { + return str + " " + namespace_name; + } + export class Point { + x: number = 0; + y: number = 0; + } + export interface PointXYZ { + x: number; + y: number; + z: number; + } + export type StrNumBool = string | number | boolean; + export enum Color { + RED = 0xFF0000, + GREEN = 0x00FF00, + BLUE = 0x0000FF, + } + export namespace SubNamespace { } + export declare var __TEST__: boolean; + export import E = ExampleG; +} +Assert.equal(ExampleG.exampleName("G"), "G Example"); +Assert.equal(ExampleG.Color.RED, 0xFF0000); +Assert.equal(ExportExampleG.exampleEName("G"), "G ExportExampleG"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/statements/statements.ts b/es2panda/test/ts_extra_tests/test/spec/grammar/statements/statements.ts new file mode 100644 index 0000000000..239165c974 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/grammar/statements/statements.ts @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + this appendix contains a summary of the grammar found in the main document. + typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface Skill { + SkillName: string; + Damage: number; + Data: string; +} +let aoe: Skill = { SkillName: "AoE", Damage: 495, Data: "AreaFire" }; +Assert.equal(aoe.SkillName, "AoE"); +Assert.equal(aoe.Damage, 495); +Assert.equal(aoe.Data, "AreaFire"); + +type NumStr = number | string; +let ns: NumStr; +ns = 1024; +Assert.isNumber(ns); +ns = "A"; +Assert.isString(ns); + +enum Color { + Red = 0xFF0000, + Green = 0x00FF00, + Bule = 0x0000FF, +} +Assert.equal(Color.Green, 0x00FF00); + +let aaa; +aaa = true; +Assert.isBoolean(aaa); +aaa = 1408; +Assert.isNumber(aaa); +let abc: string; +abc = "ABC"; +Assert.isString(abc); + +type TF = -1 | 0 | 1; +let tf0: TF = 0; +let tf1: TF = 1; +let tf2: TF = -1; +Assert.equal(tf0, 0); +Assert.equal(tf1, 1); +Assert.equal(tf2, -1); diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/types/types.ts b/es2panda/test/ts_extra_tests/test/spec/grammar/types/types.ts new file mode 100644 index 0000000000..11300ca38d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/grammar/types/types.ts @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + this appendix contains a summary of the grammar found in the main document. + typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. + options: + target: es2015 + lib: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let num: number = 1024; +let str: string = "string"; +let bool: boolean = false; +let big: bigint = 1n; +let sym: symbol = Symbol(); +let obj: object = {}; +let fun: Function = () => { return "Function"; } +let udf: undefined = undefined; +Assert.isNumber(num); +Assert.isString(str); +Assert.isBoolean(bool); +Assert.equal(typeof big, "bigint"); +Assert.isSymbol(sym); +Assert.equal(typeof obj, "object"); +Assert.isFunction(fun); +Assert.isUndefined(udf); + +type Ver = { ver: string }; +interface Data extends Ver { + data: number; +} +let v: Data = { data: 1024, ver: "1.0.1" }; +Assert.equal(v.data, 1024); +Assert.equal(v.ver, "1.0.1"); + +class AB{ + a: T | undefined; + b: U | undefined; + public c: string = ""; + private d: string = ""; + protected e: string = ""; + setD(val: string) { + this.d = val; + } + setE(val: string) { + this.e = val; + } + show() { + return JSON.stringify({ d: this.d, e: this.e }); + } + constructor(a?: T, b?: U) { + this.a = a; + this.b = b; + } +} +let ab = new AB(123, "ABC"); +Assert.equal(ab.a, 123); +Assert.equal(ab.b, "ABC"); + +let ab2 = new AB(1024); +Assert.equal(ab2.a, 1024); +Assert.isUndefined(ab2.b); + +ab.c = "1024"; +Assert.equal(ab.c, "1024"); + +ab.setD("D"); +ab.setE("E"); +Assert.equal(ab.show(), "{\"d\":\"D\",\"e\":\"E\"}"); + +type ONS = { n1?: number | string, n2?: number | string }; +let ons: ONS = { n1: 0, n2: "ABC" }; +Assert.equal(ons.n1, 0); +Assert.equal(ons.n2, "ABC"); + + +type NumStrBool = number | string | boolean; +type NumObjBool = number | object | boolean; +type NumBool = NumObjBool & NumStrBool; +let nb: NumBool = 1; +Assert.isNumber(nb); +nb = true; +Assert.isBoolean(nb); + +type StrFun = (a: string, b: string) => string; +let strFun: StrFun = (a: string, b: string) => { return a + b; } +Assert.equal(strFun("AB", "CD"), "ABCD"); + +let a: any; +let vo: void; + +let arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; +Assert.equal(arr[0], 0); + +type type0 = "A" | "B" | "C" | "D"; +let t0: type0 = "A"; +Assert.equal(t0, "A"); + +type NumStrArray = number[] | string[] | (number | string)[]; +let nsa1: NumStrArray = [1, 3, 5]; +let ar1 = [1, 3, 5] +let nsa2: NumStrArray = ["A", "B", "C"]; +let ar2 = ["A", "B", "C"]; +let nsa3: NumStrArray = ["A", 1, "B", 2, "C", 3]; +let ar3 = ["A", 1, "B", 2, "C", 3]; +Assert.equal(JSON.stringify(nsa1), JSON.stringify(ar1)); +Assert.equal(JSON.stringify(nsa2), JSON.stringify(ar2)); +Assert.equal(JSON.stringify(nsa3), JSON.stringify(ar3)); + +type ABC = [number, string, boolean]; +let abc: ABC = [1, "A", true]; +let abc2 = [1, "A", true]; +Assert.equal(JSON.stringify(abc), JSON.stringify(abc2)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/interfaces/1_interface_declarations/interface_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/interfaces/1_interface_declarations/interface_declarations_1.ts new file mode 100644 index 0000000000..a4589bf231 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/interfaces/1_interface_declarations/interface_declarations_1.ts @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + An interface declaration declares an interface type. + An InterfaceDeclaration introduces a named type (section 3.7) in the containing declaration space. + The BindingIdentifier of an interface declaration may not be one of the predefined type names (section 3.8.1). + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +{ + interface Worker { + x: number; + + work(): void; + + getS(): { velocity: number; }; + } + + interface Tool { + y: number; + + tool(): void; + + getS(): { rate: number; }; + } + + let result1: { rate: number; } = { + rate: 1 + }; + let result2: { velocity: number; } = { + velocity: 1, + }; + + let point: Worker = { + x: 1, + getS(): { velocity: number; } { + return result2 + }, + work(): void { + } + }; + let pointer: Tool = { + y: 1, + getS(): { rate: number; } { + return result1 + }, + tool(): void { + }, + }; + + Assert.equal(point.x, 1); + Assert.equal(pointer.y, 1); + Assert.equal(point.getS(), result2); + Assert.equal(pointer.getS(), result1); + Assert.equal(pointer.tool(), undefined); + Assert.equal(point.work(), undefined); +}; diff --git a/es2panda/test/ts_extra_tests/test/spec/interfaces/1_interface_declarations/interface_declarations_2.ts b/es2panda/test/ts_extra_tests/test/spec/interfaces/1_interface_declarations/interface_declarations_2.ts new file mode 100644 index 0000000000..1ee6986784 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/interfaces/1_interface_declarations/interface_declarations_2.ts @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + An interface can inherit from zero or more base types which are specified in the InterfaceExtendsClause. + The base types must be type references to class or interface types. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +{ + interface Worker { + x: number; + + work(): void; + + getS(): { velocity: number; }; + } + + interface Tool { + y: number; + + tool(): void; + + getS(): { rate: number; }; + } + + interface WorkerTool extends Worker, Tool { + z: number; + + getS(): { velocity: number; rate: number; }; + } + + let result: { velocity: number; rate: number; } = { + velocity: 1, + rate: 1 + }; + + let point: WorkerTool = { + x: 1, + z: 1, + y: 1, + getS(): { velocity: number; rate: number; } { + return result + }, + tool(): void { + }, + work(): void { + } + }; + + Assert.equal(point.x, 1); + Assert.equal(point.y, 1); + Assert.equal(point.z, 1); + Assert.equal(point.getS(), result); + Assert.equal(point.tool(), undefined); + Assert.equal(point.work(), undefined); +}; diff --git a/es2panda/test/ts_extra_tests/test/spec/interfaces/1_interface_declarations/interface_declarations_3.ts b/es2panda/test/ts_extra_tests/test/spec/interfaces/1_interface_declarations/interface_declarations_3.ts new file mode 100644 index 0000000000..e498b39d12 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/interfaces/1_interface_declarations/interface_declarations_3.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Since function and constructor types are just object types containing call and construct signatures, interfaces can + be used to declare named function and constructor types + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +{ + interface StringC { + (h_a: string, h_b: string): number; + } + + let ps: StringC = + (h_a: string, h_b: string): number => { + return 1 + }; + + class Class { + h_x: number; + h_y: number; + + constructor(h_a: number, h_b: number) { + this.h_x = h_a; + this.h_y = h_b; + } + } + + let pt: Class = new Class(0, 1); + // assert declare named function + Assert.equal(pt.h_x, 0); + // assert constructor types + Assert.equal(pt.h_y, 1); +}; diff --git a/es2panda/test/ts_extra_tests/test/spec/interfaces/2_declaration_merging/declaration_merging_1.ts b/es2panda/test/ts_extra_tests/test/spec/interfaces/2_declaration_merging/declaration_merging_1.ts new file mode 100644 index 0000000000..7aba6ce7a3 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/interfaces/2_declaration_merging/declaration_merging_1.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When a generic interface has multiple declarations, all declarations must have identical type parameter lists, + i.e. identical type parameter names with identical constraints in identical order. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +{ + interface Ds { + createE1(a: T): number; + } + + interface Ds { + createE2(a: T): number; + + createE3(a: T): number; + } + + let name: Ds = { + createE1(a: string): number { + return 0 + }, + createE2(a: boolean): number { + return 0 + }, + createE3(a: number): number { + return 0 + } + }; + + class Class { + static getName(name: Ds): Ds { + return name; + } + } + + Assert.equal(Class.getName(name).createE1(''), 0); + Assert.equal(Class.getName(name).createE3(0), 0); + Assert.equal(Class.getName(name).createE2(true), 0); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/interfaces/2_declaration_merging/declaration_merging_2.ts b/es2panda/test/ts_extra_tests/test/spec/interfaces/2_declaration_merging/declaration_merging_2.ts new file mode 100644 index 0000000000..90d5543f22 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/interfaces/2_declaration_merging/declaration_merging_2.ts @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + multiple declarations is equivalent to the following single declaration. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +{ + interface D1 { + createE1(a: string): number; + } + + interface D1 { + createE2(a: boolean): number; + + createE3(a: number): number; + } + + interface DAssert { + createE4(a: string): number; + + createE5(a: boolean): number; + + createE6(a: number): number; + } + + let name: D1 & DAssert = { + createE1(a: string): number { + return 0 + }, + createE2(a: boolean): number { + return 0 + }, + createE3(a: number): number { + return 0 + }, + createE4(a: string): number { + return 0 + }, + createE5(a: boolean): number { + return 0 + }, + createE6(a: number): number { + return 0 + } + }; + + class Class { + static getName(name: D1 & DAssert): D1 & DAssert { + return name; + } + } + + Assert.equal(Class.getName(name).createE1(''), 0); + Assert.equal(Class.getName(name).createE3(0), 0); + Assert.equal(Class.getName(name).createE2(true), 0); + Assert.equal(Class.getName(name).createE4(''), 0); + Assert.equal(Class.getName(name).createE5(true), 0); + Assert.equal(Class.getName(name).createE6(0), 0); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_1.ts b/es2panda/test/ts_extra_tests/test/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_1.ts new file mode 100644 index 0000000000..590267ccf5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_1.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When an interface type extends a class type it inherits the members of the class but not their implementations. + It is as if the interface had declared all of the members of the class without providing an implementation. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +{ + class h_C { + private state: any = 0; + point: any = 0; + } + + interface h_SC extends h_C { + choose(): number; + } + + class h_B extends h_C implements h_SC { + choose(): number { + return 0 + } + } + + Assert.isTrue(new h_B().hasOwnProperty('point')); + Assert.isTrue(new h_B().hasOwnProperty('state')); + +}; diff --git a/es2panda/test/ts_extra_tests/test/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_2.ts b/es2panda/test/ts_extra_tests/test/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_2.ts new file mode 100644 index 0000000000..115e1a2458 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_2.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Interfaces inherit even the private and protected members of a base class. + When a class containing private or protected members is the base type of an interface type, + that interface type can only be implemented by that class or a descendant class. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class h_C { + private h_pri: string; + constructor(h_pri: string) { + this.h_pri = h_pri; + } + get() { + return this.h_pri; + } + set() { + this.h_pri = this.h_pri; + } +} +interface h_I extends h_C { + choose(): string; +} +class h_c extends h_C implements h_I { + choose(): string { + return 'choose'; + } +} +var h_CC = new h_C('private'); +Assert.equal(h_CC.get(), 'private'); +var h_cc = new h_c('PRIVATE'); +Assert.equal(h_cc.get(), 'PRIVATE'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/interfaces/4_dynamic_type_checks/dynamic_type_checks_1.ts b/es2panda/test/ts_extra_tests/test/spec/interfaces/4_dynamic_type_checks/dynamic_type_checks_1.ts new file mode 100644 index 0000000000..7eb0e29d9a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/interfaces/4_dynamic_type_checks/dynamic_type_checks_1.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript does not provide a direct mechanism for dynamically testing whether an object implements a particular + interface. Instead, TypeScript code can use the JavaScript technique of checking whether an appropriate set of members + are present on the object + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +{ + interface WorkerTool { + shift(): void; + + rock(): void; + + getS(): void; + } + + function asWorkerTool(o: any): WorkerTool { + return o && o.shift && o.rock && o.getS ? o : null; + } + + let point: WorkerTool = { + getS(): void { + }, + rock(): void { + }, + shift(): void { + } + }; + + Assert.equal(asWorkerTool(point), point); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_1_1.ts b/es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_1_1.ts new file mode 100644 index 0000000000..1b184061c8 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_1_1.ts @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +namespace outside { + var native = 1; + export var h_a = native; + export namespace interior { + export var h_x = 10; + } + export interface OA { + OA: string; + } +}; diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_1_2.ts b/es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_1_2.ts new file mode 100644 index 0000000000..249f43f4be --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_1_2.ts @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +namespace outside { + var native = 2; + export var h_b = native; + export namespace interior { + export var h_y = 20; + } + export interface OB { + OB: number; + } +}; diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_1_3.ts b/es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_1_3.ts new file mode 100644 index 0000000000..40f5e04746 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_1_3.ts @@ -0,0 +1,30 @@ +/// +/// +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + namespaces are "open-ended" and namespace declarations with the same qualified name relative to a common root (as defined in section 2.3) contribute to a single namespace. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var o1: outside.OA = { OA: "OA" }; +var o2: outside.OB = { OB: 1024 }; +Assert.isString(o1.OA); +Assert.isNumber(o2.OB); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_2.ts b/es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_2.ts new file mode 100644 index 0000000000..d75e35c37e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_2.ts @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + declaration merging also extends to namespace declarations with the same qualified name relative to a common root as a function, class, or enum declaration. + when merging a non-ambient function or class declaration and a non-ambient namespace declaration, the function or class declaration must be located prior to the namespace declaration in the same source file. + this ensures that the shared object instance is created as a function object. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface Point { + x: number; + y: number; +} +function Point(x: number, y: number): Point { + return { x: x, y: y }; +} +namespace Point { + export var origin = Point(0, 0); + export function equals(p1: Point, p2: Point) { + return p1.x == p2.x && p1.y == p2.y; + } +} +var p1 = Point(0, 0); +var p2 = Point.origin; +var b = Point.equals(p1, p2); +Assert.equal(p1.x, 0); +Assert.equal(p1.y, 0); +Assert.equal(p2.x, 0); +Assert.equal(p2.y, 0); +Assert.equal(b, true); + +enum Color { + Red = 0xFF0000, + Green = 0x00FF00, + Blue = 0x0000FF, +} +namespace Color { + export interface Color { + Red: number; + Green: number; + Blue: number; + } +} +Assert.equal(Color.Red, 0xFF0000); +var color: Color.Color = { Red: 255, Green: 255, Blue: 255 }; +Assert.equal(color.Green, 255); + +class PointXYZ { + public x: number; + public y: number; + public z: number; + constructor(x: number = 0, y: number = 0, z: number = 0) { + this.x = x; + this.y = y; + this.z = z; + } + toString() { + return "( " + this.x + " , " + this.y + " , " + this.z + " )"; + } +} +namespace PointXYZ { + export var xyz = new PointXYZ(1, 1, 1); + export interface PointXYZ { + x: number; + y: number; + z: number; + } +} +var xyz1 = new PointXYZ(1, 3, 5); +var xyz2: PointXYZ.PointXYZ = { x: 2, y: 3, z: 4 }; +var xyz3 = PointXYZ.xyz; +Assert.equal(xyz1.toString(), "( 1 , 3 , 5 )"); +Assert.equal(xyz2.x, 2); +Assert.equal(xyz3.toString(), "( 1 , 1 , 1 )"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/export_declarations/export_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/namespaces/export_declarations/export_declarations_1.ts new file mode 100644 index 0000000000..8f240e609d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/namespaces/export_declarations/export_declarations_1.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + an export declaration declares an externally accessible namespace member. An export declaration is simply a regular declaration prefixed with the keyword export. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +namespace ED1 { + export interface Weapon { WName: string, Damage: number } + export var def = 1024; +} +var weapon1: ED1.Weapon = { WName: "40mmAT", Damage: 40 }; +var def1 = ED1.def; +Assert.equal(weapon1.WName, "40mmAT"); +Assert.equal(weapon1.Damage, 40); +Assert.equal(def1, 1024); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/export_declarations/export_declarations_2.ts b/es2panda/test/ts_extra_tests/test/spec/namespaces/export_declarations/export_declarations_2.ts new file mode 100644 index 0000000000..1ad82d5e7d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/namespaces/export_declarations/export_declarations_2.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the members of a namespace's export declaration space constitute the namespace's export member set. + a namespace's instance type is an object type with a property for each member in the namespace's export member set that denotes a value. + module: ESNext + isCurrent: true + ---*/ + +import { Assert } from '../../../../suite/assert.js' + + +namespace ED2 { + export var def = 1024; + interface Weapon { WName: string, Damage: number } + export var weapon1: Weapon = { WName: "Lightting", Damage: 200 } + export var tf = "False"; +} +var ed2 = ED2; +var ed2_1 = ed2.def; +var ed2_2 = ed2.weapon1; +var ed2_3 = ed2.tf; +Assert.equal(typeof ed2, "object"); +Assert.isNumber(ed2_1); +Assert.equal(typeof ed2_2, "object"); +Assert.isString(ed2_3); diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/export_declarations/export_declarations_3.ts b/es2panda/test/ts_extra_tests/test/spec/namespaces/export_declarations/export_declarations_3.ts new file mode 100644 index 0000000000..bea69bcc1b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/namespaces/export_declarations/export_declarations_3.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + an exported member depends on a (possibly empty) set of named types. Those named types must be at least as accessible as the exported member, or otherwise an error occurs. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface WeaponDamage { DamageType: string, Damage: number } +namespace ED3 { + export interface WeaponData { WName: string, ROT: number, Range: number } + export interface Weapon { WeaponDamage: WeaponDamage, WeaponData: WeaponData } + export function getWeapon(Weapon: Weapon) { + return "WeaponName = " + Weapon.WeaponData.WName + "\n" + "DamageType = " + Weapon.WeaponDamage.DamageType + "\n" + "Damage = " + Weapon.WeaponDamage.Damage + "\n" + "ROT = " + Weapon.WeaponData.ROT + "\n" + "Range = " + Weapon.WeaponData.Range; + } +} +var weapon_damage: WeaponDamage = { DamageType: "EXPLODE", Damage: 1024 }; +var weapon_data: ED3.WeaponData = { WName: "AntiTankMissiles", ROT: 75, Range: 16 }; +var weapon: ED3.Weapon = { WeaponData: weapon_data, WeaponDamage: weapon_damage }; +var weaponStr = ED3.getWeapon(weapon); +Assert.isString(weaponStr); diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/import_alias_declarations/import_alias_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/namespaces/import_alias_declarations/import_alias_declarations_1.ts new file mode 100644 index 0000000000..41e5d6172e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/namespaces/import_alias_declarations/import_alias_declarations_1.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + import alias declarations are used to create local aliases for entities in other namespaces. + an EntityName consisting of a single identifier is resolved as a NamespaceName and is thus required to reference a namespace. The resulting local alias references the given namespace and is itself classified as a namespace. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +namespace hB { + interface hA { hn: number } + export import hY = hA; + import hZ = hA.hX; + export var vb: hZ = { hs: "v" }; +} +namespace hA { + export interface hX { hs: string } + export import va = hB.vb; +} +var v1: hB.hY.hX = hB.vb; +var v2 = hA.va; +let iadFlag: boolean = false; +if (v1 == v2) { + iadFlag = true; +} +Assert.isTrue(iadFlag); + diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/import_alias_declarations/import_alias_declarations_3.ts b/es2panda/test/ts_extra_tests/test/spec/namespaces/import_alias_declarations/import_alias_declarations_3.ts new file mode 100644 index 0000000000..920cfd5cef --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/namespaces/import_alias_declarations/import_alias_declarations_3.ts @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + when an import statement includes an export modifier, all meanings of the local alias are exported. + module: ESNext + isCurrent: true + ---*/ + + +class AssertionError extends Error { + constructor(public msg: string) { + super(); + this.msg = ""; + this.msg = msg; + } +} + +function defaultMessage(actual: any, expect: any, flag: boolean = true) { + if (flag == true) { + return "expected '" + expect + "' ,but was '" + actual + "'."; + } else { + return "expected not '" + expect + "' ,but was '" + actual + "'."; + } + +} + +function equal(actual: any, expect: any, msg?: string) { + if (actual != expect) { + throw new AssertionError(msg ? msg : defaultMessage(actual, expect)); + } +} +namespace IAD1 { + export var lv: number = 5; + export interface GGI { + UIName: string; + Cost: number; + } +} +namespace IAD2 { + import I1 = IAD1; + import I2 = IAD1.GGI; + export var i2 = I1.lv * 2; + export interface GI extends I2 { + Strength: number; + } +} +var i1 = IAD2.i2; +var gi: IAD2.GI = { UIName: "GI", Cost: 200, Strength: 100 }; +equal(i1, 10); +equal(gi.UIName, "GI"); +equal(gi.Cost, 200); +equal(gi.Strength, 100); + +namespace IAD3 { + export var i = 0; + interface U { + times: number; + } + var u1: U = { times: 5 }; + export function ux5() { + return u1.times * 5; + } +} +export namespace IAD4 { + export import I3 = IAD3; +} +equal(IAD4.I3.i, 0); +equal(IAD4.I3.ux5(), 25); diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_body/namespace_body.ts b/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_body/namespace_body.ts new file mode 100644 index 0000000000..34ad1291b8 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_body/namespace_body.ts @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the body of a namespace corresponds to a function that is executed once to initialize the namespace instance. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +namespace Example { + var namespace_name = "Example"; + export function exampleName(str: string): string { + return str + " " + namespace_name; + } + class Point { + x: number = 0; + y: number = 0; + } + interface PointXYZ { + x: number; + y: number; + z: number; + } + type StrNumBool = string | number | boolean; + export enum Color { + RED = 0xFF0000, + GREEN = 0x00FF00, + BLUE = 0x0000FF, + } + namespace SubNamespace { } + declare var __TEST__: boolean; + import EE = ExportExample; +} +namespace ExportExample { + export var namespace_name = "ExportExample"; + export function exampleEName(str: string): string { + return str + " " + namespace_name; + } + export class Point { + x: number = 0; + y: number = 0; + } + export interface PointXYZ { + x: number; + y: number; + z: number; + } + export type StrNumBool = string | number | boolean; + export enum Color { + RED = 0xFF0000, + GREEN = 0x00FF00, + BLUE = 0x0000FF, + } + export namespace SubNamespace { } + export declare var __TEST__: boolean; + export import E = Example; +} +Assert.equal(Example.exampleName("G"), "G Example"); +Assert.equal(Example.Color.RED, 0xFF0000); +Assert.equal(ExportExample.exampleEName("G"), "G ExportExample"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_1.ts new file mode 100644 index 0000000000..4fa81baceb --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_1.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + namespaces are declared using the namespace keyword, + but for backward compatibility of earlier versions of TypeScript a module keyword can also be used. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +namespace A { + export interface TA { + TName: string; + Ver: number; + } +} +var varA: A.TA = { TName: "TA", Ver: 1.5 } +Assert.equal(varA.TName, "TA"); +Assert.equal(varA.Ver, 1.5); +module B { + export interface TB { + SkillName: string; + Damage: number; + } +} +var varB: B.TB = { SkillName: "OverKill", Damage: 1024 }; +Assert.equal(varB.SkillName, "OverKill"); +Assert.equal(varB.Damage, 1024); diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_2.ts b/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_2.ts new file mode 100644 index 0000000000..eef814ca13 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_2.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + namespaces are either instantiated or non-instantiated. A non-instantiated namespace is a namespace containing only interface types, type aliases, and other non-instantiated namespace. + an instantiated namespace is a namespace that doesn't meet this definition. In intuitive terms, an instantiated namespace is one for which a namespace instance is created, whereas a non-instantiated namespace is one for which no code is generated. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +namespace NonInstantiated { + export interface A { + TName: string; + Ver: number; + } + export type TF = boolean | number; + export namespace NI { + export interface B { + SkillName: string; + Damage: number; + } + export type StrNum = string | number; + } +} +var ni1: NonInstantiated.A = { TName: "Non", Ver: 1.0 }; +var ni2: NonInstantiated.NI.StrNum = "ni2"; +Assert.equal(ni1.Ver, 1.0); +Assert.equal(ni2, "ni2"); + +namespace Instantiated { + export function returnName() { + return "Instantiated"; + } + export var nsname: string = "Instantiated"; +} +Assert.equal(Instantiated.returnName(), "Instantiated"); +Assert.equal(Instantiated.nsname, "Instantiated"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_3.ts b/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_3.ts new file mode 100644 index 0000000000..ba7781ad29 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_3.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + when a namespace identifier is referenced as a NamespaceName it denotes a container of namespace and type names, and when a namespace identifier is referenced as a PrimaryExpression it denotes the singleton namespace instance. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +namespace A { + export interface TypeA { + AName: string; + Lv: number; + UID: number; + } + export var player: TypeA = { AName: "Player", Lv: 5, UID: 0x0000A0F0 }; + export var playerRandom: TypeA = { AName: "playerRandom", Lv: getRandomNumber(99), UID: getRandomNumber(0xFFFFFFFF) }; + function getRandomNumber(x: number): number { + return Math.floor(Math.random() * x); + } +} +var playerA = A.player; +var playerB = A.playerRandom; +var an = A; +var playerC: A.TypeA = { AName: "PlayerC", Lv: 95, UID: 6250 }; +var playerD = an.player; +Assert.equal(playerA.AName, "Player"); +Assert.equal(playerA.Lv, 5); +Assert.equal(playerA.UID, 41200); +Assert.equal(playerB.AName, "playerRandom"); +Assert.isNumber(playerB.Lv); +Assert.isNumber(playerB.UID); +Assert.equal(playerC.AName, "PlayerC"); +Assert.equal(playerC.Lv, 95); +Assert.equal(playerC.UID, 6250); +Assert.equal(playerD.AName, "Player"); +Assert.equal(playerD.Lv, 5); +Assert.equal(playerD.UID, 41200); diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_4.ts b/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_4.ts new file mode 100644 index 0000000000..c2c09e42be --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_4.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + a namespace declaration that specifies an IdentifierPath with more than one identifier is equivalent to a series of nested single-identifier namespace declarations where all but the outermost are automatically exported. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +namespace h_A.h_B.h_C { + export var h_x = "This is equivalent to the code below."; +} +Assert.equal(h_A.h_B.h_C.h_x, "This is equivalent to the code below."); +namespace h_A { + export namespace h_B { + export namespace h_C { + export var h_x = "This is equivalent to the code above."; + } + } +} +Assert.equal(h_A.h_B.h_C.h_x, "This is equivalent to the code above."); diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_1.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_1.ts new file mode 100644 index 0000000000..9f6fb69cad --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_1.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export function message():string { + return 'string'; +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_10.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_10.ts new file mode 100644 index 0000000000..fafe386049 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_10.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export interface Point { x: number; y: number }; + +export function point(x: number, y: number): Point { + return { x, y }; +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_2.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_2.ts new file mode 100644 index 0000000000..512c7b88a0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_2.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export let h_x: number = 0; +export let h_y: number = 1; +export let h_z: number = 2; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_3.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_3.ts new file mode 100644 index 0000000000..1f005b1ecb --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_3.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +let x:number = 0; +export default x; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_4.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_4.ts new file mode 100644 index 0000000000..15a51b3ab1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_4.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export default function message():string { + return 'string'; +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_5.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_5.ts new file mode 100644 index 0000000000..7bb278e263 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_5.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +function message():string { + return 'string'; +} + +export default message; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_6.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_6.ts new file mode 100644 index 0000000000..0ad23bd163 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_6.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +function message():string { + return 'string'; +} + +export { message as default }; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_7.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_7.ts new file mode 100644 index 0000000000..fab5d937f6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_7.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +function message():string { + return 'string'; +} + +interface message { + x: number; + y: number; +} + + +export default message; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_8.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_8.ts new file mode 100644 index 0000000000..5f1327d564 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_8.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export default 'hello'; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_9.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_9.ts new file mode 100644 index 0000000000..899278f98f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_9.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +class Point { + public x: number; + public y: number; + constructor(a: number, b: number) { + this.x = a; + this.y = b; + } +} +export default Point; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/2_modules/modules_1.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/2_modules/modules_1.ts new file mode 100644 index 0000000000..03406a4a93 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/2_modules/modules_1.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + An interface declaration declares an interface type. + An InterfaceDeclaration introduces a named type (section 3.7) in the containing declaration space. + The BindingIdentifier of an interface declaration may not be one of the predefined type names (section 3.8.1). + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import { message } from '../1_programs_and_source_files/source_1.js'; + +Assert.equal(message(), 'string'); diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_1.ts new file mode 100644 index 0000000000..482d3537e4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_1.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Import declarations are used to import entities from other modules and provide bindings for them in the current module. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import * as h_m from '../1_programs_and_source_files/source_2.js'; + +Assert.equal(h_m.h_x, 0); +Assert.equal(h_m.h_y, 1); +Assert.equal(h_m.h_z, 2); diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_2.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_2.ts new file mode 100644 index 0000000000..2fe3642b6b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_2.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + imports the module with the given name and creates a local binding for the module itself. The local binding is + classified as a value (representing the module instance) and a namespace (representing a container of types and + namespaces). + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import { h_x, h_y, h_z } from '../1_programs_and_source_files/source_2.js'; + +Assert.equal(h_x, 0); +Assert.equal(h_y, 1); +Assert.equal(h_z, 2); diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_3.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_3.ts new file mode 100644 index 0000000000..b444779c3c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_3.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + imports a given module and creates local bindings for a specified list of exported members of the module. The specified + names must each reference an entity in the export member set (11.3.4.4) of the given module. The local bindings have t + he same names and classifications as the entities they represent unless as clauses are used to that specify different + local names. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import { h_x as a, h_y as b, h_z as c } from '../1_programs_and_source_files/source_2.js'; + +Assert.equal(a, 0); +Assert.equal(b, 1); +Assert.equal(c, 2); diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_4.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_4.ts new file mode 100644 index 0000000000..11c402ebe2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_4.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + imports a given module and creates local bindings for a specified list of exported members of the module. The specified + names must each reference an entity in the export member set (11.3.4.4) of the given module. The local bindings have t + he same names and classifications as the entities they represent unless as clauses are used to that specify different + local names. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import x from '../1_programs_and_source_files/source_3.js'; +import { default as a } from '../1_programs_and_source_files/source_3.js'; + +Assert.equal(x, 0); +Assert.equal(a, 0); diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/4_import_require_declarations/import_require_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/4_import_require_declarations/import_require_declarations_1.ts new file mode 100644 index 0000000000..574384e19f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/4_import_require_declarations/import_require_declarations_1.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Import require declarations exist for backward compatibility with earlier versions of TypeScript. + An import require declaration of the form + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import * as m from "../1_programs_and_source_files/source_2.js" + +Assert.equal(m.h_x, 0); +Assert.equal(m.h_y, 1); +Assert.equal(m.h_z, 2); diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_1.ts new file mode 100644 index 0000000000..4cf7bf66f1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_1.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Export default declarations provide short-hand syntax for exporting an entity named default. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import message from '../1_programs_and_source_files/source_4.js'; + +Assert.equal(message(), 'string'); + diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_2.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_2.ts new file mode 100644 index 0000000000..88e2c6d8c2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_2.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Export default declarations provide short-hand syntax for exporting an entity named default. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import message from '../1_programs_and_source_files/source_5.js'; + +Assert.equal(message(), 'string'); + diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_3.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_3.ts new file mode 100644 index 0000000000..fc93b8382d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_3.ts @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Export default declarations provide short-hand syntax for exporting an entity named default. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import message from '../1_programs_and_source_files/source_6.js'; + +Assert.equal(message(), 'string'); diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_4.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_4.ts new file mode 100644 index 0000000000..aaa19b5480 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_4.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Export default declarations provide short-hand syntax for exporting an entity named default. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import message from '../1_programs_and_source_files/source_7.js'; + +Assert.equal(message(), 'string'); + diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_5.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_5.ts new file mode 100644 index 0000000000..c214a7f21f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_5.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Export default declarations provide short-hand syntax for exporting an entity named default. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import message from '../1_programs_and_source_files/source_8.js'; + +Assert.equal(message, 'hello'); + diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/6_export_assignments/export_assignments_1.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/6_export_assignments/export_assignments_1.ts new file mode 100644 index 0000000000..c7b3dee269 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/6_export_assignments/export_assignments_1.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Export assignments exist for backward compatibility with earlier versions of TypeScript. An export assignment + designates a module member as the entity to be exported in place of the module itself. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import Pt from '../1_programs_and_source_files/source_9.js'; + +let point = new Pt(10, 20); +Assert.equal(point.x, 10); +Assert.equal(point.y, 20); + diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_1.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_1.ts new file mode 100644 index 0000000000..c386db17ba --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_1.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A variable declaration and 'require' call is emitted for a particular imported module only if the imported module, or + a local alias that references the imported module, is referenced as a PrimaryExpression somewhere in the body of the + importing module. If an imported module is referenced only as a NamespaceName or TypeQueryExpression,nothing is emitted. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import * as g from '../1_programs_and_source_files/source_10.js'; + +let p = g.point(10, 20); +Assert.equal(p.x, 10); +Assert.equal(p.y, 20); diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_2.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_2.ts new file mode 100644 index 0000000000..c6efd439a1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_2.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A variable declaration and 'require' call is emitted for a particular imported module only if the imported module, or + a local alias that references the imported module, is referenced as a PrimaryExpression somewhere in the body of the + importing module. If an imported module is referenced only as a NamespaceName or TypeQueryExpression,nothing is emitted. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import * as g from '../1_programs_and_source_files/source_10.js'; + +let p: g.Point = { x: 10, y: 20 }; +Assert.equal(p.x, 10); +Assert.equal(p.y, 20); diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_1.ts b/es2panda/test/ts_extra_tests/test/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_1.ts new file mode 100644 index 0000000000..78369cf9e0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_1.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Expressions controlling 'if' statements can be of any type (and not just type Boolean). + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let a = true; + +if (a) { + a = false; +} + +Assert.isFalse(a); + +let b = "string b"; +if (b) { + b = "string b 2"; +} +Assert.equal("string b 2", b); + +let c = 1; +if (c) { + c = 2 +} +Assert.equal(2, c); + +var myObject = { + d: 4 +} +if (myObject) { + myObject.d = 5; +} +Assert.equal(5, myObject.d); + +let myObject2 = 1; +if (myObject2 == 2) { + myObject2 = 3; +} +Assert.equal(1, myObject2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_2.ts b/es2panda/test/ts_extra_tests/test/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_2.ts new file mode 100644 index 0000000000..b81710a25c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_2.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Expressions controlling 'Do' statements can be of any type (and not just type Boolean). + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var num = 1; +do { + if (num % 5 == 0) { + + break; + } + num++; +} while (num); +Assert.equal(5, num); + +do { + num++; +} while (num < 100); + +Assert.equal(100, num); + + +var myObject = { + d: 1, +} +do { + if (myObject.d % 5 == 0) { + + break; + } + myObject.d++; +} while (myObject); +Assert.equal(5, myObject.d); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_1.ts b/es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_1.ts new file mode 100644 index 0000000000..2139e475db --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_1.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Blocks are extended to include, local interface + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface BlocksInterface { + name: string; +} +class MyBlocks implements BlocksInterface { + name: string; + + constructor(name: string) { + this.name = name; + } + + public getName() { + return this.name; + } + +} +var myBlocks = new MyBlocks("Open Harmony"); + +Assert.equal("Open Harmony", myBlocks.getName()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_2.ts b/es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_2.ts new file mode 100644 index 0000000000..3f5e8ed75b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_2.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Blocks are extended to include, type alias + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +type Parent = { + name: string; +}; + +type Child = Parent & { + age: number +}; + + +const child: Child = { name: "name", age: 10 }; + +Assert.equal("name", child.name) +Assert.equal(10, child.age); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_3.ts b/es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_3.ts new file mode 100644 index 0000000000..803c7cab14 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_3.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Blocks are extended to include, enum + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +enum Direction { + Forward, + Back, + Left, + Right, +} + +class Car { + name!: string; + direction!: Direction; +} + +const car = new Car(); +car.name = "myCar"; +car.direction = Direction.Forward; + +Assert.equal("myCar", car.name) +Assert.equal(Direction.Forward, car.direction); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/break_statements/break_statements.ts b/es2panda/test/ts_extra_tests/test/spec/statements/break_statements/break_statements.ts new file mode 100644 index 0000000000..e9b559590c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/break_statements/break_statements.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: A 'break' statement is required to be nested, directly or indirectly (but not crossing function boundaries), within an iteration ('do', 'while', 'for', or 'for-in') or 'switch' statement. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let num: number = 0; +let count: number = 0; +do { + num++; + if (num >= 5) { + break; + } +} while (num < 10); +Assert.equal(5, num); + + +num = 0; +for (num = 0; num <= 20; num++) { + if (num >= 5) { + break; + } +} +Assert.equal(5, num); + +let arr = [0, 1, 2, 3, 4, 5]; +for (let index in arr) { + if (arr[index] >= 2) { + break; + } + count++; +} +Assert.equal(2, count); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/continue_statements/continue_statements.ts b/es2panda/test/ts_extra_tests/test/spec/statements/continue_statements/continue_statements.ts new file mode 100644 index 0000000000..95dc3b4011 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/continue_statements/continue_statements.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: A 'continue' statement is required to be nested, directly or indirectly (but not crossing function boundaries), within an iteration ('do', 'while', 'for', or 'for-in') statement. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let num: number = 0; +let count: number = 0; +do { + num++; + if (num % 2 == 0) { + continue; + } + count++; +} while (num < 10); +Assert.equal(5, count); + + +num = 0; +count = 0; +for (num = 0; num <= 20; num++) { + if (num % 2 == 0) { + continue; + } + count++; +} +Assert.equal(10, count); + +count = 0; +let arr = [0, 1, 2, 3, 4, 5]; +for (let index in arr) { + if (arr[index] % 2 == 0) { + continue; + } + count++; +} +Assert.equal(3, count); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/for_in_statements/for_in_statements.ts b/es2panda/test/ts_extra_tests/test/spec/statements/for_in_statements/for_in_statements.ts new file mode 100644 index 0000000000..45124ed810 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/for_in_statements/for_in_statements.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: test for (v in expr) statement + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let arr = [4, 5, 6]; + +let i = 0; +for (let index in arr) { + i++; +} +Assert.equal(3, i); + +const person = { + name: "opharmony", + role: "tools", + age: 3, +}; + +i = 0; +for (const key in person) { + i++; +} +Assert.equal(3, i); + +interface ABC { + a: number + b: string +} + +const x: ABC = { + a: 1, + b: '2' +} + +i = 0; +for (let key in x) { + i++; +} +Assert.equal(2, i); + +i = 0; +for (var key in x) { + i++; +} +Assert.equal(2, i); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/for_of_statements/for_of_statements.ts b/es2panda/test/ts_extra_tests/test/spec/statements/for_of_statements/for_of_statements.ts new file mode 100644 index 0000000000..774a0bd61a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/for_of_statements/for_of_statements.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: test for (v of expr) statement + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let count = 0; +for (let word of ["one", "two", "three"]) { + count++; +} +Assert.equal(3, count); + +count = 0; +let s = [0, 1, 2, 3, 4]; +for (let value of s) { + count++; +} +Assert.equal(5, count); + +count = 0; +let blogName: string = "openHarmony"; +for (let character of blogName) { + count++; +} +Assert.equal(11, count); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/for_statements/for_statements.ts b/es2panda/test/ts_extra_tests/test/spec/statements/for_statements/for_statements.ts new file mode 100644 index 0000000000..e15eda2d34 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/for_statements/for_statements.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Variable declarations in 'for' statements are extended in the same manner as variable declarations in variable statements + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let result = 0; +for (let i = 0; i < 10; i++) { + result++; +} + +Assert.equal(10, result); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/let_and_const_declarations/let_and_const_declarations.ts b/es2panda/test/ts_extra_tests/test/spec/statements/let_and_const_declarations/let_and_const_declarations.ts new file mode 100644 index 0000000000..82a9d8a39a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/let_and_const_declarations/let_and_const_declarations.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Let and Const Declarations + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let a = 1; +Assert.equal(1, a); + +a = 2; +Assert.equal(2, a); + +const num = 9; +Assert.equal(9, num); + +const myname = 'openharmony'; +Assert.equal('openharmony', myname); + +const myBoolean = true; +Assert.isTrue(myBoolean); diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/return_statements/return_statements.ts b/es2panda/test/ts_extra_tests/test/spec/statements/return_statements/return_statements.ts new file mode 100644 index 0000000000..00e7da8e49 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/return_statements/return_statements.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Return Statements + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function h_f(): (h_x: string) => number { + return h_s => h_s.length; +} + +Assert.equal(11, h_f()("openharmony")); + + + +function testReruen() { + for (let i = 0; i < 10; i++) { + + if (i == 5) { + return i; + } + } +} +Assert.equal(5, testReruen()); diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/switch_statements/switch_statements.ts b/es2panda/test/ts_extra_tests/test/spec/statements/switch_statements/switch_statements.ts new file mode 100644 index 0000000000..85a7900c2c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/switch_statements/switch_statements.ts @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from (section 3.11.4) the type of the 'switch' expression + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function testSwitch(inputVar: number) { + let outputVar: string; + switch (inputVar) { + case 1: + outputVar = 'a'; + break; + case 2: + outputVar = 'b'; + break; + case 3: + outputVar = 'c'; + break; + case 4: + outputVar = 'd'; + break; + default: + outputVar = 'e'; + break; + } + return outputVar; +} + +Assert.equal("a", testSwitch(1)); +Assert.equal("b", testSwitch(2)); +Assert.equal("c", testSwitch(3)); +Assert.equal("d", testSwitch(4)); +Assert.equal("e", testSwitch(5)); + + + +function testSwitchExpression(x: number, y: number) { + let outputVar: string; + switch (x + y) { + case 0: + outputVar = 'a'; + break; + case 5: + outputVar = 'b'; + break; + case 10: + outputVar = 'c'; + break; + + default: + outputVar = 'd'; + } + return outputVar; +} + +Assert.equal("a", testSwitchExpression(-1, 1)); +Assert.equal("b", testSwitchExpression(1, 4)); +Assert.equal("c", testSwitchExpression(5, 5)); +Assert.equal("d", testSwitchExpression(8, 10)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/throw_statements/throw_statements.ts b/es2panda/test/ts_extra_tests/test/spec/statements/throw_statements/throw_statements.ts new file mode 100644 index 0000000000..8af0522974 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/throw_statements/throw_statements.ts @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The expression specified in a 'throw' statement can be of any type. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function testThrow(inputVar: number) { + let outputVar: string; + if (inputVar == 1) { + throw 100; + } + + if (inputVar == 2) { + throw 'a'; + } + + if (inputVar == 3) { + throw true; + } + + if (inputVar == 4) { + throw new Error('Something bad happened'); + } +} + +try { + testThrow(1); +} catch (error) { + Assert.equal(100, error); +} + +try { + testThrow(2); +} catch (error) { + Assert.equal('a', error); +} + +try { + testThrow(3); +} catch (error) { + Assert.isTrue(error); +} + +try { + testThrow(4); +} catch (error: any) { + Assert.equal('Something bad happened', error.message); +} + +try { + testThrow(4); +} catch (error) { + Assert.isTrue(error instanceof Error); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/try_statements/try_statements.ts b/es2panda/test/ts_extra_tests/test/spec/statements/try_statements/try_statements.ts new file mode 100644 index 0000000000..7b1e992e7c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/try_statements/try_statements.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The variable introduced by a 'catch' clause of a 'try' statement is always of type Any. It is not possible to include a type annotation in a 'catch' clause. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +try { + new Array(100000000000000000000); +} +catch (err) { + Assert.isTrue(err instanceof RangeError); +} + +try { + let a: any; + let b = a.name; +} +catch (err) { + Assert.isTrue(err instanceof TypeError); +} + +try { + decodeURI('%'); +} +catch (err) { + Assert.isTrue(err instanceof URIError); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_1.ts new file mode 100644 index 0000000000..11088b2fcb --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_1.ts @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The type T of a variable introduced by a simple variable declaration is determined as follows: + If the declaration includes a type annotation, T is that type. + Otherwise, if the declaration includes an initializer expression, T is the widened form (section 3.12) of the type of the initializer expression. + Otherwise, T is the Any type. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +// any +var h_a; + +// number +var h_b: number; + +// number +var h_c = 30; + +// { x: number; y: string; } +var h_d = { x: 40, y: "hello" }; + +// any +var h_e: any = "test"; +h_a = 1; +Assert.equal(1, h_a); + +h_a = '111'; +Assert.equal('111', h_a); + +h_b = 20; +Assert.equal(20, h_b); + +Assert.equal(30, h_c); + +Assert.equal(40, h_d.x); +Assert.equal("hello", h_d.y); + +var h_x = 50; +Assert.equal(50, h_x); +var h_x: number; +Assert.equal(50, h_x); +if (h_x == 50) { + var h_x = 100; + Assert.equal(100, h_x); + + h_x = 200; + + Assert.equal(200, h_x); +} + +Assert.equal(200, h_x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_2.ts b/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_2.ts new file mode 100644 index 0000000000..a9501014d5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_2.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The type T of a variable introduced by a simple variable declaration is determined as follows: + If the declaration includes a type annotation, T is that type. + Otherwise, if the declaration includes an initializer expression, T is the widened form (section 3.12) of the type of the initializer expression. + Otherwise, T is the Any type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface Point { h_x: number; h_y: number; } + +var h_a = { h_x: 0, h_y: 1 }; +var h_b: Point = { h_x: 10, h_y: 11 }; +var h_c = { h_x: 100, h_y: 111 }; +var h_d: { h_x: number; h_y: number; } = { h_x: 1000, h_y: 1001 }; +var h_e = <{ h_x: number; h_y: number; }>{ h_x: 10000, h_y: 10001 }; + +Assert.equal(0, h_a.h_x); +Assert.equal(1, h_a.h_y); + +Assert.equal(10, h_b.h_x); +Assert.equal(11, h_b.h_y); + +Assert.equal(100, h_c.h_x); +Assert.equal(111, h_c.h_y); + +Assert.equal(1000, h_d.h_x); +Assert.equal(1001, h_d.h_y); + +Assert.equal(10000, h_e.h_x); +Assert.equal(10001, h_e.h_y); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_3.ts b/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_3.ts new file mode 100644 index 0000000000..7ca8929aa8 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_3.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Multiple declarations for the same variable name in the same declaration space are permitted, + provided that each declaration associates the same type with the variable. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var h_a: number = 10; +var h_a: number = 20; +Assert.equal(h_a, 20); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_1.ts new file mode 100644 index 0000000000..1d676f3b08 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_1.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: A destructuring variable declaration introduces zero or more named variables and initializes them with values extracted from properties of an object + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var object_name = { + key1: "value1", + key2: "value2", + key3: ["content1", "content2"], + key4: true, + key5: undefined +} + +var { key1, key2: y, key3, key4: z = false, key5: k = true } = object_name; + +Assert.equal("value1", key1); +Assert.equal("value2", y); +Assert.equal("content1", key3[0]); +Assert.equal("content2", key3[1]); +Assert.isTrue(z); +Assert.isTrue(k); + + diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_2.ts b/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_2.ts new file mode 100644 index 0000000000..79e1b11698 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_2.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The type T associated with a destructuring variable declaration is determined as follows: + If the declaration includes a type annotation, T is that type. + Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. + Otherwise, T is the Any type. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface IPerson { + myname: string, + myage: number, +} + +var customer: IPerson = { + myname: "Tom", + myage: 10, +} +let { myname, myage } = customer; + +Assert.isString(myname); +Assert.isNumber(myage) + + +let o = { + a: "foo", + b: 12, + c: "bar" +}; +let { a: newName1 } = o; +Assert.isString(newName1); +var ohArray: number[] = [10, 20, 30]; + +var [x, y, z = 10, k = 10] = ohArray; +Assert.equal(10, x); +Assert.equal(20, y); +Assert.equal(30, z); +Assert.equal(10, k); + diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_3.ts b/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_3.ts new file mode 100644 index 0000000000..ec75bc8e66 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_3.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The type T associated with a binding property is determined as follows: + Let S be the type associated with the immediately containing destructuring variable declaration, binding property, or binding element. + If S is the Any type: + If the binding property specifies an initializer expression, T is the type of that initializer expression. + Otherwise, T is the Any type. + Let P be the property name specified in the binding property. + If S has an apparent property with the name P, T is the type of that property. + Otherwise, if S has a numeric index signature and P is a numerical name, T is the type of the numeric index signature. + Otherwise, if S has a string index signature, T is the type of the string index signature. + Otherwise, no type is associated with the binding property and an error occurs. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var object_name = { + key1: "value1", + key2: "value2", + key3: ["content1", "content2"], + key4: true, + key5: undefined +} + + +var ohArray: number[] = [10, 20, 30]; + +var { key1, key3: [y, z = 10, k = 10] = ohArray, key5: [a, b] = ohArray } = object_name; + +Assert.equal("value1", key1); +Assert.equal("content1", y); +Assert.equal("content2", z); +Assert.equal(10, k); +Assert.equal(10, a); +Assert.equal(20, b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/3_implied_type/implied_type.ts b/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/3_implied_type/implied_type.ts new file mode 100644 index 0000000000..83b1c9e814 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/3_implied_type/implied_type.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: A variable, parameter, binding property, or binding element declaration that specifies a binding pattern has an implied type which is determined + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var object_name = { + key1: "value1" +} + +// If the declaration specifies an object binding pattern, the implied type is an object type with a set of properties corresponding to the specified binding property declarations. The type of each property is the type implied by its binding property declaration, and a property is optional when its binding property declaration specifies an initializer expression. +function f({ aa = {}, b = "hello", c = 3, d = object_name }) { + Assert.equal("object", typeof (aa)); + Assert.equal("string", typeof (b)); + Assert.equal("number", typeof (c)); + Assert.equal("object", typeof (d)); +} + +var objectFun = { + a: [1, 2], + b: "2", + c: 3, + d: object_name +}; +f(objectFun); + + +// If the declaration specifies an array binding pattern without a rest element, the implied type is a tuple type with elements corresponding to the specified binding element declarations. The type of each element is the type implied by its binding element declaration. +var [a1, b1, c1, d1] = [1, "hello", true, object_name]; + +Assert.equal("number", typeof (a1)); +Assert.equal("string", typeof (b1)); +Assert.equal("boolean", typeof (c1)); +Assert.equal("object", typeof (d1)); + +// If the declaration specifies an array binding pattern with a rest element, the implied type is an array type with an element type of Any +function testRest(...restElements: any[]): any { + Assert.isTrue(restElements.length > 0); + return restElements[0]; +} + +Assert.isString(testRest("str", "str2")); +Assert.isNumber(testRest(1, 2)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/Intersection_Types/Intersection_types_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/Intersection_Types/Intersection_types_1.ts new file mode 100644 index 0000000000..c825705bfc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/Intersection_Types/Intersection_types_1.ts @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Intersection types represent values that simultaneously have multiple types. + A value of an intersection type A & B is a value that is both of type A and type B. + Intersection types are written using intersection type literals. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface A1 { + num1: number; +} +interface B1 { + str1: string; +} +var ns1: A1 & B1 = { num1: 1, str1: "b" }; +Assert.equal(ns1.num1, 1); +Assert.equal(ns1.str1, "b"); +enum Color { + Red1 = 1, + Green1, + Blue1, +} +interface A2 { + num2: [string, number]; +} +interface B2 { + str2: Color; +} +var ns2: A2 & B2 = { num2: ["a2", 1], str2: Color.Red1 }; +Assert.equal(ns2.num2[0], "a2"); +Assert.equal(ns2.str2, 1); +interface A3 { + num3: number[]; +} +interface B3 { + str3: boolean; +} +var ns3: A3 & B3 = { num3: [1, 2, 3], str3: true }; +Assert.equal(ns3.str3, true); +interface A4 { + num4: number; +} +interface B4 { + str4: string; +} +interface C4 { + cm: any; +} +var ns4: A4 & B4 & C4 = { num4: 1, str4: "b4", cm: 3 }; +Assert.equal(ns4.num4, 1); +Assert.equal(ns4.str4, "b4"); +Assert.equal(ns4.cm, 3); +interface XX { + obj: A1; +} +interface YY { + obj: B1; +} +var xxyy: XX & YY = { obj: ns1 }; +Assert.equal(xxyy.obj.num1, 1); +type T1 = (str1: string, str2: string) => void; +type T2 = (num1: number, num2: number) => void; +var t: T1 & T2 = (ns: string | number, NS: string | number) => { }; +t("hello", "world"); +t(1, 2); +type T3 = (a: any, b: boolean) => void; +var t2: T1 & T2 & T3 = ( + nsa: string | number | any, + bns: string | number | boolean +) => { }; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/Intersection_Types/intersection_types_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/Intersection_Types/intersection_types_2.ts new file mode 100644 index 0000000000..b169902e3c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/Intersection_Types/intersection_types_2.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The union and intersection type operators can be applied to type parameters. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../suite/assert.js' + +function getSmallPet(name: string | number) { + return name; +} +let pet = getSmallPet("fishbird"); +Assert.equal(pet, "fishbird"); +interface Person1 { name: string } +interface People1 { sex: string } +type PersonMan = Person1 & People1 +function getPerson(person: PersonMan) { + return person.name; +} +let man: PersonMan = { + name: "join", + sex: "man" +} +let getpersonname = getPerson(man); +Assert.equal(getpersonname, "join"); + diff --git a/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_1.ts new file mode 100644 index 0000000000..d598923943 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_1.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Classes, enums, and type aliases are named types that are introduced through class declarations, + interface declarations, enum declarations, and type alias declarations. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Test { + name: string; + constructor(name: string) { + this.name = name; + } +} +// create instances of implementations of named types +const tt = new Test("caihua"); +Assert.equal(tt.name, "caihua"); + +enum Color { + Red, + Green, + Blue, +} + +let a: Color.Red = Color.Red; +Assert.equal(a, Color.Red); + +type pp = number | string; +let b: pp; +b = 10; +Assert.isNumber(b); +b = "hello"; +Assert.isString(b); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_2.ts new file mode 100644 index 0000000000..e920b32eba --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_2.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + class declarations with only public members introduce named types + that function exactly like those created by interface declarations. + module: ESNext + isCurrent: true +---*/ + + +import {Assert} from '../../../../suite/assert.js' + +interface TestInterface { + age: number; +} +class TestClass { + age: number; + constructor(age:number){ + this.age=age + } +} +function test1(v: TestInterface) { + return v.age; +} +function test2(v: TestClass) { + return v.age; +} +let ee = { + age: 18, +}; + +Assert.equal(test1(ee), 18); +Assert.equal(test2(ee), 18); + diff --git a/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_3.ts new file mode 100644 index 0000000000..33e5cf75fa --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_3.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Generic types are "templates" from which multiple actual types can be created by writing type references + that supply type arguments to substitute in place of the generic type's type parameters + module: ESNext + isCurrent: true +---*/ + + +import {Assert} from '../../../../suite/assert.js' + +interface Person { + m_name: string; + m_age: number; + getName(name: string): string; +} + +type Optional = { [P in keyof T]: T[P] }; +let cc: Optional = { + m_age: 18, + m_name: "caihua", + getName(name: string) { + return name; + }, +}; +Assert.equal(cc.m_age, 18); +Assert.equal(cc.m_name, "caihua"); +Assert.equal(cc.getName("caihua"), "caihua"); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_4.ts b/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_4.ts new file mode 100644 index 0000000000..51d5571cbd --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_4.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript has a structural type system, and therefore an instantiation of a generic type + is indistinguishable from an equivalent manually written expansion. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class cE { + x: number; + y: number; + constructor(x: number, y: number) { + this.x = x; + this.y = y; + } +} +interface Pi { + front: T; + later: U; +} + +function test(v: Pi) { + Assert.equal(v.front, "abc"); + Assert.equal(v.later.x, 1); + Assert.equal(v.later.y, 1); +} +// object literal +test({ front: "abc", later: { x: 1, y: 1 } }); +let cc: Pi; +cc = { + front: "abc", + later: { + x: 1, + y: 1, + }, +}; +// type reference +test(cc); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_1.ts new file mode 100644 index 0000000000..2f7e82f1f1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_1.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + array types represent JavaScript arrays with a common element type. + array types are named type references created from the generic interface type 'Array' in the global namespace with the array element type as a type argument. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var arr1: Array = ["ABC", "DEF", "GHI"]; +var arr2: Array = [1, 3, 5, 7, 9]; +var arr3: Array = [true, false]; +var arr4: Array = [Object, { 0xff: "0xFF" }]; +Assert.isString(arr1[2]); +var objArray: object[] = []; +arr1.forEach(function (element, index, arr) { + objArray[index] = { index: index, element: element, arr: arr }; +}); +Assert.isString(arr2.toString()); +Assert.equal(arr2.toString(), "1,3,5,7,9"); +Assert.isNumber(arr3.length); +Assert.equal(arr3.length, 2); +Assert.isNumber(arr2.pop()); +Assert.equal(arr2.pop(), 7); +arr2.push(15); +Assert.equal(arr2.toString(), "1,3,5,15"); +arr3[0] = false; +Assert.equal(arr3[0], false); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_2.ts new file mode 100644 index 0000000000..b6972aff57 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_2.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the declaration of the 'Array' interface includes a property 'length' and a numeric index signature for the element type, along with other members + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var arr: Array = ["A", "B", "C", "D", "E", "F", "G", "H", "I"]; +Assert.isString(arr[5]); +Assert.equal(arr[5], "F"); +Assert.isNumber(arr.length); +Assert.equal(arr.length, 9); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_3.ts new file mode 100644 index 0000000000..bf80a6cf34 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_3.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + array literals may be used to create values of array types. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var arr6: number[] = [1, 3, 5, 7, 9]; +var arr7: boolean[] = [true, false, true, false, true]; +var arr8: string[] = ["a", "b", "c", "d", "e", "f"]; +var arr9: object[] = [{ 0x00: "0x00" }, { 0x01: "0x01" }]; +arr6[3] = 14; +Assert.equal(arr6[3], 14); +Assert.isBoolean(arr7[2]); +Assert.equal(true, arr7[2]); +Assert.equal(arr8.toString(), "a,b,c,d,e,f"); +arr8.pop(); +Assert.equal(arr8.toString(), "a,b,c,d,e"); +arr8.push("0x02"); +Assert.equal(arr8.toString(), "a,b,c,d,e,0x02"); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_1.ts new file mode 100644 index 0000000000..9d4f4793e8 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_1.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + An object type containing one or more construct signatures is said to be a constructor type. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +class Person { + name: string; + age: number; + constructor(n: string, age: number) { + this.name = n; + this.age = age; + } + run(): string { + return "person"; + } +} +class Teacher extends Person { + run(): string { + return "teacher"; + } +} +// alias +type constructor = new (name: string, age: number) => T; + +const testClass1: constructor = Teacher; +let testObj1: Person = new testClass1("caihua", 20); +Assert.equal(testObj1.age, 20); +Assert.equal(testObj1.name, "caihua"); +Assert.equal(testObj1.run(), "teacher"); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_2.ts new file mode 100644 index 0000000000..42201baeec --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_2.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Constructor types may be written using constructor type literals + or by including construct signatures in object type literals. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +class Person { + name: string; + age: number; + constructor(n: string, age: number) { + this.name = n; + this.age = age; + } + run(): string { + return "person"; + } +} +class Student extends Person { + run(): string { + return "student"; + } +} +class Teacher extends Person { + run(): string { + return "teacher"; + } +} +// literal type +const testClass1: new (name: string, age: number) => Person = Student; +const testObj1: Person = new testClass1("caihua1", 12); +Assert.equal(testObj1.age, 12); +Assert.equal(testObj1.name, "caihua1"); +const testClass2: { new(n: string, a: number): Person } = Teacher; +const testObj2: Person = new testClass2("caihua2", 120); +Assert.equal(testObj2.age, 120); +Assert.equal(testObj2.name, "caihua2"); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_3.ts new file mode 100644 index 0000000000..dc307d99ef --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_3.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + An object type containing one or more construct signatures is said to be a constructor type. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface Point { + x: number; + y: number; +} +interface PointConstructor { + new(x: number, y: number): Point; +} + +class Point2D implements Point { + readonly x: number; + readonly y: number; + constructor(x: number, y: number) { + this.x = x; + this.y = y; + } +} + +function newPoint( + pointConstructor: PointConstructor, + x: number, + y: number +): Point { + return new pointConstructor(x, y); +} + +const point1: Point = new Point2D(1, 2); +Assert.equal(point1.x, 1); +Assert.equal(point1.y, 2); + +const point: Point = newPoint(Point2D, 2, 2); +Assert.equal(point.x, 2); +Assert.equal(point.y, 2); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/function_types/function_types.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/function_types/function_types.ts new file mode 100644 index 0000000000..b0f7e13ce5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/function_types/function_types.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + an object type containing one or more call signatures is said to be a function type. + function types may be written using function type literals or by including call signatures in object type literals. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var fun1: (num1: number, num2: number) => number = ( + num1: number, + num2: number +) => { + return num1 + num2; +}; +Assert.isNumber(fun1(3, 5)); +Assert.equal(fun1(3, 5), 8); +var fun2: { (num1: number, num2: number, num3: number): number } = ( + num1: number, + num2: number, + num3: number +) => { + return num1 + num2 + num3; +}; +Assert.isNumber(fun2(1, 3, 5)); +Assert.equal(fun2(1, 3, 5), 9); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/members/members_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/members/members_1.ts new file mode 100644 index 0000000000..3ce9ca2461 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/members/members_1.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Properties in a class declaration may be designated public, private, or protected, + while properties declared in other contexts are always considered public. + Private members are only accessible within their declaring class. + Protected members are only accessible within their declaring class and classes derived from it. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class h_C { + public h_pub: string; + private h_pri: string; + protected h_pro: string; + constructor(h_pub: string, h_pri: string, h_pro: string) { + this.h_pub = h_pub; + this.h_pri = h_pri; + this.h_pro = h_pro; + } + set(h_pri: string) { + this.h_pri = h_pri; + } + get() { + return this.h_pri; + } + output() { + return this.h_pro; + } +} +let h_c = new h_C('Public', 'Private', 'Protected'); +Assert.equal(h_c.h_pub, 'Public'); +Assert.equal(h_c.get(), 'Private'); +Assert.equal(h_c.output(), 'Protected'); + +class h_child extends h_C { } +let h_ch = new h_child('public', 'private', 'protected'); +Assert.equal(h_ch.output(), 'protected'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/members/members_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/members/members_2.ts new file mode 100644 index 0000000000..7b07cf0bd6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/members/members_2.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Properties in an object type literal or interface declaration may be designated required or optional, + while properties declared in other contexts are always considered required. + Properties that are optional in the target type of an assignment may be omitted from source objects. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface h_stu { + h_name: string; + h_age: number; + h_height?: number; + h_weight?: number; +} +let h_s: h_stu = { + h_name: 'xiao', + h_age: 19, + h_height: 180 +} +Assert.equal(h_s.h_name, 'xiao'); +Assert.equal(h_s.h_age, 19); +Assert.equal(h_s.h_height, 180); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/named_type_reference/named_type_reference.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/named_type_reference/named_type_reference.ts new file mode 100644 index 0000000000..5b1fd36a50 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/named_type_reference/named_type_reference.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Type references to class and interface types are classified as object types. + Type references to generic class and interface types include type arguments that are substituted for the type parameters of the class + or interface to produce an actual object type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class obj { + num1: number; + num2: number; + constructor(num1: number, num2: number) { + this.num1 = num1; + this.num2 = num2; + } + add(h_x: number, h_y: number): void { + var sum: number = h_x + h_y; + Assert.equal(sum, 10); + } +} +let o: obj = new obj(4, 6); +o.add(3, 7); + +interface h_inf { + h_name: string; + h_age: number; + greet: () => string +} +let h_i: h_inf = { + h_name: 'xiao', + h_age: 18, + greet() { return "hello"; } +} +Assert.equal(h_i.h_name, "xiao"); +Assert.equal(h_i.h_age, 18); +Assert.equal(h_i.greet(), "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_1.ts new file mode 100644 index 0000000000..f28534797b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_1.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Tuple types represent JavaScript arrays with individually tracked element types. + A tuple type combines a set of numerically named properties with the members of an array type. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +let cc: [number, string, boolean]; +cc = [12, "abcd", true]; +Assert.isNumber(cc[0]); +Assert.equal(cc[0].toString(), "12"); +Assert.isString(cc[1]); +Assert.equal(cc[1].length, 4); +Assert.isBoolean(cc[2]); +let dd = cc[2] ? 0 : 1; +Assert.equal(dd, 0); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_2.ts new file mode 100644 index 0000000000..ff88c37df2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_2.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Array literals may be used to create values of tuple types. + the members of an array type whose element type is the union type of the tuple element types + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +let cc: [number, string, boolean]; +cc = [12, "abcd", true]; +let index: number=0; +// Type of cc[index] is number | string | boolean +var x = cc[index]; +x = 12; +Assert.isNumber(x); +x = false; +Assert.isBoolean(x); +x = "string"; +Assert.isString(x); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_3.ts new file mode 100644 index 0000000000..21f0d29957 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_3.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Named tuple types can be created by declaring interfaces that derive from Array + and introduce numerically named properties + module: ESNext + isCurrent: true +---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface tt extends Array { + 0: K; + 1: V; +} +let x: tt = [10, "ten"]; +Assert.isNumber(x[0]); +Assert.equal(x[0], 10); +Assert.isString(x[1]); +Assert.equal(x[1], "ten"); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_1.ts new file mode 100644 index 0000000000..cad135fa83 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_1.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The Boolean primitive type corresponds to the similarly + named JavaScript primitive type and represents logical values that are either true or false. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +function test1(): number { + return 0; +} +function test2(): number { + return 1; +} +function test3() { + return 1; +} +function test4(i: number): number { + return i; +} +var a: boolean = true; +Assert.equal(a, true); +var b = false; +Assert.equal(b, false); +// conditional expression +let c: number = a ? 0 : 1; +Assert.equal(c, 0); +c = b ? 0 : 1; +Assert.equal(c, 1); +// if +if (a) { + Assert.equal(test1(), 0); +} else { + Assert.equal(test2(), 1); +} +// while , do ...while +while (a) { + Assert.equal(test3(), 1); + break; +} +// for +for (let i = 0; a && i < 5; i++) { + Assert.equal(test4(i), i); +}; diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_2.ts new file mode 100644 index 0000000000..9ca3183a7e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_2.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The boolean keyword references the Boolean primitive + type and the true and false literals reference the two Boolean truth values. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var a: boolean = true; +Assert.isBoolean(a); +Assert.equal(a, true); +a = false; +Assert.isBoolean(a); +Assert.equal(a, false); +// > < ! +var b: boolean = 2 > 1; +Assert.isBoolean(b); +Assert.equal(b, true); +b = !b; +Assert.isBoolean(b); +Assert.equal(b, false); +// && +var c: boolean = 2 > 1 && 7 < 8; +Assert.isBoolean(c); +Assert.equal(c, true); +c = 2 < 1 && 7 < 8; +Assert.isBoolean(c); +Assert.equal(c, false); +// || +c = 2 > 1 || 7 < 8; +Assert.isBoolean(c); +Assert.equal(c, true); +c = 2 < 1 || 7 > 8; +Assert.isBoolean(c); +Assert.equal(c, false); + diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_3.ts new file mode 100644 index 0000000000..e5b4b2cf81 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_3.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the Boolean primitive type behaves as an object + type with the same properties as the global interface type 'Boolean'. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var a = true; +Assert.equal(a.valueOf(), true); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_enum_type/the_enum_type_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_enum_type/the_enum_type_1.ts new file mode 100644 index 0000000000..31195e2762 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_enum_type/the_enum_type_1.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Enum types are distinct user defined subtypes of the Number primitive type and vice versa + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +enum Color { + Red, + Green, + Blue, + Black, +} +let cc: Color = Color.Blue; +// true +Assert.isNumber(cc); +var ee: Color = Color.Blue; +var dd: number = cc; +Assert.equal(dd, Color.Blue); +dd = 15; +ee = dd; +Assert.equal(ee, 15); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_null_type/the_null_type_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_null_type/the_null_type_1.ts new file mode 100644 index 0000000000..62e29fbb98 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_null_type/the_null_type_1.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The Null type corresponds to the similarly named JavaScript primitive type and is the type of the null literal. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var n: null = null; +let flag = false; +if (n == null) { + flag = true; +} +Assert.isTrue(flag); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_1.ts new file mode 100644 index 0000000000..2b80f668ff --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_1.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Test "Number primitive type corresponds to the similarly named JavaScript primitive type + and represents double-precision 64-bit format IEEE 754 floating point values." + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +// add +Assert.notEqual(0.1 + 0.2, 0.3); +Assert.notEqual(0.7 + 0.1, 0.8); +Assert.notEqual(0.2 + 0.4, 0.6); +// sub +Assert.notEqual(1.5 - 1.2, 0.3); +Assert.notEqual(0.3 - 0.2, 0.1); +// multiplication +Assert.notEqual(19.9 * 100, 1990); +Assert.notEqual(0.8 * 3, 2.4); +Assert.notEqual(35.41 * 100, 3541); +// division +Assert.notEqual(0.3 / 0.1, 3); +Assert.notEqual(0.69 / 10, 0.069); + +// Number.toFiexed() +Assert.equal((1.335).toFixed(2), 1.33); +Assert.equal((1.3335).toFixed(3), 1.333); +Assert.equal((1.33335).toFixed(4), 1.3334); +Assert.equal((1.333335).toFixed(5), 1.33333); +Assert.equal((1.3333335).toFixed(6), 1.333333); + + diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_2.ts new file mode 100644 index 0000000000..01f8bb0b2a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_2.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The number keyword references the Number primitive type and numeric literals may be used to write values of the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +// Integral type +let n1: number = 1; +Assert.isNumber(n1); +Assert.equal(n1, 1); +n1 = 2; +Assert.isNumber(n1); +Assert.equal(n1, 2); +// Floating point number +let n2: number = 1.51; +Assert.isNumber(n2); +Assert.equal(n2, 1.51); +n2 = 3.53; +Assert.isNumber(n2); +Assert.equal(n2, 3.53); +// binary +let n3: number = 0b1011; +Assert.isNumber(n3); +Assert.equal(n3, 0b1011); +n3 = 0b1111; +Assert.isNumber(n3); +Assert.equal(n3, 0b1111); +// octal +let n4: number = 0o17; +Assert.isNumber(n4); +Assert.equal(n4, 0o17); +n4 = 0o24; +Assert.isNumber(n4); +Assert.equal(n4, 0o24); +// hexadecimal +let n5: number = 0xf00d; +Assert.isNumber(n5); +Assert.equal(n5, 0xf00d); +n5 = 0xf01c; +Assert.isNumber(n5); +Assert.equal(n5, 0xf01c); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_3.ts new file mode 100644 index 0000000000..90c05ab3ec --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_3.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: the Number primitive type behaves as an object type with the same properties as the global interface type 'Number'. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +// Equivalent to h_z: number = 123.456 +var h_z = 123.456; +// The property of Number +var s = h_z.toFixed(2); +Assert.equal(s, 123.46); +var a = h_z.toString(); +Assert.equal(a, "123.456"); +var b = h_z.toExponential(); +Assert.equal(b, "1.23456e+2"); +b = h_z.toExponential(2); +Assert.equal(b, "1.23e+2"); +var c = h_z.toPrecision(); +Assert.equal(c, "123.456"); +c = h_z.toPrecision(3); +Assert.equal(c, "123"); +var d = h_z.valueOf(); +Assert.equal(d, 123.456); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_1.ts new file mode 100644 index 0000000000..9a3964f0c1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_1.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + All string literal types are subtypes of the String primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var cc: "hello" = "hello"; +Assert.isString(cc); +var dd: string = cc; +Assert.equal(dd, "hello"); +var ee: "" = ""; +Assert.isString(ee); +var ff: string = ee; +Assert.equal(ff, ""); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_2.ts new file mode 100644 index 0000000000..af95b4e37b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_2.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Specialized signatures permit string literals to be used as types in parameter type annotations. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface Test { + v: "hello"; +} + +function test(dd: Test) { + Assert.equal(dd.v.length, 5); + return dd; +} +var cc: Test = { + v: "hello", +}; +Assert.isString(test(cc).v); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_3.ts new file mode 100644 index 0000000000..aa6cf69676 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_3.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + String literal types are permitted only in that context and nowhere else. + string literals no longer always have the type string. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +// If you define a variable type without explicit type annotations, the variable defaults to string instead of the string literal type it should be +let HELLO: "HELLO" = "HELLO"; +let WORLD: "WORLD" = "WORLD"; +// type: string +let hello = HELLO.toLowerCase(); +Assert.equal(hello, "hello"); +// type: string +let HELLOWORLD = HELLO + WORLD; +Assert.equal(HELLOWORLD, "HELLOWORLD"); +// valid +let a: "foo" | number = "foo"; diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_1.ts new file mode 100644 index 0000000000..e74655fa8c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_1.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The String primitive type corresponds to the similarly named JavaScript primitive type + and represents sequences of characters stored as Unicode UTF-16 code units. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var str: string = "\u4f60\u597d"; +Assert.equal(str, "你好"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_2.ts new file mode 100644 index 0000000000..c3b7248adf --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_2.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The string keyword references the String primitive type and + string literals may be used to write values of the String primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var str: string; +str = "abcd"; +Assert.equal(str, "abcd"); +Assert.isString(str); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_3.ts new file mode 100644 index 0000000000..a2a4e1fa75 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_3.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the String primitive type behaves as an object type + with the same properties as the global interface type 'String'. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var str: string = "string"; +Assert.equal(str.charAt(1), "t"); + +Assert.equal(str.charCodeAt(2), 114); + +Assert.equal(str.toString(), 'string'); + +Assert.equal(str.concat("new"), "stringnew"); + +str = "cbaabcda"; +Assert.equal(str.indexOf("a"), 2); + +Assert.equal(str.indexOf("a", 4), 7); + +Assert.equal(str.lastIndexOf("b"), 4); + +Assert.equal(str.lastIndexOf("b", 2), 1); + diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_1.ts new file mode 100644 index 0000000000..58c13e9ce0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_1.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the Symbol primitive type represents a unique token + that can be used as a property key for an object. + options: + lib: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var sym: symbol = Symbol(); +var obj1: object = { [sym]: "symbol" }; +type Key = keyof typeof obj1; +Assert.equal(obj1[sym as Key], "symbol"); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_2.ts new file mode 100644 index 0000000000..8ddd1b69f4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_2.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The symbol keyword references the Symbol primitive type. + Symbol values are obtained using the global object 'Symbol' which has a number of methods and properties and can be invoked as a function. + options: + lib: es2019 + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var sym: symbol = Symbol("NARC"); +var sym2: symbol = Symbol("TypeScript"); +Assert.equal(sym.description, "NARC"); + +var s1: string = sym2.toString(); +var s2: symbol = sym.valueOf(); +Assert.equal(s1, "Symbol(TypeScript)"); + +var flag1: boolean = false; +if (sym != sym2) { + flag1 = true; +} +Assert.isTrue(flag1); + +var flag2: boolean = false; +if (sym == s2) { + flag2 = true; +} +Assert.isTrue(flag2); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_3.ts new file mode 100644 index 0000000000..61eb08c0bc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_3.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The Symbol primitive type behaves as an object type with the same properties as the global interface type 'Symbol'. + options: + lib: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var h_x: symbol = Symbol(); +var h_obj: any = {}; +h_obj[h_x] = "primitive type"; +Assert.equal(h_obj[h_x], "primitive type"); +h_obj[Symbol.toStringTag] = "project"; +Assert.equal(h_obj[Symbol.toStringTag], "project"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_undefined_type/the_undefined_type_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_undefined_type/the_undefined_type_1.ts new file mode 100644 index 0000000000..6dd9d8a960 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_undefined_type/the_undefined_type_1.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The Undefined type corresponds to the similarly named JavaScript primitive type and is the type of the undefined literal. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var u: undefined = undefined; +Assert.isUndefined(u); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_1.ts new file mode 100644 index 0000000000..70061be8ca --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_1.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the Void type, referenced by the void keyword, + represents the absence of a value and is used as the return type of functions with no return value. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var v: void = undefined; +function noReturn(): void { } +Assert.isUndefined(v); +Assert.isUndefined(noReturn()); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_2.ts new file mode 100644 index 0000000000..1d2f85d191 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_2.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the only possible values for the Void type are null and undefined. + the void type can be assigned a null value, but this is only allowed in non-strict mode. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var v: void; +Assert.isUndefined(v); +var v2: void = undefined; +Assert.isUndefined(v2); +var nu = null; +var u: undefined = undefined; +v = u; +Assert.isUndefined(v); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_3.ts new file mode 100644 index 0000000000..329bdfdb53 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_3.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the Void type is a subtype of the any type and a supertype of the null and undefined types. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var v: void; +var nu = null; +var u: undefined = undefined; +var a: any; +a = v; +Assert.isUndefined(a); +v = u; +Assert.isUndefined(v); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_1.ts new file mode 100644 index 0000000000..0dda950706 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_1.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A signature's parameter list consists of zero or more required parameters, followed by zero or more optional parameters, + finally followed by an optional rest parameter. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../../suite/assert.js' + +function fun0() { + return "zero parameter"; +} +function fun1(firstParameter: string, lastParameter?: string) { + if (lastParameter) return firstParameter + " " + lastParameter; + else return firstParameter; +} +let result1 = fun1("Bob"); +let result3 = fun1("Bob", "Adams"); +Assert.equal(result1, "Bob"); +Assert.equal(result3, "Bob Adams"); + +function fun2(firstParameter: string, ...restParameter: string[]) { + return firstParameter + " " + restParameter.join(" "); +} +let employeeName = fun2("Joseph", "Samuel", "Lucas", "MacKinzie"); +Assert.equal(employeeName, "Joseph Samuel Lucas MacKinzie"); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_2.ts new file mode 100644 index 0000000000..84b152b3b6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_2.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A parameter declaration may specify either an identifier or a binding pattern. + The identifiers specified in parameter declarations and binding patterns in a parameter list must be unique within that parameter list. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../../suite/assert.js' + +class Animal { + fname: string; + constructor(fname: string) { + this.fname = fname; + } +} +let name1 = "Anny"; +let animal = new Animal(name1); +name1 = "Bob"; +Assert.notEqual(animal.fname, name1); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_3.ts new file mode 100644 index 0000000000..1d21304ceb --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_3.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the declaration includes a type annotation, the parameter is of that type. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../../suite/assert.js' + +function ff(first: string, second: number) { + return first; +} +let first = "first"; +let second = 2; +ff(first, second); +Assert.equal(first, "first"); +Assert.equal(second, 2); + diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_4.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_4.ts new file mode 100644 index 0000000000..1e85df8da1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_4.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + if the declaration specifies a binding pattern, + the parameter type is the implied type of that binding pattern. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../../suite/assert.js' + +const x: number = 3; +function fun(a: number, c = 1, b = x) { + return a + c + b; +} +let y = 1; +Assert.equal(y, 1); +let z = fun(y); +Assert.equal(z, 5); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_5.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_5.ts new file mode 100644 index 0000000000..f2f8702e4b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_5.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + if the parameter is a rest parameter, the parameter type is any[]. + A type annotation for a rest parameter must denote an array type. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../../suite/assert.js' + +function restFun(first: any, ...restname: any[]) { + return first + " " + restname.join(" "); +} + +let restname1 = restFun("aa", "bb", "cc"); +Assert.equal(restname1, "aa bb cc"); + +let restname2 = restFun(1, 2, 3, 4); +Assert.equal(restname2, "1 2 3 4"); +// boolean +let restname3 = restFun(true, false, true); +Assert.equal(restname3, "true false true"); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_6.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_6.ts new file mode 100644 index 0000000000..0bc1c9142c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_6.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A parameter is permitted to include a public, private, + or protected modifier only if it occurs in the parameter list of a ConstructorImplementation (section 8.3.1) + and only if it doesn't specify a BindingPattern. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../../suite/assert.js' + +class Person2 { + public name: string; + private age: number; + protected sex: string; + constructor(name: string, age: number, sex: string) { + this.name = name; + this.age = age; + this.sex = sex; + } + get _age() { + return this.age; + } + set _age(value) { + if (value >= 0) { + this.age = value; + } + } +} +class Child extends Person2 { + f() { + if (this.sex === "man") { + this.sex = "male"; + } else { + this.sex = "female"; + } + } +} +const a = new Child("wangwu", 15, "man"); +a.name = "lisi"; +a._age = 19; +Assert.equal(a.name, "lisi"); +Assert.equal(a._age, 19); + diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_1.ts new file mode 100644 index 0000000000..c8ce127dab --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_1.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + a call signature's return type annotation specifies the type of the value computed and returned by a call operation. + A void return type annotation is used to indicate that a function has no return value. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../../suite/assert.js' + +function returnNum(a: number, b: number): number { + return a + b; +} +let aa = returnNum(1, 2); +Assert.isNumber(aa); +function returnString(name: string): string { + return name + " b!"; +} +let bb = returnString("rush"); +Assert.isString(bb); +function returnBoolean(a: number, b: number): Boolean { + return a > b ? true : false; +} +let cc = returnBoolean(1, 2); +Assert.isBoolean(cc); +function returnUndefine(a: undefined): undefined { + return a; +} +let ad: undefined; +let dd = returnUndefine(ad); +Assert.isUndefined(dd); +function returnVoid(a: number): void { } +let ee = returnVoid(1); +Assert.equal(ee, null); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_2.ts new file mode 100644 index 0000000000..b800f3d859 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_2.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When a call signature with no return type annotation occurs in a context without a function body, + the return type is assumed to be the Any type. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../../suite/assert.js' + +let add: { (x: number, y: number): any }; +type anyT = ReturnType; +let x: anyT; +x = 1; +Assert.isNumber(x); +x = "any"; +Assert.isString(x); +x = true; +Assert.isBoolean(x); +x = undefined; +Assert.isUndefined(x); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_3.ts new file mode 100644 index 0000000000..5a9f529d34 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_3.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When a call signature with no return type annotation occurs in a context that has a function body , + he return type is inferred from the function body. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../../suite/assert.js' + +let add = function (x: number, y: number) { + return x + y; +}; +type Tadd = ReturnType; +let x: Tadd = 1; +Assert.equal(typeof x, "number"); +let sum = function (x: string, y: string) { + return x + y; +}; +type Tsum = ReturnType; +let y: Tsum = "hello"; +Assert.equal(typeof y, "string"); +let booltp = function (x: boolean) { + return true; +}; +let z = booltp(false); +Assert.equal(z, true); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/specialized_signatures/specialized_signatures_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/specialized_signatures/specialized_signatures_1.ts new file mode 100644 index 0000000000..97f42b0ace --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/specialized_signatures/specialized_signatures_1.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Specialized signatures are used to express patterns where specific string values for some parameters + cause the types of other parameters or the function result to become further specialized. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../../suite/assert.js' + +interface specialType { + Tfun(x: "hello"): "hello"; + Tfun(x: "world"): "world"; + Tfun(x: string): string; +} +class getType implements specialType { + Tfun(x: any): any { + const xx: "hello" = "hello"; + const xx2: "world" = "world"; + if (x === xx) { + return x; + } else if (x === xx2) { + return x; + } else if (typeof x === "string") { + return "isstring"; + } + } +} +const x1 = new getType(); +const xx1: "hello" = "hello"; +const y1: "hello" = x1.Tfun(xx1); +Assert.isTrue(y1 === xx1); +const x2 = new getType(); +const xx2: "world" = "world"; +const y2 = x2.Tfun(xx2); +Assert.isTrue(xx2 === y2); +const x3 = new getType(); +const y3 = x3.Tfun("helloworld"); +Assert.equal(y3, "isstring"); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_1.ts new file mode 100644 index 0000000000..86046a334e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_1.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Type parameters in call signatures provide a mechanism for expressing the relationships of parameter and return types in call operations. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +function identity(h_x: T): T { + return h_x; +} +let h_x: number = 1; +Assert.equal(h_x, identity(h_x)); +function identity2(h_x: T, h_y: U): T { + return h_x; +} +Assert.equal(h_x, identity2(h_x, 1)); +function identity3(obj: T, key: K) { + return obj[key]; +} +let h_y = { h_a: 1, h_b: 2, h_c: 3, h_d: 4 }; +identity3(h_y, "h_a"); +function identity4(arg: T[]): T[] { + return arg; +} +let arg: number[] = [1, 2, 3]; +Assert.equal(arg, identity4(arg)); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_2.ts new file mode 100644 index 0000000000..0e67860fb9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_2.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Type arguments for call signature type parameters may be explicitly specified in a call operation or may, + when possible, be inferred from the types of the regular arguments in the call. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +function identity(h_x: T): T { + return h_x; +} +let h_x: number = 3; +// CHECK explicitly specified type in call +Assert.isNumber(identity(h_x)); +let h_y = "string"; +// CHECK inferred from argument in the call +Assert.isString(identity(h_y)); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/construct_signatures/construct_signatures.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/construct_signatures/construct_signatures.ts new file mode 100644 index 0000000000..9661b7f0ab --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/construct_signatures/construct_signatures.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: A type may overload new operations by defining multiple construct signatures with different parameter lists. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +class Animal { + name: string | undefined; + age: number | undefined; + constructor(); + constructor(name: string); + constructor(age: number); + constructor(nameorage?: string | number, age?: number) { + if (typeof nameorage == "number") { + this.age = nameorage; + } + if (typeof nameorage == "string") { + this.name = nameorage; + } + if (age) { + this.age = age; + } + } +} +type AnimalConstructor = { + new (name: string, age: number): Animal; + new (name: string): Animal; + new (age: number): Animal; + new (): Animal; +}; + +const AnimalConstructor: AnimalConstructor = Animal; + +let tt1 = new AnimalConstructor(); +Assert.isUndefined(tt1.age); +Assert.isUndefined(tt1.name); +let tt2 = new AnimalConstructor("caihua2", 12); +Assert.equal(tt2.name, "caihua2"); +Assert.equal(tt2.age, 12); +let tt3 = new AnimalConstructor("caihua3"); +Assert.equal(tt3.name, "caihua3"); +Assert.isUndefined(tt3.age); +let tt4 = new AnimalConstructor(1230); +Assert.equal(tt4.age, 1230); +Assert.isUndefined(tt4.name); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/index_signatures/index_signatures.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/index_signatures/index_signatures.ts new file mode 100644 index 0000000000..d5a53939ce --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/index_signatures/index_signatures.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + string index signatures, specified using index type string, define type constraints for all properties and numeric index signatures in the containing type. + numeric index signatures, specified using index type number, define type constraints for all numerically named properties in the containing type. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var si: { [key: string]: number } = { a: 97, A: 65 }; +si["b"] = 98; +Assert.isNumber(si["a"]); +Assert.equal(si["A"], 65); + +var ni: { [key: number]: boolean } = { 0: false, 1: true }; +ni[-1] = true; +Assert.isBoolean(ni[0]); +Assert.equal(ni[-1], true); + +interface UnionKey { + [key: string | number]: string | number; +} +var uk: UnionKey = { Name: "UnionKey", 0: "NARC", 0x0a: 10 }; +Assert.equal(uk["Name"], "UnionKey"); +Assert.equal(uk[0], "NARC"); +Assert.equal(uk[0x0a], 10); +Assert.equal(uk[0xff], undefined); + +interface StringKey { + [key: string]: string; +} +var sk: StringKey = { "1": "0x01", "2": "0x02", 3: "0x03", "4": "0x04" }; +Assert.isString(sk["1"]); +Assert.isString(sk[2]); +Assert.equal(sk[3], 0x03); + +interface NumberKey { + [key: number]: string; +} +var nk: NumberKey = { 1: "0x01", 2: "0x02", "3": "0x03", 4: "0x04" }; +Assert.isString(nk["1"]); +Assert.isString(nk[2]); +Assert.equal(nk["3"], "0x03"); + +var rk1: Record = { one: 1, two: 2, three: 3 }; +Assert.equal(rk1["one"], 1); +var rk2: Record<"a" | "b" | "c", string> = { a: "A", b: "B", c: "C" }; +Assert.equal(rk2["a"], "A"); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/method_signatures/method_signatures_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/method_signatures/method_signatures_1.ts new file mode 100644 index 0000000000..c6c1c59351 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/method_signatures/method_signatures_1.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the PropertyName is followed by a question mark, the property is optional. + Only object type literals and interfaces can declare optional properties. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +// interfaces +interface point { + point(x: number, y: number, z?: number): number; +} +class P implements point { + point(x: number, y: number, z?: number | undefined): number { + if (z) return x + y + z; + return x + y; + } +} +let p1 = new P(); +let x: number = 1; +let y: number = 2; +let z: number = 3; +let sum = p1.point(x, y, z); +Assert.equal(sum, 6); +sum = p1.point(x, y); +Assert.equal(sum, 3); +// object type literals +let point2: { x: number; y: number; z?: number }; +point2 = { x: 1, y: 2, z: 3 }; +let pp1 = point2; +Assert.equal(pp1.x, 1); +Assert.equal(pp1.y, 2); +point2 = { x: 0, y: 0, z: 0 }; +let pp2 = point2; +Assert.equal(pp2.x, 0); +Assert.equal(pp2.y, 0); +Assert.equal(pp2.z, 0); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/method_signatures/method_signatures_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/method_signatures/method_signatures_2.ts new file mode 100644 index 0000000000..d562e4624b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/method_signatures/method_signatures_2.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A literal type may overload a method by declaring multiple method signatures + with the same name but differing parameter lists. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +class A { + add(x: number, y: number): number; + add(x: number, y: number, z: number): number; + add(x: any, y: any, z?: any): any { + if ( + typeof x == "number" && + typeof y == "number" && + typeof z == "undefined" + ) { + return x + y; + } + if ( + typeof x === "number" && + typeof y === "number" && + typeof z === "number" + ) { + return x + y + z; + } + } +} +let a = new A(); +Assert.equal(a.add(1, 2), 3); +let b = new A(); +Assert.equal(b.add(1, 2, 3), 6); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/property_signatures/property_signatures.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/property_signatures/property_signatures.ts new file mode 100644 index 0000000000..dd1d4738bb --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/property_signatures/property_signatures.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the PropertyName of a property signature must be unique within its containing type, and must denote a well-known symbol if it is a computed property name. + if the property name is followed by a question mark, the property is optional. Otherwise, the property is required. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var fname: { fristName: string, middleName?: string, lastName: string; } = { fristName: "NARC", lastName: "TypeScript" }; +var f2name: { fristName: string, middleName?: string, lastName: string; } = { + fristName: "Isaac", + middleName: "F", + lastName: "Newton", +}; +function fullName(name: { fristName: string, middleName?: string, lastName: string; }): string { + if (name.middleName != undefined) { + return name.fristName + " " + name.middleName + " " + name.lastName; + } else { + return name.fristName + " " + name.lastName; + } +} +var fn1: string = fullName(fname); +Assert.isString(fn1); +Assert.equal(fn1, "NARC TypeScript"); + +var fn2: string = fullName(f2name); +Assert.isString(fn2); +Assert.equal(fn2, "Isaac F Newton"); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_1.ts new file mode 100644 index 0000000000..55ddf04871 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_1.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + An array type literal is written as an element type followed by an open and close square bracket. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var arr: number[] = [2, 4, 6, 8]; +Assert.isNumber(arr[0]); +Assert.isNumber(arr[1]); +Assert.isNumber(arr[2]); +Assert.isNumber(arr[3]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_2.ts new file mode 100644 index 0000000000..69d2998a7e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_2.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + An array type literal references an array type with the given element type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var h_arr = ['s', 5, true]; +Assert.isString(h_arr[0]); +Assert.isNumber(h_arr[1]); +Assert.isBoolean(h_arr[2]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_3.ts new file mode 100644 index 0000000000..6e845a6f60 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_3.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When union, intersection, function, or constructor types are used as array element types they must be enclosed in parentheses. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var h_test1: string | number[]; +h_test1 = 'string'; +Assert.isString(h_test1); +h_test1 = [3, 5]; +Assert.isNumber(h_test1[0]); +Assert.isNumber(h_test1[1]); + +var h_test2: (string | number)[]; +h_test2 = [2, 'b']; +Assert.isNumber(h_test2[0]); +Assert.isString(h_test2[1]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_4.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_4.ts new file mode 100644 index 0000000000..31e14bc5b9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_4.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Array types can be written using the 'Array' notation. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var arr: Array = [2, 'a']; +Assert.isNumber(arr[0]); +Assert.isString(arr[1]); + +var h_x = function () { + return 'h_x'; +} +var h_y = function () { + return 'h_y'; +} +var fun: Array<() => string> = [h_x, h_y]; +Assert.isFunction(fun[0]); +Assert.isFunction(fun[1]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/function_type_literals/function_type_literals_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/function_type_literals/function_type_literals_3.ts new file mode 100644 index 0000000000..3bd2f2c9eb --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/function_type_literals/function_type_literals_3.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Function types with multiple call or construct signatures cannot be written as function type literals + but must instead be written as object type literals. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface h_inter { + (h_x: string): number; + (h_x: number): string +} + +var h_i: h_inter = Object.assign(function (h_x: any) { + if (typeof h_x === 'string') { + return h_x.toString(); + } else { + return h_x.toString(); + } +}) +Assert.equal(h_i('a'), 'a') +Assert.equal(h_i(2), 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/intersection_type_literals/intersection_type_literals.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/intersection_type_literals/intersection_type_literals.ts new file mode 100644 index 0000000000..d9b5644909 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/intersection_type_literals/intersection_type_literals.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + An intersection type literal is written as a sequence of types separated by ampersands. + An intersection type literal references an intersection type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var t_inter: object & { name: string }; +t_inter = { + name: 'intersection' +} +Assert.isObject(t_inter); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/object_type_literals/object_type_literals.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/object_type_literals/object_type_literals.ts new file mode 100644 index 0000000000..6ed76a7536 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/object_type_literals/object_type_literals.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + An object type literal defines an object type by specifying the set of members that are statically considered to be present in instances of the type. + Object type literals can be given names using interface declarations but are otherwise anonymous. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var h_obj: { + num: number; + str: string; + boo: boolean; +} = { + num: 5, + str: 'str', + boo: true +} +Assert.equal(h_obj.num, 5); +Assert.equal(h_obj.str, 'str'); +Assert.equal(h_obj.boo, true); + +interface h_i { + name: string, + age: number +} +var h_o: h_i = { + name: 'xiao', + age: 18 +} +Assert.equal(h_o.name, 'xiao'); +Assert.equal(h_o.age, 18); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/predefined_types/predefined_types.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/predefined_types/predefined_types.ts new file mode 100644 index 0000000000..03e72d23ef --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/predefined_types/predefined_types.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The any, number, boolean, string, symbol and void keywords reference + the Any type and the Number, Boolean, String, Symbol, and Void primitive types respectively. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var m_n: number = 5; +Assert.equal(m_n.toString(), "5"); + +var m_b: boolean = true; +Assert.equal(m_b.toString(), "true"); + +var m_s: string = 's'; +Assert.equal(m_s.toString(), "s"); + +var m_sy: symbol = Symbol(); +Assert.equal(m_sy.toString(), "Symbol()"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/specifying_types_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/specifying_types_1.ts new file mode 100644 index 0000000000..39f685522f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/specifying_types_1.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Types are specified either by referencing their keyword or name, or by writing object type literals, + array type literals, tuple type literals, function type literals, constructor type literals, or type queries. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var h_num: number = 5; +Assert.isNumber(h_num); + +var h_obj = { + name: 'xiao', + age: 18 +} +Assert.equal(typeof h_obj, 'object'); + +var h_arr = [10, 5, 7, 20]; +Assert.equal(typeof h_arr, 'object'); + +var h_tup = ['str', 5, true]; +Assert.equal(typeof h_tup, 'object'); + +var h_func = (h_x: number, h_y: number) => { + return h_x + h_y +} +Assert.equal(typeof h_func, 'function'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/specifying_types_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/specifying_types_2.ts new file mode 100644 index 0000000000..e4f610b781 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/specifying_types_2.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Parentheses are required around union, intersection, function, or constructor types when they are used as array element types + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var h_arr: (string | number)[] = ['10', 5]; +Assert.equal(typeof h_arr, 'object'); + +var m_fun = function func(x: number) { + return x; +} +var h_func: ((h_x: string) => string) | ((h_x: number) => number) = m_fun; +Assert.equal(typeof h_func, 'function'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/this_type_references/this_type_references_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/this_type_references/this_type_references_1.ts new file mode 100644 index 0000000000..49a1d1d845 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/this_type_references/this_type_references_1.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The meaning of a ThisType depends on the closest enclosing FunctionDeclaration, + FunctionExpression, PropertyDefinition, ClassElement, or TypeMember, known as the root declaration of the ThisType, + when the root declaration is an instance member or constructor of a class, the ThisType references the this-type of that class. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class myClass { + num: number; + constructor(num: number) { + this.num = num; + } + get() { + return this; + } +} + +var my_c = new myClass(10); +Assert.equal(typeof my_c.get(), 'object'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/this_type_references/this_type_references_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/this_type_references/this_type_references_2.ts new file mode 100644 index 0000000000..fa4e379064 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/this_type_references/this_type_references_2.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The meaning of a ThisType depends on the closest enclosing FunctionDeclaration, + FunctionExpression, PropertyDefinition, ClassElement, or TypeMember, known as the root declaration of the ThisType, + when the root declaration is a member of an interface type, the ThisType references the this-type of that interface. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface h_inter { + name: string; + getN(this: h_inter): string; +} + +var h_i: h_inter = { + name: 'xiao', + getN() { + return this.name; + } +} +Assert.equal(h_i.getN(), 'xiao'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/tuple_type_literals/tuple_type_literals.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/tuple_type_literals/tuple_type_literals.ts new file mode 100644 index 0000000000..5e7b54f616 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/tuple_type_literals/tuple_type_literals.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A tuple type literal is written as a sequence of element types, separated by commas and enclosed in square brackets. + A tuple type literal references a tuple type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var t_arr: [number, string, boolean] = [3, 'a', true] +Assert.isNumber(t_arr[0]); +Assert.isString(t_arr[1]); +Assert.isBoolean(t_arr[2]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_queries/type_queries_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_queries/type_queries_1.ts new file mode 100644 index 0000000000..18c1c0b7aa --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_queries/type_queries_1.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type query obtains the type of an expression. + A type query consists of the keyword typeof followed by an expression. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +function func(obj: string | number): void { + if (typeof obj === 'string') { + Assert.isString(obj); + } else { + Assert.isNumber(obj); + } +} +func('obj'); +func(5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_queries/type_queries_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_queries/type_queries_2.ts new file mode 100644 index 0000000000..7f985c810a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_queries/type_queries_2.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Type queries are useful for capturing anonymous types that are generated by various constructs + such as object literals, function declarations, and namespace declarations. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var h_a: { h_x: number, h_y: string }; + +var h_b: typeof h_a; +h_b = { + h_x: 10, + h_y: 'h_y' +} +Assert.equal(typeof h_b, 'object'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_1.ts new file mode 100644 index 0000000000..8992952e77 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_1.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type reference references a named type or type parameter through its name and, in the case of a generic type, supplies a type argument list. + A TypeReference consists of a TypeName that a references a named type or type parameter. A reference to a generic type must be followed by a list of TypeArguments. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var h_obj: { + month: number; + day: number; +} = { + month: 5, + day: 15 +} +Assert.equal(h_obj.month, 5); +Assert.equal(h_obj.day, 15); + +function identity1(value: T, message: U): [T, U] { + return [value, message]; +} +let identi = identity1(1, 'string'); +Assert.equal(identi[0], 1); +Assert.equal(identi[1], 'string'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_2.ts new file mode 100644 index 0000000000..4b30ddc016 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_2.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type reference to a generic type is required to specify exactly one type argument for each type parameter + of the referenced generic type, and each type argument must be assignable to the constraint of the corresponding type parameter. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface h_A { + h_a: string; +} +interface h_B extends h_A { + h_b: string; +} +interface h_C extends h_B { + h_c: string; +} +interface h_G { + h_x: T; + h_y: U; +} + +var h_v: h_G = { + h_x: { h_a: 'h_a' }, + h_y: { + h_a: 'h_a', + h_b: 'h_b', + h_c: 'h_c' + } +} +Assert.equal(h_v.h_x.h_a, 'h_a'); +Assert.equal(h_v.h_y.h_a, 'h_a'); +Assert.equal(h_v.h_y.h_b, 'h_b'); +Assert.equal(h_v.h_y.h_c, 'h_c'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_3.ts new file mode 100644 index 0000000000..75d3de9dc9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_3.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type argument is simply a Type and may itself be a type reference to a generic type. + A type reference to a generic type G designates a type wherein all occurrences of G's type parameters have been replaced + with the actual type arguments supplied in the type reference. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface h_A { + h_a: string; +} +interface h_B extends h_A { + h_b: string; +} +interface h_C extends h_B { + h_c: string; +} +interface h_G { + h_x: T; + h_y: U; +} + +var h_v: h_G, h_C> = { + h_x: { + h_x: { h_a: 'h_a' }, + h_y: { + h_a: 'h_a', + h_b: 'h_b' + } + }, + h_y: { + h_a: 'h_a', + h_b: 'h_b', + h_c: 'h_c' + } +} +Assert.equal(h_v.h_x.h_x.h_a, 'h_a'); +Assert.equal(h_v.h_x.h_y.h_b, 'h_b'); +Assert.equal(h_v.h_y.h_a, 'h_a'); +Assert.equal(h_v.h_y.h_b, 'h_b'); +Assert.equal(h_v.h_y.h_c, 'h_c'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/union_type_literals/union_type_literals.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/union_type_literals/union_type_literals.ts new file mode 100644 index 0000000000..274586615f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/union_type_literals/union_type_literals.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A union type literal is written as a sequence of types separated by vertical bars. + A union type literal references a union type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var t_union: string | number; +t_union = 's'; +Assert.isString(t_union); +t_union = 5; +Assert.isNumber(t_union); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_1.ts new file mode 100644 index 0000000000..e308e2cb12 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_1.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The Any type is a supertype of all types, + and is assignable to and from all types. + options: + lib: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../suite/assert.js' + +var x: any; +x = 12; +Assert.isNumber(x); +x = "abc"; +Assert.isString(x); +x = true; +Assert.isBoolean(x); + diff --git a/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_2.ts new file mode 100644 index 0000000000..f6ea162cae --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_2.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + in places where a type is not explicitly provided + and TypeScript cannot infer one, the Any type is assumed. + options: + lib: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../suite/assert.js' + +var a; +a = 25.25; +Assert.isNumber(a); +a = "narc"; +Assert.isString(a); +a = function add(a: any, b: any) { + return a + b; +}; +Assert.isFunction(a); +a = false; +Assert.isBoolean(a); +a = Symbol(); +Assert.isSymbol(a); +a = { 1408: "Movie" }; +Assert.equal(JSON.stringify(a), '{"1408":"Movie"}'); +a = null; +let flag = false; +if (a === null) { + flag = true; +} +Assert.isTrue(flag); +a = undefined; +Assert.isUndefined(a); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_3.ts new file mode 100644 index 0000000000..ed46bf3ef3 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_3.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + properties of any name can be accessed through an Any value + and Any values can be called as functions with any argument list. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../suite/assert.js' + +var x: any +x = 1024; +x.toString(); +Assert.isString(x.toString()); +x = "AAA"; +x.length; +Assert.isNumber(x.length); +var fun3: any; +fun3 = () => { }; +fun3(); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_aliases/type_aliases_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_aliases/type_aliases_1.ts new file mode 100644 index 0000000000..4cbfd57a2d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_aliases/type_aliases_1.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type alias serves as an alias for the type specified in the type alias declaration. + A type alias declaration can introduce a name for any kind of type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +type MyString = string; +var h_x: MyString = 'x'; +Assert.isString(h_x); + +type MyUnionType = number | string | boolean; +var h_y: MyUnionType = 10; +Assert.isNumber(h_y); +h_y = '10'; +Assert.isString(h_y); +h_y = true; +Assert.isBoolean(h_y); + +type MyInterType = object & { name: string }; +var h_z: MyInterType = { name: 'xiao' }; +Assert.equal(typeof h_z, 'object'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_aliases/type_aliases_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_aliases/type_aliases_2.ts new file mode 100644 index 0000000000..a62ac1ad94 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_aliases/type_aliases_2.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type alias may optionally have type parameters + that serve as placeholders for actual types to be provided when the type alias is referenced in type references. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +type h_MyType = { + h_name: string; + h_age: number; + h_height?: number; + h_weight?: number +} +var h_ty: h_MyType = { + h_name: 'xiao', + h_age: 18, + h_height: 180 +} +Assert.equal(h_ty.h_height, 180); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_aliases/type_aliases_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_aliases/type_aliases_3.ts new file mode 100644 index 0000000000..b6d3499c02 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_aliases/type_aliases_3.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Type aliases are referenced using type references. + Type references to generic type aliases produce instantiations of the aliased type with the given type arguments. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface h_inter { + h_x: T; + h_y: U; +} +interface h_face { + h_y: T; + h_b: U; +} +type MyType = h_inter | h_face +var mytest: MyType = { + h_x: 10, + h_y: 'y', + h_b: true +} +Assert.isString(mytest.h_y); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/this_types/this_types.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/this_types/this_types.ts new file mode 100644 index 0000000000..f39b82d770 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/this_types/this_types.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + every class and interface has a this-type that represents the actual type of instances of the class or interface within the declaration of the class or interface. The this-type is referenced using the keyword this in a type position. + within instance methods and constructors of a class, the type of the expression this is the this-type of the class. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class CA { + name: string = "CA"; + f() { + return this; + } + caName(cname: string) { + this.name = cname; + return "CA:" + this.name; + } +} + +class CB extends CA { + b() { + return this; + } + cbName(cname: string) { + this.name = cname; + return "CB:" + this.name; + } +} + +let bB: CB = new CB(); +let xB = bB.f().b(); +Assert.equal(bB, xB); + +var thisStrB: string = bB.cbName("CB"); +Assert.equal(thisStrB, "CB:CB"); +var thisStrA: string = bB.caName("CA"); +Assert.equal(thisStrA, "CA:CA"); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/this_types/this_types_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/this_types/this_types_1.ts new file mode 100644 index 0000000000..c173d3d5b9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/this_types/this_types_1.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Every class and interface has a this-type that represents the actual type of instances of the class or interface within the declaration of the class or interface. The this-type is referenced using the keyword this in a type position. + within instance methods and constructors of a class, the type of the expression this is the this-type of the class. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface h_inter { + h_say: () => string; +} +let h_i: h_inter = { + h_say() { + return typeof this; + } +} +Assert.equal(h_i.h_say(), 'object'); + +class h_C { + num: number; + constructor(num: number) { + this.num = num; + Assert.equal(typeof this, 'object'); + } +} +let h_c = new h_C(10); +Assert.equal(h_c.num, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/this_types/this_types_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/this_types/this_types_2.ts new file mode 100644 index 0000000000..f0e04d9e1e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/this_types/this_types_2.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Classes and interfaces support inheritance and therefore the instance represented by this in a method + isn't necessarily an instance of the containing class—it may in fact be an instance of a derived class or interface. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class CA { + name: string = "CA"; + f() { + return this; + } + caName(cname: string) { + this.name = cname; + return "CA:" + this.name; + } +} + +class CB extends CA { + b() { + return this; + } + cbName(cname: string) { + this.name = cname; + return "CB:" + this.name; + } +} + +let bB: CB = new CB(); +let xB = bB.f().b(); +Assert.equal(bB, xB); + +var thisStrB: string = bB.cbName("CB"); +Assert.equal(thisStrB, "CB:CB"); +var thisStrA: string = bB.caName("CA"); +Assert.equal(thisStrA, "CA:CA"); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_1.ts new file mode 100644 index 0000000000..d0ef6684e4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_1.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type reference to a generic type must include + a list of type arguments enclosed in angle brackets and separated by commas. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +function identity1(value: T, message: U): [T, U] { + return [value, message]; +} +let identi = identity1(1, 2); +Assert.equal(identi[0], 1); +Assert.equal(identi[1], 2); + diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_2.ts new file mode 100644 index 0000000000..b2b2c138c2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_2.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + a call to a generic function may explicitly include a type argument list instead of relying on type inference. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface GenericIdentityFn { + (arg: T): T; +} +function identity(arg: T): T { + return arg; +} +let myidenti: number = 1; +let myIdentity: GenericIdentityFn = identity; +let myidenti2 = myIdentity(myidenti); +Assert.equal(myidenti2, 1); + diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_3.ts new file mode 100644 index 0000000000..933672c069 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_3.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type argument list is required to specify exactly one type argument for each corresponding type parameter, + and each type argument for a constrained type parameter is required to satisfy the constraint of that type parameter. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +function getname(name: T, number: Y): T { + return name; +} +interface Lengthwise { + length: number; +} +interface Search { + (name: T, number: Y): T; +} +let fn: Search = getname; +let aa: Lengthwise = { length: 11 }; +let a = fn("wan", aa); +Assert.equal(a, "wan"); +let fn2: Search = getname; +let bb: Lengthwise = { length: 33 }; +let b = fn2(22, bb); +Assert.equal(b, 22); +let fn3: Search = getname; +let cc: Lengthwise = { length: 44 }; +let c = fn3(true, cc); +Assert.equal(c, true); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_4.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_4.ts new file mode 100644 index 0000000000..4506e526ea --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_4.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The process of substituting type arguments for type parameters in a generic type + or generic signature is known as instantiating the generic type or signature. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +function h_iden(h_x: T): T { + return h_x; +} +var x = h_iden(10); +Assert.isNumber(x); +Assert.equal(x, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_1.ts new file mode 100644 index 0000000000..2cf95d862b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_1.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Class, interface, type alias, and function declarations may optionally include + lists of type parameters enclosed in < and > brackets. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +// class +class MinClass { + public list: T[] = []; + add(v: T) { + this.list.push(v); + } + findminNumberValue(): T { + let minNum = this.list[0]; + + for (let i = 0; i < this.list.length; i++) { + if (minNum > this.list[i]) { + minNum = this.list[i]; + } + } + return minNum; + } +} +// string type +let minStringValue = new MinClass(); +minStringValue.add("a"); +minStringValue.add("b"); +minStringValue.add("c"); +minStringValue.add("d"); +Assert.equal(minStringValue.findminNumberValue(), "a"); +// number type +let minNumberValue = new MinClass(); +minNumberValue.add(1); +minNumberValue.add(2); +minNumberValue.add(3); +minNumberValue.add(4); +Assert.equal(minNumberValue.findminNumberValue(), 1); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_2.ts new file mode 100644 index 0000000000..d8050e3c19 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_2.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Class, interface, type alias, and function declarations may optionally include + lists of type parameters enclosed in < and > brackets. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +// interface +interface OutputValue { + (arg: T): T; +} +let tt1: OutputValue = function (arg: T): T { + return arg; +}; +Assert.equal(tt1("abc"), "abc"); + diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_3.ts new file mode 100644 index 0000000000..da55632ee2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_3.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Class, interface, type alias, and function declarations may optionally include + lists of type parameters enclosed in < and > brackets. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +// alias +class Person { + name: string; + age: number; + job: string; + constructor(name: string, age: number, job: string) { + this.name = name; + this.age = age; + this.job = job; + } +} +// Mapping: This parameter is optional +type optionallyTest = { + [P in keyof T]?: T[P]; +}; +let pp: optionallyTest = {}; +pp = { name: "dog" }; +Assert.isUndefined(pp.job); +Assert.isUndefined(pp.age); +pp = { name: "dog", age: 18 }; +Assert.isUndefined(pp.job); +pp = { name: "dog", age: 18, job: "teacher" }; diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_4.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_4.ts new file mode 100644 index 0000000000..bb7eaf98f3 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_4.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Class, interface, type alias, and function declarations may optionally include + lists of type parameters enclosed in < and > brackets. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +function returnAnyTypeValue(a: T): T { + return a; +} +Assert.equal(returnAnyTypeValue(1), 1); +Assert.equal(returnAnyTypeValue("char"), "char"); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_5.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_5.ts new file mode 100644 index 0000000000..f6ade18805 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_5.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Type parameter names must be unique. A compile-time error occurs + if two or more type parameters in the same TypeParameterList have the same name. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +// function declaration +function sum(a: T, b: K): string { + return "a"; +} +Assert.equal(sum(1, 1), "a"); + diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_6.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_6.ts new file mode 100644 index 0000000000..5dee8cfec5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_6.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type parameter may have an associated type parameter constraint that establishes an upper bound for type arguments. + Type parameters may be referenced in type parameter constraints within the same type parameter list, + including even constraint declarations that occur to the left of the type parameter. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +type Dog = { + m_name: string; + m_age: number; + m_job: string; +}; +type PickProperty = { [P in K]: T[P] }; +type test = PickProperty; +let cc: test = { + m_age: 20, + m_name: "wangwang", +}; +Assert.isNumber(cc.m_age); +Assert.isString(cc.m_name); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_1.ts new file mode 100644 index 0000000000..d3280708cc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_1.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The apparent members of the primitive type Number and all enum types are the apparent members of the global interface type 'Number'. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +let num: Number = 1; +enum Color { + red, + black, + green +} +let c: Color.black = Color.black; +num.toString(); +c.toString(); +Assert.equal(num.valueOf(), c.valueOf()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_2.ts new file mode 100644 index 0000000000..4a84a2174f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_2.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The apparent members of the primitive type Boolean are the apparent members of the global interface type 'Boolean'. + The apparent members of the primitive type String and all string literal types are the apparent members of the global interface type 'String' + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +let bool: Boolean = true; +Assert.isBoolean(bool.valueOf()) + +let str1: String = "string"; +type color = "RED" | "BLUE" | "BALCK" +let str2: color = "BLUE"; +str1.toString; +str2.toString; +Assert.equal(typeof str1.valueOf(), typeof str2.valueOf()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_3.ts new file mode 100644 index 0000000000..1f02ff3b0b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_3.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The apparent members of an object type T are the combination of the following: + The declared and/or inherited members of T. + The properties of the global interface type 'Object' that aren't hidden by properties with the same name in T. + If T has one or more call or construct signatures, the properties of the global interface type 'Function' that aren't hidden by properties with the same name in T. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +let obj: Object; +obj = { + toString() { + return '123'; + } +} +Assert.notEqual(obj.toString, "123"); + +class Person { + name?: string; + age?: number; + toString(): string { + return "hello" + } +} +function test() { + let myTest1: new (str: string, num: number) => Person +} +Assert.notEqual(Person.toString(), "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_4.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_4.ts new file mode 100644 index 0000000000..81f95f0a57 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_4.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When all constituent types of U have an apparent string index signature, + U has an apparent string index signature of a union type of the respective string index signature types. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface Array1 { + [index1: string]: string +} +interface Array2 { + [index2: string]: string +} + +function test(obj: Array1 | Array2) { + return "right" +} +const stu1 = { + age: "19" +} +const stu2 = { + name: "xiao" +} +Assert.equal(test(stu1), "right") +Assert.equal(test(stu2), "right"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_5.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_5.ts new file mode 100644 index 0000000000..d9ac3a6326 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_5.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When all constituent types of U have an apparent numeric index signature, + U has an apparent numeric index signature of a union type of the respective numeric index signature types. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface Array1 { + [index1: string]: number +} +interface Array2 { + [index2: string]: number +} + +function test(obj: Array1 | Array2) { + return "right" +} +const stu1 = { + age: 19 +} +const stu2 = { + number: 10001 +} +Assert.equal(test(stu1), "right") +Assert.equal(test(stu2), "right"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_6.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_6.ts new file mode 100644 index 0000000000..6d2aa963d7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_6.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When one or more constituent types of I have an apparent string index signature, + I has an apparent string index signature of an intersection type of the respective string index signature types. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface Array1 { + [index1: string]: string +} +interface Array2 { + [index2: string]: string +} + +function test(obj: Array1 & Array2) { + return "right" +} +const stu1 = { + age: "19" +} +const stu2 = { + name: "xiao" +} +Assert.equal(test(stu1), "right") +Assert.equal(test(stu2), "right"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_7.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_7.ts new file mode 100644 index 0000000000..663a997a86 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_7.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When one or more constituent types of I have an apparent numeric index signature, + I has an apparent numeric index signature of an intersection type of the respective numeric index signature types. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface Array1 { + [index1: string]: number +} +interface Array2 { + [index2: string]: number +} + +function test(obj: Array1 & Array2) { + return "right" +} +const stu1 = { + age: 19 +} +const stu2 = { + number: 10001 +} +Assert.equal(test(stu1), "right") +Assert.equal(test(stu2), "right"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_8.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_8.ts new file mode 100644 index 0000000000..2aee866f82 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_8.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + a type's apparent members make it a subtype of the 'Object' or 'Function' interface + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var obj: Object = { num1: 10, num2: 20 }; +Assert.equal(JSON.stringify(obj), '{"num1":10,"num2":20}') + +var fun: Function = (num: number) => num * num; +Assert.isUndefined(JSON.stringify(fun)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_1.ts new file mode 100644 index 0000000000..40620e944a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_1.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is assignable to a type T, and T is assignable from S, + if S has no excess properties with respect to T, and S and T are identical types. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface T { + name: string +} +interface S { + name: string +} +let t: T; +let s: S = { name: 'xiao' } +t = s +Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_10.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_10.ts new file mode 100644 index 0000000000..11ac500ff8 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_10.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is assignable to a type T, and T is assignable from S, + if S has no excess properties with respect to T, and T is an intersection type and S is assignable to each constituent type of T. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface Foo { + name: string +} +interface Bar { + age: number +} +interface S { + name: string + age: number +} +type T = Foo & Bar +let t: T +let s: S = { + name: 'xiao', + age: 18 +} +t = s +Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_11.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_11.ts new file mode 100644 index 0000000000..02f551bf69 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_11.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is assignable to a type T, and T is assignable from S, + if S has no excess properties with respect to T, and S is a type parameter and the constraint of S is assignable to T. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface event { + data: T +} +type T = event +type S = event +let t: T +let s: S = { data: 10 } +t = s +Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_12.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_12.ts new file mode 100644 index 0000000000..f26c7fdb3d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_12.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is assignable to a type T, and T is assignable from S, + if S has no excess properties with respect to T, + and S is an object type, an intersection type, an enum type, or the Number, Boolean, or String primitive type, T is an object type, and for each member M in T, + and M is a property and S has an apparent property N where + M and N have the same name, + the type of N is assignable to that of M, + if M is a required property, N is also a required property, and + M and N are both public, M and N are both private and originate in the same declaration, + M and N are both protected and originate in the same declaration, + or M is protected and N is declared in a class derived from the class in which M is declared. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +type T = { + name: any + age: number +} +type S = { + name: string + age: number +} +let t: T +let s: S = { + name: "Xi", + age: 20, +} +t = s +Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_13.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_13.ts new file mode 100644 index 0000000000..b4b2e32315 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_13.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is assignable to a type T, and T is assignable from S, + if S has no excess properties with respect to T, + and S is an object type, an intersection type, an enum type, or the Number, Boolean, or String primitive type, T is an object type, and for each member M in T, + and M is a non-specialized call or construct signature and S has an apparent call or construct signature N where, + when M and N are instantiated using type Any as the type argument for all type parameters declared by M and N (if any), + the signatures are of the same kind (call or construct), + M has a rest parameter or the number of non-optional parameters in N is less than or equal to the total number of parameters in M, + for parameter positions that are present in both signatures, each parameter type in N is assignable to or from the corresponding parameter type in M, + and the result type of M is Void, or the result type of N is assignable to that of M. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface T { + (x: any, y: any): void +} +interface S { + (x: number): void +} +var t: T = (x, y): void => { + return; +} +var s: S = (x): void => { + return; +} +t = s +Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_14.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_14.ts new file mode 100644 index 0000000000..4500361cbc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_14.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is assignable to a type T, and T is assignable from S, + if S has no excess properties with respect to T, + and S is an object type, an intersection type, an enum type, or the Number, Boolean, or String primitive type, T is an object type, and for each member M in T, + and M is an optional property and S has no apparent property of the same name as M. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface T { + name?: string + age?: number +} +interface S { + name?: string + age?: number +} +let t: T +let s: S = { name: 'xiao' } +t = s +Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_15.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_15.ts new file mode 100644 index 0000000000..024a7d9b7b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_15.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is assignable to a type T, and T is assignable from S, + if S has no excess properties with respect to T, + and S is an object type, an intersection type, an enum type, or the Number, Boolean, or String primitive type, T is an object type, and for each member M in T, + and M is a string index signature of type U, + and U is the Any type or S has an apparent string index signature of a type that is assignable to U. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface U { + anything: string +} +interface T { + [key: string]: U +} +interface S { + [keyname: string]: U +} +let t: T = {} +let s: S = {} +s['obj'] = { anything: "thing" } +t = s +Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_16.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_16.ts new file mode 100644 index 0000000000..179e0efd85 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_16.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is assignable to a type T, and T is assignable from S, + if S has no excess properties with respect to T, + and S is an object type, an intersection type, an enum type, or the Number, Boolean, or String primitive type, T is an object type, and for each member M in T, + and M is a numeric index signature of type U, + and U is the Any type or S has an apparent string or numeric index signature of a type that is assignable to U. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface U { + anything: string +} +interface T { + [key: number]: U +} +interface S { + [keyname: number]: U +} +let t: T = {} +let s: S = {} +s[10] = { anything: "thing" } +t = s +Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_17.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_17.ts new file mode 100644 index 0000000000..b7a36cfa23 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_17.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The assignment compatibility and subtyping rules differ only in that, + an object type without a particular property is assignable to an object type in which that property is optional. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface T { + name?: string + age?: number +} +interface S { +} +let t: T +let s: S = {} +t = s +Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_18.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_18.ts new file mode 100644 index 0000000000..d4a8cf61f2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_18.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + when assigning values or passing parameters, + optional properties must either be present and of a compatible type, or not be present at all. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +function func(stu: { num: number; name?: string }) { + return stu +} +var f1 = func({ num: 1234 }); +Assert.equal(JSON.stringify(f1), '{"num":1234}') + +var f2 = func({ num: 1234, name: "xiao" }) +Assert.equal(JSON.stringify(f2), '{"num":1234,"name":"xiao"}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_2.ts new file mode 100644 index 0000000000..f7d9366ad6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_2.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is assignable to a type T, and T is assignable from S, + if S has no excess properties with respect to T, and S or T is the Any type. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface T { + name: string +} +let t: T +const S: any = 'str' +t = S +Assert.equal(t, S); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_3.ts new file mode 100644 index 0000000000..5b3ef6c5e9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_3.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is assignable to a type T, and T is assignable from S, + if S has no excess properties with respect to T, and S is the Undefined type. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface T { + name: undefined +} +interface S { + name: undefined +} +let t: T +let s: S = { name: undefined } +t = s +Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_4.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_4.ts new file mode 100644 index 0000000000..8b11adc97e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_4.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is assignable to a type T, and T is assignable from S, + if S has no excess properties with respect to T, and S is the Null type and T is not the Undefined type. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +let T: any; +const S: null = null; +T = S; +Assert.equal(T, S); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_5.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_5.ts new file mode 100644 index 0000000000..9dacbcde77 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_5.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is assignable to a type T, and T is assignable from S, + if S has no excess properties with respect to T, and S or T is an enum type and the other is the primitive type Number. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +enum T { + A, + B, + C +} +let S: number = 5 +let t: T +t = S +Assert.equal(t, S); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_6.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_6.ts new file mode 100644 index 0000000000..b63b572c2c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_6.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is assignable to a type T, and T is assignable from S, + if S has no excess properties with respect to T, and S is a string literal type and T is the primitive type String. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var T: string = "T"; +type S = "s" | "str" | "string"; +let s: S = "str" +T = s +Assert.equal(T, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_7.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_7.ts new file mode 100644 index 0000000000..1c93752d9f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_7.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is assignable to a type T, and T is assignable from S, + if S has no excess properties with respect to T, and S is a union type and each constituent type of S is assignable to T. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface T { + name: string + age: number + hobby: string +} +interface Foo { + name: string + age: number +} +interface Bar { + hobby: string +} +type S = Foo & Bar +let t: T; +let s: S = { + name: "S", + age: 20, + hobby: "drawing" +} +t = s +Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_8.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_8.ts new file mode 100644 index 0000000000..8d5a56d4d0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_8.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is assignable to a type T, and T is assignable from S, + if S has no excess properties with respect to T, and T is an intersection type and S is assignable to each constituent type of T. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface T { + name: string + age: number +} +interface Foo { + name: string + age: number +} +interface Bar { + hobby: string +} +type S = Foo & Bar +let t: T; +let s: S = { + name: "S", + age: 20, + hobby: "drawing" +} +t = s +Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_9.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_9.ts new file mode 100644 index 0000000000..bfc0b3f541 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_9.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is assignable to a type T, and T is assignable from S, + if S has no excess properties with respect to T, and T is a union type and S is assignable to at least one constituent type of T. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface Foo { + name: string +} +interface Bar { + age: number +} +interface S { + age: number +} +type T = Foo | Bar +let t: T +let s: S = { + age: 18 +} +t = s +Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/contextual_signature_instantiation/contextual_signature_instantiation.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/contextual_signature_instantiation/contextual_signature_instantiation.ts new file mode 100644 index 0000000000..0282fa627d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/contextual_signature_instantiation/contextual_signature_instantiation.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + During type argument inference in a function call, + it is in certain circumstances necessary to instantiate a generic call signature of an argument expression in the context of a non-generic call signature of a parameter such that further inferences can be made. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +function zip(x: S[], y: T[], combine: (x: S) => (y: T) => U): U[] { + var len = Math.max(x.length, y.length); + var result: U[] = []; + for (var i = 0; i < len; i++) result.push(combine(x[i])(y[i])); + return result; +} + +var names = ["Peter", "Paul", "Mary"]; +var ages = [7, 9, 12]; +// the type of 'pairs' is '{ name: string; age: number }[]' +var pairs = zip(names, ages, s => n => ({ name: s, age: n })); +Assert.equal(JSON.stringify(pairs), '[{"name":"Peter","age":7},{"name":"Paul","age":9},{"name":"Mary","age":12}]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/excess_properties/excess_properties_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/excess_properties/excess_properties_1.ts new file mode 100644 index 0000000000..c8e74197d2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/excess_properties/excess_properties_1.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the type contains only optional properties, without the excess property check, + any object literal would be assignable to the variable. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface Options { + strict?: boolean + source?: string + target?: string +} +var options: Options = { + strict: true, + source: "./src", + target: "./bin" +} +Assert.equal(JSON.stringify(options), '{"strict":true,"source":"./src","target":"./bin"}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/excess_properties/excess_properties_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/excess_properties/excess_properties_2.ts new file mode 100644 index 0000000000..3751b7e930 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/excess_properties/excess_properties_2.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In cases where excess properties are expected, an index signature can be added to the target type as an indicator of intent. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface Input { + place: string; + phanic?: boolean; + // the any type is allowed to be the additional properties + [str: string]: any; +} + +var site: Input = { + place: "Address", + phanic: true, + // Can do this because of index signature + use: "Enter address here", + // Can do this because of index signature + shortcut: "Alt-A" +}; +Assert.equal(JSON.stringify(site), '{"place":"Address","phanic":true,"use":"Enter address here","shortcut":"Alt-A"}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/excess_properties/excess_properties_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/excess_properties/excess_properties_3.ts new file mode 100644 index 0000000000..8cdf425225 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/excess_properties/excess_properties_3.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The type inferred for an object literal is considered a fresh object literal type. + The freshness disappears when an object literal type is widened or is the type of the expression in a type assertion. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +// { x: 0, y: 0 } is the fresh object literal type +const p: { x: number, y: number } = { x: 0, y: 0 } +Assert.equal(JSON.stringify(p), '{"x":0,"y":0}') + +// The freshness disappears when the type of the express in a type assertion +// There is Excess Property y but no error +const p1: { x: number } = { x: 0, y: 0 } as { x: 0, y: 0 } +Assert.equal(JSON.stringify(p1), '{"x":0,"y":0}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/recursive_types/recursive_types.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/recursive_types/recursive_types.ts new file mode 100644 index 0000000000..9622da97a0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/recursive_types/recursive_types.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + when comparing types S and T for a given relationship, + the relationship in question is assumed to be true for every directly or indirectly nested occurrence of the same S and the same T + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface iA { + next: iA; +} +interface iB { + next: iC; +} +interface iC { + next: iD; +} +interface iD { + next: iB; +} +type IsEqual = + (() => T1 extends T ? 1 : 2) extends + (() => T2 extends U ? 1 : 2) + ? true + : false +var t1: IsEqual = true +Assert.isTrue(t1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_1.ts new file mode 100644 index 0000000000..10ca7b99b9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_1.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is a subtype of a type T, and T is a supertype of S, + if S has no excess properties with respect to T, S and T are identical types. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface T { + name: string + age: number +} +interface S { + name: string + age: number + hobbies: string[] +} +let t: T = { + name: "T", + age: 20 +}; +let s: S = { + name: "S", + age: 19, + hobbies: ["draw", "game"] +}; + +t = s +Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_10.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_10.ts new file mode 100644 index 0000000000..05364e35c2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_10.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is a subtype of a type T, and T is a supertype of S, + if S has no excess properties with respect to T, + and T is an intersection type and S is a subtype of each constituent type of T. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface S { + name: string + age: number + height: number +} +interface Foo { + name: string +} +interface Bar { + age: number +} +type T = Foo & Bar +let s: S = { + name: "T", + age: 18, + height: 180 +} +let t: T = { + name: "S", + age: 20 +} + +t = s +Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_11.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_11.ts new file mode 100644 index 0000000000..51fb1ee827 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_11.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is a subtype of a type T, and T is a supertype of S, + if S has no excess properties with respect to T, + and S is a type parameter and the constraint of S is a subtype of T. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +let test = (obj: T, key: S): any => { + return obj[key]; +} +let obj = { + a: 'a', + b: 'b' +} +let res = test(obj, "a"); +Assert.equal(res, 'a'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_12.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_12.ts new file mode 100644 index 0000000000..231d656fb7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_12.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is a subtype of a type T, and T is a supertype of S, + if S has no excess properties with respect to T, + and S is an object type, an intersection type, an enum type, or the Number, Boolean, or String primitive type, T is an object type, + and for each member M in T, M is a property and S has an apparent property N where, + M and N have the same name, + the type of N is a subtype of that of M, + if M is a required property, N is also a required property, and + M and N are both public, M and N are both private and originate in the same declaration, + M and N are both protected and originate in the same declaration, + or M is protected and N is declared in a class derived from the class in which M is declared. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +type T = { + name: any + age: number +} +type S = { + name: string + age: number + height: number +} +let t: T = { + name: "xiao", + age: 19 +} +let s: S = { + name: "Xi", + age: 20, + height: 180 +} + +t = s +Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_13.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_13.ts new file mode 100644 index 0000000000..c580cb34a6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_13.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is a subtype of a type T, and T is a supertype of S, + if S has no excess properties with respect to T, + and M is a non-specialized call or construct signature and S has an apparent call or construct signature N where, + when M and N are instantiated using type Any as the type argument for all type parameters declared by M and N (if any), + and for each member M in T, M is a property and S has an apparent property N where, + the signatures are of the same kind (call or construct), + M has a rest parameter or the number of non-optional parameters in N is less than or equal to the total number of parameters in M, + for parameter positions that are present in both signatures, each parameter type in N is a subtype or supertype of the corresponding parameter type in M, + and the result type of M is Void, or the result type of N is a subtype of that of M. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface T { + (x: any, y: any): void +} +interface S { + (x: number): void +} +var t: T = (x, y): void => { + return; +} +var s: S = (x): void => { + return; +} + +t = s +Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_14.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_14.ts new file mode 100644 index 0000000000..16b8499c48 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_14.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is a subtype of a type T, and T is a supertype of S, + if S has no excess properties with respect to T, + and S is an object type, an intersection type, an enum type, or the Number, Boolean, or String primitive type, T is an object type, + and for each member M in T, M is a string index signature of type U, + and U is the Any type or S has an apparent string index signature of a type that is a subtype of U. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface T { + name: string +} +interface S { + name: string + age: number +} +interface U { + [name: string]: any +} +let obj: U = { name: "xiao", age: 18 } +Assert.equal(JSON.stringify(obj), '{"name":"xiao","age":18}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_15.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_15.ts new file mode 100644 index 0000000000..0c0c320900 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_15.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is a subtype of a type T, and T is a supertype of S, + if S has no excess properties with respect to T, + and S is an object type, an intersection type, an enum type, or the Number, Boolean, or String primitive type, T is an object type, + and for each member M in T, M is a numeric index signature of type U, + and U is the Any type or S has an apparent string or numeric index signature of a type that is a subtype of U. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface T { + age: number +} +interface S { + age: number + height: number +} +interface U { + [age: number]: any +} +let obj: U = {} +obj[5] = { age: 18, height: 180 } +Assert.equal(JSON.stringify(obj[5]), '{"age":18,"height":180}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_16.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_16.ts new file mode 100644 index 0000000000..f4d3f7382f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_16.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the only subtypes of a type parameter T are T itself and other type parameters that are directly or indirectly constrained to T. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +function getProperty(obj: T, key: K) { + return obj[key]; +} +let x = { a: 1, b: 2, c: 3, d: 4 }; +Assert.equal(getProperty(x, 'a'), 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_2.ts new file mode 100644 index 0000000000..8519d9fb99 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_2.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is a subtype of a type T, and T is a supertype of S, + if S has no excess properties with respect to T, and T is the Any type. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface T { + name: any + age: any +} +interface S { + name: string + age: number + hobbies: string[] +} +let t: T = { + name: "T", + age: 20 +}; +let s: S = { + name: "S", + age: 19, + hobbies: ["draw", "game"] +}; + +t = s +Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_3.ts new file mode 100644 index 0000000000..69126a26c6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_3.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is a subtype of a type T, and T is a supertype of S, + if S has no excess properties with respect to T and S is the Undefined type. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface T { + name: string | undefined + age: number | undefined +} +interface S { + name: undefined + age: undefined + hobbies: undefined +} +let t: T = { + name: "T", + age: 20 +}; + +let s: S = { + name: undefined, + age: undefined, + hobbies: undefined +}; + +t = s +Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_4.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_4.ts new file mode 100644 index 0000000000..aeb89ec4f8 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_4.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is a subtype of a type T, and T is a supertype of S, + if S has no excess properties with respect to T, and S is the Null type and T is not the Undefined type. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface T { + name: any + age: any +} +interface S { + name: null + age: null + hobbies: null +} +let t: T = { + name: "T", + age: 20 +}; + +let s: S = { + name: null, + age: null, + hobbies: null +}; + +t = s +Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_5.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_5.ts new file mode 100644 index 0000000000..9b51a5e29f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_5.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is a subtype of a type T, and T is a supertype of S, + if S has no excess properties with respect to T, and S is an enum type and T is the primitive type Number. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var T: number = 4; +enum S { + Mon = 1, + Tue, + Wde, + Thur, + Fri +} + +T = S.Mon; +Assert.equal(T, S.Mon); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_6.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_6.ts new file mode 100644 index 0000000000..7f0232654d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_6.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is a subtype of a type T, and T is a supertype of S, + if S has no excess properties with respect to T, + and S is a string literal type and T is the primitive type String. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var T: string = "T"; +type S = "s" | "str" | "string"; +let s: S = "str" + +T = s +Assert.equal(T, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_7.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_7.ts new file mode 100644 index 0000000000..55ec5d8fd9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_7.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is a subtype of a type T, and T is a supertype of S, + if S has no excess properties with respect to T, + and S is a union type and each constituent type of S is a subtype of T. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var T: any = true; +var S: number | string = 18; + +T = S +Assert.equal(T, 18); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_8.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_8.ts new file mode 100644 index 0000000000..43c69739d2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_8.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is a subtype of a type T, and T is a supertype of S, + if S has no excess properties with respect to T, + and S is an intersection type and at least one constituent type of S is a subtype of T. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface T { + name: string + age: number +} +interface Foo { + name: string + age: number +} +interface Bar { + hobby: string +} +type S = Foo & Bar +let t: T = { + name: "T", + age: 18 +} +let s: S = { + name: "S", + age: 20, + hobby: "drawing" +} + +t = s +Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_9.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_9.ts new file mode 100644 index 0000000000..f26efd106a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_9.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + S is a subtype of a type T, and T is a supertype of S, + if S has no excess properties with respect to T, + and T is a union type and S is a subtype of at least one constituent type of T. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +var T: number | string = "18"; +var S: number = 20; + +T = S +Assert.equal(T, S); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_1.ts new file mode 100644 index 0000000000..9dfc40d45e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_1.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In certain contexts, + inferences for a given set of type parameters are made from a type S, in which those type parameters do not occur, + to another type T, in which those type parameters do occur. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface Cb { + (a: number): void +} +interface Fn { + (cb: Cb): void +} +const fn: Fn = function (cb) { } +// The argument a to the anonymous function is of type number +fn(function (a) { + Assert.isNumber(a); + a = a + 1; +}); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_2.ts new file mode 100644 index 0000000000..d6a76f6d34 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_2.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + if S and T are references to the same generic type, + inferences are made from each type argument in S to each corresponding type argument in T. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +function map(a: T[], f: (x: T) => U): U[] { + var result: U[] = []; + for (var i = 0; i < a.length; i++) result.push(f(a[i])); + return result; +} + +var names = ["Peter", "Paul", "Mary"]; +// the type of lengths is number[] +var lengths = map(names, s => s.length); +Assert.equal(typeof lengths, 'object'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_3.ts new file mode 100644 index 0000000000..0663487aad --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_3.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + if S and T are tuple types with the same number of elements, + inferences are made from each element type in S to each corresponding element type in T. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +// the type of T is string | number | boolean +let T = [1, 'a', true] +Assert.equal(typeof T, 'object') +// the type of S is string | number | number[] +let S = [[1, 2, 3], 2, 'b'] +Assert.equal(typeof S, 'object'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_4.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_4.ts new file mode 100644 index 0000000000..60c35327d9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_4.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + if T is a union or intersection type: + First, inferences are made from S to each constituent type in T + that isn't simply one of the type parameters for which inferences are being made. + If the first step produced no inferences then + if T is a union type and exactly one constituent type in T is simply a type parameter for which inferences are being made, + inferences are made from S to that type parameter. + Otherwise, if S is a union or intersection type, inferences are made from each constituent type in S to T. + module: ESNext + isCurrent: true + ---*/ + +import {Assert} from '../../../../../suite/assert.js' + + +type Maybe = T | void +function isDefined(x: Maybe): x is T { + return x! == undefined && x !== null; +} +function isUndefined(x: Maybe): x is void { + return x === undefined || x === null; +} +function getOrElse(x: Maybe, defaultValue: T): T { + return isDefined(x) ? x : defaultValue; +} +function test1(x: Maybe) { + // x1,x2,x3 are of type string + let x1 = getOrElse(x, "Undefined"); + Assert.isString(x1) + let x2 = isDefined(x) ? x : "undefined"; + Assert.isString(x2) + let x3 = isUndefined(x) ? "Undefined" : x; + Assert.isString(x3) +} +test1('t1') +function test2(x: Maybe) { + // x1,x2,x3 are of type number + let x1 = getOrElse(x, - 1); + Assert.isNumber(x1) + let x2 = isDefined(x) ? x : -1; + Assert.isNumber(x2) + let x3 = isUndefined(x) ? -1 : x; + Assert.isNumber(x3) +} +test2(5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_5.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_5.ts new file mode 100644 index 0000000000..2f5580fb5c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_5.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + if S and T are object types, then for each member M in T, + If M is a property and S contains a property N with the same name as M, + inferences are made from the type of N to the type of M. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface T { + name: any +} +interface S { + name: string +} +var t: T +var s: S = { name: "xxx" } +t = s + +Assert.isString(t.name); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_6.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_6.ts new file mode 100644 index 0000000000..e1dc8877d4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_6.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + if S and T are object types, then for each member M in T, + if M is a string index signature and S contains a string index signature N, + inferences are made from the type of N to the type of M. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface T { + [key: string]: string +} +interface S { + [value: string]: string +} +let s: S = { + 'name': 'xiao' +} +Assert.equal(typeof s, 'object'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_7.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_7.ts new file mode 100644 index 0000000000..535f582d80 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_7.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + if S and T are object types, then for each member M in T, + if M is a numeric index signature and S contains a numeric index signature N, + inferences are made from the type of N to the type of M. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +interface T { + [key: number]: string +} +let S: { [value: number]: T } = {} +Assert.equal(typeof S, 'object'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_1.ts new file mode 100644 index 0000000000..19d8ff749e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_1.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + union types represent values that may have one of several distinct representations. + a value of a union type A | B is a value that is either of type A or type B. Union types are written using union type literals + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../suite/assert.js' + +var n_s: number | string; +var b_s: boolean | string; +var o_na: object | number[]; +n_s = 2048; +Assert.isNumber(n_s); +b_s = false; +Assert.isFalse(b_s); +n_s = "NARC"; +Assert.isString(n_s); +b_s = "1"; +Assert.equal(b_s, "1"); + + diff --git a/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_2.ts new file mode 100644 index 0000000000..b2a1c3391c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_2.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + a union type encompasses an ordered set of constituent types. + while it is generally true that A | B is equivalent to B | A, the order of the constituent types may matter when determining the call and construct signatures of the union type. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../suite/assert.js' + +var ab: number | string; +var ba: string | number; +ab = 1408; +ba = 1408; +Assert.equal(ab, ba); +Assert.equal(typeof ab, typeof ba); +ab = "Shift"; +ba = "Shift"; +Assert.equal(ab, ba); +Assert.equal(typeof ab, typeof ba); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_3.ts new file mode 100644 index 0000000000..69dd98e314 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_3.ts @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + a union type U is a subtype of a type T if each type in U is a subtype of T. + a type T is a subtype of a union type U if T is a subtype of any type in U. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../suite/assert.js' + +class ClassT { + size: number = 0; + description: string = ''; +} + +class ClassU1 extends ClassT { + alive: boolean = false; +} + +class ClassU2 extends ClassT { + weight: number = 0; +} + +interface InterfaceU1 { + speak(): string; +} + +interface InterfaceU2 { + eat(): string; +} + +class ClassT2 implements InterfaceU1, InterfaceU2 { + food: string = ''; + language: string = ''; + speak() { + return this.language; + } + + eat() { + return this.food; + } + constructor(food: string, language: string) { + this.food = food; + this.language = language; + } +} + +var u1: ClassU1 | ClassU2 = { size: 7, description: "A", alive: false }; +var t1: ClassT; +t1 = u1; +Assert.equal(JSON.stringify(t1), '{"size":7,"description":"A","alive":false}'); + +var u2: InterfaceU1 | InterfaceU2; +var t2: ClassT2 = new ClassT2("rice", "Chinese"); +u2 = t2; +Assert.equal(JSON.stringify(u2), '{"food":"rice","language":"Chinese"}'); + diff --git a/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_4.ts b/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_4.ts new file mode 100644 index 0000000000..aa16e34c9c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_4.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + a union type U is assignable to a type T if each type in U is assignable to T. + a type T is assignable to a union type U if T is assignable to any type in U. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../suite/assert.js' + +type numType = { num: number }; +type strType = { str: string }; +type boolType = { bool: boolean }; +type objType = { obj: Object }; +var u4a: any; +var u4: numType | strType | boolType | objType | undefined; +var u4_1: numType = { num: 0xCA }; +u4a = u4_1; +Assert.equal(JSON.stringify(u4a), '{"num":202}'); + +var u4_2: strType = { str: "QWER" }; +u4a = u4_2; +Assert.equal(JSON.stringify(u4a), '{"str":"QWER"}'); + +var u4_3: boolType = { bool: false }; +u4a = u4_3; +Assert.equal(JSON.stringify(u4a), '{"bool":false}'); + +var u4_4: objType = { obj: { 0: "ZERO" } }; +u4a = u4_4; +Assert.equal(JSON.stringify(u4a), '{"obj":{"0":"ZERO"}}'); + + +u4 = { num: 0xCA, str: "ABC", bool: false, obj: u4_4 }; +u4a = u4; +Assert.equal(JSON.stringify(u4a), '{"num":202,"str":"ABC","bool":false,"obj":{"obj":{"0":"ZERO"}}}'); + + +u4 = u4_1; +Assert.equal(JSON.stringify(u4), '{"num":202}'); + +u4 = u4_2; +Assert.equal(JSON.stringify(u4), '{"str":"QWER"}'); + +u4 = u4_3; +Assert.equal(JSON.stringify(u4), '{"bool":false}'); + +u4 = u4_4; +Assert.equal(JSON.stringify(u4), '{"obj":{"0":"ZERO"}}'); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_5.ts b/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_5.ts new file mode 100644 index 0000000000..c48510570d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_5.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the || and conditional operators may produce values of union types, and array literals may produce array values that have union types as their element types. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../suite/assert.js' + +var ns5: A1 = 1408 || "NARC"; +var ns5_1: number | string; +var ns5_2: string | number; +ns5 = 1500; +ns5_2 = ns5 <= 1408 ? "NARC" : 1024; +Assert.equal(ns5_2, 1024); +ns5 = 100; +ns5_2 = ns5 <= 1408 ? "NARC" : 1024; +Assert.equal(ns5_2, "NARC"); + +type A1 = string | number | object; +type B1 = number | boolean | string; +var ns5_3: A1 & B1; +ns5_3 = 125; +Assert.isNumber(ns5_3); +ns5_3 = "Fn"; +Assert.isString(ns5_3); + +var arruni1: Array | Array; +arruni1 = [0, true, -1, false]; +Assert.equal(JSON.stringify(arruni1), '[0,true,-1,false]'); +arruni1 = [true, "True", false, "False"]; +Assert.equal(JSON.stringify(arruni1), '[true,"True",false,"False"]'); + +var arruni2: number[] | boolean[]; +arruni2 = [2, 4, 6]; +Assert.equal(JSON.stringify(arruni2), '[2,4,6]'); +arruni2 = [true, false]; +Assert.equal(JSON.stringify(arruni2), '[true,false]'); + +var arruni3: (number | string)[] | (boolean | Object)[]; +arruni3 = [1, 3, 5, "AND", "OR"]; +Assert.equal(JSON.stringify(arruni3), '[1,3,5,"AND","OR"]'); +arruni3 = [true, false, { 0x00: "0x00" }, { 0xFA: "0xFA" }]; +Assert.equal(JSON.stringify(arruni3), '[true,false,{"0":"0x00"},{"250":"0xFA"}]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_6.ts b/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_6.ts new file mode 100644 index 0000000000..3f0746b6bc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_6.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + type guards may be used to narrow a union type to a more specific type. + in particular, type guards are useful for narrowing union type values to a non-union type values. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var h_x: string | number; +h_x = 37; +h_x = "hello"; +var h_n = typeof h_x === "string" ? h_x.length : h_x; +Assert.isNumber(h_n); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_7.ts b/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_7.ts new file mode 100644 index 0000000000..83312bb861 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_7.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + for purposes of property access and function calls, the apparent members of a union type are those that are present in every one of its constituent types, + with types that are unions of the respective apparent members in the constituent types. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../suite/assert.js' + +type numType = { num: number }; +type strType = { str: string }; +type boolType = { bool: boolean }; +type objType = { obj: Object }; +type NS = numType | strType; +type OB = objType | boolType; +var nsv: NS = { num: 1024, str: "NS" }; +var obv: OB = { bool: true, obj: { 0xFF: "0xFF" } }; +var nsobv_1: NS | OB = { num: 1024, obj: { 0xFF: "0xFF" } } +var nsobv_2: NS | OB = { bool: false, str: "nsobv_2" }; +var nsobv_3: NS | OB = { num: 114, bool: false, str: "nsobv_3", obj: { 0xAF: "0xAF" } } +Assert.equal(typeof nsv, "object"); +Assert.equal(typeof obv, "object"); +Assert.equal(typeof nsobv_1, "object"); +Assert.equal(typeof nsobv_2, "object"); +Assert.equal(typeof nsobv_3, "object"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/widend_types/widend_types_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/widend_types/widend_types_1.ts new file mode 100644 index 0000000000..24b4a2df49 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/widend_types/widend_types_1.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In several situations TypeScript infers types from context, + alleviating the need for the programmer to explicitly specify types that appear obvious. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../suite/assert.js' + +var str = "xiao" +Assert.isString(str); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/widend_types/widend_types_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/widend_types/widend_types_2.ts new file mode 100644 index 0000000000..efa9109865 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/widend_types/widend_types_2.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When inferring the type of a variable, property or function result from an expression, + the widened form of the source type is used as the inferred type of the target. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../suite/assert.js' + +var x = 10 +var y = 'a' +var z = x + y +Assert.isString(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/widend_types/widend_types_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/widend_types/widend_types_3.ts new file mode 100644 index 0000000000..b1b02996d9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/widend_types/widend_types_3.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The widened form of a type is the type in which all occurrences of the Null and Undefined types have been replaced with the type any. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var nu = null +Assert.equal(typeof nu, 'object') +var un = undefined +Assert.isUndefined(un) +var obj = { x: 0, y: null } +Assert.equal(typeof obj, 'object') +var arr = [null, undefined] +Assert.equal(typeof arr, 'object'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/tool/test_helper.py b/es2panda/test/ts_extra_tests/tool/test_helper.py new file mode 100644 index 0000000000..890bd9b9e2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/tool/test_helper.py @@ -0,0 +1,101 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +import re +import os + +def read_declaration(path): + start_pattern = re.compile(r'^\/\*\*\-*') + end_pattern = re.compile(r'^\s*\-+\*\/') + context = "" + with open(path,'r', encoding='utf-8', errors='ignore') as f: + declaration_begin = False + while True: + line = f.readline() + if not line: + break + if start_pattern.match(line): + declaration_begin = True + continue + if end_pattern.match(line): + declaration_begin = False + break + if declaration_begin == True: + context += line + return context + +# LIMIT_VERSION = 4.2 +ROOT_FOLDER = 'test' + +def get_path_file(dir_path, all_file_path=None, is_root=False, limit_version=None): + if all_file_path is None: + all_file_path = [] + file_or_dir = os.listdir(dir_path) + file_or_dir_results = [] + if dir_path.endswith("test") or dir_path.endswith("test/"): + is_root = True + else: + is_root = False + if is_root: + root_folder = os.path.basename(dir_path) + if root_folder == ROOT_FOLDER: + # file_or_dir like: ['2.0', '2.1', '2.2', ... '4.9', 'spec'] + for f_item in file_or_dir: + if limit_version is None: + file_or_dir_results = file_or_dir + break + else: + limit_version = float(limit_version) + try: + f_num = float(f_item) + if f_num <= limit_version: + file_or_dir_results.append(f_item) + except Exception as e: + print(e) + continue + if not limit_version is None: + file_or_dir_results.append('spec') + + else: + file_or_dir_results = file_or_dir + for file_dir in file_or_dir_results: + file_or_dir_path = os.path.join(dir_path, file_dir) + if '\\' in file_or_dir_path: + file_or_dir_path = file_or_dir_path.replace('\\', '/') + + if os.path.isdir(file_or_dir_path): + get_path_file(file_or_dir_path, all_file_path, False, None) + else: + all_file_path.append(file_or_dir_path) + + return all_file_path + +def get_disable_list(file_path): + disable_list = [] + with open(file_path,'r', encoding='utf-8', errors='ignore') as f: + while True: + line = f.readline() + if not line: + break + disable_list.append(os.path.abspath(line.strip())) + return disable_list + +def is_disable_case(file_path, disable_list): + if disable_list == None: + return False + if file_path in disable_list: + return True + for disable_path in disable_list: + if disable_path in file_path: + return True diff --git a/es2panda/test/ts_extra_tests/tool/testcfg.py b/es2panda/test/ts_extra_tests/tool/testcfg.py new file mode 100644 index 0000000000..5fbd205e56 --- /dev/null +++ b/es2panda/test/ts_extra_tests/tool/testcfg.py @@ -0,0 +1,245 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +import os +import re +import yaml +import platform +import subprocess +from tool.test_helper import read_declaration + +STRICT_OFF = ['--strict', 'false'] +STRICT_ON = ['--strict', 'true'] +MODULE = ['--module'] + +def get_error_message(str, filename): + if len(re.findall(filename + r':(\d+)', str)) > 0: + line_number = re.findall(filename + r':(\d+)', str) + else: + line_number = 0 + err_message = str + return err_message, line_number + + +class TestCase(): + + temp_path = "" + ld_library_path = "" + js_runtime_path = "" + es2abc = "" + + def __init__(self, path): + self.path = path + self.target_js_path ="" + try: + data = yaml.load(read_declaration(path), yaml.SafeLoader) + except: + data = {} + self.declaration = data + self.fail = False + self.is_test_case = False if data is None else True + self.detail_result = "" + self.err_line = 0 + self.abc_file_path = "" + self.abc_file_path_temp = "" + + + def execute(self, arkruntime = False): + if not self.is_test_case: + return + if arkruntime: + with open(self.path, 'a') as fileAdded: + fileAdded.write('print("TESTCASE SUCCESS");') + self.__test_es2abc() + if(os.path.exists(self.abc_file_path)): + os.remove(self.abc_file_path) + else: + self.__tsc_test() + + def is_negative(self): + if 'error' in self.declaration: + return True + return False + def is_current(self): + if 'isCurrent' in self.declaration: + return True + return False + def is_set_module(self): + if 'module' in self.declaration: + return True + return False + # check if + def check_declaration(self): + if self.declaration == {}: + self.detail_result = "parse test case declaration failed, maybe bad format." + return False + if 'error' in self.declaration: + if self.declaration['error'] is None or 'code' not in self.declaration['error'] and 'type' not in self.declaration['error']: + self.detail_result = "neither error code nor error type are defined in negative case." + return False + return True + + def __error_code(self): + if 'code' in self.declaration['error']: + return self.declaration['error']['code'] + return None + + def __error_type(self): + if 'type' in self.declaration['error']: + return self.declaration['error']['type'] + return None + + def __get_tsc_cmd(self): + if platform.system().lower() == 'windows': + cmd = ['cmd', '/c', 'tsc', '--target', 'es2020'] + else: + cmd = ['tsc', '--target', 'es2020'] + if self.__is_strict(): + cmd.extend(STRICT_ON) + else: + cmd.extend(STRICT_OFF) + if self.is_set_module(): + cmd.extend(MODULE) + cmd.append('es2020') + if self.is_current(): + cmd.append(self.path) + cmd.append('--outDir') + cmd.append(TestCase.temp_path) + self.target_js_path = TestCase.temp_path + self.__get_js_basename() + return cmd + + def __get_node_cmd(self): + cmd = ['node'] + if self.is_current(): + cmd.append(self.target_js_path) + else: + cmd.append(TestCase.temp_path + self.__get_js_basename()) + return cmd + + # get es2abc --merge-abc + def __get_es2abc_cmd(self, file_path): + abc_file_path = ("%s.abc" % (os.path.splitext(file_path)[0])) + self.abc_file_path_temp = abc_file_path + cmd = [TestCase.es2abc + 'es2abc'] + cmd.extend(['--module', '--output', abc_file_path, file_path]) + return cmd + + # create abc files + def create_abc(self, filename): + process = subprocess.Popen(self.__get_es2abc_cmd(filename), stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE) + out, err = process.communicate() + returncode = process.returncode + if returncode != 0: + err_msg, line = get_error_message(out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore"), filename) + self.detail_result = err_msg + self.err_line = line + self.fail = True + return + if "TESTCASE SUCCESS" not in out.decode("utf-8", errors="ignore"): + self.detail_result = "check stdout failed!" + self.fail = True + return + + # get es2abc file commands + def _get_ark_js_cmd(self): + os.environ.setdefault("LD_LIBRARY_PATH", TestCase.ld_library_path) + run_abc_cmd = [os.path.join(TestCase.js_runtime_path, 'ark_js_vm')] + run_abc_cmd.append(self.abc_file_path_temp) + return run_abc_cmd + pass + + def __get_js_basename(self): + sp = '/' + return "test" + sp + self.path.split(sp+"test"+sp)[1].replace('.ts', '.js') + + def __is_strict(self): + if 'strict' in self.declaration: + return bool(self.declaration['strict']) + return True + + def __tsc_test(self): + process = subprocess.Popen(self.__get_tsc_cmd(), stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE) + out, err = process.communicate() + returncode = process.returncode + if self.is_negative(): + if returncode == 0: + self.fail = True + self.detail_result = "No error found in negative case." + return + if self.__error_code() in out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore"): + return + self.fail = True + self.detail_result = "Error code not as expected." + return + # positive case + if returncode != 0 : + self.detail_result = out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore") + self.fail = True + return + if self.is_current(): + with open(self.target_js_path, 'a') as fileAdded: + fileAdded.write('console.log("TESTCASE SUCCESS");') + # run node command + process = subprocess.Popen(self.__get_node_cmd(), stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE) + out, err = process.communicate() + returncode = process.returncode + if self.is_current(): + if os.path.exists(self.target_js_path): + os.remove(self.target_js_path) + if returncode != 0: + err_msg, line = get_error_message(out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore"), self.__get_js_basename()) + self.detail_result = err_msg + self.err_line = line + self.fail = True + return + # check std out + if "TESTCASE SUCCESS" not in out.decode("utf-8", errors="ignore"): + self.detail_result = "check stdout failed!" + self.fail = True + return + + def __test_es2abc(self): + # compiler to abc + process = subprocess.Popen(self.__get_es2abc_cmd(self.path), stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE) + out, err = process.communicate() + returncode = process.returncode + if self.is_negative(): + if returncode == 0: + self.fail = True + return + if self.__error_type() in out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore"): + return + self.fail = True + self.detail_result = "Error type not as expected." + return + # positive case + if returncode != 0 : + self.detail_result = out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore") + self.fail = True + return + # execute ark_js_vm + process = subprocess.Popen(self._get_ark_js_cmd(), stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE) + out, err = process.communicate() + returncode = process.returncode + if returncode != 0: + err_msg, line = get_error_message(out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore"), os.path.basename(self.abc_file_path)) + self.detail_result = err_msg + self.err_line = line + self.fail = True + return + # check std out + if "TESTCASE SUCCESS" not in out.decode("utf-8", errors="ignore"): + self.detail_result = "check stdout failed!" + self.fail = True + return -- Gitee From b164dd74bd98e150589f28753407267e85c99396 Mon Sep 17 00:00:00 2001 From: tanglizhen Date: Thu, 1 Jun 2023 20:35:54 +0800 Subject: [PATCH 02/18] =?UTF-8?q?Ts=20test=20cases=20Issues=EF=BC=9Ahttps:?= =?UTF-8?q?//gitee.com/openharmony/arkcompiler=5Fets=5Ffrontend/issues/I78?= =?UTF-8?q?HJU=3Ffrom=3Dproject-issue=20Signed-off-by:=20tanglizhen=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../abstract_properties_and_accessors.ts | 4 +- .../control_flow_based_type_analysis1.ts | 24 ++- .../control_flow_based_type_analysis2.ts | 2 +- .../expression_operators_1.ts | 23 +-- .../expression_operators_2.ts | 35 +++-- .../implicit_index_signatures.ts | 19 ++- .../optional_class_properties.ts | 30 ++-- .../optional_parameters_and_properties.ts | 27 ++++ .../private_and_protected_constructor.ts | 16 +- .../downlevel_async_functions_1.ts | 4 +- ..._for_types_with_string_index_signatures.ts | 18 +++ .../async_iterators/async_iterators_1.ts | 5 - .../iterators/iterators_1.ts | 5 - .../3_improved_inference_for_generics.ts | 6 +- .../2.5/1_optional_catch_clause_variables.ts | 15 +- .../1_constant_named_properties.ts | 40 +++-- .../2.7/2_unique_symbol/2_unique_symbol.ts | 21 +-- .../4_definite_assignment_assertions.ts | 35 +++-- .../5_fixed_length_tuples.ts | 17 +-- ...oved_type_inference_for_object_literals.ts | 35 ++++- .../7_improved_handling.ts | 107 ++++++++------ ...8_Type_guards_inferred_from_in_operator.ts | 46 +++--- .../test/2.8/conditional_types.ts | 45 +++--- ...oved_control_over_mapped_type_modifiers.ts | 74 ++++++---- .../1_support_number_and_symbol_nam_1.ts | 1 - .../ts_extra_tests/test/2.9/4_import_types.ts | 21 ++- .../test/ts_extra_tests/test/2.9/module.ts | 8 +- .../new_unknown_top_type.ts | 138 +++++++++--------- .../test/3.2/bigint/bigint_1.ts | 30 ++-- ...spread_expressions_in_object_literals_1.ts | 11 +- ...spread_expressions_in_object_literals_2.ts | 15 +- .../non-unit_types_as_union_discriminants.ts | 6 +- ....ts => a_new_syntax_for_readonly_array.ts} | 28 +--- .../test/3.4/const_assertions.ts | 42 +++++- .../test/3.4/higher_order_type_inference.ts | 22 ++- .../test/3.4/readonly_tuples.ts | 34 +++++ .../test/3.5/higher_order_type_inference.ts | 24 ++- ...d_excess_property_checks_in_union_types.ts | 41 ++++++ .../test/3.5/omit_helper_type.ts | 4 +- .../test/3.5/smarter_union_type_checking.ts | 52 +++++-- ...ssors_are_allowed_in_ambient_contexts_1.ts | 21 ++- .../test.ts | 4 +- .../stricter_generators_1.ts | 4 +- .../stricter_generators_2.ts | 4 +- .../stricter_generators_3.ts | 4 +- .../stricter_generators_4.ts | 4 +- .../stricter_generators_5.ts | 4 +- .../assertion_functions_1.ts | 4 +- .../nullish_coalescing_2.ts | 4 +- .../optional_chaining/optional_chaining_1.ts | 4 +- .../optional_chaining/optional_chaining_2.ts | 10 +- .../optional_chaining/optional_chaining_3.ts | 6 +- .../optional_chaining/optional_chaining_4.ts | 24 ++- .../optional_chaining/optional_chaining_5.ts | 6 +- .../3.8/1_type_only_imports_and_export.ts | 7 +- .../2_ecmsscript_private_fields_1.ts | 7 +- .../2_ecmsscript_private_fields_2.ts | 9 +- .../2_ecmsscript_private_fields_3.ts | 13 +- .../test/3.8/3_which_should_i_use.ts | 16 +- .../ts_extra_tests/test/3.8/some_module.ts | 2 +- ...provements_in_inference_and_Promise.all.ts | 24 +-- .../Checked_Indexed_Accesses.ts | 44 ++++++ .../for_each_index.ts | 35 +++++ .../Checked_Indexed_Accesses/for_of_index.ts | 35 +++++ .../for_traversal_index.ts | 35 +++++ .../Reverting_Template_Literal_Inference.ts | 41 ++++++ .../abstract_construct_signatures_2.ts | 33 +++++ ...ng_middle_rest_elements_in_tuple_types1.ts | 14 +- ...ng_middle_rest_elements_in_tuple_types2.ts | 22 +-- ...ng_middle_rest_elements_in_tuple_types3.ts | 30 ++-- .../contextual_narrowing_for_generics.ts | 54 +++++++ .../ecmascript_private_calss_elements.ts | 54 +++++++ ...verride_and_the_noImplicitOverride_Flag.ts | 50 +++++++ .../separate_write_types_on_properties_2.ts | 51 +++++++ .../static_blocks_in_classes1.ts | 41 ++++++ .../static_blocks_in_classes2.ts | 43 ++++++ ...lates_string_pattern_index_signatures_3.ts | 8 +- ...lates_string_pattern_index_signatures_5.ts | 2 +- .../4.6/1_allowing_code_in_constructors.ts | 2 +- .../test/4.6/2_control_flow_analysis.ts | 4 +- ...4_indexed_access_inference_improvements.ts | 2 +- ...w_analysis_for_bracketed_element_access.ts | 35 ++++- ...analysis_for_bracketed_element_access_1.ts | 43 ++++++ ...nds_constraints_on_infer_type_variables.ts | 55 +++---- ...nction_inference_in_objects_and_methods.ts | 86 +++++++---- .../instantiation_expressions.ts | 46 +++++- ...ariance_annotations_for_type_parameters.ts | 35 ++++- ...tion_Union_Compatibility,_and_Narrowing.ts | 70 +++++++++ .../ambient_function_declarations.ts | 2 +- .../declarations/declarations_2.ts | 3 - .../names/property_names/property_names_1.ts | 26 ++-- .../any_cannot_be_type_name_1.ts | 28 ++++ .../boolean_cannot_be_type_name_1.ts | 28 ++++ .../number_cannot_be_type_name_1.ts | 28 ++++ .../string_cannot_be_type_name_1.ts | 27 ++++ .../symbol_cannot_be_type_name_1.ts | 27 ++++ .../spec/basic_concepts/scopes/scopes_1.ts | 42 ++++++ .../spec/basic_concepts/scopes/scopes_2.ts | 27 ++++ .../spec/basic_concepts/scopes/scopes_2_m.ts | 33 +++++ .../spec/basic_concepts/scopes/scopes_3.ts | 37 +++++ .../spec/basic_concepts/scopes/scopes_4.ts | 33 +++++ .../class_body/class_body.ts | 12 +- .../class_declarations_1.ts | 36 +++++ .../class_declarations_2.ts | 43 ++++++ .../class_declarations_3.ts | 56 +++++++ .../class_heritage_specification_1.ts | 31 +--- .../class_heritage_specification_2.ts | 44 +++--- .../class_heritage_specification_3.ts | 50 ++++--- .../class_heritage_specification_4.ts | 9 +- .../class_heritage_specification_5.ts | 17 ++- .../class_heritage_specification_6.ts | 15 +- .../automatic_constructors_1.ts | 2 + .../constructor_parameters_1.ts | 3 +- .../constructor_parameters_2.ts | 2 +- .../constructor_parameters_3.ts | 7 +- .../constructor_parameters_4.ts | 4 +- .../constructor_parameters_5.ts | 6 +- .../constructor_parameters_6.ts | 36 +++++ .../index_member_declarations.ts | 2 +- .../members/accessibility/accessibility_1.ts | 60 ++++++-- .../members/accessibility/accessibility_2.ts | 18 ++- .../members/accessibility/accessibility_3.ts | 32 +++- .../members/class_types/class_types_1.ts | 67 +++++++++ .../{class_types.ts => class_types_2.ts} | 49 ++++--- .../members/class_types/class_types_3.ts | 60 ++++++++ .../constructor_function_types_1.ts | 1 + .../constructor_function_types_2.ts | 11 +- .../constructor_function_types_3.ts | 13 +- .../constructor_function_types_5.ts | 2 +- .../constructor_function_types_6.ts | 45 ++++++ .../constructor_function_types_7.ts | 50 +++++++ .../constructor_function_types_8.ts | 36 +++++ .../inheritance_and_overriding_1.ts | 19 ++- .../inheritance_and_overriding_2.ts | 33 +++-- .../inheritance_and_overriding_3.ts | 5 +- .../inheritance_and_overriding_5.ts | 59 ++++++++ .../instance_and_static_members_1.ts | 25 +++- .../instance_and_static_members_2.ts | 37 ++++- .../instance_and_static_members_3.ts | 11 +- .../member_accessor_declarations.ts | 2 +- .../member_function_declarations_1.ts | 19 +-- .../member_function_declarations_2.ts | 2 +- .../member_function_declarations_3.ts | 2 +- .../member_function_declarations_4.ts | 25 ++-- .../member_function_declarations_5.ts | 18 +-- .../member_variable_declarations_1.ts | 27 ++-- .../member_variable_declarations_2.ts | 47 ++++-- .../member_variable_declarations_4.ts | 31 ++-- .../property_member_declarations_1.ts | 43 ++++++ ...5.ts => property_member_declarations_2.ts} | 17 ++- .../property_member_declarations_3.ts | 43 ++++++ .../enum_declarations/enum_declarations_3.ts | 15 +- .../spec/enums/enum_members/enum_members_1.ts | 6 + .../arrow_function/arrow_function_2.ts | 2 +- .../arrow_function/arrow_function_4.ts | 41 ++++++ .../the_congruence_operator.ts | 0 .../the_equal_operator.ts | 0 .../the_greater_operator.ts | 0 .../the_greater_or_equal_operator.ts | 0 .../the_incongruence_operator.ts | 0 .../the_less_operator.ts | 0 .../the_less_or_equal_operator.ts | 0 .../the_unequal_operator.ts | 0 .../the_and_operator.ts | 0 .../the_division_method_operator.ts | 0 .../the_left_shift_operator.ts | 0 .../the_multiplication_operator.ts | 0 .../the_or_operator.ts | 0 .../the_remainder_operator.ts | 0 .../the_right_shift_operator.ts | 0 .../the_subtraction_operator.ts | 0 .../the_unsigned_shift_to_the_right.ts | 0 .../the_xor_operator.ts | 0 .../function_expressions_2.ts | 2 +- .../function_expressions_3.ts | 2 +- .../spec/expressions/identifiers/class.ts | 2 +- .../spec/expressions/identifiers/parameter.ts | 2 +- .../object_literal/object_literal_7.ts | 2 +- .../expressions/parentheses/parentheses.ts | 4 +- .../asynchronous_functions_1.ts | 12 +- .../asynchronous_functions_2.ts | 61 ++++++++ .../asynchronous_functions_3.ts | 71 +++++++++ .../asynchronous_functions_4.ts | 36 +++++ .../destructuring_parameter_declarations_4.ts | 3 +- .../destructuring_parameter_declarations_7.ts | 1 - .../function_declarations_1.ts | 4 +- .../function_declarations_2.ts | 22 +-- .../function_implementations_4.ts | 4 +- .../function_implementations_5.ts | 8 +- .../function_overloads_1.ts | 6 +- .../generator_functions_3.ts | 54 +++++++ .../generic_functions/generic_functions_1.ts | 15 +- .../test/spec/grammar/enums/enums.ts | 27 ++++ .../scripts_and_modules.ts | 63 ++++++++ .../scripts_and_modules/source_file_1.ts | 61 ++++++++ .../scripts_and_modules/source_file_2.ts | 27 ++++ .../scripts_and_modules/source_file_3.ts | 30 ++++ .../scripts_and_modules/source_file_4.ts | 29 ++++ .../test/spec/grammar/types/types.ts | 33 ++++- .../interface_declarations_3.ts | 22 +-- .../import_alias_declarations_3.ts | 34 +---- .../namespace_declarations_1.ts | 1 + .../1_source_files_dependencies/source_00.ts | 17 +++ .../source_files_dependencies.ts | 28 ++++ ...arations_1.ts => export_declarations_1.ts} | 0 ...arations_2.ts => export_declarations_2.ts} | 0 ...arations_3.ts => export_declarations_3.ts} | 0 ...arations_4.ts => export_declarations_4.ts} | 0 ...arations_5.ts => export_declarations_5.ts} | 0 .../if_do_and_while_Statements_1.ts | 11 +- .../test/spec/statements/blocks/blocks_4.ts | 35 +++++ .../for_statements/for_statements.ts | 2 +- .../simple_variable_declarations_1.ts | 5 - .../Intersection_types_1.ts | 22 +-- .../intersection_types_2.ts | 5 +- .../spec/types/named_types/named_types_1.ts | 19 ++- .../spec/types/named_types/named_types_2.ts | 12 +- .../spec/types/named_types/named_types_3.ts | 5 +- .../spec/types/named_types/named_types_4.ts | 5 +- .../object_types/array_types/array_types_1.ts | 27 ++-- .../object_types/array_types/array_types_2.ts | 9 +- .../object_types/array_types/array_types_3.ts | 13 +- .../constructor_types/constructor_types_1.ts | 10 +- .../constructor_types/constructor_types_2.ts | 16 +- .../constructor_types/constructor_types_3.ts | 14 +- .../constructor_types/constructor_types_4.ts | 51 +++++++ ...{function_types.ts => function_types_1.ts} | 10 +- .../function_types/function_types_2.ts | 33 +++++ .../types/object_types/members/members_1.ts | 1 - .../object_types/tuple_types/tuple_types_1.ts | 14 +- .../object_types/tuple_types/tuple_types_2.ts | 17 +-- .../object_types/tuple_types/tuple_types_3.ts | 10 +- .../the_boolean_type/the_boolean_type_1.ts | 10 +- .../the_boolean_type/the_boolean_type_2.ts | 11 +- .../the_boolean_type/the_boolean_type_3.ts | 4 +- .../the_enum_type/the_enum_type_1.ts | 10 +- .../the_null_type/the_null_type_1.ts | 6 +- .../the_number_type/the_number_type_1.ts | 7 +- .../the_number_type/the_number_type_2.ts | 4 +- .../the_number_type/the_number_type_3.ts | 12 +- .../the_string_literal_type_1.ts | 10 +- .../the_string_literal_type_2.ts | 6 +- .../the_string_literal_type_3.ts | 4 +- .../the_string_type/the_string_type_1.ts | 4 +- .../the_string_type/the_string_type_2.ts | 7 +- .../the_string_type/the_string_type_3.ts | 14 +- .../the_symbol_type/the_symbol_type_1.ts | 8 +- .../the_symbol_type/the_symbol_type_2.ts | 19 +-- .../the_symbol_type/the_symbol_type_3.ts | 4 +- .../the_undefined_type_1.ts | 6 +- .../the_void_type/the_void_type_1.ts | 8 +- .../the_void_type/the_void_type_2.ts | 16 +- .../the_void_type/the_void_type_3.ts | 14 +- .../parameter_list/parameter_list_1.ts | 9 +- .../parameter_list/parameter_list_2.ts | 8 +- .../parameter_list/parameter_list_3.ts | 7 +- .../parameter_list/parameter_list_4.ts | 4 +- .../parameter_list/parameter_list_5.ts | 10 +- .../parameter_list/parameter_list_6.ts | 13 +- .../return_type/return_type_1.ts | 12 +- .../return_type/return_type_2.ts | 10 +- .../return_type/return_type_3.ts | 4 +- .../specialized_signatures_1.ts | 28 ++-- .../type_parameters/type_parameters_1.ts | 2 +- .../type_parameters/type_parameters_2.ts | 4 +- .../construct_signatures.ts | 22 ++- .../index_signatures/index_signatures.ts | 33 ++--- .../method_signatures/method_signatures_1.ts | 4 +- .../method_signatures/method_signatures_2.ts | 4 +- .../property_signatures.ts | 15 +- .../array_type_literals_1.ts | 12 +- .../array_type_literals_2.ts | 10 +- .../array_type_literals_3.ts | 19 ++- .../array_type_literals_4.ts | 13 +- .../function_type_literals_3.ts | 7 +- .../intersection_type_literals.ts | 6 +- .../object_type_literals.ts | 9 +- .../predefined_types/predefined_types.ts | 12 +- .../specifying_types/specifying_types_1.ts | 14 +- .../specifying_types/specifying_types_2.ts | 9 +- .../this_type_references_1.ts | 14 +- .../this_type_references_2.ts | 9 +- .../tuple_type_literals.ts | 6 +- .../type_queries/type_queries_1.ts | 4 +- .../type_queries/type_queries_2.ts | 8 +- .../type_references/type_references_1.ts | 7 +- .../type_references/type_references_2.ts | 6 +- .../type_references/type_references_3.ts | 9 +- .../union_type_literals.ts | 6 +- .../spec/types/the_any_type/any_type_1.ts | 11 +- .../spec/types/the_any_type/any_type_2.ts | 6 +- .../spec/types/the_any_type/any_type_3.ts | 12 +- .../Type_and_Member_Identity.ts | 49 +++++++ 293 files changed, 4176 insertions(+), 1454 deletions(-) rename es2panda/test/ts_extra_tests/test/3.4/{readonly_array.ts => a_new_syntax_for_readonly_array.ts} (53%) create mode 100644 es2panda/test/ts_extra_tests/test/3.4/readonly_tuples.ts create mode 100644 es2panda/test/ts_extra_tests/test/3.5/improved_excess_property_checks_in_union_types.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/Checked_Indexed_Accesses.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/for_each_index.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/for_of_index.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/for_traversal_index.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.2/Reverting_Template_Literal_Inference/Reverting_Template_Literal_Inference.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.3/contextual_narrowing_for_generic/contextual_narrowing_for_generics.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.3/ecmascript_private_class_elements/ecmascript_private_calss_elements.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.3/override_and_the_noImplicitOverride_Flag/override_and_the_noImplicitOverride_Flag.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.3/separate_write_types_on_properties/separate_write_types_on_properties_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.4/static_blocks_in_classe/static_blocks_in_classes1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.4/static_blocks_in_classe/static_blocks_in_classes2.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/4.8/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_2_m.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_declarations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_6.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types_1.ts rename es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/{class_types.ts => class_types_2.ts} (59%) create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_6.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_7.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_8.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_5.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/property_member_declarations_1.ts rename es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/{member_variable_declarations/member_variable_declarations_5.ts => property_member_declarations_2.ts} (74%) create mode 100644 es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/property_member_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_4.ts rename es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/{the_operators => the_greater_less_lessEqual}/the_congruence_operator.ts (100%) rename es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/{the_operators => the_greater_less_lessEqual}/the_equal_operator.ts (100%) rename es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/{the_operators => the_greater_less_lessEqual}/the_greater_operator.ts (100%) rename es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/{the_operators => the_greater_less_lessEqual}/the_greater_or_equal_operator.ts (100%) rename es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/{the_operators => the_greater_less_lessEqual}/the_incongruence_operator.ts (100%) rename es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/{the_operators => the_greater_less_lessEqual}/the_less_operator.ts (100%) rename es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/{the_operators => the_greater_less_lessEqual}/the_less_or_equal_operator.ts (100%) rename es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/{the_operators => the_greater_less_lessEqual}/the_unequal_operator.ts (100%) rename es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/{the_mul_div_operators => the_mul_div_rem}/the_and_operator.ts (100%) rename es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/{the_mul_div_operators => the_mul_div_rem}/the_division_method_operator.ts (100%) rename es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/{the_mul_div_operators => the_mul_div_rem}/the_left_shift_operator.ts (100%) rename es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/{the_mul_div_operators => the_mul_div_rem}/the_multiplication_operator.ts (100%) rename es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/{the_mul_div_operators => the_mul_div_rem}/the_or_operator.ts (100%) rename es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/{the_mul_div_operators => the_mul_div_rem}/the_remainder_operator.ts (100%) rename es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/{the_mul_div_operators => the_mul_div_rem}/the_right_shift_operator.ts (100%) rename es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/{the_mul_div_operators => the_mul_div_rem}/the_subtraction_operator.ts (100%) rename es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/{the_mul_div_operators => the_mul_div_rem}/the_unsigned_shift_to_the_right.ts (100%) rename es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/{the_mul_div_operators => the_mul_div_rem}/the_xor_operator.ts (100%) create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/functions/generator_functions/generator_functions_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/scripts_and_modules.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_1.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_3.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_00.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_files_dependencies.ts rename es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/{export_default_declarations_1.ts => export_declarations_1.ts} (100%) rename es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/{export_default_declarations_2.ts => export_declarations_2.ts} (100%) rename es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/{export_default_declarations_3.ts => export_declarations_3.ts} (100%) rename es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/{export_default_declarations_4.ts => export_declarations_4.ts} (100%) rename es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/{export_default_declarations_5.ts => export_declarations_5.ts} (100%) create mode 100644 es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_4.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_4.ts rename es2panda/test/ts_extra_tests/test/spec/types/object_types/function_types/{function_types.ts => function_types_1.ts} (80%) create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/object_types/function_types/function_types_2.ts create mode 100644 es2panda/test/ts_extra_tests/test/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts b/es2panda/test/ts_extra_tests/test/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts index ef52977f0a..32b910779f 100644 --- a/es2panda/test/ts_extra_tests/test/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts +++ b/es2panda/test/ts_extra_tests/test/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts @@ -24,8 +24,8 @@ isCurrent: true import { Assert } from "../../../suite/assert.js" abstract class Skill { - name: string; - damage:number; + name: string = "derive"; + damage:number = 1; } class Divied extends Skill { name = "derived"; diff --git a/es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis1.ts b/es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis1.ts index 4d6ebc8304..23b7306a7c 100644 --- a/es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis1.ts +++ b/es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis1.ts @@ -22,23 +22,21 @@ import { Assert } from "../../../suite/assert.js" -function fun01(x: string | number | boolean): void { - if (typeof x === "string") { - x; - Assert.equal(typeof x, "string"); - x = 1; - x; - } - x; +let arg = Math.random() < 0.5 ? 5 : 'a'; +if (typeof arg === 'string') { + Assert.isString(arg); + arg = 3; + Assert.isNumber(arg); } +arg; +Assert.isNumber(arg); -function fun02(x: string | number): void { + +function func(x: string | number): void { if (typeof x === "number") { - Assert.equal(typeof x, "number"); return; } x; + Assert.isNumber(x); } - -fun01("hello"); -fun02(1024); +func(10); diff --git a/es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis2.ts b/es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis2.ts index 52ec8dab1d..5cd0cce7bf 100644 --- a/es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis2.ts +++ b/es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis2.ts @@ -24,10 +24,10 @@ import { Assert } from "../../../suite/assert.js" function testFun(x: string | null): void { if (x === null) { - Assert.equal(typeof x, "object"); return; } x; + Assert.isString(x); } testFun(null); diff --git a/es2panda/test/ts_extra_tests/test/2.0/expression_operators/expression_operators_1.ts b/es2panda/test/ts_extra_tests/test/2.0/expression_operators/expression_operators_1.ts index 2c83991d27..587bf97ab4 100644 --- a/es2panda/test/ts_extra_tests/test/2.0/expression_operators/expression_operators_1.ts +++ b/es2panda/test/ts_extra_tests/test/2.0/expression_operators/expression_operators_1.ts @@ -21,20 +21,11 @@ import { Assert } from "../../../suite/assert.js" -function sum(a: number, b: number) { - return a + b; -} -sum(3, 5); +var x: number | undefined; +var y: string | null; +var method: string | number | undefined | null; -interface Entity { - name: string; -} - -function getEntityName(e: Entity): string { - return e.name; -} -Assert.equal(getEntityName({ name: "caihua" }), "caihua"); - -let x: (e: Entity) => string = getEntityName; -let s: (e: Entity) => string = x; -let y: (e: Entity) => string = x || { name: "test" }; +x = undefined; +y = 'a'; +method = x + y; +Assert.isString(method); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.0/expression_operators/expression_operators_2.ts b/es2panda/test/ts_extra_tests/test/2.0/expression_operators/expression_operators_2.ts index 859c348ace..0a5b375bec 100644 --- a/es2panda/test/ts_extra_tests/test/2.0/expression_operators/expression_operators_2.ts +++ b/es2panda/test/ts_extra_tests/test/2.0/expression_operators/expression_operators_2.ts @@ -21,17 +21,32 @@ import { Assert } from "../../../suite/assert.js" -interface Entity { - name: string; +type o = { + num: 10 } -// Compiled with --strictNullChecks -function getEntityName(e: Entity): string { - return e.name; +type T = o | undefined; +let x: T; + +let y = x && x.num; +y = 10; +Assert.isNumber(y); +y = undefined; +Assert.isUndefined(y); + +let z = x || { num: 5 }; +Assert.isObject(z); + +interface I{ + str: string; } -Assert.equal(getEntityName({ name: "caihua" }), "caihua"); +type t = I | undefined; +let a: t; -let x: (e: Entity) => string = getEntityName; -let s: (e: Entity) => string = x; -let y: (e: Entity) => string = x || { name: "test" }; +let b = a && a.str; +b = ' '; +Assert.isString(b); +b = undefined; +Assert.isUndefined(b); -Assert.equal(x.name, "getEntityName"); +let c = a || { str: 's' }; +Assert.isObject(c); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.0/implicit_index_signatures/implicit_index_signatures.ts b/es2panda/test/ts_extra_tests/test/2.0/implicit_index_signatures/implicit_index_signatures.ts index 65ebc007fd..187d0b9a90 100644 --- a/es2panda/test/ts_extra_tests/test/2.0/implicit_index_signatures/implicit_index_signatures.ts +++ b/es2panda/test/ts_extra_tests/test/2.0/implicit_index_signatures/implicit_index_signatures.ts @@ -23,17 +23,16 @@ import { Assert } from "../../../suite/assert.js" -function httpService(path: string, headers: { [x: string]: string }) { - return JSON.stringify(headers); +function func(path: string, arg: { [x: string]: string }) { + return JSON.stringify(arg); } -const headers = { - "Content-Type": "application/x-www-form-urlencoded", +const arg = { + "Color": "Red", }; -let s1: string = httpService("", { - "Content-Type": "application/x-www-form-urlencoded", +let s1: string = func("", { + "Color": "red", }); -Assert.equal(s1, '{"Content-Type":"application/x-www-form-urlencoded"}'); +Assert.equal(s1, '{"Color":"red"}'); -// Now ok, previously wasn't -let s2: string = httpService("", headers); -Assert.equal(s2, '{"Content-Type":"application/x-www-form-urlencoded"}'); +let s2: string = func("", arg); +Assert.equal(s2, '{"Color":"Red"}'); diff --git a/es2panda/test/ts_extra_tests/test/2.0/optional_class_properties/optional_class_properties.ts b/es2panda/test/ts_extra_tests/test/2.0/optional_class_properties/optional_class_properties.ts index 95fff8a358..0331889f94 100644 --- a/es2panda/test/ts_extra_tests/test/2.0/optional_class_properties/optional_class_properties.ts +++ b/es2panda/test/ts_extra_tests/test/2.0/optional_class_properties/optional_class_properties.ts @@ -21,32 +21,32 @@ import { Assert } from '../../../suite/assert.js' -class Class0000 { +class myClass { a: number = 0; b?: number; - f() { + func() { return this.a; } // Body of optional method can be omitted - g?(): number; - h?() { + get?(): number; + handle?() { return this.b; } } -let c0000 = new Class0000(); -c0000.a = 1024; -c0000.b = 1408; -Assert.equal(c0000.f(), 1024); +let c = new myClass(); +c.a = 1024; +c.b = 1408; +Assert.equal(c.func(), 1024); -if (c0000.h) { - Assert.equal(c0000.h(), 1408); +if (c.handle) { + Assert.equal(c.handle(), 1408); } -c0000.g = () => { - if (c0000.b !== undefined) { - return c0000.a + c0000.b; +c.get = () => { + if (c.b !== undefined) { + return c.a + c.b; } else { - return c0000.a; + return c.a; } } -Assert.equal(c0000.g(), 2432); +Assert.equal(c.get(), 2432); diff --git a/es2panda/test/ts_extra_tests/test/2.0/optional_parameters_and_properties/optional_parameters_and_properties.ts b/es2panda/test/ts_extra_tests/test/2.0/optional_parameters_and_properties/optional_parameters_and_properties.ts index 1b2e6da560..8aa15f10aa 100644 --- a/es2panda/test/ts_extra_tests/test/2.0/optional_parameters_and_properties/optional_parameters_and_properties.ts +++ b/es2panda/test/ts_extra_tests/test/2.0/optional_parameters_and_properties/optional_parameters_and_properties.ts @@ -34,3 +34,30 @@ function printPoint(a: number, b: number, c?: number): string { } Assert.equal(printPoint(1, 3, 5), '{"a":1,"b":3,"c":5}'); Assert.equal(printPoint(1, 1), '{"a":1,"b":1}'); + +interface I{ + num: number; + str?: string; +} +let i1: I = { + num: 5 +} +Assert.isUndefined(i1.str); +let i2: I = { + num: 5, + str: 'a' +} +Assert.isString(i2.str); + +class C{ + num: number; + str?: string; + constructor(num: number, str?: string) { + this.num = num; + this.str = str; + } +} +let c1 = new C(10); +Assert.isUndefined(c1.str); +let c2 = new C(10, 'a'); +Assert.isString(c2.str); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.0/private_and_protected_constructor/private_and_protected_constructor.ts b/es2panda/test/ts_extra_tests/test/2.0/private_and_protected_constructor/private_and_protected_constructor.ts index cb5f793ac3..02e1b14b7d 100644 --- a/es2panda/test/ts_extra_tests/test/2.0/private_and_protected_constructor/private_and_protected_constructor.ts +++ b/es2panda/test/ts_extra_tests/test/2.0/private_and_protected_constructor/private_and_protected_constructor.ts @@ -35,4 +35,18 @@ class Box { } } let v: Box = Box.getSubBos(); -Assert.equal(v.cname, "Box"); \ No newline at end of file +Assert.equal(v.cname, "Box"); + +class myBox{ + arg: string; + protected constructor(arg: string) { + this.arg = arg; + } +} +class myLittleBox extends myBox{ + constructor(arg: string) { + super(arg); + } +} +let tool = new myLittleBox('hammer'); +Assert.equal(tool.arg, 'hammer'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.1/downlevel_async_functions/downlevel_async_functions_1.ts b/es2panda/test/ts_extra_tests/test/2.1/downlevel_async_functions/downlevel_async_functions_1.ts index d588b47e8a..44170db19e 100644 --- a/es2panda/test/ts_extra_tests/test/2.1/downlevel_async_functions/downlevel_async_functions_1.ts +++ b/es2panda/test/ts_extra_tests/test/2.1/downlevel_async_functions/downlevel_async_functions_1.ts @@ -26,9 +26,9 @@ import { Assert } from '../../../suite/assert.js' -function delayTime(milliseconds: number) { +function delayTime(milli: number) { return new Promise((resolve) => { - setTimeout(resolve, milliseconds); + setTimeout(resolve, milli); }); } async function showMsg(a: number, b: string) { diff --git a/es2panda/test/ts_extra_tests/test/2.2/dotted_property_for_types_with_string_index_signatures/dotted_property_for_types_with_string_index_signatures.ts b/es2panda/test/ts_extra_tests/test/2.2/dotted_property_for_types_with_string_index_signatures/dotted_property_for_types_with_string_index_signatures.ts index 2fcfb0a992..a6dbefe1f5 100644 --- a/es2panda/test/ts_extra_tests/test/2.2/dotted_property_for_types_with_string_index_signatures/dotted_property_for_types_with_string_index_signatures.ts +++ b/es2panda/test/ts_extra_tests/test/2.2/dotted_property_for_types_with_string_index_signatures/dotted_property_for_types_with_string_index_signatures.ts @@ -23,6 +23,24 @@ import { Assert } from '../../../suite/assert.js' +type myType = { [arg: string]: string }; +let my_t: myType = { + 'color': 'blue' +} + +Assert.equal(my_t['color'], 'blue'); +Assert.equal(my_t.color, 'blue'); + +class C{ + Arg: { [arg: string]: string }; + constructor(Arg: { [arg: string]: string }) { + this.Arg = Arg; + } +} +let c = new C({ 'color': 'black' }); +Assert.equal(c.Arg['color'], 'black'); +Assert.equal(c.Arg.color, 'black'); + interface StringArrIndex { [x: string]: T; } diff --git a/es2panda/test/ts_extra_tests/test/2.3/async_iteration/async_iterators/async_iterators_1.ts b/es2panda/test/ts_extra_tests/test/2.3/async_iteration/async_iterators/async_iterators_1.ts index 4985109519..53ba33954d 100644 --- a/es2panda/test/ts_extra_tests/test/2.3/async_iteration/async_iterators/async_iterators_1.ts +++ b/es2panda/test/ts_extra_tests/test/2.3/async_iteration/async_iterators/async_iterators_1.ts @@ -25,11 +25,6 @@ import { Assert } from '../../../../suite/assert.js' -interface AsyncIterator { - next(value?: any): Promise>; - return?(value?: any): Promise>; - throw?(e?: any): Promise>; -} function createAsyncInterator(arr: any[]): AsyncIterator { let index = 0; let len = arr.length; diff --git a/es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_1.ts b/es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_1.ts index 1e21d398f7..ea70a82050 100644 --- a/es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_1.ts +++ b/es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_1.ts @@ -24,11 +24,6 @@ import { Assert } from '../../../../suite/assert.js' -interface Iterator { - next(value?: any): IteratorResult; - return?(value?: any): IteratorResult; - throw?(e?: any): IteratorResult; -} function createInterator(arr: any[]): Iterator { let index = 0; let len = arr.length; diff --git a/es2panda/test/ts_extra_tests/test/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts b/es2panda/test/ts_extra_tests/test/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts index 73714c39a5..d59d0e39ba 100644 --- a/es2panda/test/ts_extra_tests/test/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts +++ b/es2panda/test/ts_extra_tests/test/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts @@ -21,11 +21,11 @@ import { Assert } from '../../../suite/assert.js' -function arrayGen(f: (x: T) => U): (a: T[]) => U[] { +function func(f: (x: T) => U): (a: T[]) => U[] { return a => a.map(f); } -const len: (a: string[]) => number[] = arrayGen(s => s.length); +const len: (a: string[]) => number[] = func(s => s.length); Assert.equal(1, len(["s", "ss", "sss"])[0]); Assert.equal(2, len(["s", "ss", "sss"])[1]); Assert.equal(3, len(["s", "ss", "sss"])[2]); @@ -36,7 +36,7 @@ type B = (x: S, y: S) => [S, S]; function f(a: A, b: B) { b = a; - Assert.isTrue(true); + Assert.isTrue(b == a); } let a: A = function funA(x: T, y: U): [T, U] { diff --git a/es2panda/test/ts_extra_tests/test/2.5/1_optional_catch_clause_variables.ts b/es2panda/test/ts_extra_tests/test/2.5/1_optional_catch_clause_variables.ts index 2b36499517..126baff724 100644 --- a/es2panda/test/ts_extra_tests/test/2.5/1_optional_catch_clause_variables.ts +++ b/es2panda/test/ts_extra_tests/test/2.5/1_optional_catch_clause_variables.ts @@ -21,9 +21,12 @@ import { Assert } from '../../suite/assert.js' -let input: string = "Error!"; -try { - JSON.parse(input); -} catch { - Assert.equal("Error!", input); -}; \ No newline at end of file +function func(arg: string) { + try { + JSON.parse(arg); + } catch { + Assert.equal(arg, "string"); + } +} +let str: string = 'string'; +func(str); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.7/1_constant_named_properties/1_constant_named_properties.ts b/es2panda/test/ts_extra_tests/test/2.7/1_constant_named_properties/1_constant_named_properties.ts index ccfa8d5d3b..533af9dadd 100644 --- a/es2panda/test/ts_extra_tests/test/2.7/1_constant_named_properties/1_constant_named_properties.ts +++ b/es2panda/test/ts_extra_tests/test/2.7/1_constant_named_properties/1_constant_named_properties.ts @@ -21,33 +21,29 @@ isCurrent: true import { Assert } from "../../../suite/assert.js" -const SERIALIZE = Symbol("serialize-method-key"); -interface Test { - [SERIALIZE](obj: {}): string; +const sym = Symbol(); +interface I{ + [sym](func: Function): Function; } - -class JSONTest implements Test { - [SERIALIZE](obj: {}) { - return JSON.stringify(obj); +class C implements I{ + [sym](func: Function) { + return func; } } -var obj = new JSONTest(); -Assert.equal('"test open harmony"', obj[SERIALIZE]("test open harmony")); -Assert.equal(123456, obj[SERIALIZE](123456)); - +var f = new C(); +Assert.isFunction(f[sym]); // This also applies to numeric and string literals. -const test01 = "test01"; -const test02 = "test02"; -let x = { - [test01]: 100, - [test02]: "hello" -}; +const num = 5; +const str = 'a'; +let obj = { + [num]: 5, + [str]: "string" +} -let a = x[test01]; - -let b = x[test02]; -Assert.equal(100, a); -Assert.equal("hello", b); +let para1 = obj[num]; +let para2 = obj[str]; +Assert.isNumber(para1); +Assert.isString(para2); diff --git a/es2panda/test/ts_extra_tests/test/2.7/2_unique_symbol/2_unique_symbol.ts b/es2panda/test/ts_extra_tests/test/2.7/2_unique_symbol/2_unique_symbol.ts index 601b31e3c5..f5f3f96b36 100644 --- a/es2panda/test/ts_extra_tests/test/2.7/2_unique_symbol/2_unique_symbol.ts +++ b/es2panda/test/ts_extra_tests/test/2.7/2_unique_symbol/2_unique_symbol.ts @@ -21,22 +21,17 @@ import { Assert } from '../../../suite/assert.js' +const usym1: unique symbol = Symbol(); +const usym2: unique symbol = Symbol.for("Bar"); -declare const usym: unique symbol; - -const test03: unique symbol = Symbol(); -const test04: unique symbol = Symbol.for("Bar2"); - -// Works - refers to a unique symbol, but its identity is tied to 'Foo'. // in order to reference a specific unique symbol, you’ll have to use the typeof operator. -let t01: typeof test03 = test03; -let t02: typeof test04 = test04; +let t1: typeof usym1 = usym1; +let t2: typeof usym2 = usym2; -// Also works. class C { - static readonly StaticSymbol: unique symbol = Symbol(); + static readonly StaticUsym: unique symbol = Symbol(); } -Assert.isTrue('symbol' === typeof t01); -Assert.isTrue('symbol' === typeof t02); -Assert.isTrue('symbol' === typeof C.StaticSymbol); \ No newline at end of file +Assert.isTrue('symbol' === typeof t1); +Assert.isTrue('symbol' === typeof t2); +Assert.isTrue('symbol' === typeof C.StaticUsym); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.7/4_definite_assignment_assertions/4_definite_assignment_assertions.ts b/es2panda/test/ts_extra_tests/test/2.7/4_definite_assignment_assertions/4_definite_assignment_assertions.ts index eb382bd4c6..67f4f82ff5 100644 --- a/es2panda/test/ts_extra_tests/test/2.7/4_definite_assignment_assertions/4_definite_assignment_assertions.ts +++ b/es2panda/test/ts_extra_tests/test/2.7/4_definite_assignment_assertions/4_definite_assignment_assertions.ts @@ -21,19 +21,30 @@ import { Assert } from '../../../suite/assert.js' -// With definite assignment assertions, we can assert that x is really assigned by appending an ! to its declaration -let x!: number; - -// In a sense, the definite assignment assertion operator is the dual of the non-null assertion operator (in which expressions are post-fixed with a !) -let y = x! + x!; +function func(arg: number | undefined) { + let sum = arg! + arg!; + return sum; +} +let num = func(5); +Assert.isFalse(Number.isNaN(num)); -Assert.isTrue(Number.isNaN(y)); -initialize(); +let x: number; +let add = x! + x!; +Assert.isTrue(Number.isNaN(add)); -// No error! -let z = x + x; -function initialize() { - x = 10; +// The definite assignment assertion operator is the dual of the non-null assertion operator +let num1: number; +later1(); +let sum1 = num1! + num1!; +function later1() { + num1 = 5; } +Assert.equal(sum1, 10); -Assert.equal(20, z); \ No newline at end of file +let num2!: number; +later2(); +let sum2 = num2 + num2; +function later2() { + num2 = 5; +} +Assert.equal(sum2, 10); diff --git a/es2panda/test/ts_extra_tests/test/2.7/5_fixed_length_tuples/5_fixed_length_tuples.ts b/es2panda/test/ts_extra_tests/test/2.7/5_fixed_length_tuples/5_fixed_length_tuples.ts index f909db53a0..4604dd7470 100644 --- a/es2panda/test/ts_extra_tests/test/2.7/5_fixed_length_tuples/5_fixed_length_tuples.ts +++ b/es2panda/test/ts_extra_tests/test/2.7/5_fixed_length_tuples/5_fixed_length_tuples.ts @@ -21,25 +21,22 @@ import { Assert } from '../../../suite/assert.js' -interface NumStrTuple extends Array { +interface NSTup extends Array { 0: number; 1: string; length: 2; } -const numstr01: NumStrTuple = [1, "string"]; +const numstr01: NSTup = [1, "string"]; -interface NumStr extends Array { +interface NS extends Array { 0: number; 1: string; } -const numstr02: NumStr = [2, "string", 3, "string2"]; +let numstr02: NS = [2, "string"]; +numstr02= [2, "string", 3, "string2"]; +Assert.equal(numstr01.length, 2); -Assert.equal(1, numstr01[0]); -Assert.equal("string", numstr01[1]); -Assert.equal(2, numstr02[0]); -Assert.equal("string", numstr02[1]); -Assert.equal(3, numstr02[2]); -Assert.equal("string2", numstr02[3]); \ No newline at end of file +Assert.equal(numstr02.length, 4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.7/6_improved_type_inference_for_object_literals/6_improved_type_inference_for_object_literals.ts b/es2panda/test/ts_extra_tests/test/2.7/6_improved_type_inference_for_object_literals/6_improved_type_inference_for_object_literals.ts index 220f864a12..9f53e3b046 100644 --- a/es2panda/test/ts_extra_tests/test/2.7/6_improved_type_inference_for_object_literals/6_improved_type_inference_for_object_literals.ts +++ b/es2panda/test/ts_extra_tests/test/2.7/6_improved_type_inference_for_object_literals/6_improved_type_inference_for_object_literals.ts @@ -22,14 +22,35 @@ import { Assert } from '../../../suite/assert.js' let obj1 = [{ a: 1, b: 2 }, { a: "abc" }, {}][0]; +// The type of a is number|string|undefined +obj1.a = 5; +Assert.isNumber(obj1.a); +obj1.a = 'a'; +Assert.isString(obj1.a); +obj1.a = undefined; +Assert.isUndefined(obj1.a); +// The type of b is number|undefined +obj1.b = 6; +Assert.isNumber(obj1.b); +obj1.b = undefined; +Assert.isUndefined(obj1.b); - -function fun(...items: T[]): T { - return items[1]; +function fun(...args: T[]): T { + return args[1]; }; let obj2 = fun({ a: 1, b: 2 }, { a: "abc", b: "ABC" }, {}); -Assert.equal(1, obj1.a); -Assert.equal(2, obj1.b); -Assert.equal("abc", obj2.a); -Assert.equal("ABC", obj2.b); \ No newline at end of file +// The type of a is number|string|undefined +obj2.a = 5; +Assert.isNumber(obj2.a); +obj2.a = 'a'; +Assert.isString(obj2.a); +obj2.a = undefined; +Assert.isUndefined(obj2.a); +// The type of a is number|string|undefined +obj2.b = 6; +Assert.isNumber(obj2.b); +obj2.b = 'b'; +Assert.isString(obj2.b); +obj2.b = undefined; +Assert.isUndefined(obj2.b); diff --git a/es2panda/test/ts_extra_tests/test/2.7/7_improved_handling/7_improved_handling.ts b/es2panda/test/ts_extra_tests/test/2.7/7_improved_handling/7_improved_handling.ts index 0b8f8a5b24..68cd086851 100644 --- a/es2panda/test/ts_extra_tests/test/2.7/7_improved_handling/7_improved_handling.ts +++ b/es2panda/test/ts_extra_tests/test/2.7/7_improved_handling/7_improved_handling.ts @@ -25,52 +25,77 @@ import { Assert } from '../../../suite/assert.js' -class HWA { } -class HWB extends HWA { } -class HWC extends HWA { } -class HWD extends HWA { } -class HWE extends HWD { } - - -let x1 = !true ? new HWA() : new HWB(); - -let x2 = !true ? new HWB() : new HWC(); - -let x3 = !true ? new HWC() : new HWD(); -Assert.isTrue(x1 instanceof HWB); -Assert.isTrue(x2 instanceof HWC); -Assert.isTrue(x3 instanceof HWD); - - -let a1 = [new HWA(), new HWB(), new HWC(), new HWD(), new HWE()]; - -let a2 = [new HWB(), new HWC(), new HWD(), new HWE()]; +class C1{ + num: number; + constructor(num: number) { + this.num = num; + } +} +class C2 extends C1{ + str: string; + constructor(num: number,str:string) { + super(5); + this.num = num; + this.str = str; + } +} +class C3 extends C1{ + boo: boolean; + constructor(num: number,boo:boolean) { + super(6); + this.num = num; + this.boo = boo; + } +} +class C4 extends C1{ + obj: object; + constructor(num: number, obj: object) { + super(7); + this.obj = obj; + this.num = num; + } +} -Assert.isTrue(a1[0] instanceof HWA); -Assert.isTrue(a1[1] instanceof HWB); -Assert.isTrue(a1[2] instanceof HWC); -Assert.isTrue(a1[3] instanceof HWD); -Assert.isTrue(a1[4] instanceof HWE); +let t1 = !true ? new C1(10) : new C2(11, 'a'); +function func1(arg: C1 | C2 | C3 | C4) { + if (arg instanceof C1) { + arg.num = 20; + return arg.num + } + return false; +} +Assert.equal(func1(t1), 20); +let t2 = !true ? new C2(12, 'b') : new C3(13, false); +function func2(arg: C1 | C2 | C3 | C4) { + if (arg instanceof C3) { + arg.num = 20; + return arg.num + } + return false; +} +Assert.equal(func2(t2), 20); -Assert.isTrue(a2[0] instanceof HWB); -Assert.isTrue(a2[1] instanceof HWC); -Assert.isTrue(a2[2] instanceof HWD); -Assert.isTrue(a2[3] instanceof HWE); +let t3 = !true ? new C3(14, true) : new C4(15, { a: 'a' }); +function func3(arg: C1 | C2 | C3 | C4) { + if (arg instanceof C4) { + arg.num = 20; + return arg.num + } + return false; +} +Assert.equal(func3(t3), 20); -function fun(x: HWB | HWC | HWD) { - if (x instanceof HWB) { - Assert.isTrue(x instanceof HWB); - } else if (x instanceof HWC) { - Assert.isTrue(x instanceof HWC); +function func(x: C2 | C3 | C4) { + if (x instanceof C2 ) { + return x.str; + } else if (x instanceof C3) { + return x.boo; } else { - Assert.isFalse(x instanceof HWB); - Assert.isFalse(x instanceof HWC); + return x.obj } } - -fun(new HWA()); -fun(new HWB()); -fun(new HWC()); -fun(new HWD()); \ No newline at end of file +Assert.isString(func(new C2(1, 'C2'))); +Assert.isBoolean(func(new C3(2, true))); +Assert.isObject(func(new C4(3, { o: 'obj' }))); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.7/8_Type_guards_inferred_from_in_operator/8_Type_guards_inferred_from_in_operator.ts b/es2panda/test/ts_extra_tests/test/2.7/8_Type_guards_inferred_from_in_operator/8_Type_guards_inferred_from_in_operator.ts index 501d95fe1d..5390cca33a 100644 --- a/es2panda/test/ts_extra_tests/test/2.7/8_Type_guards_inferred_from_in_operator/8_Type_guards_inferred_from_in_operator.ts +++ b/es2panda/test/ts_extra_tests/test/2.7/8_Type_guards_inferred_from_in_operator/8_Type_guards_inferred_from_in_operator.ts @@ -23,27 +23,35 @@ import { Assert } from '../../../suite/assert.js' -interface HWX { - a: number; -} -interface HWY { - b: string; +type myType = { [T in 'key1' | 'key2' | 'key3']: string }; +let mt: myType = { + key1: 'a', + key2: 'b', + key3: 'c' } +Assert.isObject(mt); -function fun(x: HWX | HWY) { - if ("a" in x) { - return x.a; - } - return x.b; +interface I1{ + name: string; + age: number; } - -let a1: HWX = { - a: 1 +interface I2{ + height: number; } - -let b1: HWY = { - b: 'this is a string' +let i1: I1 = { + name: 'xiao', + age: 18 +}; +let i2: I2 = { + height: 180 +}; +function func(arg: I1 | I2) { + if ('name' in arg) { + arg.age = 20; + return arg.age; + } + arg.height = 185; + return arg.height; } - -Assert.equal(1, fun(a1)); -Assert.equal('this is a string', fun(b1)); \ No newline at end of file +Assert.equal(func(i1), 20); +Assert.equal(func(i2), 185); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.8/conditional_types.ts b/es2panda/test/ts_extra_tests/test/2.8/conditional_types.ts index 2b1471bb27..ca35f0e50d 100644 --- a/es2panda/test/ts_extra_tests/test/2.8/conditional_types.ts +++ b/es2panda/test/ts_extra_tests/test/2.8/conditional_types.ts @@ -21,30 +21,23 @@ isCurrent: true import { Assert } from "../../suite/assert.js" -type TypeGather = - T extends string ? string : - T extends number ? number : - T extends boolean ? boolean : - T extends undefined ? undefined : - T extends Function ? Function : - object; -type T0 = TypeGather; -type T1 = TypeGather<"a">; -type T2 = TypeGather; -type T3 = TypeGather<() => void>; -type T4 = TypeGather; - - -let a: T0 = "string"; -let b: T1 = 'string'; -let c: T2 = true; -let d: T3 = (() => { }); -let e: T4 = {}; - - -Assert.equal(typeof a, 'string'); -Assert.equal(typeof b, 'string'); -Assert.equal(typeof c, 'boolean'); -Assert.equal(typeof d, 'function'); -Assert.equal(typeof e, 'object'); +interface I1{ + str: string; +} +interface I2{ + num: number; +} +type mT = T extends I1 ? boolean : T extends I2 ? number : string; +function func1>(arg: T) { + return arg; +} +Assert.isBoolean(func1(true)); +function func2>(arg: T) { + return arg; +} +Assert.isNumber(func2(5)); +function func3>(arg: T) { + return arg; +} +Assert.isString(func3('a')); diff --git a/es2panda/test/ts_extra_tests/test/2.8/improved_control_over_mapped_type_modifiers.ts b/es2panda/test/ts_extra_tests/test/2.8/improved_control_over_mapped_type_modifiers.ts index a85c7796be..29c8a0499f 100644 --- a/es2panda/test/ts_extra_tests/test/2.8/improved_control_over_mapped_type_modifiers.ts +++ b/es2panda/test/ts_extra_tests/test/2.8/improved_control_over_mapped_type_modifiers.ts @@ -14,7 +14,7 @@ */ /**--- description: > - Improved control over mapped type modifiers + With TypeScript 2.8 keyof applied to an intersection type is transformed to a union of keyof applied to each intersection constituent. module: ESNext isCurrent: true ---*/ @@ -23,33 +23,57 @@ import { Assert } from '../../suite/assert.js' { - type OA = { a: string }; - type OB = { b: string }; - - - type T1 = keyof (OA & OB); - - type T2 = keyof (T & OB); - - type T3 = keyof (OA & U); + type myType1 = 'a' | 4; + type myType2 = { str: string }; + interface I{ + mem: string; + } + type T1 = keyof (myType1 & myType2); + type T2 = keyof (T & myType2); + type T3 = keyof (myType1 & U); type T4 = keyof (T & U); + type T5 = T2; + type T6 = T3; + type T7 = T4; - type T5 = T2; - - type T6 = T3; - - type T7 = T4; + // The type of a,b,c,d is "toString" | "valueOf" | "str" + let a: T1 = 'str'; + a = 'toString'; + a = 'valueOf'; + Assert.equal(a, 'valueOf'); + let b: T5 = "str"; + b = 'toString'; + b = 'valueOf'; + Assert.equal(b, 'valueOf'); + let c: T6 = "str"; + c = 'toString'; + c = 'valueOf'; + Assert.equal(c, 'valueOf'); + let d: T7 = "str"; + d = 'toString'; + d = 'valueOf'; + Assert.equal(d, 'valueOf'); - let a: T1 = 'a'; - let b: T1 = "b"; - let c: T5 = "a"; - let d: T6 = "a"; - let e: T7 = "a"; + type T11 = keyof (I & myType2); + type T22 = keyof (T & myType2); + type T33 = keyof (I & U); + type T44 = keyof (T & U); + type T55 = T22; + type T66 = T33; + type T77 = T44; - Assert.equal(a, 'a'); - Assert.equal(b, 'b'); - Assert.equal(c, 'a'); - Assert.equal(d, 'a'); - Assert.equal(e, 'a'); + let aa: T11 = 'mem'; + aa = 'str'; + Assert.equal(aa, 'str'); + let bb: T55 = 'mem'; + bb = 'str'; + Assert.equal(bb, 'str'); + let cc: T66 = 'mem'; + cc = 'str'; + Assert.equal(cc, 'str'); + let dd: T77 = 'mem'; + dd = 'str'; + Assert.equal(dd, 'str'); + }; diff --git a/es2panda/test/ts_extra_tests/test/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts b/es2panda/test/ts_extra_tests/test/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts index da0b45084e..940a470d1d 100644 --- a/es2panda/test/ts_extra_tests/test/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts +++ b/es2panda/test/ts_extra_tests/test/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts @@ -24,7 +24,6 @@ import { Assert } from '../../../suite/assert.js' const str = "c"; const num = 10; const sym = Symbol(); -const bool = true; const enum ABC { A, B, C } const enum ABCStr { A = "A", B = "B", C = "C" } diff --git a/es2panda/test/ts_extra_tests/test/2.9/4_import_types.ts b/es2panda/test/ts_extra_tests/test/2.9/4_import_types.ts index 3b4dcefe25..a07ebe3760 100644 --- a/es2panda/test/ts_extra_tests/test/2.9/4_import_types.ts +++ b/es2panda/test/ts_extra_tests/test/2.9/4_import_types.ts @@ -23,12 +23,21 @@ import { Assert } from '../../suite/assert.js' -function hw_adopt(p: import("./module").Pet) { - Assert.equal('puppy', `${p.name}`); - Assert.equal('puppy', p.name); +function func1(i: import("./module").I) { + Assert.equal(5, `${i.num}`); + Assert.equal(5, i.num); +} +let i: import("./module.js").I = { + num: 5 +} +func1(i); + +function func(p: import("./module").C) { + Assert.equal('puppy', `${p.str}`); + Assert.equal('puppy', p.str); } -let p: import("./module.js").Pet = { - name: "puppy", +let p: import("./module.js").C = { + str: "puppy", }; -hw_adopt(p); \ No newline at end of file +func(p); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/2.9/module.ts b/es2panda/test/ts_extra_tests/test/2.9/module.ts index 381a7f8836..d38ce3a37c 100644 --- a/es2panda/test/ts_extra_tests/test/2.9/module.ts +++ b/es2panda/test/ts_extra_tests/test/2.9/module.ts @@ -14,6 +14,10 @@ */ -export declare class Pet { - name: string; +export declare class C { + str: string; +}; + +export declare interface I{ + num: number; }; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.0/new_unknown_top_type/new_unknown_top_type.ts b/es2panda/test/ts_extra_tests/test/3.0/new_unknown_top_type/new_unknown_top_type.ts index f86cf6ca25..89366a764d 100644 --- a/es2panda/test/ts_extra_tests/test/3.0/new_unknown_top_type/new_unknown_top_type.ts +++ b/es2panda/test/ts_extra_tests/test/3.0/new_unknown_top_type/new_unknown_top_type.ts @@ -24,53 +24,80 @@ import { Assert } from '../../../suite/assert.js' -type HWT00 = unknown & null; -type HWT01 = unknown & undefined; -type HWT02 = unknown & null & undefined; -type HWT03 = unknown & string; -type HWT04 = unknown & string[]; -type HWT05 = unknown & unknown; -type HWT06 = unknown & any; - -type HWT10 = unknown | null; -type HWT11 = unknown | undefined; -type HWT12 = unknown | null | undefined; -type HWT13 = unknown | string; -type HWT14 = unknown | string[]; -type HWT15 = unknown | unknown; -type HWT16 = unknown | any; - -type HWT20 = T & {}; -type HWT21 = T | {}; -type HWT22 = T & unknown; -type HWT23 = T | unknown; - -type HWT30 = unknown extends T ? true : false; -type HWT31 = T extends unknown ? true : false; -type HWT32 = never extends T ? true : false; -type HWT33 = T extends never ? true : false; - -type HWT40 = keyof any; -type HWT41 = keyof unknown; - -function hwfun01(x: unknown): unknown { +type T1 = unknown & undefined; +let t1: T1 = undefined; +Assert.isUndefined(t1); +type T2 = unknown & string; +let t2: T2 = 'a'; +Assert.isString(t2); + +type T3 = unknown | undefined; +let t3: T3 = undefined; +Assert.isUndefined(t3); +type T4 = unknown | null | undefined; +let t4: T4 = null; +t4 = undefined; +Assert.isUndefined(t4); +type T5 = unknown | string; +let t5: T5 = 'a'; +Assert.isString(t5); + +type T6 = T & {}; +let t6: T6 = { arg: 'arg' }; +Assert.isObject(t6); +type T7 = T | {}; +let t7: T7 = 10; +t7 = {}; +Assert.isObject(t7); +type T8 = T & unknown; +let t8: T8 = 10; +Assert.isNumber(t8); +type T9 = T | unknown; +let t9: T9 = 10; +Assert.isNumber(t9); + +type T10 = unknown extends T ? true : false; +let t10: T10 = false; +Assert.isFalse(t10); +type T11 = T extends unknown ? true : false; +let t11: T11 = true; +Assert.isTrue(t11); +type T12 = never extends T ? true : false; +let t12: T12 = true; +Assert.isTrue(t12); +type T13 = T extends never ? true : false; +let t13: T13 = false; +Assert.isFalse(t13); + +function func1(x: unknown): unknown { x = 10; return x; } -Assert.equal(hwfun01(0), 10); +Assert.equal(func1(0), 10); -declare function isFunction(x: unknown): x is Function; - -function hwfun02(x: unknown) { +function func2(x: unknown) { return typeof x; } -Assert.equal(hwfun02("N"), "string"); - -type HWT50 = { [P in keyof T]: number }; -type HWT51 = HWT50; -type HWT52 = HWT50; +Assert.equal(func2("N"), "string"); -function hwfun03(pAny: any, pundefined: undefined, pT: T) { +function func3(x: unknown) { + if (x instanceof Error) { + return 0; + } + return false; +} +let e: Error = Error(); +Assert.isNumber(func3(e)); + +type T14 = { [P in keyof T]: number }; +type T15 = T14; +type T16 = T14; +let t15: T15 = {}; +Assert.isObject(t15); +let t16: T16 = {}; +Assert.isObject(t16); + +function func4(pAny: any, pundefined: undefined, pT: T) { let x: unknown; x = 123; Assert.isNumber(x); @@ -83,34 +110,13 @@ function hwfun03(pAny: any, pundefined: undefined, pT: T) { x = pundefined; x = pT; } -hwfun03(1024, undefined, "A"); - -function hwfun04(x: unknown) { - let v1: any = x; - let v2: unknown = x; -} -hwfun04(1024); - -function hwfun05(x: { [x: string]: unknown }) { - x = {}; - x = { a: 5 }; -} - -function hwfun06() { - let x: unknown; - let y = x; -} - -function hwfun07(): unknown { - let x: unknown; - return x; -} +func4(1024, undefined, "A"); -class C1 { - a: string = ""; - b: unknown; - c: any; +function fun5(x: unknown) { + let v: unknown = x; + return v; } +Assert.equal(fun5(1024), 1024); let x: number = 1024; (x as unknown as string).length; diff --git a/es2panda/test/ts_extra_tests/test/3.2/bigint/bigint_1.ts b/es2panda/test/ts_extra_tests/test/3.2/bigint/bigint_1.ts index a772f413f2..b802830d80 100644 --- a/es2panda/test/ts_extra_tests/test/3.2/bigint/bigint_1.ts +++ b/es2panda/test/ts_extra_tests/test/3.2/bigint/bigint_1.ts @@ -27,21 +27,23 @@ import { Assert } from '../../../suite/assert.js' -let bi01: bigint = BigInt(100); -Assert.equal(bi01, 100n) +let b1: bigint = 10n; +let b2: bigint = BigInt(10n); +Assert.equal(b1, b2); -let bi02: bigint = 100n; -Assert.equal(bi02, 100n) - -function hwfun(n: bigint) { - let a = 1n; - for (let x = 0n, i = 0n; i < n; i++) { - const y = a; - a += x; - x = y; +function func(bnum: bigint) { + for (let i = 0; i < 10; i++){ + bnum++; } - return a; + return bnum; } +Assert.equal(func(10n), 20n); -let a = hwfun(100n); -Assert.equal(a, 573147844013817084101n); \ No newline at end of file +class C{ + bigN: bigint + constructor(bigN: bigint) { + this.bigN = bigN; + } +} +let c = new C(10n); +Assert.equal(c.bigN, 10n); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_1.ts b/es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_1.ts index 3835682e9d..924a5b135f 100644 --- a/es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_1.ts +++ b/es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_1.ts @@ -23,10 +23,11 @@ import { Assert } from "../../../suite/assert.js" -function cObj(obj: T, tag: U) { - return { ...obj, tag }; +function func(arg: T) { + return { ...arg }; } +let f1 = { num: 5, str: 'a' }; +let f2 = { num: 8, str: 'b', boo: true }; -let x = cObj({ x: 10, y: 20 }, "point"); - -Assert.equal(JSON.stringify(x), '{"x":10,"y":20,"tag":"point"}'); +Assert.isObject(func(f1)); +Assert.isObject(func(f2)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts b/es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts index a052b02f17..3dc60a6482 100644 --- a/es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts +++ b/es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts @@ -22,16 +22,17 @@ import { Assert } from "../../../suite/assert.js" -function hwFun(t: T, obj1: { a: string }, obj2: { b: string }) { - var arr = { ...obj1, x: 1, ...t, ...obj2, y: 2 }; - return arr; +function func(arg1: T, arg2: { str: string }, arg3:{num: number}) { + let obj = { n: 5, ...arg2, ...arg1, s: 's', ...arg3 }; + return obj; } + let o1 = { - a: "a", + str: 'a' }; let o2 = { - b: "b", + num: 10 }; -var f = hwFun("s", o1, o2); +var f = func({ s: "string" }, o1, o2); -Assert.equal(JSON.stringify(f), '{"0":"s","a":"a","x":1,"b":"b","y":2}'); +Assert.isObject(f); diff --git a/es2panda/test/ts_extra_tests/test/3.2/non-unit_types_as_union_discriminants/non-unit_types_as_union_discriminants.ts b/es2panda/test/ts_extra_tests/test/3.2/non-unit_types_as_union_discriminants/non-unit_types_as_union_discriminants.ts index 32bfb03d7c..c8b88b43dc 100644 --- a/es2panda/test/ts_extra_tests/test/3.2/non-unit_types_as_union_discriminants/non-unit_types_as_union_discriminants.ts +++ b/es2panda/test/ts_extra_tests/test/3.2/non-unit_types_as_union_discriminants/non-unit_types_as_union_discriminants.ts @@ -25,7 +25,7 @@ import { Assert } from "../../../suite/assert.js" type R = { error: Error; data: null } | { error: null; data: T }; -function hwfun(result: R) { +function func(result: R) { if (result.error) { throw result.error; } @@ -36,7 +36,7 @@ var a = { error: null, data: null, }; -var b = hwfun(a); +var b = func(a); let f = false; if (b == null) { f = true; @@ -47,5 +47,5 @@ var c = { error: null, data: 10, }; -var d = hwfun(c); +var d = func(c); Assert.equal(d, "10"); diff --git a/es2panda/test/ts_extra_tests/test/3.4/readonly_array.ts b/es2panda/test/ts_extra_tests/test/3.4/a_new_syntax_for_readonly_array.ts similarity index 53% rename from es2panda/test/ts_extra_tests/test/3.4/readonly_array.ts rename to es2panda/test/ts_extra_tests/test/3.4/a_new_syntax_for_readonly_array.ts index 5ecc29daa7..078ba79959 100644 --- a/es2panda/test/ts_extra_tests/test/3.4/readonly_array.ts +++ b/es2panda/test/ts_extra_tests/test/3.4/a_new_syntax_for_readonly_array.ts @@ -14,8 +14,7 @@ */ /**--- description: > - Improvements for ReadonlyArray and readonly tuples. - const assertions. + TypeScript 3.4 introduces a new syntax for ReadonlyArray using a new readonly modifier for array types. module: ESNext isCurrent: true ---*/ @@ -23,25 +22,8 @@ import { Assert } from "../../suite/assert.js" +let arr1: ReadonlyArray = ["1", "2"]; +let arr2: readonly string[] = ["1", "2"]; - let hw_arr: ReadonlyArray = ["1", "2"]; - let hw_rsa: readonly string[] = ["1", "2"]; - - Assert.equal(hw_arr[1], "2"); - Assert.equal(hw_rsa[1], "2"); - - function hwfun() { - let result = [ - { kind: "circle", radius: 100 }, - { kind: "square", sideLength: 50 }, - ] as const; - return result; - } - for (const shape of hwfun()) { - if (shape.kind === "circle") { - Assert.equal(shape.radius, 100); - } else { - Assert.equal(shape.sideLength, 50); - } - } - +Assert.equal(arr1[1], "2"); +Assert.equal(arr2[1], "2"); diff --git a/es2panda/test/ts_extra_tests/test/3.4/const_assertions.ts b/es2panda/test/ts_extra_tests/test/3.4/const_assertions.ts index 31e3f100d5..a1d1900ab1 100644 --- a/es2panda/test/ts_extra_tests/test/3.4/const_assertions.ts +++ b/es2panda/test/ts_extra_tests/test/3.4/const_assertions.ts @@ -14,16 +14,44 @@ */ /**--- description: > - TypeScript 3.4 introduces a new construct for literal values called const assertions. Its syntax is a type assertion with const in place of the type name (e.g. 123 as const). + TypeScript 3.4 introduces a new construct for literal values called const assertions. Its syntax is a type assertion with const in place of the type name. + The angle bracket assertion syntax can also be used. module: ESNext isCurrent: true ---*/ import { Assert } from "../../suite/assert.js" -let a = 1408 as const; -Assert.equal(a, 1408); -let b = 'NARC' as const; -Assert.equal(b, 'NARC'); -let c = [255, 0, 0] as const; -Assert.equal(JSON.stringify(c), '[255,0,0]'); + +let a1 = 1408 as const; +let a2 = 1408; +Assert.equal(a1, 1408); +Assert.equal(a2, 1408); +let b1 = 'NARC' as const; +let b2 = 'NARC'; +Assert.equal(b1, 'NARC'); +Assert.equal(b2, 'NARC'); +let c1 = [255, 0, 0] as const; +let c2 = [255, 0, 0]; +Assert.equal(JSON.stringify(c1), '[255,0,0]'); +Assert.equal(JSON.stringify(c2), '[255,0,0]'); +let d1 = { mem: 'member' } as const; +let d2 = { mem: 'member' }; +Assert.equal(JSON.stringify(d1), '{"mem":"member"}'); +Assert.equal(JSON.stringify(d2), '{"mem":"member"}'); + + +let obj1 = { kind: "circle", length: 80 }; +let obj2 = { kind: "square", length: 50 }; + +function func() { + let result = [obj1, obj2] as const; + return result; +} +for (const shape of func()) { + if (shape.kind === "circle") { + Assert.equal(shape.length, 80); + } else { + Assert.equal(shape.length, 50); + } +}; diff --git a/es2panda/test/ts_extra_tests/test/3.4/higher_order_type_inference.ts b/es2panda/test/ts_extra_tests/test/3.4/higher_order_type_inference.ts index 3fb489b573..9fd47c8f43 100644 --- a/es2panda/test/ts_extra_tests/test/3.4/higher_order_type_inference.ts +++ b/es2panda/test/ts_extra_tests/test/3.4/higher_order_type_inference.ts @@ -22,27 +22,25 @@ import { Assert } from '../../suite/assert.js' -function hwfun01(f: (arg: A) => B, g: (arg: B) => C): (arg: A) => C { +function Func(f: (arg: A) => B, g: (arg: B) => C): (arg: A) => C { return (x) => g(f(x)); } interface A { - value: T; + arr: T; } -function hwfun02(x: T): T[] { - return [x]; +function func1(index: T): T[] { + return [index]; } -function hwfun03(value: U): A { - return { value }; +function func2(arr: U): A { + return { arr }; } -// has type '(arg: {}) => Box<{}[]>' -const hw00 = hwfun01( - hwfun02, - hwfun03, +const result = Func( + func1, + func2, ) - -Assert.equal(hw00("hello").value[0].toUpperCase(), 'HELLO'); \ No newline at end of file +Assert.equal(result("hello").arr[0].toUpperCase(), 'HELLO'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.4/readonly_tuples.ts b/es2panda/test/ts_extra_tests/test/3.4/readonly_tuples.ts new file mode 100644 index 0000000000..93d85342f5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.4/readonly_tuples.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript 3.4 introduces new support for readonly tuples. + a readonly tuple with elements 'T1, T2, … Tn' extends from ReadonlyArray'< T1 | T2 | … Tn >'. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../suite/assert.js" + +let arr1: ReadonlyArray = [10, 'b', false]; +let arr2: readonly [number, string, boolean] = [5, 'a', true]; + +Assert.isNumber(arr1[0]); +Assert.isNumber(arr2[0]); +Assert.isString(arr1[1]); +Assert.isString(arr2[1]); +Assert.isBoolean(arr1[2]); +Assert.isBoolean(arr2[2]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.5/higher_order_type_inference.ts b/es2panda/test/ts_extra_tests/test/3.5/higher_order_type_inference.ts index c6315bb15a..92578f067c 100644 --- a/es2panda/test/ts_extra_tests/test/3.5/higher_order_type_inference.ts +++ b/es2panda/test/ts_extra_tests/test/3.5/higher_order_type_inference.ts @@ -14,7 +14,7 @@ */ /**--- description: > - In TypeScript 3.4, we improved inference for when generic functions that return functions. + TypeScript 3.5 generalizes TypeScript 3.4's inference behavior to work on constructor functions as well. module: ESNext isCurrent: true ---*/ @@ -24,22 +24,20 @@ import { Assert } from '../../suite/assert.js' { class A { - value: T; - - constructor(value: T) { - this.value = value; + mem: T; + constructor(mem: T) { + this.mem = mem; } } class B { - value: U; - - constructor(value: U) { - this.value = value; + mem: U; + constructor(mem: U) { + this.mem = mem; } } - function hwfun( + function func( F: new (x: T) => U, G: new (y: U) => V ): (x: T) => V { @@ -47,9 +45,9 @@ import { Assert } from '../../suite/assert.js' } - let f = hwfun(A, B); + let f = func(A, B); - let a = f(1024); + let a = f(10); - Assert.equal(a.value.value, 1024); + Assert.equal(a.mem.mem, 10); }; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.5/improved_excess_property_checks_in_union_types.ts b/es2panda/test/ts_extra_tests/test/3.5/improved_excess_property_checks_in_union_types.ts new file mode 100644 index 0000000000..144e5d91df --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/3.5/improved_excess_property_checks_in_union_types.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In TypeScript 3.5, the type-checker at least verifies that all the provided properties belong to some union member and have the appropriate type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../suite/assert.js' + +interface I{ + num: number; + mem2: string; +} +type T = { + num: number; + str: string; +} + +type ut = I | T; +let result: ut = { + mem2: 'member', + num: 10, + str: 'string' +} +Assert.isNumber(result.num); +Assert.isObject(result); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.5/omit_helper_type.ts b/es2panda/test/ts_extra_tests/test/3.5/omit_helper_type.ts index 425d7fa6ea..5712d517e0 100644 --- a/es2panda/test/ts_extra_tests/test/3.5/omit_helper_type.ts +++ b/es2panda/test/ts_extra_tests/test/3.5/omit_helper_type.ts @@ -39,5 +39,5 @@ import { Assert } from '../../suite/assert.js' c: 'string' } Assert.isFalse("c" in s) - Assert.isTrue("c" in s1) -} \ No newline at end of file + Assert.isTrue("c" in s1); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.5/smarter_union_type_checking.ts b/es2panda/test/ts_extra_tests/test/3.5/smarter_union_type_checking.ts index 4e3bce0250..5444045108 100644 --- a/es2panda/test/ts_extra_tests/test/3.5/smarter_union_type_checking.ts +++ b/es2panda/test/ts_extra_tests/test/3.5/smarter_union_type_checking.ts @@ -14,7 +14,8 @@ */ /**--- description: > - Smarter union type checking. + In TypeScript 3.5, when assigning to types with discriminant properties like in T, + the language actually will go further and decompose types like S into a union of every possible inhabitant type. module: ESNext isCurrent: true ---*/ @@ -23,20 +24,41 @@ import { Assert } from '../../suite/assert.js' { - type PointData = { - x: number; - y: number; - name: string; - }; + type T = { mem: string } | { mem: number }; + interface I1{ + num: number; + boo: T; + } + interface I2{ + num: number; + boo: { mem: string }; + } + interface I3{ + num: number; + boo: { mem: number }; + } + let i1: I1 = { + num: 10, + boo: { mem: 'member' } + } + let i2: I2 | I3 = { + num: 20, + boo: { mem: 15 } + } - type Data = { - name: string; - }; + i1 = i2; + Assert.equal(i1, i2); - const point: PointData | Data = { - x: 0, - y: 0, - name: 'name' + type T1 = { mem1: number, mem2: boolean }; + type T2 = { mem1: number, mem2: true } | { mem1: number, mem2: false }; + let t1: T1 = { + mem1: 10, + mem2: true + } + let t2: T2 = { + mem1: 20, + mem2: false } - Assert.equal(point.name, 'name') -} \ No newline at end of file + t1 = t2; + Assert.equal(t1, t2); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/get_and_set_accessors_are_allowed_in_ambient_contexts_1.ts b/es2panda/test/ts_extra_tests/test/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/get_and_set_accessors_are_allowed_in_ambient_contexts_1.ts index fb45c459c7..eec2489326 100644 --- a/es2panda/test/ts_extra_tests/test/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/get_and_set_accessors_are_allowed_in_ambient_contexts_1.ts +++ b/es2panda/test/ts_extra_tests/test/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/get_and_set_accessors_are_allowed_in_ambient_contexts_1.ts @@ -20,10 +20,23 @@ isCurrent: true import { Assert } from "../../../suite/assert.js" -import { HWC } from "./test.js" +import { C } from "./test.js" -let hw: HWC = { x: 1 }; - -Assert.equal(1, hw.x); +let obj: C = { x: 1 }; +Assert.equal(1, obj.x); +class mC{ + mem: string; + constructor(mem: string) { + this.mem = mem; + } + get mC_mem() { + return this.mem; + } + set mC_mem(str:string) { + this.mem = str; + } +} +let eg = new mC('member'); +Assert.equal(eg.mC_mem, 'member'); diff --git a/es2panda/test/ts_extra_tests/test/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/test.ts b/es2panda/test/ts_extra_tests/test/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/test.ts index 118f9b77d4..8eb109acba 100644 --- a/es2panda/test/ts_extra_tests/test/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/test.ts +++ b/es2panda/test/ts_extra_tests/test/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/test.ts @@ -14,8 +14,8 @@ */ -declare class HWC { +declare class C { get x(): number; set x(val: number); } -export { HWC }; +export { C }; diff --git a/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_1.ts b/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_1.ts index 6a81093741..cdc9c54341 100644 --- a/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_1.ts +++ b/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_1.ts @@ -23,12 +23,12 @@ import { Assert } from '../../../suite/assert.js' -function* hwtest() { +function* func() { yield 100; yield "Finished!"; return false; } -let t1 = hwtest(); +let t1 = func(); let t2 = t1.next(); Assert.isNumber(t2.value); t2 = t1.next(); diff --git a/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_2.ts b/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_2.ts index 70c6ab2480..db3b2d533c 100644 --- a/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_2.ts +++ b/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_2.ts @@ -24,7 +24,7 @@ import { Assert } from '../../../suite/assert.js' -class HWC1 { +class C { name: string; age: number; isJob: boolean; @@ -35,7 +35,7 @@ class HWC1 { } } -let c1 = new HWC1("caihua", 12, false); +let c1 = new C("caihua", 12, false); const keys = Object.keys(c1); var nextIndex = 0; diff --git a/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_3.ts b/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_3.ts index 743a45cd1e..7422d03f1a 100644 --- a/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_3.ts +++ b/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_3.ts @@ -23,7 +23,7 @@ import { Assert } from '../../../suite/assert.js' -function* hwtest3(): Generator { +function* func(): Generator { let i = 0; while (true) { if (yield i++) { @@ -33,7 +33,7 @@ function* hwtest3(): Generator { return "done!"; } -let t1 = hwtest3(); +let t1 = func(); let t2 = t1.next(); while (!t2.done) { Assert.equal(typeof t2.value, "number"); diff --git a/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_4.ts b/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_4.ts index a2aa88bd55..3c04f98e76 100644 --- a/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_4.ts +++ b/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_4.ts @@ -25,10 +25,10 @@ import { Assert } from '../../../suite/assert.js' -function* hwtest4() { +function* func() { let x: number = yield; Assert.isNumber(x); } -let x = hwtest4(); +let x = func(); x.next(); x.next(1); diff --git a/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_5.ts b/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_5.ts index 5286318135..5117cb9163 100644 --- a/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_5.ts +++ b/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_5.ts @@ -25,7 +25,7 @@ import { Assert } from '../../../suite/assert.js' -function* hwtest5(): Generator { +function* func(): Generator { let i = 0; while (true) { let cc = yield i++; @@ -37,7 +37,7 @@ function* hwtest5(): Generator { return "done!"; } -var t1 = hwtest5(); +var t1 = func(); var t2 = t1.next(); while (!t2.done) { t2 = t1.next(t2.value === 5); diff --git a/es2panda/test/ts_extra_tests/test/3.7/assertion_functions/assertion_functions_1.ts b/es2panda/test/ts_extra_tests/test/3.7/assertion_functions/assertion_functions_1.ts index a27ad9d52c..fb4269a3e4 100644 --- a/es2panda/test/ts_extra_tests/test/3.7/assertion_functions/assertion_functions_1.ts +++ b/es2panda/test/ts_extra_tests/test/3.7/assertion_functions/assertion_functions_1.ts @@ -23,10 +23,10 @@ isCurrent: true import { Assert } from "../../../suite/assert.js" -function hwtest(x: any, y: any) { +function func(x: any, y: any) { Assert.equal(typeof x, "number"); Assert.equal(typeof y, "number"); return x * y; } -Assert.equal(typeof hwtest(6, 8), "number"); \ No newline at end of file +Assert.equal(typeof func(6, 8), "number"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.7/nullish_coalescing/nullish_coalescing_2.ts b/es2panda/test/ts_extra_tests/test/3.7/nullish_coalescing/nullish_coalescing_2.ts index 14a5192cd2..8e9aa84741 100644 --- a/es2panda/test/ts_extra_tests/test/3.7/nullish_coalescing/nullish_coalescing_2.ts +++ b/es2panda/test/ts_extra_tests/test/3.7/nullish_coalescing/nullish_coalescing_2.ts @@ -23,9 +23,9 @@ isCurrent: true import { Assert } from "../../../suite/assert.js" let n = 0; -function hwtset() { +function func() { n = n ?? 0.5; return n; } -Assert.equal(hwtset(), 0); \ No newline at end of file +Assert.equal(func(), 0); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_1.ts b/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_1.ts index 65a25df529..5fc9d90f47 100644 --- a/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_1.ts +++ b/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_1.ts @@ -22,12 +22,12 @@ isCurrent: true import { Assert } from "../../../suite/assert.js" -const hwobj = { +const obj1 = { x: { y: 'NARC' } }; -let str = hwobj?.x.y; +let str = obj1?.x.y; Assert.equal(str, "NARC"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_2.ts b/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_2.ts index 94e06d6a37..fa7fa04c8c 100644 --- a/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_2.ts +++ b/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_2.ts @@ -21,12 +21,16 @@ isCurrent: true import { Assert } from "../../../suite/assert.js" -const hwobj = { + +const obj = { x: { y: 'e2' } }; -if (hwobj?.x?.y) { - Assert.equal(hwobj?.x?.y, "e2", "true"); +if (obj?.x?.y) { + Assert.equal(obj?.x?.y, "e2", "true"); +} +if (obj && obj.x && obj.x.y) { + Assert.equal(obj && obj.x && obj.x.y, "e2", "true"); }; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_3.ts b/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_3.ts index ab21496c7e..33526523ee 100644 --- a/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_3.ts +++ b/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_3.ts @@ -22,12 +22,12 @@ isCurrent: true import { Assert } from "../../../suite/assert.js" -function hwtset(arr?: T[]) { +function func(arr?: T[]) { return arr?.[0]; } const arr: number[] = [1, 25, 8]; -Assert.equal(hwtset(arr), 1, "true"); +Assert.equal(func(arr), 1, "true"); const arrStr: string[] = ["flower", "xian"]; -Assert.equal(hwtset(arrStr), "flower", "true"); \ No newline at end of file +Assert.equal(func(arrStr), "flower", "true"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_4.ts b/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_4.ts index 20ca32f9eb..8275e3b116 100644 --- a/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_4.ts +++ b/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_4.ts @@ -22,13 +22,25 @@ import { Assert } from '../../../suite/assert.js' -async function hwtest(url: string, log?: (msg: string) => void) { - log?.(`Request started at ${new Date().toISOString()}`); - const result = ((await fetch(url)).json()); - log?.(`Request finished at ${new Date().toISOString()}`); +class C{ + mem: string; + constructor(mem: string) { + this.mem = mem; + } + func(mem: string) { + this.mem = mem; + return this.mem; + } +} +async function func(str: string, arg?: (str: string) => void): Promise{ + let c = new C('member'); + let para = c.func('member'); + arg?.(para); + const result: Promise = ((await func(str)).json()); + arg?.(para); return result; } -hwtest("https://www.typescriptlang.org/").then(res => { - Assert.equal(typeof res, "object"); +func('string').then(res => { + Assert.isObject(res); }).catch(err => { }); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_5.ts b/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_5.ts index 5be370ece0..63facc273c 100644 --- a/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_5.ts +++ b/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_5.ts @@ -22,13 +22,13 @@ import { Assert } from '../../../suite/assert.js' -const hwobjnum = { +const obj = { n1: { n2: 10 } }; -function hwfun(divisor: number) { +function func(divisor: number) { return divisor + 4; } -let result = hwobjnum?.n1?.n2 / hwfun(1); +let result = obj?.n1?.n2 / func(1); Assert.equal(typeof result, "number"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.8/1_type_only_imports_and_export.ts b/es2panda/test/ts_extra_tests/test/3.8/1_type_only_imports_and_export.ts index 4e561a3a1a..8bafe780ee 100644 --- a/es2panda/test/ts_extra_tests/test/3.8/1_type_only_imports_and_export.ts +++ b/es2panda/test/ts_extra_tests/test/3.8/1_type_only_imports_and_export.ts @@ -20,10 +20,9 @@ isCurrent: true import { Assert } from "../../suite/assert.js"; -import type { SomeThing } from "./some_module.js"; +import type { T } from "./some_module.js"; -export type { SomeThing }; - -let sth: SomeThing = { legs: 5 }; +export type { T }; +let sth: T = { legs: 5 }; Assert.equal(5, sth.legs); diff --git a/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_1.ts b/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_1.ts index d2ae798caf..e3b0c286dd 100644 --- a/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_1.ts +++ b/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_1.ts @@ -21,9 +21,8 @@ import { Assert } from '../../../suite/assert.js' -class HWC { +class C { #name: string; - constructor(name: string) { this.#name = name; } @@ -33,7 +32,5 @@ class HWC { } } -let c = new HWC("NARC"); - +let c = new C("NARC"); Assert.equal("NARC", c.getName()); - diff --git a/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_2.ts b/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_2.ts index 34540e0d89..cb87b21577 100644 --- a/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_2.ts +++ b/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_2.ts @@ -21,24 +21,21 @@ import { Assert } from '../../../suite/assert.js' -class HWC { +class C { #x = 10; - getX() { return this.#x; } } -class HWD extends HWC { +class D extends C { #y = 20; - getY() { return this.#y; } } -let d = new HWD(); +let d = new D(); Assert.equal(10, d.getX()); - Assert.equal(20, d.getY()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_3.ts b/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_3.ts index 6ccf904d78..8b465aca43 100644 --- a/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_3.ts +++ b/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_3.ts @@ -21,21 +21,18 @@ import { Assert } from '../../../suite/assert.js' -class HWS { +class S { #len: number; - constructor(len: number) { this.#len = len; } - - equals(other: any) { + compare(other: any) { return this.#len === other.#len; } } -const a = new HWS(100); -const b = { len: 100 }; -const c = new HWS(100); +const a = new S(100); +const c = new S(100); -Assert.isTrue(a.equals(c)); \ No newline at end of file +Assert.isTrue(a.compare(c)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.8/3_which_should_i_use.ts b/es2panda/test/ts_extra_tests/test/3.8/3_which_should_i_use.ts index e94fca21b4..46ec8d9ba1 100644 --- a/es2panda/test/ts_extra_tests/test/3.8/3_which_should_i_use.ts +++ b/es2panda/test/ts_extra_tests/test/3.8/3_which_should_i_use.ts @@ -21,13 +21,21 @@ import { Assert } from '../../suite/assert.js' -class HWC { +class C1 { private x = 10; } +Assert.equal(10, new C1()["x"]); -class HWD { - #x = 10; +class C2 { + #x: number; + constructor(x: number) { + this.#x = x; + } + getX(): number { + return this.#x; + } } -Assert.equal(10, new HWC()["x"]); +let c = new C2(5); +Assert.equal(c.getX(), 5); diff --git a/es2panda/test/ts_extra_tests/test/3.8/some_module.ts b/es2panda/test/ts_extra_tests/test/3.8/some_module.ts index 7f32b745bc..ffb0e823ce 100644 --- a/es2panda/test/ts_extra_tests/test/3.8/some_module.ts +++ b/es2panda/test/ts_extra_tests/test/3.8/some_module.ts @@ -16,4 +16,4 @@ const cat: any = { legs: 4 }; -export type SomeThing = typeof cat; \ No newline at end of file +export type T = typeof cat; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/3.9/improvements_in_inference_and_Promise.all/improvements_in_inference_and_Promise.all.ts b/es2panda/test/ts_extra_tests/test/3.9/improvements_in_inference_and_Promise.all/improvements_in_inference_and_Promise.all.ts index cbb0dd3bf9..9e490ea851 100644 --- a/es2panda/test/ts_extra_tests/test/3.9/improvements_in_inference_and_Promise.all/improvements_in_inference_and_Promise.all.ts +++ b/es2panda/test/ts_extra_tests/test/3.9/improvements_in_inference_and_Promise.all/improvements_in_inference_and_Promise.all.ts @@ -26,19 +26,23 @@ import { Assert } from '../../../suite/assert.js' -interface HW_Lion { - roar(): void; +interface I1 { + func1(): number; } -interface HW_Seal { - visit(): void; +interface I2 { + func2(): number; } -async function zoo( - lionExhibit: Promise, - sealExhibit: Promise +async function func( + arg1: Promise, + arg2: Promise ) { - let [lion, seal] = await Promise.all([lionExhibit, sealExhibit]); - lion.roar(); + let [t1, t2] = await Promise.all([arg1, arg2]); + return t1.func1(); } -Assert.isString("The \"lion.roar()\" in the above example was incorrectly reported as having the value \"undefined\" and has now been fixed."); \ No newline at end of file + +let para1: Promise = new Promise(() => { return 10; }); +let para2: Promise = new Promise(() => { return 5; }); +func(para1, para2); +Assert.isObject(func(para1, para2)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/Checked_Indexed_Accesses.ts b/es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/Checked_Indexed_Accesses.ts new file mode 100644 index 0000000000..4e88b0a4cf --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/Checked_Indexed_Accesses.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript has a way to describe objects which have unknown keys but known values on an object, via index signatures. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +interface HwStaff{ + name:string; + age:number; + + [propName: string]: string|number; +} +let env:HwStaff = { + name:"lll", + age: 22, +}; +function check(op?:HwStaff): HwStaff|undefined { + if (op){ + Assert.isString(op.name); + Assert.isNumber(op.age); + }; + return op; +}; +let env2 = check(env); +Assert.equal(env2!.name,"lll"); +Assert.equal(env2!.age,22); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/for_each_index.ts b/es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/for_each_index.ts new file mode 100644 index 0000000000..3b875c2276 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/for_each_index.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + You can using a forEach call. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +let str:string[] =["3","4"]; +function indexs(strs:string[]) { + strs.forEach((str:string) =>{ + if (str == "3") { + Assert.equal(str, "3"); + } else { + Assert.equal(str, "4") + } + }) +} +indexs(str); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/for_of_index.ts b/es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/for_of_index.ts new file mode 100644 index 0000000000..e57088e71e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/for_of_index.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + You can using a for-of loop. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +let str:string[] =["1","2"]; +function indexs(strs:string[]) { + for (let str of strs) { + if (str == "1") { + Assert.equal(str, "1"); + } else { + Assert.equal(str, "2") + } + } +} +indexs(str); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/for_traversal_index.ts b/es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/for_traversal_index.ts new file mode 100644 index 0000000000..20758ec8f2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/for_traversal_index.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + You can traverse the index. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +let str:string[] =["1","2"]; +function index(strs: string[]) { + for (let i:number = 0; i < strs.length; i++) { + if (i<1) { + Assert.equal(strs[i], "1"); + }else{ + Assert.equal(strs[i],"2"); + } + } +} +index(str); diff --git a/es2panda/test/ts_extra_tests/test/4.2/Reverting_Template_Literal_Inference/Reverting_Template_Literal_Inference.ts b/es2panda/test/ts_extra_tests/test/4.2/Reverting_Template_Literal_Inference/Reverting_Template_Literal_Inference.ts new file mode 100644 index 0000000000..9a1b4317d4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.2/Reverting_Template_Literal_Inference/Reverting_Template_Literal_Inference.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + template string literals would either be given template string types or simplify to multiple string literal types. + These types would then widen to string when assigning to mutable variables. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +const logo:string ="just do it" + +const hw: string = `go ${logo}`; + +let hwa: string = `hello ${logo}`; + +let hws:string = `luckily dog ${logo}` as const; + +function check(op?:string){ + if (op){ + Assert.isString(op) + } +} +check(hw+hwa+hws); +Assert.equal(hw,"go just do it"); +Assert.equal(hwa,"hello just do it"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures_2.ts b/es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures_2.ts new file mode 100644 index 0000000000..b00228cffb --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures_2.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript 4.2 allows you to specify an abstract modifier on constructor signatures. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +abstract class myClass { + abstract getMy(): number; +} +interface myInter { + getMy(): number; +} + +let myTest: abstract new () => myInter = myClass; +Assert.equal(myTest.toString(), 'class myClass {\n}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types1.ts b/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types1.ts index e209c494d1..6883648348 100644 --- a/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types1.ts +++ b/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types1.ts @@ -22,10 +22,14 @@ import { Assert } from '../../../suite/assert.js' +type myType = Function | object; -let a: [number, number] = [1, 2]; +let tup: [myType, string, boolean] = [() => { }, 'a', true]; +Assert.isFunction(tup[0]); +Assert.isString(tup[1]); +Assert.isBoolean(tup[2]); -let b: [string, number, boolean] = ["hello", 42, true]; - -Assert.equal(JSON.stringify(a), "[1,2]"); -Assert.equal(JSON.stringify(b), "[\"hello\",42,true]"); \ No newline at end of file +tup = [{ o: 'obj' }, 'b', false]; +Assert.isObject(tup[0]); +Assert.isString(tup[1]); +Assert.isBoolean(tup[2]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types2.ts b/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types2.ts index 97c8d7dd96..95db41ca99 100644 --- a/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types2.ts +++ b/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types2.ts @@ -22,18 +22,20 @@ import { Assert } from '../../../suite/assert.js' +type myType = Function | object; -let c: [string, string?] = ["hello"]; -c = ["hello", "world"]; +let tup1: [myType, string?] = [() => { }]; +tup1 = [{ o: "obj" }, "a"]; -let d: [first: string, second?: string] = ["hello"]; -d = ["hello", "world"]; +let tup2: [arg1: myType, arg2?: string] = [() => { }]; +tup2 = [{ o: "obj" }, "a"]; -let e: [string, string, ...boolean[]]; +let tup3: [myType, string, ...unknown[]]; -e = ["hello", "world"]; -e = ["hello", "world", false]; -e = ["hello", "world", true, false, true]; +tup3 = [() => { }, "world"]; +tup3 = [{ o: "obj" }, "world", false]; +tup3 = [{ o: "obj" }, "world", true, 2]; -Assert.equal(JSON.stringify(c), "[\"hello\",\"world\"]"); -Assert.equal(JSON.stringify(e), "[\"hello\",\"world\",true,false,true]"); \ No newline at end of file +Assert.equal(JSON.stringify(tup1), "[{\"o\":\"obj\"},\"a\"]"); +Assert.equal(JSON.stringify(tup2), "[{\"o\":\"obj\"},\"a\"]"); +Assert.equal(JSON.stringify(tup3), "[{\"o\":\"obj\"},\"world\",true,2]"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types3.ts b/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types3.ts index 5eacd58fc4..4ebee21e95 100644 --- a/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types3.ts +++ b/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types3.ts @@ -14,7 +14,8 @@ */ /**--- description: > - In prior versions, TypeScript only allowed ...rest elements at the very last position of a tuple type.However, now rest elements can occur anywhere within a tuple - with only a few restrictions. + In prior versions, TypeScript only allowed '...rest' elements at the very last position of a tuple type. + However, now rest elements can occur anywhere within a tuple. module: ESNext isCurrent: true ---*/ @@ -22,18 +23,25 @@ import { Assert } from '../../../suite/assert.js' -let f: [...string[], number]; +interface h_i{ + num: number; +} +interface h_f{ + str: string; +} +type myType = h_i | h_f; -f = [123]; -f = ['hello', 123]; -f = ['hello!', 'hello!', 'hello!', 123]; +let tup1: [...myType[], boolean]; +tup1 = [true]; +tup1 = [{ num: 10 }, true]; +tup1 = [{ num: 10 }, { str: 'string' }, true]; -let g: [boolean, ...string[], boolean]; +let tup2: [string, ...myType[], boolean]; -g = [true, false]; -g = [true, 'some text', false]; -g = [true, 'some', 'separated', 'text', false]; +tup2 = ['a', false]; +tup2 = ['a', { num: 10 }, false]; +tup2 = ['a', { num: 10 }, { str: 'string' }, false]; -Assert.equal(JSON.stringify(f), "[\"hello!\",\"hello!\",\"hello!\",123]"); -Assert.equal(JSON.stringify(g), "[true,\"some\",\"separated\",\"text\",false]"); +Assert.equal(JSON.stringify(tup1), "[{\"num\":10},{\"str\":\"string\"},true]"); +Assert.equal(JSON.stringify(tup2), "[\"a\",{\"num\":10},{\"str\":\"string\"},false]"); diff --git a/es2panda/test/ts_extra_tests/test/4.3/contextual_narrowing_for_generic/contextual_narrowing_for_generics.ts b/es2panda/test/ts_extra_tests/test/4.3/contextual_narrowing_for_generic/contextual_narrowing_for_generics.ts new file mode 100644 index 0000000000..812e751234 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.3/contextual_narrowing_for_generic/contextual_narrowing_for_generics.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript 4.3 now includes some slightly smarter type-narrowing logic on generic values. + This allows TypeScript to accept more patterns, and sometimes even catch mistakes. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +function hwtest01 | T[]>( + collection: C, + comparer: (x: T, y: T) => number +): C { + if (collection instanceof Set) { + return collection; + } + collection.sort(comparer); + for (let i = 0; i < collection.length; i++) { + let j = i; + while ( + j < collection.length && + comparer(collection[i], collection[j + 1]) === 0 + ) { + j++; + } + collection.splice(i + 1, j - i); + } + return collection; +} + +let num: number[] = [1, 3, 2, 2, 4]; +function hwtest02(a: number, b: number) { + if (a == b) { + return 0; + } + return 1; +} +Assert.equal(hwtest01(num, hwtest02), "1,3,2,4"); diff --git a/es2panda/test/ts_extra_tests/test/4.3/ecmascript_private_class_elements/ecmascript_private_calss_elements.ts b/es2panda/test/ts_extra_tests/test/4.3/ecmascript_private_class_elements/ecmascript_private_calss_elements.ts new file mode 100644 index 0000000000..a876b85f39 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.3/ecmascript_private_class_elements/ecmascript_private_calss_elements.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript 4.3 expands which elements in a class can be given #private #names to make them truly private at run-time. + In addition to properties, methods and accessors can also be given private names. + Even more broadly, static members can now also have private names. + options: + target: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +class HWC { + #someMethod() { + return 1; + } + test1() { + return this.#someMethod(); + } + static #something(num: number) { + return num; + } + test2() { + return HWC.#something(10); + } + get #someValue() { + return 100; + } + publicMethod() { + this.#someMethod(); + return this.#someValue; + } +} + +let c = new HWC(); +Assert.equal(c.test1(), 1); +Assert.equal(c.test2(), 10); +Assert.equal(c.publicMethod(), 100); diff --git a/es2panda/test/ts_extra_tests/test/4.3/override_and_the_noImplicitOverride_Flag/override_and_the_noImplicitOverride_Flag.ts b/es2panda/test/ts_extra_tests/test/4.3/override_and_the_noImplicitOverride_Flag/override_and_the_noImplicitOverride_Flag.ts new file mode 100644 index 0000000000..89788b6316 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.3/override_and_the_noImplicitOverride_Flag/override_and_the_noImplicitOverride_Flag.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + adds the override keyword.provides a new noImplicitOverride flag.When this option is turned on, it becomes an error to override any method from a superclass unless you explicitly use an override keyword. + In that last example, TypeScript would error under noImplicitOverride, and give us a clue that we probably need to rename our method inside of Derived. + And index signatures can now be declared as static. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +class Boss{ + run(person?:string): string{ + return person+" go" + } +} +class manage extends Boss{ + run(person?: string): string { + return super.run(person); + } +} +class staff extends Boss{ + override run(person?:string): string { + super.run(); + return person+" run"; + } +} +let Hwa = new Boss(); +Assert.equal(Hwa.run("boss"),"boss go"); + +let hwc = new manage(); +Assert.equal(hwc.run("manage"),"manage go"); + +let Hwb = new staff(); +Assert.equal(Hwb.run("staff"),"staff run"); diff --git a/es2panda/test/ts_extra_tests/test/4.3/separate_write_types_on_properties/separate_write_types_on_properties_2.ts b/es2panda/test/ts_extra_tests/test/4.3/separate_write_types_on_properties/separate_write_types_on_properties_2.ts new file mode 100644 index 0000000000..7658edf31d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.3/separate_write_types_on_properties/separate_write_types_on_properties_2.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Be able to write getters and setters with different types in object literals. + options: + lib: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +interface HWC { + get size(): number; + set size(value: number | string | boolean); +} + +function hwtest(): HWC { + let size = 0; + return { + get size(): number { + return size; + }, + set size(value: string | number | boolean) { + let num = Number(value); + + if (!Number.isFinite(num)) { + size = 0; + return; + } + size = num; + }, + }; +} + +let t = hwtest(); +Assert.equal(t.size, 0); diff --git a/es2panda/test/ts_extra_tests/test/4.4/static_blocks_in_classe/static_blocks_in_classes1.ts b/es2panda/test/ts_extra_tests/test/4.4/static_blocks_in_classe/static_blocks_in_classes1.ts new file mode 100644 index 0000000000..b2b8956166 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.4/static_blocks_in_classe/static_blocks_in_classes1.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + These static blocks allow you to write a sequence of statements with their own scope + that can access private fields within the containing class. + we can write initialization code with all the capabilities of writing statements, no leakage of variables, and full access to our class’s internals. + options: + target: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +class HW_Test { + static #count = 0; + + get countValue() { + return HW_Test.#count; + } + + static { + HW_Test.#count++; + } +} +let hwt = new HW_Test(); +Assert.equal(hwt.countValue, 1); diff --git a/es2panda/test/ts_extra_tests/test/4.4/static_blocks_in_classe/static_blocks_in_classes2.ts b/es2panda/test/ts_extra_tests/test/4.4/static_blocks_in_classe/static_blocks_in_classes2.ts new file mode 100644 index 0000000000..beba98cd70 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.4/static_blocks_in_classe/static_blocks_in_classes2.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: a class can have multiple static blocks, and they’re run in the same order in which they’re written. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +class HW_Test { + static count = 0; + + get countValue() { + return HW_Test.count; + } + static { + HW_Test.count++; + Assert.equal(HW_Test.count, 1); + } + static { + HW_Test.count++; + Assert.equal(HW_Test.count, 2); + } + static { + HW_Test.count++; + Assert.equal(HW_Test.count, 3); + } +} +new HW_Test(); diff --git a/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_3.ts b/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_3.ts index 14aa9339f1..3d314e9c03 100644 --- a/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_3.ts +++ b/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_3.ts @@ -24,11 +24,11 @@ import { Assert } from '../../../suite/assert.js' interface HWColor { - [keys: number]: any; + [keys: number|string]: any; } -const red = Symbol("red"); -const green = Symbol("green"); -const blue = Symbol("blue"); +const red:any = Symbol("red"); +const green:any = Symbol("green"); +const blue:any = Symbol("blue"); let c: HWColor = {}; c[red] = 0xff0000; diff --git a/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_5.ts b/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_5.ts index cea4503d47..d371bb939e 100644 --- a/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_5.ts +++ b/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_5.ts @@ -36,7 +36,7 @@ interface HWDI2 { interface HWDI3 extends HWDI2 { [key: number]: any; } -const one = Symbol(1); +const one:1 = 1; let a: HWDI1 = {}; let b: HWDI3 = {}; b[one] = 1; diff --git a/es2panda/test/ts_extra_tests/test/4.6/1_allowing_code_in_constructors.ts b/es2panda/test/ts_extra_tests/test/4.6/1_allowing_code_in_constructors.ts index 60b2f505fa..5a6ff7e2c2 100644 --- a/es2panda/test/ts_extra_tests/test/4.6/1_allowing_code_in_constructors.ts +++ b/es2panda/test/ts_extra_tests/test/4.6/1_allowing_code_in_constructors.ts @@ -41,5 +41,5 @@ class HWB2 extends HWB1 { let d = new HWB2(); -Assert.equal(false, d.getBool()); +Assert.equal(d.getBool(),false ); diff --git a/es2panda/test/ts_extra_tests/test/4.6/2_control_flow_analysis.ts b/es2panda/test/ts_extra_tests/test/4.6/2_control_flow_analysis.ts index d8fece6f5c..0e9912e9a6 100644 --- a/es2panda/test/ts_extra_tests/test/4.6/2_control_flow_analysis.ts +++ b/es2panda/test/ts_extra_tests/test/4.6/2_control_flow_analysis.ts @@ -78,5 +78,5 @@ let action4: HWA = { payload: " 5678 " } -Assert.equal(4, hwtest02(action3)); -Assert.equal("5678", hwtest02(action4)); \ No newline at end of file +Assert.equal(hwtest02(action3),4); +Assert.equal(hwtest02(action4),"5678"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.6/4_indexed_access_inference_improvements.ts b/es2panda/test/ts_extra_tests/test/4.6/4_indexed_access_inference_improvements.ts index 4b247cc4a9..fdffe32f72 100644 --- a/es2panda/test/ts_extra_tests/test/4.6/4_indexed_access_inference_improvements.ts +++ b/es2panda/test/ts_extra_tests/test/4.6/4_indexed_access_inference_improvements.ts @@ -43,6 +43,6 @@ hwtest({ kind: "string", v: "hello!", f: (val) => { - Assert.equal("HELLO!", val.toUpperCase()); + Assert.equal(val.toUpperCase(),"HELLO!"); }, }); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access.ts b/es2panda/test/ts_extra_tests/test/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access.ts index a8eea7425f..462fcc96a0 100644 --- a/es2panda/test/ts_extra_tests/test/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access.ts +++ b/es2panda/test/ts_extra_tests/test/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access.ts @@ -14,7 +14,7 @@ */ /**--- description: > - TypeScript 4.7 now narrows the types of element accesses when the indexed keys are literal types and unique symbols. + TypeScript 4.7 now narrows the types of element accesses when the indexed key is unique symbols. module: ESNext isCurrent: true ---*/ @@ -22,15 +22,34 @@ import { Assert } from "../../../suite/assert.js" -const sym = Symbol(); +var sym = Symbol(); -const numstr = Math.random() < 0.5 ? 42 : "hello"; +var func = function () { + return 5; +}; -const obj = { - [sym]: numstr, +var o = { + obj: "obejct" }; -if (typeof obj[sym] === "string") { - let str = obj[sym].toUpperCase(); - Assert.equal(str, "HELLO"); +var x = Math.random(); +var y = Math.random(); +const fo = x > y ? func() : o; + +const key = { + [sym]: fo }; + +if (typeof key[sym] === "object") { + o.obj = 'Object'; +} else { + func = function () { + return 10; + } +} + +if (x < y) { + Assert.equal(o.obj, 'Object'); +} else { + Assert.equal(JSON.stringify(func), undefined); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access_1.ts b/es2panda/test/ts_extra_tests/test/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access_1.ts new file mode 100644 index 0000000000..c401307150 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access_1.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript 4.7 now narrows the types of element accesses when the indexed key is literal types. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +type myType = "a" | 3 | "b"; +if (Math.random() > 0.8) { + var arg1: myType = "a"; +} else if (Math.random() < 0.3) { + var arg1: myType = "b"; +} else { + var arg1: myType = 3; +} + +const arg2 = Math.random() > 0.5 ? 15 : 'rand'; + +const o = { + [arg1]: arg2 +} +if (typeof o[arg1] === 'string') { + Assert.equal(arg2, 'rand'); +} else { + Assert.equal(arg2, 15); +}; diff --git a/es2panda/test/ts_extra_tests/test/4.7/extends_constraints_on_infer_type_variables/extends_constraints_on_infer_type_variables.ts b/es2panda/test/ts_extra_tests/test/4.7/extends_constraints_on_infer_type_variables/extends_constraints_on_infer_type_variables.ts index 0231ad2eb6..3d2071969e 100644 --- a/es2panda/test/ts_extra_tests/test/4.7/extends_constraints_on_infer_type_variables/extends_constraints_on_infer_type_variables.ts +++ b/es2panda/test/ts_extra_tests/test/4.7/extends_constraints_on_infer_type_variables/extends_constraints_on_infer_type_variables.ts @@ -16,7 +16,7 @@ description: > Conditional types are a bit of a power-user feature. They allow us to match and infer against the shape of types, and make decisions based on them. - To avoid that second level of nesting, TypeScript 4.7 now allows to place a constraint on any infer type. + TypeScript 4.7 now allows to place a constraint on any infer type. module: ESNext isCurrent: true ---*/ @@ -24,34 +24,25 @@ import { Assert } from "../../../suite/assert.js" -type FStr1 = T extends [infer S, ...unknown[]] - ? S extends string - ? S - : boolean - : boolean; - -type FStr2 = T extends [infer S extends string, ...unknown[]] ? S : boolean; - -let A1: FStr1<[string, number, number]> = "A1"; -let A2: FStr2<[string, number, number]> = "A2"; -Assert.isString(A1); -Assert.isString(A2); - -let B1: FStr1<["hello", number, number]> = "hello"; -let B2: FStr2<["hello", number, number]> = "hello"; -Assert.equal(B1, "hello"); -Assert.equal(B2, "hello"); - -let C1: FStr1<["hello" | "world", boolean]> = "hello"; -Assert.equal(C1, "hello"); -let C2: FStr2<["hello" | "world", boolean]> = "world"; -Assert.equal(C2, "world"); -C1 = "world"; -Assert.equal(C1, "world"); -C2 = "hello"; -Assert.equal(C2, "hello"); - -let D1: FStr1<[object, number, string]> = false; -Assert.isBoolean(D1); -let D2: FStr2<[object, number, string]> = false; -Assert.isBoolean(D2); +type myType1 = T extends (...arg: infer R) => number ? R : boolean; + +const Add = (a: number, b: number) => a + b; +type add = typeof Add; +type t1 = myType1; +const arr: t1 = [1, 2]; +Assert.isObject(arr); + +type fs = Function | string; +type myType2 = T extends [infer S extends fs, ...any[]] ? S : boolean; + +const Min = (a: number, b: number)=>{ + if (a > b) { + return b; + } else { + return a; + } +} +type min = typeof Min; +type t2 = myType2<[min, number, string]>; +const func: t2 = Min; +Assert.isFunction(func); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.7/improved_function_inference_in_objects_and_methods/improved_function_inference_in_objects_and_methods.ts b/es2panda/test/ts_extra_tests/test/4.7/improved_function_inference_in_objects_and_methods/improved_function_inference_in_objects_and_methods.ts index f32dee01f2..0c215e39ea 100644 --- a/es2panda/test/ts_extra_tests/test/4.7/improved_function_inference_in_objects_and_methods/improved_function_inference_in_objects_and_methods.ts +++ b/es2panda/test/ts_extra_tests/test/4.7/improved_function_inference_in_objects_and_methods/improved_function_inference_in_objects_and_methods.ts @@ -23,41 +23,69 @@ import { Assert } from "../../../suite/assert.js" +function func1(arg: T): T{ + return arg; +} +var f1 = func1(5); +Assert.isNumber(f1); +var f2 = func1('a'); +Assert.isString(f2); +var f3 = func1(true); +Assert.isBoolean(f3); +var f4 = func1({ num: 5 }); +Assert.isObject(f4); +var f5 = func1(() => { return; }); +Assert.isFunction(f5); + +function func2(arg: { member: (str: string) => T }) { + return arg; +} +var f6 = func2({ member: str => { return str; } }); +var result = f6.member('a'); +Assert.isString(result); function hwtest(arg: { produce: (n: string) => T; consume: (x: T) => void; -}): void { } +}) { + arg.consume = function (x:T) { + Assert.equal(typeof x,"String") + } + arg.consume; -var a = hwtest({ - produce: () => "hello", - consume: (x) => x.toLowerCase(), +} +hwtest({ + produce: ():string => "hello", + consume: (x:string) => x.toLowerCase(), }); -Assert.isUndefined(a); -var b = hwtest({ - produce: (n: string) => n, - consume: (x) => x.toLowerCase(), -}); -Assert.isUndefined(b); -var c = hwtest({ - produce: (n) => n, - consume: (x) => x.toLowerCase(), -}); -Assert.isUndefined(c); +class C{ + arg: { + mem: (str: string) => T; + t: T; + } + constructor(arg: { + mem: (str: string) => T; + t: T; + }) { + this.arg = arg; + this.arg.t = arg.t; + } +} +var c1 = new C({ + mem: function () { return 'a' }, + t: 't' +}) +Assert.isString(c1.arg.t); +var c2 = new C({ + mem() { return 'a' }, + t: 't' +}) +Assert.isString(c1.arg.t); +var c3 = new C({ + mem: str => str, + t: 't' +}) +Assert.isString(c1.arg.t); -var d = hwtest({ - produce: function () { - return "hello"; - }, - consume: (x) => x.toLowerCase(), -}); -Assert.isUndefined(d); -var e = hwtest({ - produce() { - return "hello"; - }, - consume: (x) => x.toLowerCase(), -}); -Assert.isUndefined(e); diff --git a/es2panda/test/ts_extra_tests/test/4.7/instantiation_expressions/instantiation_expressions.ts b/es2panda/test/ts_extra_tests/test/4.7/instantiation_expressions/instantiation_expressions.ts index 00cb29d8fe..1f3702ba0c 100644 --- a/es2panda/test/ts_extra_tests/test/4.7/instantiation_expressions/instantiation_expressions.ts +++ b/es2panda/test/ts_extra_tests/test/4.7/instantiation_expressions/instantiation_expressions.ts @@ -22,6 +22,15 @@ import { Assert } from "../../../suite/assert.js" +const Data:any = Map; + +const data = new Data(); + +data.set("name",new Error("TS error")) + +Assert.equal(data.get("name").name, 'Error'); + + interface HWI1 { value: T; } @@ -32,10 +41,35 @@ interface HWI3 { use: string; } function hwtest(value: T) { - return { value }; -} + return {value}; +// Function + type myType1 = number | string; + type myType2 = { str: string } | (() => number); -const m1 = hwtest({ name: "hammer" }); -Assert.equal(JSON.stringify(m1), '{"value":{"name":"hammer"}}'); -const m2 = hwtest({ use: "turn the screw" }); -Assert.equal(JSON.stringify(m2), '{"value":{"use":"turn the screw"}}'); + function func(arg: T) { + return arg; + } + + var f1 = func(5); + Assert.isNumber(f1); + var f2 = func('a'); + Assert.isString(f2); + + var f3 = func({str: 'str'}); + Assert.isObject(f3); + var f4 = func(() => { + return 10; + }); + Assert.isFunction(f4); + +// Constructor + let map = Map; + let map_instantiation = new map(); + map_instantiation.set('num', 8); + Assert.isNumber(map_instantiation.get('num')); + + let set = new Set([2]); + for (let arg of set) { + Assert.isNumber(arg); + } +} diff --git a/es2panda/test/ts_extra_tests/test/4.7/optional_variance_annotations_for_type_parameters/optional_variance_annotations_for_type_parameters.ts b/es2panda/test/ts_extra_tests/test/4.7/optional_variance_annotations_for_type_parameters/optional_variance_annotations_for_type_parameters.ts index 7c05355af3..07b0564308 100644 --- a/es2panda/test/ts_extra_tests/test/4.7/optional_variance_annotations_for_type_parameters/optional_variance_annotations_for_type_parameters.ts +++ b/es2panda/test/ts_extra_tests/test/4.7/optional_variance_annotations_for_type_parameters/optional_variance_annotations_for_type_parameters.ts @@ -22,13 +22,34 @@ import { Assert } from "../../../suite/assert.js" +interface P{ + num: number; +} +interface C extends P{ + str: string; +} + +type myType1 = Array

; +type myType2 = Array; + +var m_ins1: myType1 = [{ num: 5 }]; +var m_ins2: myType2 = [{ num: 10, str: 'a' }]; -class Dog { - dogType: any; +m_ins1 = m_ins2; +Assert.equal(m_ins1, m_ins2); + + +interface h_P{ + name: string; +} +interface h_C{ + name: string; + age: number; } -type Setter = (value) => void; -let animal2: Setter = (): any => { }; -let dog2: Setter= (): any => { }; -dog2 = animal2; -Assert.isTrue(dog2 == animal2); +type myType3 = () => T; +type myType4 = () => T; +var m_ins3: myType3 = () => { return { name: 'xiao' } }; +var m_ins4: myType4 = () => { return { name: 'xi', age: 18 } }; +m_ins3 = m_ins4; +Assert.equal(m_ins3, m_ins4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/4.8/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing.ts b/es2panda/test/ts_extra_tests/test/4.8/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing.ts new file mode 100644 index 0000000000..3990d1225a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/4.8/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing.ts @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + consistency improvements under --strictNullChecks. + These changes affect how intersection and union types work, and are leveraged in how TypeScript narrows types. + Another change is that {} intersected with any other object type simplifies right down to that object type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +type T1 = {} & string; +let Hwa:T1 = "sss"; +Assert.equal(Hwa,"sss") + +type T2 = {} & unknown; +let Hwb:T2 = 2; +Assert.equal(Hwb,2) + +let x:unknown = 1 ; +function f1(x: unknown) { + let y:null|undefined|{}; + y=x; + if (x) { + Assert.equal(y,1); + } +} +f1(x); + +let z:T1 ="Hw"; +function f2(x: T,y?:T) { + y=x; + if (x) { + Assert.equal(y,"Hw"); // T & {} + } +} +f2(z,undefined); + +let bar:unknown = 555; +function f3(x: unknown, y?: {} | null | undefined) { + y = x; + Assert.equal(y,555); +} +f3(bar,null); + +function ensureNotNull(x: T) { + if (x != null){ + Assert.isNumber(x); + } +} +let run:unknown = 111; +ensureNotNull(run); + + + diff --git a/es2panda/test/ts_extra_tests/test/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts b/es2panda/test/ts_extra_tests/test/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts index 5c835b2811..fe0946a3fe 100644 --- a/es2panda/test/ts_extra_tests/test/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts +++ b/es2panda/test/ts_extra_tests/test/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts @@ -34,7 +34,7 @@ const dFun1: DF1 = () => { Assert.isString("dFun1"); } const dFun2: DF2 = (a: string, b: string) => { Assert.isString("dFun2"); return a + b; } const dFun3: DF3 = (a: number, b?: number) => { - var c: any; + let c: any; if (b != undefined) { c = a + b; } else { diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/declarations/declarations_2.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/declarations/declarations_2.ts index 681e422701..1b4586c4ea 100644 --- a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/declarations/declarations_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/declarations/declarations_2.ts @@ -28,7 +28,6 @@ import { Assert } from '../../../../suite/assert.js' -// class declaration class C { x: string; constructor(x: string) { @@ -38,7 +37,6 @@ class C { var c: C = new C("x"); Assert.equal(c.x, "x"); -// enum declaration enum WeekDay { MON = 1, TUE, @@ -52,7 +50,6 @@ type a = WeekDay; var mon: a = WeekDay.MON; Assert.equal(mon, 1); -// namespace declaration namespace N { export let x: string = "x"; } diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/property_names/property_names_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/property_names/property_names_1.ts index 279e16f4df..4dfc8a2dea 100644 --- a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/property_names/property_names_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/property_names/property_names_1.ts @@ -26,20 +26,26 @@ import { Assert } from '../../../../../suite/assert.js' class Property { - // reserved word as property name break: string; - // string literal as property name + let: string; + any: string; + as: string; "with blank": number; - // numeric literal as property name 1: boolean; - constructor(x: string, y: number, z: boolean) { - this.break = x; - this["with blank"] = y; - this[1] = z; + constructor() { + this.break = "break"; + this["with blank"] = 12; + this[1] = true; + this.any = "any"; + this.let = "let"; + this.as = "as"; } } -var p: Property = new Property("abc", 12, false); -Assert.equal("abc", p.break); +var p: Property = new Property(); +Assert.equal("break", p.break); Assert.equal(12, p["with blank"]); -Assert.equal(false, p[1]); \ No newline at end of file +Assert.equal(true, p[1]); +Assert.equal("any", p.any); +Assert.equal("let", p.let); +Assert.equal("as", p.as); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_1.ts new file mode 100644 index 0000000000..eb7ca5582b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_1.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: any cannot be type name, but are otherwise not restricted. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +function any(): string { + return "any"; +}; +Assert.isFunction(any); +Assert.equal(any(), "any"); diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_1.ts new file mode 100644 index 0000000000..2a84c8f1f4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_1.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: boolean cannot be type name, but are otherwise not restricted. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +function boolean(): number { + return 0; +} +Assert.isFunction(boolean); +Assert.equal(boolean(), 0); diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_1.ts new file mode 100644 index 0000000000..48c432e0f4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_1.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: number cannot be type name, but are otherwise not restricted. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +function number(): string { + return "number"; +} +Assert.isFunction(number); +Assert.equal(number(), "number"); diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_1.ts new file mode 100644 index 0000000000..b4f75864c2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_1.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: string cannot be type name, but are otherwise not restricted. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +function string(): number { + return 10; +} +Assert.equal(string, 10); diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_1.ts new file mode 100644 index 0000000000..291cc64563 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_1.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: symbol cannot be type name, but are otherwise not restricted. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../../suite/assert.js' + +function symbol(): string { + return "symbol" +} +Assert.equal(symbol(), "symbol"); diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_1.ts new file mode 100644 index 0000000000..3b43a9df4b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_1.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The scope of a name declared in the global namespace is the entire program text. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../../suite/assert.js"; + +var a: number = 1024; +let b: string = 'NARC'; +Assert.equal(a, 1024); +Assert.equal(b, 'NARC'); + +function add() { + return a + b; +} +Assert.equal(add(), '1024NARC'); + +class OUT { + out: string; + constructor() { + this.out = b + a; + } +} +let out = new OUT(); +Assert.equal(out.out, 'NARC1024'); diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_2.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_2.ts new file mode 100644 index 0000000000..e9923de9b8 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_2.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The scope of a name declared in a module is the source file of that module. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../../suite/assert.js"; +import * as m from "./scopes_2_m.js"; + +Assert.equal(m.m3, 1970); +Assert.equal(m.m4, 'EXP'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_2_m.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_2_m.ts new file mode 100644 index 0000000000..ede92c6b7a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_2_m.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The scope of a name declared in a module is the source file of that module. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../../suite/assert.js"; + +let m1 = 1969; +var m2 = 'XO'; +Assert.equal(m1, 1969); +Assert.equal(m2, 'XO'); + +export let m3 = 1970; +export var m4 = 'EXP'; +Assert.equal(m3, 1970); +Assert.equal(m4, 'EXP'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_3.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_3.ts new file mode 100644 index 0000000000..bb23044007 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_3.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The scope of an exported name declared within a namespace declaration is the body of that namespace declaration and every namespace declaration with the same root and the same qualified name relative to that root. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../../suite/assert.js"; + +namespace X { + export var a: string = '404NotFound'; + export let b: number = 119; + export namespace Y { + export function pak() { + return { a, b }; + } + } +} +Assert.equal(X.a, '404NotFound'); +Assert.equal(X.b, 119); +Assert.equal(X.Y.pak().a, '404NotFound'); +Assert.equal(X.Y.pak().b, 119); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_4.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_4.ts new file mode 100644 index 0000000000..4fdb88caf3 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_4.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The scope of a non-exported name declared within a namespace declaration is the body of that namespace declaration. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../../suite/assert.js"; + +namespace X { + var a: string = 'TypeScript'; + let b: number = 110; + export function assert() { + Assert.equal(a, 'TypeScript'); + Assert.equal(b, 110); + } +} +X.assert(); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_body/class_body.ts b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_body/class_body.ts index 65b420216b..6a1e79eb5c 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_body/class_body.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_body/class_body.ts @@ -35,15 +35,17 @@ class P { } static initial = new P(0, 0); } -var p: P = new P(10, 20); +let p: P = new P(10, 20); Assert.equal(10, p.num1); Assert.equal(20, p.num2); +Assert.equal(0, P.initial.num1); +Assert.equal(0, P.initial.num2); // zero constructor class Circle { radius: number = 1; } -const c = new Circle(); +let c = new Circle(); Assert.equal(c.radius, 1); // more constructor @@ -70,8 +72,8 @@ class summation { return this.width * this.height; } } -const sun = new summation(4, 5); +let sun = new summation(4, 5); Assert.equal(sun.sunArea(), 20); -const obj: TypeSummation = { width: 10, height: 2 }; -const sun2 = new summation(obj); +let obj: TypeSummation = { width: 10, height: 2 }; +let sun2 = new summation(obj); Assert.equal(sun2.sunArea(), 20); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_declarations_1.ts new file mode 100644 index 0000000000..adad411ecc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_declarations_1.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A class declaration declares a class type and a constructor function: class BindingIdentifieropt TypeParametersopt ClassHeritage { ClassBody } + module: ESNext + isCurrent: true + ---*/ +import { Assert } from '../../../../suite/assert.js' + +class Rectangle { + // constructor + constructor(public height: number, public width: number) { }; + // Getter + get area() { + return this.calcArea() + } + // Method + calcArea() { + return this.height * this.width; + } +} +let square = new Rectangle(10, 10); +Assert.equal(100, square.area); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_declarations_2.ts b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_declarations_2.ts new file mode 100644 index 0000000000..606b9083bc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_declarations_2.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A class declaration declares a class type and a constructor function: class BindingIdentifieropt TypeParametersopt ClassHeritage { ClassBody } + module: ESNext + isCurrent: true + ---*/ +import { Assert } from '../../../../suite/assert.js' + +class Point { + constructor(public x: number, public y: number) { + this.x = x; + this.y = y; + } + static initial = new Point(0, 0); + static distance(a: Point, b: Point) { + let dx = a.x - b.x; + let dy = a.y - b.y; + return Math.hypot(dx, dy); + } +} +Assert.equal(0, Point.initial.x); +Assert.equal(0, Point.initial.y); +let p1 = new Point(0, 4); +let p2 = new Point(3, 0); +Assert.equal(0, p1.x); +Assert.equal(4, p1.y); +Assert.equal(3, p2.x); +Assert.equal(0, p2.y); +Assert.equal(5, Point.distance(p1, p2)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_declarations_3.ts b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_declarations_3.ts new file mode 100644 index 0000000000..4fa83ed5b0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_declarations_3.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A class with type parameters is called a generic class. + module: ESNext + isCurrent: true + ---*/ +import { Assert } from '../../../../suite/assert.js' + +class MyClass { + field: T; + constructor(field: T) { + this.field = field; + } + public getFieldName(): T { + return this.field; + } +} +class P { + constructor(public num1: number, public num2: number) { } + public hypot() { + return Math.sqrt(this.num1 * this.num1 + this.num2 * this.num2); + } +} +let mc1: MyClass = new MyClass("a"); +Assert.equal("a", mc1.field); +let mc2: MyClass = new MyClass(1); +Assert.equal(1, mc2.field); +let mc3: MyClass = new MyClass(false); +Assert.equal(false, mc3.field); +let p: P = new P(10, 20); +let mc4: MyClass

= new MyClass

(p); +Assert.equal(10, mc4.field.num1); +Assert.equal(20, mc4.field.num2); +let obj: object = { + x: 1, + y: 2 +} +let mc5: MyClass = new MyClass(obj); +Assert.equal(obj, mc5.field); +let list: Array = [1, 2, 3]; +let mc6: MyClass> = new MyClass>(list); +Assert.equal(list, mc6.field); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts index 4f3e141121..791b4f0873 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts @@ -14,7 +14,7 @@ */ /**--- description: > - A class declaration declares a class type and a constructor function: class BindingIdentifieropt TypeParametersopt ClassHeritage { ClassBody } + A class that includes an extends clause is called a derived class, and the class specified in the extends clause is called the base class of the derived class. module: ESNext isCurrent: true ---*/ @@ -29,11 +29,6 @@ class P { } static initial = new P(0, 0); } - -var p: P = new P(10, 20); -Assert.equal(10, p.num1); -Assert.equal(20, p.num2); - class ChildP extends P { constructor(public x: number, public y: number) { super(x, y); @@ -43,26 +38,10 @@ class ChildP extends P { this.y += 1; } } - -var pChild: ChildP = new ChildP(10, 20); +let pChild: ChildP = new ChildP(10, 20); +Assert.equal(10, pChild.x); +Assert.equal(20, pChild.y); pChild.move(); Assert.equal(11, pChild.x); Assert.equal(21, pChild.y); -class MyClass { - field: T; - constructor(field: T) { - this.field = field; - } - - public getFieldName(): T { - return this.field; - } -} -let mc: MyClass = new MyClass("a"); -Assert.equal("a", mc.field); -let mc2: MyClass = new MyClass(1); -Assert.equal(1, mc2.field); -let mc3: MyClass = new MyClass(false); -Assert.equal(false, mc3.field); -let mc4: MyClass = new MyClass(pChild); -Assert.isTrue(mc4.field instanceof ChildP); +Assert.equal(0, ChildP.initial.num1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts index 2eda0a2895..e04b080942 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts @@ -14,9 +14,7 @@ */ /**--- description: > - The heritage specification of a class consists of optional extends and implements clauses. - The extends clause specifies the base class of the class - and the implements clause specifies a set of interfaces for which to validate the class provides an implementation. + the implements clause specifies a set of interfaces for which to validate the class provides an implementation. module: ESNext isCurrent: true ---*/ @@ -24,43 +22,39 @@ import { Assert } from '../../../../../suite/assert.js' -class P { +class P1 { constructor(public num1: number, public num2: number) { } public hypot() { return Math.sqrt(this.num1 * this.num1 + this.num2 * this.num2); } - static initial = new P(0, 0); + static initial = new P1(0, 0); } - -var p: P = new P(10, 20); +let p: P1 = new P1(10, 20); Assert.equal(10, p.num1); Assert.equal(20, p.num2); -// the extends -class ChildP extends P { - constructor(public x: number, public y: number) { - super(x, y); - } - public move() { - this.x += 1; - this.y += 1; - } -} -var pChild: ChildP = new ChildP(10, 20); -pChild.move(); -Assert.equal(11, pChild.x); -Assert.equal(21, pChild.y); -// the implements -interface InterP { +// the implements1 +interface InterP1 { x: number; y: number; } -class P2 implements InterP { +class P2 implements InterP1 { x = 1; y = 1; setarea(x: number, y: number) { return x * y; } } -var ipoint = new P2(); +let ipoint = new P2(); Assert.equal(1, ipoint.x); Assert.equal(1, ipoint.y); +// the implements2 +interface InterP2 { + Area(x: number, y: number): number; +} +class Rectangle implements InterP2 { + Area(x: number, y: number): number { + return x * y; + } +} +let rec = new Rectangle(); +Assert.equal(200, rec.Area(10, 20)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts index 90b7b218b2..9e6bff1da3 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts @@ -14,9 +14,8 @@ */ /**--- description: > - The this-type (section 3.6.3) of the declared class - must be assignable (section 3.11.4) to the base type reference - and each of the type references listed in the implements clause. + The this-type (section 3.6.3) of the declared class must be assignable (section 3.11.4) to the base type reference + and each of the type references listed in the implements clause. module: ESNext isCurrent: true ---*/ @@ -24,18 +23,16 @@ import { Assert } from '../../../../../suite/assert.js' -class Point { - constructor(public x: number = 0) { } +class Addx { + constructor(public x: number) { } public add(): this { this.x++; return this; } } -var p: Point = new Point(10); -Assert.equal(11, p.add().x); // the extends -class ChildPoint extends Point { - constructor(public x: number = 0) { +class ChildAddx extends Addx { + constructor(public x: number) { super(x); } public move(): this { @@ -43,22 +40,37 @@ class ChildPoint extends Point { return this; } } -var pChild: ChildPoint = new ChildPoint(10); -Assert.equal(11, pChild.move().x); -var basePoint: Point = pChild.move(); -Assert.equal(13, basePoint.add().x); +let childadd: ChildAddx = new ChildAddx(10); +Assert.equal(11, childadd.move().x); +let a: Addx = childadd.move(); +Assert.equal(13, a.add().x); // the implements -interface InterPoint { +interface InterAddx { x: number; } -class Point2 implements InterPoint { +class Addx2 implements InterAddx { x = 1; setadd(): this { this.x++; return this; } } -var ipoint = new Point2(); -Assert.equal(2, ipoint.setadd().x); -var interpoint: InterPoint = ipoint.setadd(); -Assert.equal(3, interpoint.x); +let b1 = new Addx2(); +Assert.equal(2, b1.setadd().x); +let interb1: InterAddx = b1.setadd(); +Assert.equal(3, interb1.x); +interface InterP { + Area(x: number, y: number): number; +} +class Rectangle implements InterP { + Area(x: number, y: number): number { + return x * y; + } + setRec(): this { + return this; + } +} +let b2 = new Rectangle(); +Assert.equal(200, b2.Area(10, 20)); +let interb2: InterP = b2.setRec(); +Assert.equal(200, interb2.Area(10, 20)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts index 8446e99901..c10cde2600 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts @@ -14,9 +14,9 @@ */ /**--- description: > - as is the case with every object type, type references (section 3.3.1) to the class - will appear to have the members of the global interface type named 'Object' - unless those members are hidden by members with the same name in the class. + as is the case with every object type, type references (section 3.3.1) to the class + will appear to have the members of the global interface type named 'Object' + unless those members are hidden by members with the same name in the class. module: ESNext isCurrent: true ---*/ @@ -29,7 +29,6 @@ class P { public hypot() { } static initial = new P(0, 0); } - let p = new P(1, 2); let obj = new Object(); -Assert.equal(p.toString(), obj.toString()); +Assert.equal(p.toString(), obj.toString()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_5.ts b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_5.ts index fe2cbfd833..7126a82c87 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_5.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_5.ts @@ -14,8 +14,7 @@ */ /**--- description: > - A class may optionally have type parameters. A class with type parameters is called a generic class. - The type parameters of a generic class declaration are in scope in the entire declaration and may be referenced in the ClassHeritage and ClassBody. + The type parameters of a generic class declaration are in scope in the entire declaration and may be referenced in the ClassHeritage and ClassBody. module: ESNext isCurrent: true ---*/ @@ -29,8 +28,8 @@ class MyClass{ this.myArry.push(num); } max(): T { - var mNum = this.myArry[0]; - for (var i = 0; i < this.myArry.length; i++) { + let mNum = this.myArry[0]; + for (let i = 0; i < this.myArry.length; i++) { if (mNum < this.myArry[i]) { mNum = this.myArry[i]; } @@ -38,9 +37,15 @@ class MyClass{ return mNum; } } -var h_m = new MyClass(); +let h_m: MyClass = new MyClass(); h_m.add(5); h_m.add(4); h_m.add(9); h_m.add(15); -Assert.equal(h_m.max(), 15); \ No newline at end of file +Assert.equal(h_m.max(), 15); +let h_m2: MyClass = new MyClass(); +h_m2.add('b'); +h_m2.add('a'); +h_m2.add('w'); +h_m2.add('f'); +Assert.equal(h_m2.max(), 'w'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_6.ts b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_6.ts index 6a9d96087a..227a5aaefe 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_6.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_6.ts @@ -14,8 +14,7 @@ */ /**--- description: > - A class that includes an extends clause is called a derived class, - and the class specified in the extends clause is called the base class of the derived class. + The constructor function type created by the class declaration must be assignable to the base class constructor function type module: ESNext isCurrent: true ---*/ @@ -30,14 +29,14 @@ class Person { this.name = name; this.age = age; } - introduce() { - return 'I am a college student'; - } } class Student extends Person { - constructor(name: string, age: number) { + constructor(name: string, age: number, public id: string) { super(name, age); + this.id = id; } } -var m_C = new Student('xiao', 18); -Assert.equal(m_C.introduce(), 'I am a college student'); \ No newline at end of file +let stu1: Student = new Student("xiao", 18, "001"); +let per1: Person = stu1; +Assert.equal("xiao", per1.name); +Assert.equal(18, per1.age); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_1.ts b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_1.ts index ff4aea69c4..3e40064410 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_1.ts @@ -40,3 +40,5 @@ class B { let b = new B(); Assert.equal(a.x, 1); Assert.equal(a.y, "go"); +Assert.equal(b.x, 1); +Assert.equal(b.y, "go"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts index a2b1b75a0f..8ce8ea743b 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts @@ -51,5 +51,4 @@ Assert.equal(tt2.age, 12); let tt3 = new Animal1("caihua3"); Assert.equal(tt3.name, "caihua3"); let tt4 = new Animal1(1230); -Assert.equal(tt4.age, 1230); - +Assert.equal(tt4.age, 1230); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts index 7160740278..82f12111d9 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts @@ -45,4 +45,4 @@ let p1 = new P1(1, 2); Assert.equal(p1.num1, 1); Assert.equal(p1.foo, 2); let p2 = new Point2(3, 4); -Assert.equal(p2.foo, 4); +Assert.equal(p2.foo, 4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_3.ts b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_3.ts index 2c0cd465a8..8138bbfb04 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_3.ts @@ -31,10 +31,8 @@ class myClass1 { return; } } - -var myTest1 = new myClass1(5); +let myTest1 = new myClass1(5); Assert.equal(myTest1.num, 5); - class myClass2 { num: number; constructor(num: number) { @@ -42,6 +40,5 @@ class myClass2 { return { num: 10 }; } } - -var myTest2 = new myClass2(5); +let myTest2 = new myClass2(5); Assert.equal(myTest2.num, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_4.ts b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_4.ts index cca29f29f0..ce311d0f45 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_4.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_4.ts @@ -28,5 +28,5 @@ class myClass{ this.num = num; } } -var myTest = new myClass(10); -Assert.isNumber(myTest.num); \ No newline at end of file +let myTest = new myClass(10); +Assert.equal(myTest.num, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_5.ts b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_5.ts index 6852182d4d..4ee4119aa9 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_5.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_5.ts @@ -30,7 +30,7 @@ class myClass { this.num3 = num3; } } -var myTest = new myClass(3); +let myTest = new myClass(3); Assert.equal(myTest.num1, 3); -Assert.isUndefined(myTest.num2); -Assert.equal(myTest.num3, 10); \ No newline at end of file +Assert.equal(myTest.num3, 10); +Assert.equal(myTest.num2, undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_6.ts b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_6.ts new file mode 100644 index 0000000000..3c0093b044 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_6.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a class with no constructor declaration, an automatic constructor is provided, as described in section 8.3.3. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class myClass { + public a: string = "test"; + public b: number = 1; +} +class myClass2 { + public c: number = 2; +} +let myTest: myClass = new myClass(); +Assert.equal(myTest.a, "test"); +Assert.equal(myTest.b, 1); +let myTest2: myClass2 = new myClass2(); +Assert.equal(myTest2.c, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/index_member_declarations/index_member_declarations.ts b/es2panda/test/ts_extra_tests/test/spec/classes/index_member_declarations/index_member_declarations.ts index b721607bcf..d0584deafc 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/index_member_declarations/index_member_declarations.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/index_member_declarations/index_member_declarations.ts @@ -35,4 +35,4 @@ a.name = "pig"; a.age = 12; Assert.equal(a.age, 12); a.add = "qindao"; -Assert.equal(a.add, "qindao"); +Assert.equal(a.add, "qindao"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_1.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_1.ts index efbeb274c2..90ac66d160 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_1.ts @@ -23,19 +23,57 @@ import { Assert } from '../../../../../suite/assert.js' class Base { - public a: number = 2; + public a: number; + constructor(a: number) { + this.a = a; + } + public add() { + this.a++; + } } - class Derived extends Base { - public b() { + public b: number; + constructor(a: number, b: number) { + super(a); + this.b = b; + } + public geta() { return this.a; } } -const derived = new Derived(); -let a = derived.a; -Assert.equal(a, 2); -let b = derived.b(); -Assert.equal(b, 2); -const base = new Base(); -a = base.a; -Assert.equal(a, 2); +let derived: Derived = new Derived(1, 2); +let x = derived.a; +Assert.equal(x, 1); +let y = derived.geta(); +Assert.equal(y, 1); +let z: Base = new Base(3); +Assert.equal(z.a, 3); +z.add(); +Assert.equal(z.a, 4); +class MyClass{ + public myArry: T[] = []; + public add(num: T): void { + this.myArry.push(num); + } + public max(): T { + let mNum = this.myArry[0]; + for (let i = 0; i < this.myArry.length; i++) { + if (mNum < this.myArry[i]) { + mNum = this.myArry[i]; + } + } + return mNum; + } +} +let h_m: MyClass = new MyClass(); +h_m.add(5); +h_m.add(4); +h_m.add(9); +h_m.add(15); +Assert.equal(h_m.max(), 15); +let h_m2: MyClass = new MyClass(); +h_m2.add('b'); +h_m2.add('a'); +h_m2.add('w'); +h_m2.add('f'); +Assert.equal(h_m2.max(), 'w'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_2.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_2.ts index aff50e9204..c8bb08dfaf 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_2.ts @@ -25,13 +25,25 @@ import { Assert } from '../../../../../suite/assert.js' class Base { private x: number = 1; - add() { + private y: number = 2; + addx() { this.x++; } get foo() { return this.x; } + public addxy(): number { + return this.x + this.y; + } + static f(a: Base, b: Derived) { + a.x = 1; + b.x = 1; + a.y = 1; + b.y = 1; + } } -const a: Base = new Base(); -a.add(); +class Derived extends Base { } +let a: Base = new Base(); +a.addx(); Assert.equal(a.foo, 2); +Assert.equal(a.addxy(), 4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_3.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_3.ts index 5b798caaea..93465706ca 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_3.ts @@ -25,21 +25,39 @@ import { Assert } from '../../../../../suite/assert.js' class Base { protected x: number = 1; - add() { + protected y: number = 4; + protected addxy() { + return this.x + this.y; + } + public addx() { this.x++; } - get foo() { + public get foo() { return this.x; } + static f(a: Base, b: Derived) { + a.x = 1; + b.x = 1; + a.y = 1; + b.y = 1; + } } class Derived extends Base { - get foo() { + public get add(): number { + return this.addxy() + } + public get foo() { return this.x; } + static f(b: Derived) { + b.x = 1; + b.y = 1; + } } -const a: Base = new Base(); -a.add(); +let a: Base = new Base(); +a.addx(); Assert.equal(a.foo, 2); -const b: Derived = new Derived(); -b.add(); +let b: Derived = new Derived(); +b.addx(); Assert.equal(b.foo, 2); +Assert.equal(b.add, 6); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types_1.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types_1.ts new file mode 100644 index 0000000000..90da40dc5c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types_1.ts @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Within the constructor and instance member functions of a class, the type of this is the this-type of that class type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class A { + public x: number; + public y: number; + constructor(x: number, y: number) { + this.x = x; + this.y = y; + } + public addx(): this { + this.x++; + return this + } + public addy(): this { + this.y++; + return this; + } + public add() { + return this.x + this.y; + } +} +class B extends A { + public z: number; + constructor(x: number, y: number, z: number) { + super(x, y); + this.z = z; + } + public addz(): this { + this.z++; + return this; + } +} +let a: A = new A(1, 1); +let b: B = new B(1, 1, 1); +Assert.equal(a.addx().x, 2); +Assert.equal(a.addx().y, 1); +Assert.equal(a.addx().add(), 5); +Assert.equal(a.addy().x, 4); +Assert.equal(a.addy().y, 3); +Assert.equal(a.add(), 7); +Assert.equal(b.addx().x, 2); +Assert.equal(b.addx().y, 1); +Assert.equal(b.addy().x, 3); +Assert.equal(b.addy().y, 3); +Assert.equal(b.addz().z, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types_2.ts similarity index 59% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types.ts rename to es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types_2.ts index e6832615d9..ae51565b7d 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types_2.ts @@ -14,8 +14,7 @@ */ /**--- description: > - A class declaration declares a new named type called a class type. - Within the constructor and instance member functions of a class, the type of this is the this-type of that class type + All instance property members of a class must satisfy the constraints implied by the index members of the class . module: ESNext isCurrent: true ---*/ @@ -23,39 +22,49 @@ import { Assert } from '../../../../../suite/assert.js' -class h_A { +class A { public h_x: number; - public h_f() { } - public h_g(h_a: any): any { - return undefined; - } constructor(h_x: number) { this.h_x = h_x; } - static h_s: string; + public h_f() { + this.h_x++; + } + public h_g(): any { + return this.h_x; + } + static h_s: string = "aa"; } -let h_a = new h_A(1); -class h_B extends h_A { +let aa: A = new A(1); +Assert.equal(aa.h_x, 1); +aa.h_f(); +Assert.equal(aa.h_x, 2); +class B extends A { public h_y: number; - public h_g(h_b: boolean) { return false; } constructor(h_x: number, h_y: number) { super(h_x); this.h_y = h_y; } + public h_g(): boolean { return false; } } -let h_b = new h_B(1, 2); -interface h_C { +let bb: B = new B(1, 2); +Assert.equal(bb.h_x, 1); +Assert.equal(bb.h_y, 2); +bb.h_f(); +Assert.equal(bb.h_x, 2); +Assert.equal(bb.h_g(), false); +interface C { h_x: number; h_f: () => void; - h_g: (h_a: any) => any; + h_g: () => any; } -let h_c: h_C = h_a; -Assert.equal(h_c.h_g(1), undefined); -interface h_D { +let c: C = aa; +Assert.equal(c.h_g(), 2); +interface D { h_x: number; h_y: number; h_f: () => void; - h_g: (h_b: boolean) => boolean; + h_g: () => boolean; } -let h_d: h_D = h_b; -Assert.isFalse(h_d.h_g(true)); +let d: D = bb; +Assert.equal(d.h_g(), false); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types_3.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types_3.ts new file mode 100644 index 0000000000..2122f76c3e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types_3.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The class type has a property for each constructor parameter declared with a public, private, or protected modifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class A { + public x: number = 10; + private y: number = 10; + protected z: number = 10; + constructor() { }; + public f() { + this.x++; + return this; + } + public gety(): number { + return this.y; + } + public getz(): number { + return this.z; + } + protected g(): boolean { + return false; + } + public getg() { + return this.g(); + } +} +class B extends A { + protected z: number = 20; + protected g(): boolean { + return true; + } +} +let a: A = new A(); +Assert.equal(a.x, 10); +Assert.equal(a.gety(), 10); +Assert.equal(a.getz(), 10); +Assert.equal(a.getg(), false); +Assert.equal(a.f().x, 11); +let b: B = new B(); +Assert.equal(b.x, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_1.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_1.ts index 1d0b696a3c..0eeb7cee80 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_1.ts @@ -32,3 +32,4 @@ class A { } let a = new A(); Assert.equal(a.a, 0); +Assert.equal(a.b, 0); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_2.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_2.ts index 84aea38fb7..83f781677c 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_2.ts @@ -26,9 +26,9 @@ import { Assert } from '../../../../../suite/assert.js' class A1 { - public num: number; + public numa: number; constructor(a: number) { - this.num = a; + this.numa = a; } } class B1 extends A1 { @@ -38,5 +38,8 @@ class B1 extends A1 { this.numb = b; } } -const b = new B1(2, 2); -Assert.equal(b.num, 2); +let a: A1 = new A1(1); +Assert.equal(a.numa, 1); +let b: B1 = new B1(2, 2); +Assert.equal(b.numa, 2); +Assert.equal(b.numb, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_3.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_3.ts index b954cb847f..4d8e22be4b 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_3.ts @@ -26,10 +26,13 @@ import { Assert } from '../../../../../suite/assert.js' class A { - r: number; - constructor(r: number) { - this.r = r; + public x: number; + public y: number; + constructor(x: number, y: number) { + this.x = x; + this.y = y; } } -let a = new A(1); -Assert.equal(a.r, 1); +let a = new A(1, 2); +Assert.equal(a.x, 1); +Assert.equal(a.y, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts index 4e0c13e613..8755124016 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts @@ -37,4 +37,4 @@ let p2 = new P(x2, y2); Assert.equal(p2.pro1, "one"); let x3: boolean = true; let p3 = new P(x3, y); -Assert.isBoolean(p3.pro1); +Assert.equal(p3.pro1, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_6.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_6.ts new file mode 100644 index 0000000000..98ad0473e6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_6.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A property for each static member variable declaration in the class body. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class A1 { + public numa: number; + constructor(a: number) { + this.numa = a; + } + static c: number = 20; +} +class B1 extends A1 { + public numb: number; + constructor(a: number, b: number) { + super(a); + this.numb = b; + } +} +let a: A1 = new A1(10); +Assert.equal(a.numa, 10); +Assert.equal(A1.c, 20); +let b: B1 = new B1(10, 20); +Assert.equal(b.numa, 10); +Assert.equal(b.numb, 20); +Assert.equal(B1.c, 20); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_7.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_7.ts new file mode 100644 index 0000000000..d97b249c6e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_7.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A property of a function type for each static member function declaration in the class body. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class A1 { + public numa: number; + constructor(a: number) { + this.numa = a; + } + static c = 10; + static f(): void { + this.c++; + } +} +class B1 extends A1 { + public numb: number; + constructor(a: number, b: number) { + super(a); + this.numb = b; + } + static f() { + this.c++; + return this.c + } +} +Assert.equal(A1.c, 10); +A1.f(); +Assert.equal(A1.c, 11); +Assert.equal(B1.c, 11); +Assert.equal(B1.f(), 12); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_8.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_8.ts new file mode 100644 index 0000000000..8435c66f74 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_8.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A property named 'prototype', the type of which is an instantiation of the class type with type Any supplied + as a type argument for each type parameter. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Animal { + public name: string; + constructor(name: string) { + this.name = name; + } +} +Assert.equal(typeof (Animal.prototype), "object"); +let cat = new Animal("Cat") +Assert.equal(Object.getPrototypeOf(cat) === Animal.prototype, true); +Assert.equal(Object.getPrototypeOf(Animal.prototype) === Object.prototype, true); +Assert.equal(Object.getPrototypeOf(Object.prototype) === null, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_1.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_1.ts index 500e6eb8ad..c813e63ef5 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_1.ts @@ -24,15 +24,22 @@ import { Assert } from '../../../../../suite/assert.js' class Shape { - color: string = "black"; - switchColor() { + public color: string = "black"; + protected side: number = 10; + constructor() { }; + public switchColor() { this.color = this.color === "black" ? "white" : "black"; } } -class Circle extends Shape { } -const circle = new Circle(); -let a = circle.color; +class Circle extends Shape { + get gside() { + return this.side; + } +} +let circle: Circle = new Circle(); +let a: string = circle.color; Assert.equal(a, "black"); circle.switchColor(); -let b = circle.color; +let b: string = circle.color; Assert.equal(b, "white"); +Assert.equal(10, circle.gside); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_2.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_2.ts index aa3105f80f..093a81f893 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_2.ts @@ -14,8 +14,7 @@ */ /**--- description: > - A property member in a derived class is said to override a property member in a base class - when the derived class property member has the same name and kind (instance or static) as the base class property member. + Only public and protected property members can be overridden. module: ESNext isCurrent: true ---*/ @@ -24,21 +23,29 @@ import { Assert } from '../../../../../suite/assert.js' class Shape { - color: string = "black"; - switchColor() { + public color: string = "black"; + protected side: number = 10; + constructor() { }; + public switchColor() { this.color = this.color === "black" ? "white" : "black"; } } class Circle extends Shape { - color: string = "red"; - - switchColor() { - this.color = this.color === "red" ? "green" : "red"; + public color: string = "red"; + protected side: number = 11; + get gside() { + return this.side; + } + public switchColor() { + this.color = this.color === "red" ? "white" : "black"; } } -const circle = new Circle(); -let a = circle.color; -Assert.equal(a, "red"); +let shape: Shape = new Shape(); +Assert.equal(shape.color, "black"); +shape.switchColor(); +Assert.equal(shape.color, "white"); +let circle: Circle = new Circle(); +Assert.equal(circle.color, "red"); circle.switchColor(); -let b = circle.color; -Assert.equal(b, "green"); +Assert.equal(circle.color, "white"); +Assert.equal(11, circle.gside); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_3.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_3.ts index 288514a9b5..42c1eecee2 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_3.ts @@ -15,7 +15,7 @@ /**--- description: > Base class static property members can be overridden by derived class static property members - of any kind as long as the types are compatible, as described above. + of any kind as long as the types are compatible. module: ESNext isCurrent: true ---*/ @@ -31,7 +31,6 @@ class Shape { } class Circle extends Shape { static color: string = "red"; - static switchColor() { this.color = this.color === "red" ? "green" : "red"; } @@ -40,4 +39,4 @@ let a = Circle.color; Assert.equal(a, "red"); Circle.switchColor(); let b = Circle.color; -Assert.equal(b, "green"); +Assert.equal(b, "green"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_5.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_5.ts new file mode 100644 index 0000000000..aa473982b5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_5.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A property member in a derived class is said to override a property member in a base class + when the derived class property member has the same name and kind (instance or static) as the base class property member. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Shape { + public color: string = "black"; + protected name: string = "shape"; + public switchColor() { + this.color = this.color === "black" ? "white" : "black"; + } + protected f(a: Shape, b: Circle) { + a.color = "blue"; + b.color = "blue"; + } + static size: number = 10; +} +class Circle extends Shape { + public color: string = "red"; + protected name: string = "circle"; + public switchColor() { + this.color = this.color === "red" ? "green" : "red"; + } + static size: number = 12; + protected f(a: Shape, b: Circle) { + a.color = "pink"; + b.color = "pink"; + } +} +let shape: Shape = new Shape(); +Assert.equal(shape.color, "black"); +shape.switchColor(); +Assert.equal(shape.color, "white"); +Assert.equal(Shape.size, 10); +let circle = new Circle(); +Assert.equal(circle.color, "red"); +circle.switchColor(); +Assert.equal(circle.color, "green"); +Assert.equal(Circle.size, 12); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_1.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_1.ts index c4b2200b96..5683f2888a 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_1.ts @@ -23,10 +23,25 @@ import { Assert } from '../../../../../suite/assert.js' class Person { - name: string = "rain"; - static age: number = 0; - constructor() { } + private _name: string; + public age: number; + constructor(name: string, age: number) { + this._name = name; + this.age = age; + } + public set name(name: string) { + this._name = name; + } + public get name() { + return this._name; + } + static language: string = "english"; + static ageAdd() { + return this.language + "aaa"; + } } -const per = new Person(); +let per: Person = new Person("rain", 22); Assert.equal(per.name, "rain"); -Assert.equal(Person.age, 0); +Assert.equal(per.age, 22); +Assert.equal(Person.language, "english"); +Assert.equal(Person.ageAdd(), "englishaaa"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts index 69c27e181b..868d4977ef 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts @@ -37,14 +37,39 @@ class Counter { this.count--; return this; } - - public getResult(): number { + public get Result(): number { return this.count; } } -const counter = new Counter(1); -counter.add(); -Assert.equal(counter.getResult(), 2); +let counter = new Counter(1); counter.add(); +Assert.equal(counter.add(), counter); +Assert.equal(counter.Result, 3); counter.subtract(); -Assert.equal(counter.getResult(), 2); +Assert.equal(counter.subtract(), counter); +Assert.equal(counter.Result, 1); +class P { + constructor(public num1: number, public num2: number) { } + public hypot() { + return Math.sqrt(this.num1 * this.num1 + this.num2 * this.num2); + } + static initial = new P(0, 0); +} +class ChildP extends P { + constructor(public x: number, public y: number, public z: number) { + super(x, y); + this.z = z; + } + public move(): this { + this.x += 1; + this.y += 1; + this.z += 1; + return this + } +} +let childp: ChildP = new ChildP(1, 2, 3); +childp.move(); +Assert.equal(childp.x, 2); +Assert.equal(childp.y, 3); +Assert.equal(childp.z, 4); +Assert.equal(childp.move(), childp); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts b/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts index 4d988e93f1..af88dcf3bd 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts @@ -29,16 +29,21 @@ class Person { tool(): number { return 30; } - static tool2() { + static tool1(): number { return this.n2; } - static get foo() { + static tool2() { + this.n2++; + return this; + } + static get foo(): number { return this.n2; } } let a: number = Person.n2; Assert.equal(a, 20); -let b: number = Person.tool2(); +let b: number = Person.tool1(); Assert.equal(b, 20); let c: number = Person.foo; Assert.equal(c, 20); +Assert.equal(Person, Person.tool2()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_accessor_declarations/member_accessor_declarations.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_accessor_declarations/member_accessor_declarations.ts index a0713729af..d4789e76dc 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_accessor_declarations/member_accessor_declarations.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_accessor_declarations/member_accessor_declarations.ts @@ -44,4 +44,4 @@ x.foo = 10; Assert.equal(x.foo, 10); Assert.equal(A.aa, 0); A.aa = 20; -Assert.equal(A.aa, 20); +Assert.equal(A.aa, 20); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts index b97a731c9b..8df54b7a99 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts @@ -22,18 +22,19 @@ import { Assert } from '../../../../../suite/assert.js' -class Point { +class P { constructor(public x: number, public y: number) { } - public distance(p: Point) { - var dx = this.x - p.x; - var dy = this.y - p.y; + public distance(p: P) { + let dx = this.x - p.x; + let dy = this.y - p.y; return Math.sqrt(dx * dx + dy * dy); } - static distance(p1: Point, p2: Point) { - return p1.distance(p2); + static add(p1: P) { + p1.x++; + return p1.x } } -var p1: Point = new Point(2, 2); -var p2: Point = new Point(1, 1); +let p1: P = new P(2, 2); +let p2: P = new P(1, 1); Assert.equal(p1.distance(p2), Math.sqrt(2)); -Assert.equal(Point.distance(p1, p2), Math.sqrt(2)); +Assert.equal(P.add(p1), 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_2.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_2.ts index d0eb468760..913abdd47c 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_2.ts @@ -32,4 +32,4 @@ let c = new Circle(); Assert.equal(c.radius, 1); Assert.equal(c.area(), Math.PI); c.radius = 2; -Assert.equal(c.area(), Math.PI * 4); +Assert.equal(c.area(), Math.PI * 4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts index 3d48544ea3..1b220996f1 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts @@ -33,4 +33,4 @@ class Point { } } Assert.equal(Point.pro(), "[object Object]"); -Assert.equal(Point.returnz(), undefined); +Assert.equal(Point.returnz(), undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts index 61f21a1b9a..bcbc62b837 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts @@ -22,21 +22,24 @@ import { Assert } from '../../../../../suite/assert.js' -class Point { +class P { constructor(public x: number, public y: number) { } - public toString() { - return "x=" + this.x + " y=" + this.y; + public add() { + return this.x + this.y; } } -class ColoredPoint extends Point { - constructor(x: number, y: number, public color: string) { +class childP extends P { + constructor(x: number, y: number, public z: number) { super(x, y); } - public toString() { - return super.toString() + " color=" + this.color; + public add() { + return super.add() + this.z; } } -let cp = new ColoredPoint(1, 2, "red"); -Assert.equal(cp.color, "red"); -Assert.equal(cp.x, 1); -Assert.equal(cp.y, 2); +let p = new P(1, 2); +Assert.equal(p.x, 1); +Assert.equal(p.y, 2); +Assert.equal(p.add(), 3); +let cp = new childP(1, 2, 3); +Assert.equal(cp.z, 3); +Assert.equal(cp.add(), 6); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts index 182f9a898c..d428053613 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts @@ -22,20 +22,18 @@ import { Assert } from '../../../../../suite/assert.js' -class A { - constructor(public a: number = 1) { } - static create() { +class P { + constructor(public a: number = 1, public b: number = 1) { } + static createthis() { return new this(); } } -class B extends A { - constructor(public b: number = 2) { +class CP extends P { + constructor(public a: number = 2, public b = 2) { super(); } } -// new A() -var x = A.create(); -// new B() -var y = B.create(); +let x = P.createthis(); +let y = CP.createthis(); Assert.equal(x.a, 1); -Assert.equal(y.a, 1); +Assert.equal(y.a, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts index 73b409830b..97ed1b4270 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts @@ -14,8 +14,7 @@ */ /**--- description: > - Member declarations with a static modifier are called static member declarations. - it is possible to have instance and static property members with the same name. + Initializers in static member variable declarations are executed once when the containing script or module is loaded. module: ESNext isCurrent: true ---*/ @@ -25,20 +24,16 @@ import { Assert } from '../../../../../suite/assert.js' class Point { constructor(public x: number, public y: number) { } - public distance(p: Point) { - var dx = this.x - p.x; - var dy = this.y - p.y; - return Math.sqrt(dx * dx + dy * dy); + public addc() { + Point.c++; } static origin = new Point(0, 0); - static distance(p1: Point, p2: Point) { - return p1.distance(p2); - } - static x: number = 10; + static c: number = 10; } -var p1: Point = new Point(2, 2); -var p2: Point = new Point(1, 1); -Assert.equal(p1.distance(p2), Math.sqrt(2)); -Assert.equal(Point.distance(p1, p2), Math.sqrt(2)); -Assert.equal(p1.distance(Point.origin), Math.sqrt(8)); -Assert.equal(Point.x, 10); +let a: Point = new Point(1, 1); +Assert.equal(Point.c, 10); +a.addc(); +Assert.equal(Point.c, 11); +let b: Point = new Point(1, 1); +b.addc(); +Assert.equal(Point.c, 12); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_2.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_2.ts index b3d35d834a..f6709f6ede 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_2.ts @@ -14,7 +14,7 @@ */ /**--- description: > - Every class automatically contains a static property member named 'prototype' + Instance member variable initializers are equivalent to assignments to properties of this in the constructor module: ESNext isCurrent: true ---*/ @@ -22,22 +22,37 @@ import { Assert } from '../../../../../suite/assert.js' -class Point { - public x: number; - public y: number; - constructor(x: number, y: number) { - this.x = x; - this.y = y; +class Staff1 { + public name: string; + public place: string; + public work: boolean; + constructor(name: string, place: string, work: boolean) { + this.name = name; + this.place = place; + this.work = work; + } + initializer(name: string, place: string, work: boolean) { + this.name = name; + this.place = place; + this.work = work; } - static origin = new Point(0, 0); } -class ColoredPoint extends Point { - constructor(x: number, y: number, public color: string) { - super(x, y); +class Staff2 { + public name: string; + public place: string; + public work: boolean; + constructor(name: string, place: string, work: boolean) { + this.name = name; + this.place = place; + this.work = work; } } -Assert.equal(ColoredPoint.prototype.color, undefined); -Assert.equal(ColoredPoint.prototype.x, undefined); -Assert.equal(ColoredPoint.prototype.y, undefined); -Assert.equal(Point.prototype.x, undefined); -Assert.equal(Point.prototype.y, undefined); +let em1 = new Staff1("zhangsan", "shanghai", true); +em1.initializer("wangwu", "hainan", true); +let em2 = new Staff2("lisi", "qingdao", true); +Assert.equal(em1.name, "wangwu"); +Assert.equal(em1.place, "hainan"); +Assert.equal(em1.work, true); +Assert.equal(em2.name, "lisi"); +Assert.equal(em2.place, "qingdao"); +Assert.equal(em2.work, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts index 89d71c8a10..bd4cc35054 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts @@ -22,21 +22,22 @@ import { Assert } from '../../../../../suite/assert.js' -class Staff1 { - constructor(public name: string, public place: string, public work = false) { } + +class A { + public x: number = 1; + public y: string = "name"; + public z: boolean = false; + constructor() { } } -class Staff2 { - public name: string; - public place: string; - public work: boolean; - constructor(name: string, place: string, work: boolean = false) { - this.name = name; - this.place = place; - this.work = work; +class B { + public x: number = 1; + public y: string = "name"; + public z: boolean + constructor(z: boolean = false) { + this.z = z; } } -let em1 = new Staff1("name", "qindao", false); -let em2 = new Staff2("name", "qingdao", true); -Assert.equal(em1.work, false); -Assert.equal(em2.work, true); - +let a = new A(); +Assert.equal(a.z, false); +let b = new B(); +Assert.equal(b.z, false); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/property_member_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/property_member_declarations_1.ts new file mode 100644 index 0000000000..ffc966b8c7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/property_member_declarations_1.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Member declarations with a static modifier are called static member declarations. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Point { + constructor(public x: number, public y: number) { } + public distance(p1: Point, p2: Point) { + let dx = p1.x - p2.x; + let dy = p1.y - p2.y; + return Math.sqrt(dx * dx + dy * dy); + } + static getx() { + return this.x; + } + static origin = new Point(0, 0); + static x: number = 10; +} +let p1: Point = new Point(2, 2); +let p2: Point = new Point(1, 1); +Assert.equal(p1.distance(p1, p2), Math.sqrt(2)); +Assert.equal(Point.getx(), 10); +Assert.equal(p1.distance(p1, Point.origin), Math.sqrt(8)); +Assert.equal(Point.x, 10); diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_5.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/property_member_declarations_2.ts similarity index 74% rename from es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_5.ts rename to es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/property_member_declarations_2.ts index ca5218be5b..12ffdf3f7d 100644 --- a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_5.ts +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/property_member_declarations_2.ts @@ -14,14 +14,13 @@ */ /**--- description: > - The declaration spaces of instance and static property members are separate. - Thus, it is possible to have instance and static property members with the same name. + it is possible to have instance and static property members with the same name. module: ESNext isCurrent: true ---*/ - -import { Assert } from "../../../../../suite/assert.js" + +import { Assert } from "../../../../suite/assert.js" class myClass { public x: number; @@ -30,10 +29,18 @@ class myClass { this.x = x; this.y = y; } + public add(): number { + return this.x + this.y; + } static x: number = 3; + static add(): number { + this.x++; + return this.x; + } } - let myTest = new myClass(1, 2); Assert.equal(myTest.x, 1); Assert.equal(myTest.y, 2); +Assert.equal(myTest.add(), 3); Assert.equal(myClass.x, 3); +Assert.equal(myClass.add(), 4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/property_member_declarations_3.ts b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/property_member_declarations_3.ts new file mode 100644 index 0000000000..66ce721daa --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/property_member_declarations_3.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Every class automatically contains a static property member named 'prototype' + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Point { + public x: number; + public y: number; + constructor(x: number, y: number) { + this.x = x; + this.y = y; + } + static origin = new Point(0, 0); +} +class ColoredPoint extends Point { + constructor(x: number, y: number, public color: string) { + super(x, y); + } +} +Assert.equal(ColoredPoint.prototype.color, undefined); +Assert.equal(ColoredPoint.prototype.x, undefined); +Assert.equal(ColoredPoint.prototype.y, undefined); +Assert.equal(Point.prototype.x, undefined); +Assert.equal(Point.prototype.y, undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/enums/enum_declarations/enum_declarations_3.ts b/es2panda/test/ts_extra_tests/test/spec/enums/enum_declarations/enum_declarations_3.ts index 0d9081920c..dba107b1aa 100644 --- a/es2panda/test/ts_extra_tests/test/spec/enums/enum_declarations/enum_declarations_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/enums/enum_declarations/enum_declarations_3.ts @@ -46,4 +46,17 @@ Assert.equal(h_date5, 'Fri'); let h_date6 = H_Date.Saturday; Assert.equal(h_date6, 'Satur'); let h_date7 = H_Date.Sunday; -Assert.equal(h_date7, 'Sun'); \ No newline at end of file +Assert.equal(h_date7, 'Sun'); + +const enum H_Odd { + a = 1, + b = a + 2, + c = a + 4, + d = c + 2, + e = b * b, +} +Assert.equal(H_Odd.a, 1); +Assert.equal(H_Odd.b, 3); +Assert.equal(H_Odd.c, 5); +Assert.equal(H_Odd.d, 7); +Assert.equal(H_Odd.e, 9); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/enums/enum_members/enum_members_1.ts b/es2panda/test/ts_extra_tests/test/spec/enums/enum_members/enum_members_1.ts index a1e648d870..1029a371f9 100644 --- a/es2panda/test/ts_extra_tests/test/spec/enums/enum_members/enum_members_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/enums/enum_members/enum_members_1.ts @@ -26,6 +26,10 @@ import { Assert } from '../../../../suite/assert.js' +function toLength(str: string): number { + return str.length; +} + enum ABCList { A, B, @@ -36,6 +40,7 @@ enum ABCList { G = 0x0f << 0x02, H = 0xff & 0xaa, I = E | F, + J = toLength(ABCList[11]), } Assert.equal(ABCList.A, 0); Assert.equal(ABCList.B, 1); @@ -46,3 +51,4 @@ Assert.equal(ABCList.F, -18); Assert.equal(ABCList.G, 60); Assert.equal(ABCList.H, 170); Assert.equal(ABCList.I, -17); +Assert.equal(ABCList.J, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_2.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_2.ts index 09c28ac84f..ca38ddf8de 100644 --- a/es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_2.ts @@ -38,7 +38,7 @@ let getTempItem = (id: any) => ({ id: id, name: "Temp" }); const TempAResult = getTempItem(123); Assert.equal(TempAResult.id, 123); -var getTempItemB = function (id: any) { +let getTempItemB = function (id: any) { return { id: id, name: "Temp", diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_4.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_4.ts new file mode 100644 index 0000000000..c238cf8a5f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_4.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A function expression introduces a new dynamically bound this, whereas an arrow function expression preserves the this of its enclosing context. + Arrow function expressions are particularly useful for writing callbacks, which otherwise often have an undefined or unexpected this. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class ToAlert { + information = "Have a good time!"; + start() { + let for_this = this; + setTimeout(function() { + for_this.information="sad boy"; + }, 2250); + Assert.notEqual(for_this.information,"sad boy") + } +}; +let Hwa = new ToAlert(); +Hwa.start(); + +Hwa.information = "boy!"; +Assert.isString(Hwa.information) +Assert.equal(Hwa.information,"boy!") \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_congruence_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_congruence_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_congruence_operator.ts rename to es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_congruence_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_equal_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_equal_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_equal_operator.ts rename to es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_equal_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_greater_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_greater_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_greater_operator.ts rename to es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_greater_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_greater_or_equal_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_greater_or_equal_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_greater_or_equal_operator.ts rename to es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_greater_or_equal_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_incongruence_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_incongruence_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_incongruence_operator.ts rename to es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_incongruence_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_less_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_less_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_less_operator.ts rename to es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_less_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_less_or_equal_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_less_or_equal_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_less_or_equal_operator.ts rename to es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_less_or_equal_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_unequal_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_unequal_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_operators/the_unequal_operator.ts rename to es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_unequal_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_and_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_and_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_and_operator.ts rename to es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_and_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_division_method_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_division_method_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_division_method_operator.ts rename to es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_division_method_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_left_shift_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_left_shift_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_left_shift_operator.ts rename to es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_left_shift_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_multiplication_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_multiplication_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_multiplication_operator.ts rename to es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_multiplication_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_or_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_or_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_or_operator.ts rename to es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_or_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_remainder_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_remainder_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_remainder_operator.ts rename to es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_remainder_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_right_shift_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_right_shift_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_right_shift_operator.ts rename to es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_right_shift_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_subtraction_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_subtraction_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_subtraction_operator.ts rename to es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_subtraction_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_unsigned_shift_to_the_right.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_unsigned_shift_to_the_right.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_unsigned_shift_to_the_right.ts rename to es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_unsigned_shift_to_the_right.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_xor_operator.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_xor_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_operators/the_xor_operator.ts rename to es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_xor_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_2.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_2.ts index ffa91c1630..bb29d63f53 100644 --- a/es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_2.ts @@ -27,7 +27,7 @@ type MyFunctionType = (x: number, y: number) => number; function myFunction(fn: MyFunctionType) { return fn(2, 3); } -const add: MyFunctionType = function (x, y) { +const add: MyFunctionType = function (x:number, y:number) { return x + y; }; const result = myFunction(add); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_3.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_3.ts index 34af633da7..42112a3510 100644 --- a/es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_3.ts @@ -31,7 +31,7 @@ function myFunction(obj: MyType) { Assert.isTrue(result); } -var h_x: MyType = { +let h_x: MyType = { fn: function func(x: number, y: string) { return true; } diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/class.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/class.ts index 188b7b895d..70d0bea0b4 100644 --- a/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/class.ts +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/class.ts @@ -31,5 +31,5 @@ class Car { this.agelimit = agelimit; } } -var car = new Car("Benci", 2); +let car = new Car("Benci", 2); Assert.equal(car.agelimit, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/parameter.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/parameter.ts index 0893470877..bc2916424a 100644 --- a/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/parameter.ts +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/parameter.ts @@ -32,4 +32,4 @@ class paramMethod { Assert.isNumber(age); } } -var newparam = new paramMethod("xiaoli", 18); +let newparam = new paramMethod("xiaoli", 18); diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_7.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_7.ts index 63ddd93fa9..68b54aaa78 100644 --- a/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_7.ts +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_7.ts @@ -35,6 +35,6 @@ class h_C { return this.num } } -var h_c = new h_C(10); +let h_c = new h_C(10); Assert.isNumber(h_c.get()) Assert.isNumber(h_c.set()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/parentheses/parentheses.ts b/es2panda/test/ts_extra_tests/test/spec/expressions/parentheses/parentheses.ts index c5d2881422..4900910bb9 100644 --- a/es2panda/test/ts_extra_tests/test/spec/expressions/parentheses/parentheses.ts +++ b/es2panda/test/ts_extra_tests/test/spec/expressions/parentheses/parentheses.ts @@ -23,11 +23,11 @@ import { Assert } from '../../../../suite/assert.js' -var addparent = function (n1: number, n2: number): number { +let addparent = function (n1: number, n2: number): number { return n1 + n2; }; // is equivalent to -var addnoparent = (n1: number, n2: number): number => n1 + n2; +let addnoparent = (n1: number, n2: number): number => n1 + n2; let isCorrect = addparent(11, 22) === addnoparent(11, 22); Assert.isTrue(isCorrect); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_1.ts b/es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_1.ts index 1aeb210cd4..c331d744fe 100644 --- a/es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_1.ts @@ -26,30 +26,30 @@ import { Assert } from '../../../../suite/assert.js' -// globally defined + let pp: Promise = Promise.resolve(1); -// Function + async function fetchTest1(): Promise { return await pp; } fetchTest1().then((params) => { Assert.equal(params, 1); }); -// Function : No Return Type + async function fetchTest1NoReturnType() { return await pp; } fetchTest1NoReturnType().then((params) => { Assert.equal(params, 1); }); -// Arrow Function + const fetchTest2 = async (): Promise => { return await pp; }; fetchTest2().then((params) => { Assert.equal(params, 1); }); -// Arrow Function : No Return Type + const fetchTest2NoReturnType = async () => { return await pp; }; @@ -58,11 +58,9 @@ fetchTest2NoReturnType().then((params) => { }); class Person { - // Method async fetchTest3(): Promise { return await pp; } - // Method : No Return Type async fetchTest3NoReturnType() { return await pp; } diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_2.ts b/es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_2.ts new file mode 100644 index 0000000000..1ddc1ac347 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_2.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Async Generator Functions + options: + lib:es2018 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +async function* ag() { + let i = 0; + let c = 0; + yield* [0, 0, 0, 0]; + while (true) { + yield c++; + i++; + if (i > 20) { + break; + } + } +} +function newArray() { + let arr: number[] = [0, 0, 0, 0]; + let i = 0; + let c = 0; + while (true) { + arr[i + 4] = c; + c++; + i++; + if (i > 20) { + break; + } + } + return arr; +} +let arr = ag(); +async function showAsyncGenerator(arr: AsyncGenerator) { + let i = 0; + for await (let x of arr) { + Assert.equal(x as number, arr2[i++]); + } +} +let arr2 = newArray(); +showAsyncGenerator(arr); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_3.ts b/es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_3.ts new file mode 100644 index 0000000000..3054c731b9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_3.ts @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Async Iterators Functions + options: + lib:es2018 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function createAsyncInterator(arr: any[]): AsyncIterator { + let index = 0; + let len = arr.length; + return { + async next() { + return new Promise((resolve, reject) => { + if (index < len) { + resolve({ value: arr[index++], done: false }); + } else { + resolve({ value: undefined, done: true }); + } + }); + }, + }; +} + +export function newArray(len: number, step: number = 1) { + if (len <= 0) { return [] }; + let arr: any[] = []; + let x: number = 0; + for (let i: number = 0; i < len; i++) { + arr[i] = x + step; + } + return arr; +} +let arr = newArray(15); +async function exp(arr: any[]) { + let asy = createAsyncInterator(arr); + let i = 0; + let fg; + while (true) { + if (fg == true) { + break; + } + await asy.next().then((v) => { + if (v.done == true) { + fg = true; + } + Assert.equal(v.value, arr[i++]); + return; + }); + } +} +exp(arr); + diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_4.ts b/es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_4.ts new file mode 100644 index 0000000000..d6a9232379 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_4.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Async Iterators Functions + options: + lib:es2018 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import { newArray } from './asynchronous_functions_3.js'; + +async function asc(arr: any[]) { + let i = 0; + for await (let x of arr) { + Assert.equal(x, arr[i]); + i++ + } +} +let arr = newArray(15, 5); +asc(arr); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts b/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts index 06d22b813a..8f90e8d1b7 100644 --- a/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts +++ b/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts @@ -23,9 +23,8 @@ import { Assert } from '../../../../suite/assert.js' -// string literal type type testStr = "caihua"; -// number literal type + type testStrNum = 12; class Person { m_name: testStr | undefined; diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts b/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts index ee0f7341dc..602be0ad4a 100644 --- a/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts +++ b/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts @@ -24,7 +24,6 @@ import { Assert } from '../../../../suite/assert.js' -// v is any[]. function test(...v: any[]) { Assert.isString(v[0]); Assert.isNumber(v[1]); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/function_declarations/function_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/functions/function_declarations/function_declarations_1.ts index 24c3af62ae..1efd942935 100644 --- a/es2panda/test/ts_extra_tests/test/spec/functions/function_declarations/function_declarations_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/functions/function_declarations/function_declarations_1.ts @@ -37,9 +37,7 @@ function add(arg1: string | number, arg2: string | number) { return `${arg1}${arg2}`; } } -// (number, number) + Assert.equal(add(0, 1), 1); -// (string, number) Assert.equal(add("0", 1), "01"); -// (string, string) Assert.equal(add("0", "1"), "01"); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/function_declarations/function_declarations_2.ts b/es2panda/test/ts_extra_tests/test/spec/functions/function_declarations/function_declarations_2.ts index 6490e33a31..ecc449b0f7 100644 --- a/es2panda/test/ts_extra_tests/test/spec/functions/function_declarations/function_declarations_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/functions/function_declarations/function_declarations_2.ts @@ -22,10 +22,10 @@ import { Assert } from '../../../../suite/assert.js' -function add(a: string, b: string): string; -function add(a: number, b: number): number; -function add(a: string, b: number): string; -function add(arg1: string | number, arg2: string | number) { +export function add1(a: string, b: string): string; +export function add1(a: number, b: number): number; +export function add1(a: string, b: number): string; +export function add1(arg1: string | number, arg2: string | number) { if (typeof arg1 === "number" && typeof arg2 === "number") { return arg1 + arg2; } @@ -35,9 +35,11 @@ function add(arg1: string | number, arg2: string | number) { } } -// (number, number) -Assert.equal(add(0, 1), 1); -// (string, number) -Assert.equal(add("0", 1), "01"); -// (string, string) -Assert.equal(add("0", "1"), "01"); +Assert.equal(add1(0, 1), 1); +Assert.equal(add1("0", 1), "01"); +Assert.equal(add1("0", "1"), "01"); + +declare function add2(a: string, b: string): string; +declare function add2(a: number, b: number): number; +declare function add2(a: string, b: number): string; +declare function add2(arg1: string | number, arg2: string | number): unknown; diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_4.ts b/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_4.ts index 9a30fc41e4..0d11b60153 100644 --- a/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_4.ts +++ b/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_4.ts @@ -26,13 +26,11 @@ import { Assert } from '../../../../suite/assert.js' -// stated type class Test { a: number; constructor(a: number) { this.a = a; } } function f(x: number, y: Test = { a: 1 }, z = "hello") { - // the type of the parameter is the widened Assert.isString(z); return { x, @@ -40,6 +38,6 @@ function f(x: number, y: Test = { a: 1 }, z = "hello") { z: z, }; } -// y and z are optional + Assert.equal(f(0).yy.a, 1); Assert.equal(f(0).z, "hello"); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_5.ts b/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_5.ts index 2cb9debe1a..f98730b2bd 100644 --- a/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_5.ts +++ b/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_5.ts @@ -24,8 +24,8 @@ import { Assert } from '../../../../suite/assert.js' -let a = 1; -function f(x: number, y = x * 2, z = x + y) { +let a = 3; +function f(x: number = a, y = x * 2, z = x + y) { let b = 12; function g(xx = b) { return xx; @@ -33,6 +33,10 @@ function f(x: number, y = x * 2, z = x + y) { let c = g(); return { x, y, z, g: c }; } +Assert.equal(f().x, 3); +Assert.equal(f().y, 6); +Assert.equal(f().z, 9); +Assert.equal(f().g, 12); Assert.equal(f(1).x, 1); Assert.equal(f(1).y, 2); Assert.equal(f(1).z, 3); diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/function_overloads/function_overloads_1.ts b/es2panda/test/ts_extra_tests/test/spec/functions/function_overloads/function_overloads_1.ts index a0598bff36..07bee7d2aa 100644 --- a/es2panda/test/ts_extra_tests/test/spec/functions/function_overloads/function_overloads_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/functions/function_overloads/function_overloads_1.ts @@ -27,10 +27,10 @@ function add(): number; function add(x: number): number; function add(y: number): number; function add(x: number, y: number): number; -function add(xOry?: number, y?: number): number { +function add(x?: number, y?: number): number { let sum: number = 0; - if (xOry) { - sum += xOry; + if (x) { + sum += x; } if (y) { sum += y; diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/generator_functions/generator_functions_3.ts b/es2panda/test/ts_extra_tests/test/spec/functions/generator_functions/generator_functions_3.ts new file mode 100644 index 0000000000..237d92a46d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/functions/generator_functions/generator_functions_3.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Generator Functions + options: + lib: es2015 + target: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function* g1(n: number, step: number = 1): Generator { + let i: number = 0, c: number = 0; + while (true) { + yield i += step; + c++; + if (c >= n) { + break; + } + } +} +function getGeneratorArray(gen: Generator, step: number = 1): any[] { + let c: number = 0; + let arr: any[] = []; + let i: number = 0; + while (true) { + let next = gen.next(); + if (next.done == true) { + break; + } + arr[i] = next.value; + i++; + Assert.equal(next.value, c += step); + } + return arr; +} +let genS1 = g1(10); +let arr: number[] = getGeneratorArray(genS1); +Assert.equal(JSON.stringify(arr), '[1,2,3,4,5,6,7,8,9,10]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/generic_functions/generic_functions_1.ts b/es2panda/test/ts_extra_tests/test/spec/functions/generic_functions/generic_functions_1.ts index a8968c2096..054e367e88 100644 --- a/es2panda/test/ts_extra_tests/test/spec/functions/generic_functions/generic_functions_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/functions/generic_functions/generic_functions_1.ts @@ -23,9 +23,16 @@ import { Assert } from '../../../../suite/assert.js' -function identity(arg: T): T { +type XY = { x: number; y: number }; + +function f1(arg: T): T { + return arg; +} +Assert.equal(f1(0), 0); +Assert.equal(f1("hello"), "hello"); +Assert.equal(f1(true), true); + +function f2(arg: T): T { return arg; } -Assert.equal(identity(0), 0); -Assert.equal(identity("hello"), "hello"); -Assert.equal(identity(true), true); +Assert.equal(JSON.stringify(f2<{ x: number, y: number, z: number }>({ x: 0, y: 0, z: 0 })), '{"x":0,"y":0,"z":0}'); diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/enums/enums.ts b/es2panda/test/ts_extra_tests/test/spec/grammar/enums/enums.ts index dbb432d691..18f047adf9 100644 --- a/es2panda/test/ts_extra_tests/test/spec/grammar/enums/enums.ts +++ b/es2panda/test/ts_extra_tests/test/spec/grammar/enums/enums.ts @@ -39,3 +39,30 @@ Assert.equal(CED["False"], 0); Assert.equal(CED["True"], 1); Assert.equal(CED["DEF"], 1024); Assert.equal(CED.Ver, "1.0.1"); + +function toLength(str: string): number { + return str.length; +} + +enum ABCList { + A, + B, + C = "string".length, + D = 10, + E, + F = ~17, + G = 0x0f << 0x02, + H = 0xff & 0xaa, + I = E | F, + J = toLength(ABCList[11]), +} +Assert.equal(ABCList.A, 0); +Assert.equal(ABCList.B, 1); +Assert.equal(ABCList.C, 6); +Assert.equal(ABCList.D, 10); +Assert.equal(ABCList.E, 11); +Assert.equal(ABCList.F, -18); +Assert.equal(ABCList.G, 60); +Assert.equal(ABCList.H, 170); +Assert.equal(ABCList.I, -17); +Assert.equal(ABCList.J, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/scripts_and_modules.ts b/es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/scripts_and_modules.ts new file mode 100644 index 0000000000..f719c24c2e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/scripts_and_modules.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + this appendix contains a summary of the grammar found in the main document. + typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. + module: ESNext + isCurrent: true + ---*/ + + +import * as sf1 from "./source_file_1.js"; +import checkGenerator from "./source_file_2.js"; +import arr1 from "./source_file_3.js"; +import PointXY from "./source_file_4.js"; +import { Assert } from "../../../../suite/assert.js"; + +Assert.equal(sf1.num, 1408); + +Assert.equal(sf1.show(), "show"); + +let a3: Generator = sf1.arr3(9); +checkGenerator(a3, 3); + +let green = new sf1.Color(0, 255, 0); +Assert.equal(JSON.stringify(green.ColorData), '[0,255,0]'); + +let p: sf1.Point = { x: 0, y: 0 }; +Assert.equal(p.x, 0); +Assert.equal(p.y, 0); + +let arrstrnum: sf1.ArrStrNum; +arrstrnum = ["a", "b", "c", "d", "e"]; +Assert.equal(JSON.stringify(arrstrnum), '["a","b","c","d","e"]'); +arrstrnum = [1, 2, 3, 4, 5]; +Assert.equal(JSON.stringify(arrstrnum), '[1,2,3,4,5]'); +arrstrnum = ["a", 2, "c"]; +Assert.equal(JSON.stringify(arrstrnum), '["a",2,"c"]'); +arrstrnum = "arrstrnum"; +Assert.isString(arrstrnum); +arrstrnum = 0; +Assert.isNumber(arrstrnum); + +Assert.equal(sf1.XXXX.x, 1024); +Assert.equal(sf1.XXXX.showXXXX(), "showXXXX"); + +let a1 = arr1(9); +checkGenerator(a1, 1); + +let p1 = new PointXY(10, 10); +Assert.equal(JSON.stringify(p1.point), '[10,10]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_1.ts b/es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_1.ts new file mode 100644 index 0000000000..a19235627c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_1.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export let num: number = 1408; +export function show() { return "show"; }; +export function* arr3(n: number): Generator { + let i = 0; + let c = 0; + if (n > 0) { + while (true) { + yield i += 3; + if (c >= n) { + break; + } else { + c++; + } + } + } +} +export class Color { + Red: number; + Green: number; + Blue: number; + ColorData: [number, number, number] = [0, 0, 0]; + getColor(): [number, number, number] { + this.ColorData = [this.Red, this.Green, this.Blue]; + return this.ColorData; + } + constructor(red: number, green: number, blue: number) { + this.Red = red; + this.Green = green; + this.Blue = blue; + this.getColor(); + } +} +export interface Point { + x: number; + y: number; +} +export type ArrStrNum = string[] | number[] | (string | number)[] | string | number; +export enum ABC { + A, B, C, D, E, +} +export namespace XXXX { + export let x: number = 1024; + export function showXXXX() { return "showXXXX"; }; +} +export declare let dnum: number; diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_2.ts b/es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_2.ts new file mode 100644 index 0000000000..624f3d3f5a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_2.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +import { Assert } from "../../../../suite/assert.js"; +export default function checkGenerator(gen: Generator, step: number) { + let c = 0; + while (true) { + let next = gen.next(); + if (next.done == true) { + break; + } + Assert.equal(next.value, c += step); + } +} \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_3.ts b/es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_3.ts new file mode 100644 index 0000000000..bc333e40b1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_3.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export default function* arr1(n: number): Generator { + let i = 0; + let c = 0; + if (n > 0) { + while (true) { + yield i += 1; + if (c >= n) { + break; + } else { + c++; + } + } + } +} \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_4.ts b/es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_4.ts new file mode 100644 index 0000000000..67fbe4f588 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_4.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export default class PointXY { + x: number; y: number; + point: [number, number] = [0, 0]; + getPoint(): [number, number] { + this.point = [this.x, this.y]; + return this.point; + } + constructor(x: number, y: number) { + this.x = x; + this.y = y; + this.getPoint(); + } +} \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/types/types.ts b/es2panda/test/ts_extra_tests/test/spec/grammar/types/types.ts index 11300ca38d..a7f8823b07 100644 --- a/es2panda/test/ts_extra_tests/test/spec/grammar/types/types.ts +++ b/es2panda/test/ts_extra_tests/test/spec/grammar/types/types.ts @@ -15,7 +15,8 @@ /**--- description: > this appendix contains a summary of the grammar found in the main document. - typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. + typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) + and this appendix lists only productions that are new or modified from the ECMAScript grammar. options: target: es2015 lib: es2015 @@ -51,6 +52,36 @@ let v: Data = { data: 1024, ver: "1.0.1" }; Assert.equal(v.data, 1024); Assert.equal(v.ver, "1.0.1"); +function addNumbers(...num: number[]): number { + let n: number = 0; + for (let i: number = 0; i < num.length; i++) { + n += num[i]; + } + return n; +} +Assert.equal(addNumbers(5, 5, 5, 5, 5), 25); + +interface StrIndex { + [key: string]: number; +} +let si: StrIndex = { C: 3, D: 4 }; +si['A'] = 1; +si.B = 2; +Assert.equal(si.A, 1); +Assert.equal(si['B'], 2); +Assert.equal(si.C, 3); +Assert.equal(si['D'], 4); +Assert.equal(JSON.stringify(si), '{"C":3,"D":4,"A":1,"B":2}'); + +interface NumIndex { + [key: number]: string; +} +let ni: NumIndex = { 1: 'A' }; +ni[3] = 'C'; +Assert.equal(ni[1], 'A'); +Assert.equal(ni[3], 'C'); +Assert.equal(JSON.stringify(ni), '{"1":"A","3":"C"}'); + class AB{ a: T | undefined; b: U | undefined; diff --git a/es2panda/test/ts_extra_tests/test/spec/interfaces/1_interface_declarations/interface_declarations_3.ts b/es2panda/test/ts_extra_tests/test/spec/interfaces/1_interface_declarations/interface_declarations_3.ts index e498b39d12..11351ac9fa 100644 --- a/es2panda/test/ts_extra_tests/test/spec/interfaces/1_interface_declarations/interface_declarations_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/interfaces/1_interface_declarations/interface_declarations_3.ts @@ -28,24 +28,6 @@ import { Assert } from '../../../../suite/assert.js' (h_a: string, h_b: string): number; } - let ps: StringC = - (h_a: string, h_b: string): number => { - return 1 - }; - - class Class { - h_x: number; - h_y: number; - - constructor(h_a: number, h_b: number) { - this.h_x = h_a; - this.h_y = h_b; - } - } - - let pt: Class = new Class(0, 1); - // assert declare named function - Assert.equal(pt.h_x, 0); - // assert constructor types - Assert.equal(pt.h_y, 1); + let sc: StringC = (h_a: string, h_b: string): number => { return h_a.charCodeAt(0) + h_b.charCodeAt(0); }; + Assert.equal(sc('a', 'b'), 195); }; diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/import_alias_declarations/import_alias_declarations_3.ts b/es2panda/test/ts_extra_tests/test/spec/namespaces/import_alias_declarations/import_alias_declarations_3.ts index 920cfd5cef..dc177e8eaa 100644 --- a/es2panda/test/ts_extra_tests/test/spec/namespaces/import_alias_declarations/import_alias_declarations_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/namespaces/import_alias_declarations/import_alias_declarations_3.ts @@ -20,28 +20,8 @@ ---*/ -class AssertionError extends Error { - constructor(public msg: string) { - super(); - this.msg = ""; - this.msg = msg; - } -} - -function defaultMessage(actual: any, expect: any, flag: boolean = true) { - if (flag == true) { - return "expected '" + expect + "' ,but was '" + actual + "'."; - } else { - return "expected not '" + expect + "' ,but was '" + actual + "'."; - } +import { Assert } from "../../../../suite/assert.js"; -} - -function equal(actual: any, expect: any, msg?: string) { - if (actual != expect) { - throw new AssertionError(msg ? msg : defaultMessage(actual, expect)); - } -} namespace IAD1 { export var lv: number = 5; export interface GGI { @@ -59,10 +39,10 @@ namespace IAD2 { } var i1 = IAD2.i2; var gi: IAD2.GI = { UIName: "GI", Cost: 200, Strength: 100 }; -equal(i1, 10); -equal(gi.UIName, "GI"); -equal(gi.Cost, 200); -equal(gi.Strength, 100); +Assert.equal(i1, 10); +Assert.equal(gi.UIName, "GI"); +Assert.equal(gi.Cost, 200); +Assert.equal(gi.Strength, 100); namespace IAD3 { export var i = 0; @@ -77,5 +57,5 @@ namespace IAD3 { export namespace IAD4 { export import I3 = IAD3; } -equal(IAD4.I3.i, 0); -equal(IAD4.I3.ux5(), 25); +Assert.equal(IAD4.I3.i, 0); +Assert.equal(IAD4.I3.ux5(), 25); diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_1.ts index 4fa81baceb..47588be5e2 100644 --- a/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_1.ts @@ -32,6 +32,7 @@ namespace A { var varA: A.TA = { TName: "TA", Ver: 1.5 } Assert.equal(varA.TName, "TA"); Assert.equal(varA.Ver, 1.5); + module B { export interface TB { SkillName: string; diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_00.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_00.ts new file mode 100644 index 0000000000..4c22da7bc1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_00.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +type Color = [number, number, number]; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_files_dependencies.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_files_dependencies.ts new file mode 100644 index 0000000000..257831a87f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_files_dependencies.ts @@ -0,0 +1,28 @@ +/// +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The TypeScript compiler automatically determines a source file's dependencies and includes those dependencies in the program being compiled. + Any files included as dependencies in turn have their references analyzed in a transitive manner until all dependencies have been determined. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../../../suite/assert.js"; + +let red: Color = [255, 0, 0]; +Assert.equal(JSON.stringify(red), '[255,0,0]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_declarations_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_1.ts rename to es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_declarations_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_2.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_declarations_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_2.ts rename to es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_declarations_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_3.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_declarations_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_3.ts rename to es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_declarations_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_4.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_declarations_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_4.ts rename to es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_declarations_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_5.ts b/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_declarations_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_default_declarations_5.ts rename to es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_declarations_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_1.ts b/es2panda/test/ts_extra_tests/test/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_1.ts index 78369cf9e0..9c29f77149 100644 --- a/es2panda/test/ts_extra_tests/test/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_1.ts @@ -53,4 +53,13 @@ let myObject2 = 1; if (myObject2 == 2) { myObject2 = 3; } -Assert.equal(1, myObject2); \ No newline at end of file +Assert.equal(1, myObject2); + +let und: undefined; +let flag = false; +if (und) { + flag = true; +} else { + flag = false; +} +Assert.isFalse(flag); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_4.ts b/es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_4.ts new file mode 100644 index 0000000000..a884aa1e6c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_4.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Blocks {} + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +{ + var block1: number | undefined = 1024; + let block2: string | undefined = "NARC"; + Assert.equal(block1, 1024); + Assert.equal(block2, "NARC"); +} +{ + var block1: number | undefined; + let block2: string | undefined; + Assert.equal(block1, 1024); + Assert.isUndefined(block2); +} \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/for_statements/for_statements.ts b/es2panda/test/ts_extra_tests/test/spec/statements/for_statements/for_statements.ts index e15eda2d34..1205fd4b4a 100644 --- a/es2panda/test/ts_extra_tests/test/spec/statements/for_statements/for_statements.ts +++ b/es2panda/test/ts_extra_tests/test/spec/statements/for_statements/for_statements.ts @@ -22,7 +22,7 @@ import { Assert } from '../../../../suite/assert.js' let result = 0; -for (let i = 0; i < 10; i++) { +for (let i: number = 0; i < 10; i++) { result++; } diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_1.ts b/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_1.ts index 11088b2fcb..8eae01c6f4 100644 --- a/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_1.ts @@ -25,19 +25,14 @@ import { Assert } from '../../../../../suite/assert.js' -// any var h_a; -// number var h_b: number; -// number var h_c = 30; -// { x: number; y: string; } var h_d = { x: 40, y: "hello" }; -// any var h_e: any = "test"; h_a = 1; Assert.equal(1, h_a); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/Intersection_Types/Intersection_types_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/Intersection_Types/Intersection_types_1.ts index c825705bfc..f984b6777a 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/Intersection_Types/Intersection_types_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/Intersection_Types/Intersection_types_1.ts @@ -30,7 +30,7 @@ interface A1 { interface B1 { str1: string; } -var ns1: A1 & B1 = { num1: 1, str1: "b" }; +let ns1: A1 & B1 = { num1: 1, str1: "b" }; Assert.equal(ns1.num1, 1); Assert.equal(ns1.str1, "b"); enum Color { @@ -44,7 +44,7 @@ interface A2 { interface B2 { str2: Color; } -var ns2: A2 & B2 = { num2: ["a2", 1], str2: Color.Red1 }; +let ns2: A2 & B2 = { num2: ["a2", 1], str2: Color.Red1 }; Assert.equal(ns2.num2[0], "a2"); Assert.equal(ns2.str2, 1); interface A3 { @@ -53,7 +53,7 @@ interface A3 { interface B3 { str3: boolean; } -var ns3: A3 & B3 = { num3: [1, 2, 3], str3: true }; +let ns3: A3 & B3 = { num3: [1, 2, 3], str3: true }; Assert.equal(ns3.str3, true); interface A4 { num4: number; @@ -64,7 +64,7 @@ interface B4 { interface C4 { cm: any; } -var ns4: A4 & B4 & C4 = { num4: 1, str4: "b4", cm: 3 }; +let ns4: A4 & B4 & C4 = { num4: 1, str4: "b4", cm: 3 }; Assert.equal(ns4.num4, 1); Assert.equal(ns4.str4, "b4"); Assert.equal(ns4.cm, 3); @@ -74,15 +74,5 @@ interface XX { interface YY { obj: B1; } -var xxyy: XX & YY = { obj: ns1 }; -Assert.equal(xxyy.obj.num1, 1); -type T1 = (str1: string, str2: string) => void; -type T2 = (num1: number, num2: number) => void; -var t: T1 & T2 = (ns: string | number, NS: string | number) => { }; -t("hello", "world"); -t(1, 2); -type T3 = (a: any, b: boolean) => void; -var t2: T1 & T2 & T3 = ( - nsa: string | number | any, - bns: string | number | boolean -) => { }; \ No newline at end of file +let xxyy: XX & YY = { obj: ns1 }; +Assert.equal(xxyy.obj.num1, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/Intersection_Types/intersection_types_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/Intersection_Types/intersection_types_2.ts index b169902e3c..27fc57353d 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/Intersection_Types/intersection_types_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/Intersection_Types/intersection_types_2.ts @@ -20,7 +20,7 @@ ---*/ -import {Assert} from '../../../../suite/assert.js' +import { Assert } from '../../../../suite/assert.js' function getSmallPet(name: string | number) { return name; @@ -38,5 +38,4 @@ let man: PersonMan = { sex: "man" } let getpersonname = getPerson(man); -Assert.equal(getpersonname, "join"); - +Assert.equal(getpersonname, "join"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_1.ts index d598923943..d8e97e6992 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_1.ts @@ -29,22 +29,27 @@ class Test { this.name = name; } } -// create instances of implementations of named types -const tt = new Test("caihua"); +let tt = new Test("caihua"); Assert.equal(tt.name, "caihua"); - +interface A { + a: string; +} +function f(obj: A) { + obj.a = obj.a + "bb"; +} +let obj: A = { a: "aa" }; +f(obj); +Assert.equal(obj.a, "aabb"); enum Color { Red, Green, Blue, } - let a: Color.Red = Color.Red; Assert.equal(a, Color.Red); - type pp = number | string; let b: pp; b = 10; -Assert.isNumber(b); +Assert.equal(b, 10); b = "hello"; -Assert.isString(b); +Assert.equal(b, "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_2.ts index e920b32eba..4da21efaaa 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_2.ts @@ -21,15 +21,15 @@ ---*/ -import {Assert} from '../../../../suite/assert.js' +import { Assert } from '../../../../suite/assert.js' interface TestInterface { age: number; } class TestClass { - age: number; - constructor(age:number){ - this.age=age + public age: number; + constructor(age: number) { + this.age = age } } function test1(v: TestInterface) { @@ -41,7 +41,5 @@ function test2(v: TestClass) { let ee = { age: 18, }; - Assert.equal(test1(ee), 18); -Assert.equal(test2(ee), 18); - +Assert.equal(test2(ee), 18); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_3.ts index 33e5cf75fa..1a804e2ed7 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_3.ts @@ -21,14 +21,13 @@ ---*/ -import {Assert} from '../../../../suite/assert.js' +import { Assert } from '../../../../suite/assert.js' interface Person { m_name: string; m_age: number; getName(name: string): string; } - type Optional = { [P in keyof T]: T[P] }; let cc: Optional = { m_age: 18, @@ -39,4 +38,4 @@ let cc: Optional = { }; Assert.equal(cc.m_age, 18); Assert.equal(cc.m_name, "caihua"); -Assert.equal(cc.getName("caihua"), "caihua"); +Assert.equal(cc.getName("caihua"), "caihua"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_4.ts b/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_4.ts index 51d5571cbd..25e67c6016 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_4.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_4.ts @@ -35,13 +35,11 @@ interface Pi { front: T; later: U; } - function test(v: Pi) { Assert.equal(v.front, "abc"); Assert.equal(v.later.x, 1); Assert.equal(v.later.y, 1); } -// object literal test({ front: "abc", later: { x: 1, y: 1 } }); let cc: Pi; cc = { @@ -51,5 +49,4 @@ cc = { y: 1, }, }; -// type reference -test(cc); +test(cc); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_1.ts index 2f7e82f1f1..5a70e7896c 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_1.ts @@ -21,24 +21,23 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -var arr1: Array = ["ABC", "DEF", "GHI"]; -var arr2: Array = [1, 3, 5, 7, 9]; -var arr3: Array = [true, false]; -var arr4: Array = [Object, { 0xff: "0xFF" }]; -Assert.isString(arr1[2]); -var objArray: object[] = []; +let arr1: Array = ["ABC", "DEF", "GHI"]; +let arr2: Array = [1, 3, 5, 7, 9]; +let arr3: Array = [true, false]; +let arr4: Array = [Object, { 0xff: "0xFF" }]; +Assert.equal(arr1[0], "ABC"); +Assert.equal(arr2[0], 1); +Assert.equal(arr3[0], true); +Assert.equal(arr4[0], Object); +let objArray: object[] = []; arr1.forEach(function (element, index, arr) { objArray[index] = { index: index, element: element, arr: arr }; }); -Assert.isString(arr2.toString()); Assert.equal(arr2.toString(), "1,3,5,7,9"); -Assert.isNumber(arr3.length); Assert.equal(arr3.length, 2); -Assert.isNumber(arr2.pop()); -Assert.equal(arr2.pop(), 7); -arr2.push(15); -Assert.equal(arr2.toString(), "1,3,5,15"); +Assert.equal(arr2.pop(), 9); +Assert.equal(arr2.toString(), "1,3,5,7"); arr3[0] = false; -Assert.equal(arr3[0], false); +Assert.equal(arr3[0], false); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_2.ts index b6972aff57..2c8c61db45 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_2.ts @@ -20,10 +20,9 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -var arr: Array = ["A", "B", "C", "D", "E", "F", "G", "H", "I"]; -Assert.isString(arr[5]); +let arr: Array = ["A", "B", "C", "D", "E", "F", "G", "H", "I"]; +Assert.equal(arr[0], "A"); Assert.equal(arr[5], "F"); -Assert.isNumber(arr.length); -Assert.equal(arr.length, 9); +Assert.equal(arr.length, 9); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_3.ts index bf80a6cf34..c059cef765 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_3.ts @@ -20,18 +20,17 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -var arr6: number[] = [1, 3, 5, 7, 9]; -var arr7: boolean[] = [true, false, true, false, true]; -var arr8: string[] = ["a", "b", "c", "d", "e", "f"]; -var arr9: object[] = [{ 0x00: "0x00" }, { 0x01: "0x01" }]; +let arr6: number[] = [1, 3, 5, 7, 9]; +let arr7: boolean[] = [true, false, true, false, true]; +let arr8: string[] = ["a", "b", "c", "d", "e", "f"]; +let arr9: object[] = [{ 0x00: "0x00" }, { 0x01: "0x01" }]; arr6[3] = 14; Assert.equal(arr6[3], 14); -Assert.isBoolean(arr7[2]); Assert.equal(true, arr7[2]); Assert.equal(arr8.toString(), "a,b,c,d,e,f"); arr8.pop(); Assert.equal(arr8.toString(), "a,b,c,d,e"); arr8.push("0x02"); -Assert.equal(arr8.toString(), "a,b,c,d,e,0x02"); +Assert.equal(arr8.toString(), "a,b,c,d,e,0x02"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_1.ts index 9d4f4793e8..e20b34625c 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_1.ts @@ -14,13 +14,13 @@ */ /**--- description: > - An object type containing one or more construct signatures is said to be a constructor type. + An object type containing one or more construct signatures is said to be a constructor type. module: ESNext isCurrent: true ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' class Person { name: string; @@ -38,11 +38,9 @@ class Teacher extends Person { return "teacher"; } } -// alias type constructor = new (name: string, age: number) => T; - -const testClass1: constructor = Teacher; +let testClass1: constructor = Teacher; let testObj1: Person = new testClass1("caihua", 20); Assert.equal(testObj1.age, 20); Assert.equal(testObj1.name, "caihua"); -Assert.equal(testObj1.run(), "teacher"); +Assert.equal(testObj1.run(), "teacher"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_2.ts index 42201baeec..15f65e8616 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_2.ts @@ -14,14 +14,14 @@ */ /**--- description: > - Constructor types may be written using constructor type literals - or by including construct signatures in object type literals. + Constructor types may be written using constructor type literals + or by including construct signatures in object type literals. module: ESNext isCurrent: true ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' class Person { name: string; @@ -45,11 +45,11 @@ class Teacher extends Person { } } // literal type -const testClass1: new (name: string, age: number) => Person = Student; -const testObj1: Person = new testClass1("caihua1", 12); +let testClass1: new (name: string, age: number) => Person = Student; +let testObj1: Person = new testClass1("caihua1", 12); Assert.equal(testObj1.age, 12); Assert.equal(testObj1.name, "caihua1"); -const testClass2: { new(n: string, a: number): Person } = Teacher; -const testObj2: Person = new testClass2("caihua2", 120); +let testClass2: { new(n: string, a: number): Person } = Teacher; +let testObj2: Person = new testClass2("caihua2", 120); Assert.equal(testObj2.age, 120); -Assert.equal(testObj2.name, "caihua2"); +Assert.equal(testObj2.name, "caihua2"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_3.ts index dc307d99ef..88d7ec7b20 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_3.ts @@ -14,13 +14,13 @@ */ /**--- description: > - An object type containing one or more construct signatures is said to be a constructor type. + An object type containing one or more construct signatures is said to be a constructor type. module: ESNext isCurrent: true ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' interface Point { x: number; @@ -29,7 +29,6 @@ interface Point { interface PointConstructor { new(x: number, y: number): Point; } - class Point2D implements Point { readonly x: number; readonly y: number; @@ -38,7 +37,6 @@ class Point2D implements Point { this.y = y; } } - function newPoint( pointConstructor: PointConstructor, x: number, @@ -46,11 +44,9 @@ function newPoint( ): Point { return new pointConstructor(x, y); } - -const point1: Point = new Point2D(1, 2); +let point1: Point = new Point2D(1, 2); Assert.equal(point1.x, 1); Assert.equal(point1.y, 2); - -const point: Point = newPoint(Point2D, 2, 2); +let point: Point = newPoint(Point2D, 2, 2); Assert.equal(point.x, 2); -Assert.equal(point.y, 2); +Assert.equal(point.y, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_4.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_4.ts new file mode 100644 index 0000000000..56dd96b99c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_4.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + An object type containing one or more construct signatures is said to be a constructor type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Animal1 { + name: string | undefined; + age: number | undefined; + constructor(); + constructor(name: string); + constructor(age: number); + constructor(name: string, age: number); + constructor(nameorage?: string | number, age?: number) { + if (typeof nameorage == "number") { + this.age = nameorage; + } + if (typeof nameorage == "string") { + this.name = nameorage; + } + if (age) { + this.age = age; + } + } +} +let tt1 = new Animal1(); +let tt2 = new Animal1("caihua2", 12); +Assert.equal(tt2.name, "caihua2"); +Assert.equal(tt2.age, 12); +let tt3 = new Animal1("caihua3"); +Assert.equal(tt3.name, "caihua3"); +let tt4 = new Animal1(1230); +Assert.equal(tt4.age, 1230); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/function_types/function_types.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/function_types/function_types_1.ts similarity index 80% rename from es2panda/test/ts_extra_tests/test/spec/types/object_types/function_types/function_types.ts rename to es2panda/test/ts_extra_tests/test/spec/types/object_types/function_types/function_types_1.ts index b0f7e13ce5..6c2b213317 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/object_types/function_types/function_types.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/function_types/function_types_1.ts @@ -21,22 +21,20 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -var fun1: (num1: number, num2: number) => number = ( +let fun1: (num1: number, num2: number) => number = ( num1: number, num2: number ) => { return num1 + num2; }; -Assert.isNumber(fun1(3, 5)); Assert.equal(fun1(3, 5), 8); -var fun2: { (num1: number, num2: number, num3: number): number } = ( +let fun2: { (num1: number, num2: number, num3: number): number } = ( num1: number, num2: number, num3: number ) => { return num1 + num2 + num3; }; -Assert.isNumber(fun2(1, 3, 5)); -Assert.equal(fun2(1, 3, 5), 9); +Assert.equal(fun2(1, 3, 5), 9); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/function_types/function_types_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/function_types/function_types_2.ts new file mode 100644 index 0000000000..ff197f56a8 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/function_types/function_types_2.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + an object type containing one or more call signatures is said to be a function type. + function types may be written using function type literals or by including call signatures in object type literals. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +function add(x: number, y: number): number { + return x + y; +} +let a = add(1, 2); +Assert.equal(a, 3); +let add2 = function (x: number, y: number): number { return x + y; }; +let b = add2(3, 4); +Assert.equal(b, 7); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/members/members_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/members/members_1.ts index 3ce9ca2461..cf442fede8 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/object_types/members/members_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/members/members_1.ts @@ -48,7 +48,6 @@ let h_c = new h_C('Public', 'Private', 'Protected'); Assert.equal(h_c.h_pub, 'Public'); Assert.equal(h_c.get(), 'Private'); Assert.equal(h_c.output(), 'Protected'); - class h_child extends h_C { } let h_ch = new h_child('public', 'private', 'protected'); Assert.equal(h_ch.output(), 'protected'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_1.ts index f28534797b..adf7b4858e 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_1.ts @@ -14,21 +14,21 @@ */ /**--- description: > - Tuple types represent JavaScript arrays with individually tracked element types. - A tuple type combines a set of numerically named properties with the members of an array type. + Tuple types represent JavaScript arrays with individually tracked element types. + A tuple type combines a set of numerically named properties with the members of an array type. module: ESNext isCurrent: true ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' let cc: [number, string, boolean]; cc = [12, "abcd", true]; -Assert.isNumber(cc[0]); +Assert.equal(cc[0], "12"); Assert.equal(cc[0].toString(), "12"); -Assert.isString(cc[1]); +Assert.equal(cc[1], "abcd"); Assert.equal(cc[1].length, 4); -Assert.isBoolean(cc[2]); +Assert.equal(cc[2], true); let dd = cc[2] ? 0 : 1; -Assert.equal(dd, 0); +Assert.equal(dd, 0); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_2.ts index ff88c37df2..ecbffe23bc 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_2.ts @@ -14,23 +14,22 @@ */ /**--- description: > - Array literals may be used to create values of tuple types. - the members of an array type whose element type is the union type of the tuple element types + Array literals may be used to create values of tuple types. + the members of an array type whose element type is the union type of the tuple element types module: ESNext isCurrent: true ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' let cc: [number, string, boolean]; cc = [12, "abcd", true]; -let index: number=0; -// Type of cc[index] is number | string | boolean -var x = cc[index]; +let index: number = 0; +let x = cc[index]; x = 12; -Assert.isNumber(x); +Assert.equal(x, 12); x = false; -Assert.isBoolean(x); +Assert.equal(x, false); x = "string"; -Assert.isString(x); +Assert.equal(x, "string"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_3.ts index 21f0d29957..333748d2aa 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_3.ts @@ -14,21 +14,19 @@ */ /**--- description: > - Named tuple types can be created by declaring interfaces that derive from Array - and introduce numerically named properties + Named tuple types can be created by declaring interfaces that derive from Array + and introduce numerically named properties module: ESNext isCurrent: true ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' interface tt extends Array { 0: K; 1: V; } let x: tt = [10, "ten"]; -Assert.isNumber(x[0]); Assert.equal(x[0], 10); -Assert.isString(x[1]); -Assert.equal(x[1], "ten"); +Assert.equal(x[1], "ten"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_1.ts index cad135fa83..777c76804a 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_1.ts @@ -21,7 +21,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' function test1(): number { return 0; @@ -29,15 +29,15 @@ function test1(): number { function test2(): number { return 1; } -function test3() { +function test3(): number { return 1; } function test4(i: number): number { return i; } -var a: boolean = true; +let a: boolean = true; Assert.equal(a, true); -var b = false; +let b: boolean = false; Assert.equal(b, false); // conditional expression let c: number = a ? 0 : 1; @@ -58,4 +58,4 @@ while (a) { // for for (let i = 0; a && i < 5; i++) { Assert.equal(test4(i), i); -}; +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_2.ts index 9ca3183a7e..c34fd9e338 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_2.ts @@ -21,23 +21,23 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -var a: boolean = true; +let a: boolean = true; Assert.isBoolean(a); Assert.equal(a, true); a = false; Assert.isBoolean(a); Assert.equal(a, false); // > < ! -var b: boolean = 2 > 1; +let b: boolean = 2 > 1; Assert.isBoolean(b); Assert.equal(b, true); b = !b; Assert.isBoolean(b); Assert.equal(b, false); // && -var c: boolean = 2 > 1 && 7 < 8; +let c: boolean = 2 > 1 && 7 < 8; Assert.isBoolean(c); Assert.equal(c, true); c = 2 < 1 && 7 < 8; @@ -49,5 +49,4 @@ Assert.isBoolean(c); Assert.equal(c, true); c = 2 < 1 || 7 > 8; Assert.isBoolean(c); -Assert.equal(c, false); - +Assert.equal(c, false); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_3.ts index e5b4b2cf81..c4f7d5a5ef 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_3.ts @@ -21,7 +21,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -var a = true; +let a = true; Assert.equal(a.valueOf(), true); diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_enum_type/the_enum_type_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_enum_type/the_enum_type_1.ts index 31195e2762..76cdb333de 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_enum_type/the_enum_type_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_enum_type/the_enum_type_1.ts @@ -19,7 +19,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' enum Color { Red, @@ -29,10 +29,10 @@ enum Color { } let cc: Color = Color.Blue; // true -Assert.isNumber(cc); -var ee: Color = Color.Blue; -var dd: number = cc; +Assert.equal(cc, 2); +let ee: Color = Color.Blue; +let dd: number = cc; Assert.equal(dd, Color.Blue); dd = 15; ee = dd; -Assert.equal(ee, 15); +Assert.equal(ee, 15); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_null_type/the_null_type_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_null_type/the_null_type_1.ts index 62e29fbb98..6fc02dcb11 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_null_type/the_null_type_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_null_type/the_null_type_1.ts @@ -19,11 +19,11 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -var n: null = null; +let n: null = null; let flag = false; if (n == null) { flag = true; } -Assert.isTrue(flag); \ No newline at end of file +Assert.equal(flag, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_1.ts index 2b80f668ff..9242f3f8d8 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_1.ts @@ -21,7 +21,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' // add Assert.notEqual(0.1 + 0.2, 0.3); @@ -37,12 +37,9 @@ Assert.notEqual(35.41 * 100, 3541); // division Assert.notEqual(0.3 / 0.1, 3); Assert.notEqual(0.69 / 10, 0.069); - // Number.toFiexed() Assert.equal((1.335).toFixed(2), 1.33); Assert.equal((1.3335).toFixed(3), 1.333); Assert.equal((1.33335).toFixed(4), 1.3334); Assert.equal((1.333335).toFixed(5), 1.33333); -Assert.equal((1.3333335).toFixed(6), 1.333333); - - +Assert.equal((1.3333335).toFixed(6), 1.333333); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_2.ts index 01f8bb0b2a..a88d6beed3 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_2.ts @@ -19,7 +19,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' // Integral type let n1: number = 1; @@ -55,4 +55,4 @@ Assert.isNumber(n5); Assert.equal(n5, 0xf00d); n5 = 0xf01c; Assert.isNumber(n5); -Assert.equal(n5, 0xf01c); +Assert.equal(n5, 0xf01c); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_3.ts index 90c05ab3ec..876e4b56ab 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_3.ts @@ -22,19 +22,19 @@ import { Assert } from '../../../../../suite/assert.js' // Equivalent to h_z: number = 123.456 -var h_z = 123.456; +let h_z = 123.456; // The property of Number -var s = h_z.toFixed(2); +let s = h_z.toFixed(2); Assert.equal(s, 123.46); -var a = h_z.toString(); +let a = h_z.toString(); Assert.equal(a, "123.456"); -var b = h_z.toExponential(); +let b = h_z.toExponential(); Assert.equal(b, "1.23456e+2"); b = h_z.toExponential(2); Assert.equal(b, "1.23e+2"); -var c = h_z.toPrecision(); +let c = h_z.toPrecision(); Assert.equal(c, "123.456"); c = h_z.toPrecision(3); Assert.equal(c, "123"); -var d = h_z.valueOf(); +let d = h_z.valueOf(); Assert.equal(d, 123.456); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_1.ts index 9a3964f0c1..96d9da95e0 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_1.ts @@ -20,13 +20,13 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -var cc: "hello" = "hello"; +let cc: "hello" = "hello"; Assert.isString(cc); -var dd: string = cc; +let dd: string = cc; Assert.equal(dd, "hello"); -var ee: "" = ""; +let ee: "" = ""; Assert.isString(ee); -var ff: string = ee; +let ff: string = ee; Assert.equal(ff, ""); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_2.ts index af95b4e37b..152aa09ada 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_2.ts @@ -20,7 +20,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' interface Test { v: "hello"; @@ -30,7 +30,7 @@ function test(dd: Test) { Assert.equal(dd.v.length, 5); return dd; } -var cc: Test = { +let cc: Test = { v: "hello", }; -Assert.isString(test(cc).v); +Assert.equal(test(cc).v, "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_3.ts index aa6cf69676..7e2a89a138 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_3.ts @@ -21,7 +21,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' // If you define a variable type without explicit type annotations, the variable defaults to string instead of the string literal type it should be let HELLO: "HELLO" = "HELLO"; @@ -33,4 +33,4 @@ Assert.equal(hello, "hello"); let HELLOWORLD = HELLO + WORLD; Assert.equal(HELLOWORLD, "HELLOWORLD"); // valid -let a: "foo" | number = "foo"; +let a: "foo" | number = "foo"; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_1.ts index e74655fa8c..d74dc821f0 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_1.ts @@ -21,7 +21,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -var str: string = "\u4f60\u597d"; +let str: string = "\u4f60\u597d"; Assert.equal(str, "你好"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_2.ts index c3b7248adf..78d89c6fc2 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_2.ts @@ -21,9 +21,8 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -var str: string; +let str: string; str = "abcd"; -Assert.equal(str, "abcd"); -Assert.isString(str); \ No newline at end of file +Assert.equal(str, "abcd"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_3.ts index a2a4e1fa75..dd0e5f903e 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_3.ts @@ -21,23 +21,15 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -var str: string = "string"; +let str: string = "string"; Assert.equal(str.charAt(1), "t"); - Assert.equal(str.charCodeAt(2), 114); - Assert.equal(str.toString(), 'string'); - Assert.equal(str.concat("new"), "stringnew"); - str = "cbaabcda"; Assert.equal(str.indexOf("a"), 2); - Assert.equal(str.indexOf("a", 4), 7); - Assert.equal(str.lastIndexOf("b"), 4); - -Assert.equal(str.lastIndexOf("b", 2), 1); - +Assert.equal(str.lastIndexOf("b", 2), 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_1.ts index 58c13e9ce0..8ccc6d6508 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_1.ts @@ -23,9 +23,9 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -var sym: symbol = Symbol(); -var obj1: object = { [sym]: "symbol" }; +let sym: symbol = Symbol(); +let obj1: object = { [sym]: "symbol" }; type Key = keyof typeof obj1; -Assert.equal(obj1[sym as Key], "symbol"); +Assert.equal(obj1[sym as Key], "symbol"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_2.ts index 8ddd1b69f4..fd46477d62 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_2.ts @@ -23,24 +23,21 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -var sym: symbol = Symbol("NARC"); -var sym2: symbol = Symbol("TypeScript"); +let sym: symbol = Symbol("NARC"); +let sym2: symbol = Symbol("TypeScript"); Assert.equal(sym.description, "NARC"); - -var s1: string = sym2.toString(); -var s2: symbol = sym.valueOf(); +let s1: string = sym2.toString(); +let s2: symbol = sym.valueOf(); Assert.equal(s1, "Symbol(TypeScript)"); - -var flag1: boolean = false; +let flag1: boolean = false; if (sym != sym2) { flag1 = true; } Assert.isTrue(flag1); - -var flag2: boolean = false; +let flag2: boolean = false; if (sym == s2) { flag2 = true; } -Assert.isTrue(flag2); +Assert.isTrue(flag2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_3.ts index 61eb08c0bc..3abcb36b7e 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_3.ts @@ -24,8 +24,8 @@ import { Assert } from '../../../../../suite/assert.js' -var h_x: symbol = Symbol(); -var h_obj: any = {}; +let h_x: symbol = Symbol(); +let h_obj: any = {}; h_obj[h_x] = "primitive type"; Assert.equal(h_obj[h_x], "primitive type"); h_obj[Symbol.toStringTag] = "project"; diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_undefined_type/the_undefined_type_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_undefined_type/the_undefined_type_1.ts index 6dd9d8a960..b29b6fd279 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_undefined_type/the_undefined_type_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_undefined_type/the_undefined_type_1.ts @@ -19,7 +19,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -var u: undefined = undefined; -Assert.isUndefined(u); \ No newline at end of file +let u: undefined = undefined; +Assert.equal(u, undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_1.ts index 70061be8ca..2cf13d6f14 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_1.ts @@ -21,9 +21,9 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -var v: void = undefined; +let v: void = undefined; function noReturn(): void { } -Assert.isUndefined(v); -Assert.isUndefined(noReturn()); +Assert.equal(v, undefined); +Assert.equal(noReturn(), undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_2.ts index 1d2f85d191..19086e188f 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_2.ts @@ -21,13 +21,13 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -var v: void; -Assert.isUndefined(v); -var v2: void = undefined; -Assert.isUndefined(v2); -var nu = null; -var u: undefined = undefined; +let v: void; +Assert.equal(v, undefined); +let v2: void = undefined; +Assert.equal(v2, undefined); +let nu = null; +let u: undefined = undefined; v = u; -Assert.isUndefined(v); +Assert.equal(v, undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_3.ts index 329bdfdb53..c5ef13370a 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_3.ts @@ -20,13 +20,13 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -var v: void; -var nu = null; -var u: undefined = undefined; -var a: any; +let v: void; +let nu = null; +let u: undefined = undefined; +let a: any; a = v; -Assert.isUndefined(a); +Assert.equal(a, undefined); v = u; -Assert.isUndefined(v); +Assert.equal(v, undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_1.ts index 0dda950706..6d0fc9322f 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_1.ts @@ -14,14 +14,14 @@ */ /**--- description: > - A signature's parameter list consists of zero or more required parameters, followed by zero or more optional parameters, - finally followed by an optional rest parameter. + A signature's parameter list consists of zero or more required parameters, followed by zero or more optional parameters, + finally followed by an optional rest parameter. module: ESNext isCurrent: true ---*/ -import {Assert} from '../../../../../../suite/assert.js' +import { Assert } from '../../../../../../suite/assert.js' function fun0() { return "zero parameter"; @@ -34,9 +34,8 @@ let result1 = fun1("Bob"); let result3 = fun1("Bob", "Adams"); Assert.equal(result1, "Bob"); Assert.equal(result3, "Bob Adams"); - function fun2(firstParameter: string, ...restParameter: string[]) { return firstParameter + " " + restParameter.join(" "); } let employeeName = fun2("Joseph", "Samuel", "Lucas", "MacKinzie"); -Assert.equal(employeeName, "Joseph Samuel Lucas MacKinzie"); +Assert.equal(employeeName, "Joseph Samuel Lucas MacKinzie"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_2.ts index 84b152b3b6..1202a176b9 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_2.ts @@ -14,14 +14,14 @@ */ /**--- description: > - A parameter declaration may specify either an identifier or a binding pattern. - The identifiers specified in parameter declarations and binding patterns in a parameter list must be unique within that parameter list. + A parameter declaration may specify either an identifier or a binding pattern. + The identifiers specified in parameter declarations and binding patterns in a parameter list must be unique within that parameter list. module: ESNext isCurrent: true ---*/ -import {Assert} from '../../../../../../suite/assert.js' +import { Assert } from '../../../../../../suite/assert.js' class Animal { fname: string; @@ -32,4 +32,4 @@ class Animal { let name1 = "Anny"; let animal = new Animal(name1); name1 = "Bob"; -Assert.notEqual(animal.fname, name1); +Assert.notEqual(animal.fname, name1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_3.ts index 1d21304ceb..f88d8baf94 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_3.ts @@ -14,13 +14,13 @@ */ /**--- description: > - If the declaration includes a type annotation, the parameter is of that type. + If the declaration includes a type annotation, the parameter is of that type. module: ESNext isCurrent: true ---*/ -import {Assert} from '../../../../../../suite/assert.js' +import { Assert } from '../../../../../../suite/assert.js' function ff(first: string, second: number) { return first; @@ -29,5 +29,4 @@ let first = "first"; let second = 2; ff(first, second); Assert.equal(first, "first"); -Assert.equal(second, 2); - +Assert.equal(second, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_4.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_4.ts index 1e85df8da1..6c64838374 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_4.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_4.ts @@ -21,7 +21,7 @@ ---*/ -import {Assert} from '../../../../../../suite/assert.js' +import { Assert } from '../../../../../../suite/assert.js' const x: number = 3; function fun(a: number, c = 1, b = x) { @@ -30,4 +30,4 @@ function fun(a: number, c = 1, b = x) { let y = 1; Assert.equal(y, 1); let z = fun(y); -Assert.equal(z, 5); +Assert.equal(z, 5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_5.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_5.ts index f2f8702e4b..5a338ef874 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_5.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_5.ts @@ -14,24 +14,22 @@ */ /**--- description: > - if the parameter is a rest parameter, the parameter type is any[]. - A type annotation for a rest parameter must denote an array type. + if the parameter is a rest parameter, the parameter type is any[]. + A type annotation for a rest parameter must denote an array type. module: ESNext isCurrent: true ---*/ -import {Assert} from '../../../../../../suite/assert.js' +import { Assert } from '../../../../../../suite/assert.js' function restFun(first: any, ...restname: any[]) { return first + " " + restname.join(" "); } - let restname1 = restFun("aa", "bb", "cc"); Assert.equal(restname1, "aa bb cc"); - let restname2 = restFun(1, 2, 3, 4); Assert.equal(restname2, "1 2 3 4"); // boolean let restname3 = restFun(true, false, true); -Assert.equal(restname3, "true false true"); +Assert.equal(restname3, "true false true"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_6.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_6.ts index 0bc1c9142c..ab97af1724 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_6.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_6.ts @@ -14,15 +14,15 @@ */ /**--- description: > - A parameter is permitted to include a public, private, - or protected modifier only if it occurs in the parameter list of a ConstructorImplementation (section 8.3.1) - and only if it doesn't specify a BindingPattern. + A parameter is permitted to include a public, private, + or protected modifier only if it occurs in the parameter list of a ConstructorImplementation (section 8.3.1) + and only if it doesn't specify a BindingPattern. module: ESNext isCurrent: true ---*/ -import {Assert} from '../../../../../../suite/assert.js' +import { Assert } from '../../../../../../suite/assert.js' class Person2 { public name: string; @@ -51,9 +51,8 @@ class Child extends Person2 { } } } -const a = new Child("wangwu", 15, "man"); +let a = new Child("wangwu", 15, "man"); a.name = "lisi"; a._age = 19; Assert.equal(a.name, "lisi"); -Assert.equal(a._age, 19); - +Assert.equal(a._age, 19); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_1.ts index c8ce127dab..d3949692a8 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_1.ts @@ -21,29 +21,29 @@ ---*/ -import {Assert} from '../../../../../../suite/assert.js' +import { Assert } from '../../../../../../suite/assert.js' function returnNum(a: number, b: number): number { return a + b; } let aa = returnNum(1, 2); -Assert.isNumber(aa); +Assert.equal(aa, 3); function returnString(name: string): string { return name + " b!"; } let bb = returnString("rush"); -Assert.isString(bb); +Assert.equal(bb, "rush b!"); function returnBoolean(a: number, b: number): Boolean { return a > b ? true : false; } let cc = returnBoolean(1, 2); -Assert.isBoolean(cc); +Assert.equal(cc, false); function returnUndefine(a: undefined): undefined { return a; } let ad: undefined; let dd = returnUndefine(ad); -Assert.isUndefined(dd); +Assert.equal(dd, undefined); function returnVoid(a: number): void { } let ee = returnVoid(1); -Assert.equal(ee, null); +Assert.equal(ee, null); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_2.ts index b800f3d859..f3068cbb81 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_2.ts @@ -21,16 +21,16 @@ ---*/ -import {Assert} from '../../../../../../suite/assert.js' +import { Assert } from '../../../../../../suite/assert.js' let add: { (x: number, y: number): any }; type anyT = ReturnType; let x: anyT; x = 1; -Assert.isNumber(x); +Assert.equal(x, 1); x = "any"; -Assert.isString(x); +Assert.equal(x, "any"); x = true; -Assert.isBoolean(x); +Assert.equal(x, true); x = undefined; -Assert.isUndefined(x); +Assert.equal(x, undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_3.ts index 5a9f529d34..51369f871a 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_3.ts @@ -21,7 +21,7 @@ ---*/ -import {Assert} from '../../../../../../suite/assert.js' +import { Assert } from '../../../../../../suite/assert.js' let add = function (x: number, y: number) { return x + y; @@ -39,4 +39,4 @@ let booltp = function (x: boolean) { return true; }; let z = booltp(false); -Assert.equal(z, true); +Assert.equal(z, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/specialized_signatures/specialized_signatures_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/specialized_signatures/specialized_signatures_1.ts index 97f42b0ace..28ae71c53d 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/specialized_signatures/specialized_signatures_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/specialized_signatures/specialized_signatures_1.ts @@ -21,7 +21,7 @@ ---*/ -import {Assert} from '../../../../../../suite/assert.js' +import { Assert } from '../../../../../../suite/assert.js' interface specialType { Tfun(x: "hello"): "hello"; @@ -30,8 +30,8 @@ interface specialType { } class getType implements specialType { Tfun(x: any): any { - const xx: "hello" = "hello"; - const xx2: "world" = "world"; + let xx: "hello" = "hello"; + let xx2: "world" = "world"; if (x === xx) { return x; } else if (x === xx2) { @@ -41,14 +41,14 @@ class getType implements specialType { } } } -const x1 = new getType(); -const xx1: "hello" = "hello"; -const y1: "hello" = x1.Tfun(xx1); -Assert.isTrue(y1 === xx1); -const x2 = new getType(); -const xx2: "world" = "world"; -const y2 = x2.Tfun(xx2); -Assert.isTrue(xx2 === y2); -const x3 = new getType(); -const y3 = x3.Tfun("helloworld"); -Assert.equal(y3, "isstring"); +let x1 = new getType(); +let xx1: "hello" = "hello"; +let y1: "hello" = x1.Tfun(xx1); +Assert.equal(xx1, y1); +let x2 = new getType(); +let xx2: "world" = "world"; +let y2 = x2.Tfun(xx2); +Assert.equal(xx2, y2); +let x3 = new getType(); +let y3 = x3.Tfun("helloworld"); +Assert.equal(y3, "isstring"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_1.ts index 86046a334e..80957119ba 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_1.ts @@ -40,4 +40,4 @@ function identity4(arg: T[]): T[] { return arg; } let arg: number[] = [1, 2, 3]; -Assert.equal(arg, identity4(arg)); +Assert.equal(arg, identity4(arg)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_2.ts index 0e67860fb9..4592b7c737 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_2.ts @@ -28,7 +28,7 @@ function identity(h_x: T): T { } let h_x: number = 3; // CHECK explicitly specified type in call -Assert.isNumber(identity(h_x)); +Assert.equal(identity(h_x), 3); let h_y = "string"; // CHECK inferred from argument in the call -Assert.isString(identity(h_y)); +Assert.equal(identity(h_y), "string"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/construct_signatures/construct_signatures.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/construct_signatures/construct_signatures.ts index 9661b7f0ab..c6c51a3567 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/construct_signatures/construct_signatures.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/construct_signatures/construct_signatures.ts @@ -19,7 +19,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' class Animal { name: string | undefined; @@ -40,23 +40,21 @@ class Animal { } } type AnimalConstructor = { - new (name: string, age: number): Animal; - new (name: string): Animal; - new (age: number): Animal; - new (): Animal; + new(name: string, age: number): Animal; + new(name: string): Animal; + new(age: number): Animal; + new(): Animal; }; - -const AnimalConstructor: AnimalConstructor = Animal; - +let AnimalConstructor: AnimalConstructor = Animal; let tt1 = new AnimalConstructor(); -Assert.isUndefined(tt1.age); -Assert.isUndefined(tt1.name); +Assert.equal(tt1.age, undefined); +Assert.equal(tt1.name, undefined); let tt2 = new AnimalConstructor("caihua2", 12); Assert.equal(tt2.name, "caihua2"); Assert.equal(tt2.age, 12); let tt3 = new AnimalConstructor("caihua3"); Assert.equal(tt3.name, "caihua3"); -Assert.isUndefined(tt3.age); +Assert.equal(tt3.age, undefined); let tt4 = new AnimalConstructor(1230); Assert.equal(tt4.age, 1230); -Assert.isUndefined(tt4.name); +Assert.equal(tt4.name, undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/index_signatures/index_signatures.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/index_signatures/index_signatures.ts index d5a53939ce..42b66ba780 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/index_signatures/index_signatures.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/index_signatures/index_signatures.ts @@ -21,44 +21,39 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -var si: { [key: string]: number } = { a: 97, A: 65 }; +let si: { [key: string]: number } = { a: 97, A: 65 }; si["b"] = 98; -Assert.isNumber(si["a"]); +Assert.equal(si["a"], 97); Assert.equal(si["A"], 65); - -var ni: { [key: number]: boolean } = { 0: false, 1: true }; +let ni: { [key: number]: boolean } = { 0: false, 1: true }; ni[-1] = true; Assert.isBoolean(ni[0]); Assert.equal(ni[-1], true); - interface UnionKey { [key: string | number]: string | number; } -var uk: UnionKey = { Name: "UnionKey", 0: "NARC", 0x0a: 10 }; +let uk: UnionKey = { Name: "UnionKey", 0: "NARC", 0x0a: 10 }; Assert.equal(uk["Name"], "UnionKey"); Assert.equal(uk[0], "NARC"); Assert.equal(uk[0x0a], 10); Assert.equal(uk[0xff], undefined); - interface StringKey { [key: string]: string; } -var sk: StringKey = { "1": "0x01", "2": "0x02", 3: "0x03", "4": "0x04" }; -Assert.isString(sk["1"]); -Assert.isString(sk[2]); +let sk: StringKey = { "1": "0x01", "2": "0x02", 3: "0x03", "4": "0x04" }; +Assert.equal(sk["1"], "0x01"); +Assert.equal(sk["2"], "0x02"); Assert.equal(sk[3], 0x03); - interface NumberKey { [key: number]: string; } -var nk: NumberKey = { 1: "0x01", 2: "0x02", "3": "0x03", 4: "0x04" }; -Assert.isString(nk["1"]); -Assert.isString(nk[2]); +let nk: NumberKey = { 1: "0x01", 2: "0x02", "3": "0x03", 4: "0x04" }; +Assert.equal(nk[1], "0x01"); +Assert.equal(nk[2], "0x02"); Assert.equal(nk["3"], "0x03"); - -var rk1: Record = { one: 1, two: 2, three: 3 }; +let rk1: Record = { one: 1, two: 2, three: 3 }; Assert.equal(rk1["one"], 1); -var rk2: Record<"a" | "b" | "c", string> = { a: "A", b: "B", c: "C" }; -Assert.equal(rk2["a"], "A"); +let rk2: Record<"a" | "b" | "c", string> = { a: "A", b: "B", c: "C" }; +Assert.equal(rk2["a"], "A"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/method_signatures/method_signatures_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/method_signatures/method_signatures_1.ts index c6c1c59351..1eacb9e701 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/method_signatures/method_signatures_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/method_signatures/method_signatures_1.ts @@ -21,7 +21,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' // interfaces interface point { @@ -51,4 +51,4 @@ point2 = { x: 0, y: 0, z: 0 }; let pp2 = point2; Assert.equal(pp2.x, 0); Assert.equal(pp2.y, 0); -Assert.equal(pp2.z, 0); +Assert.equal(pp2.z, 0); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/method_signatures/method_signatures_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/method_signatures/method_signatures_2.ts index d562e4624b..055430d639 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/method_signatures/method_signatures_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/method_signatures/method_signatures_2.ts @@ -21,7 +21,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' class A { add(x: number, y: number): number; @@ -46,4 +46,4 @@ class A { let a = new A(); Assert.equal(a.add(1, 2), 3); let b = new A(); -Assert.equal(b.add(1, 2, 3), 6); +Assert.equal(b.add(1, 2, 3), 6); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/property_signatures/property_signatures.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/property_signatures/property_signatures.ts index dd1d4738bb..626a7d8444 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/property_signatures/property_signatures.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/property_signatures/property_signatures.ts @@ -21,10 +21,10 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -var fname: { fristName: string, middleName?: string, lastName: string; } = { fristName: "NARC", lastName: "TypeScript" }; -var f2name: { fristName: string, middleName?: string, lastName: string; } = { +let fname: { fristName: string, middleName?: string, lastName: string; } = { fristName: "NARC", lastName: "TypeScript" }; +let f2name: { fristName: string, middleName?: string, lastName: string; } = { fristName: "Isaac", middleName: "F", lastName: "Newton", @@ -36,10 +36,7 @@ function fullName(name: { fristName: string, middleName?: string, lastName: stri return name.fristName + " " + name.lastName; } } -var fn1: string = fullName(fname); -Assert.isString(fn1); +let fn1: string = fullName(fname); Assert.equal(fn1, "NARC TypeScript"); - -var fn2: string = fullName(f2name); -Assert.isString(fn2); -Assert.equal(fn2, "Isaac F Newton"); +let fn2: string = fullName(f2name); +Assert.equal(fn2, "Isaac F Newton"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_1.ts index 55ddf04871..065f411360 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_1.ts @@ -14,7 +14,7 @@ */ /**--- description: > - An array type literal is written as an element type followed by an open and close square bracket. + An array type literal is written as an element type followed by an open and close square bracket. module: ESNext isCurrent: true ---*/ @@ -22,8 +22,8 @@ import { Assert } from '../../../../../suite/assert.js' -var arr: number[] = [2, 4, 6, 8]; -Assert.isNumber(arr[0]); -Assert.isNumber(arr[1]); -Assert.isNumber(arr[2]); -Assert.isNumber(arr[3]); \ No newline at end of file +let arr: number[] = [2, 4, 6, 8]; +Assert.equal(arr[0], 2); +Assert.equal(arr[1], 4); +Assert.equal(arr[2], 6); +Assert.equal(arr[3], 8); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_2.ts index 69d2998a7e..40a0c6b1b4 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_2.ts @@ -14,7 +14,7 @@ */ /**--- description: > - An array type literal references an array type with the given element type. + An array type literal references an array type with the given element type. module: ESNext isCurrent: true ---*/ @@ -22,7 +22,7 @@ import { Assert } from '../../../../../suite/assert.js' -var h_arr = ['s', 5, true]; -Assert.isString(h_arr[0]); -Assert.isNumber(h_arr[1]); -Assert.isBoolean(h_arr[2]); \ No newline at end of file +let arr = ['s', 5, true]; +Assert.equal(arr[0], 's'); +Assert.equal(arr[1], 5); +Assert.equal(arr[2], true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_3.ts index 6e845a6f60..fdfccc3279 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_3.ts @@ -14,7 +14,7 @@ */ /**--- description: > - When union, intersection, function, or constructor types are used as array element types they must be enclosed in parentheses. + When union, intersection, function, or constructor types are used as array element types they must be enclosed in parentheses. module: ESNext isCurrent: true ---*/ @@ -22,14 +22,13 @@ import { Assert } from '../../../../../suite/assert.js' -var h_test1: string | number[]; +let h_test1: string | number[]; h_test1 = 'string'; -Assert.isString(h_test1); +Assert.equal(h_test1, 'string'); h_test1 = [3, 5]; -Assert.isNumber(h_test1[0]); -Assert.isNumber(h_test1[1]); - -var h_test2: (string | number)[]; -h_test2 = [2, 'b']; -Assert.isNumber(h_test2[0]); -Assert.isString(h_test2[1]); \ No newline at end of file +Assert.equal(h_test1[0], 3); +Assert.equal(h_test1[1], 5); +let h_test2: (string | number)[]; +h_test2 = [2, 'a']; +Assert.equal(h_test2[0], 2); +Assert.equal(h_test2[1], 'a'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_4.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_4.ts index 31e14bc5b9..6f96a48423 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_4.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_4.ts @@ -22,16 +22,15 @@ import { Assert } from '../../../../../suite/assert.js' -var arr: Array = [2, 'a']; -Assert.isNumber(arr[0]); -Assert.isString(arr[1]); - -var h_x = function () { +let arr: Array = [2, 'a']; +Assert.equal(arr[0], 2); +Assert.equal(arr[1], 'a'); +let h_x = function () { return 'h_x'; } -var h_y = function () { +let h_y = function () { return 'h_y'; } -var fun: Array<() => string> = [h_x, h_y]; +let fun: Array<() => string> = [h_x, h_y]; Assert.isFunction(fun[0]); Assert.isFunction(fun[1]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/function_type_literals/function_type_literals_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/function_type_literals/function_type_literals_3.ts index 3bd2f2c9eb..75a002d76f 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/function_type_literals/function_type_literals_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/function_type_literals/function_type_literals_3.ts @@ -14,8 +14,8 @@ */ /**--- description: > - Function types with multiple call or construct signatures cannot be written as function type literals - but must instead be written as object type literals. + Function types with multiple call or construct signatures cannot be written as function type literals + but must instead be written as object type literals. module: ESNext isCurrent: true ---*/ @@ -27,8 +27,7 @@ interface h_inter { (h_x: string): number; (h_x: number): string } - -var h_i: h_inter = Object.assign(function (h_x: any) { +let h_i: h_inter = Object.assign(function (h_x: any) { if (typeof h_x === 'string') { return h_x.toString(); } else { diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/intersection_type_literals/intersection_type_literals.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/intersection_type_literals/intersection_type_literals.ts index d9b5644909..d0483b0e6f 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/intersection_type_literals/intersection_type_literals.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/intersection_type_literals/intersection_type_literals.ts @@ -14,8 +14,8 @@ */ /**--- description: > - An intersection type literal is written as a sequence of types separated by ampersands. - An intersection type literal references an intersection type. + An intersection type literal is written as a sequence of types separated by ampersands. + An intersection type literal references an intersection type. module: ESNext isCurrent: true ---*/ @@ -23,7 +23,7 @@ import { Assert } from '../../../../../suite/assert.js' -var t_inter: object & { name: string }; +let t_inter: object & { name: string }; t_inter = { name: 'intersection' } diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/object_type_literals/object_type_literals.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/object_type_literals/object_type_literals.ts index 6ed76a7536..535c85a317 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/object_type_literals/object_type_literals.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/object_type_literals/object_type_literals.ts @@ -14,8 +14,8 @@ */ /**--- description: > - An object type literal defines an object type by specifying the set of members that are statically considered to be present in instances of the type. - Object type literals can be given names using interface declarations but are otherwise anonymous. + An object type literal defines an object type by specifying the set of members that are statically considered to be present in instances of the type. + Object type literals can be given names using interface declarations but are otherwise anonymous. module: ESNext isCurrent: true ---*/ @@ -23,7 +23,7 @@ import { Assert } from '../../../../../suite/assert.js' -var h_obj: { +let h_obj: { num: number; str: string; boo: boolean; @@ -35,12 +35,11 @@ var h_obj: { Assert.equal(h_obj.num, 5); Assert.equal(h_obj.str, 'str'); Assert.equal(h_obj.boo, true); - interface h_i { name: string, age: number } -var h_o: h_i = { +let h_o: h_i = { name: 'xiao', age: 18 } diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/predefined_types/predefined_types.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/predefined_types/predefined_types.ts index 03e72d23ef..2637703d61 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/predefined_types/predefined_types.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/predefined_types/predefined_types.ts @@ -14,8 +14,8 @@ */ /**--- description: > - The any, number, boolean, string, symbol and void keywords reference - the Any type and the Number, Boolean, String, Symbol, and Void primitive types respectively. + The any, number, boolean, string, symbol and void keywords reference + the Any type and the Number, Boolean, String, Symbol, and Void primitive types respectively. module: ESNext isCurrent: true ---*/ @@ -23,14 +23,14 @@ import { Assert } from '../../../../../suite/assert.js' -var m_n: number = 5; +let m_n: number = 5; Assert.equal(m_n.toString(), "5"); -var m_b: boolean = true; +let m_b: boolean = true; Assert.equal(m_b.toString(), "true"); -var m_s: string = 's'; +let m_s: string = 's'; Assert.equal(m_s.toString(), "s"); -var m_sy: symbol = Symbol(); +let m_sy: symbol = Symbol(); Assert.equal(m_sy.toString(), "Symbol()"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/specifying_types_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/specifying_types_1.ts index 39f685522f..fbc74449db 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/specifying_types_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/specifying_types_1.ts @@ -14,8 +14,8 @@ */ /**--- description: > - Types are specified either by referencing their keyword or name, or by writing object type literals, - array type literals, tuple type literals, function type literals, constructor type literals, or type queries. + Types are specified either by referencing their keyword or name, or by writing object type literals, + array type literals, tuple type literals, function type literals, constructor type literals, or type queries. module: ESNext isCurrent: true ---*/ @@ -23,22 +23,22 @@ import { Assert } from '../../../../suite/assert.js' -var h_num: number = 5; +let h_num: number = 5; Assert.isNumber(h_num); -var h_obj = { +let h_obj = { name: 'xiao', age: 18 } Assert.equal(typeof h_obj, 'object'); -var h_arr = [10, 5, 7, 20]; +let h_arr = [10, 5, 7, 20]; Assert.equal(typeof h_arr, 'object'); -var h_tup = ['str', 5, true]; +let h_tup = ['str', 5, true]; Assert.equal(typeof h_tup, 'object'); -var h_func = (h_x: number, h_y: number) => { +let h_func = (h_x: number, h_y: number) => { return h_x + h_y } Assert.equal(typeof h_func, 'function'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/specifying_types_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/specifying_types_2.ts index e4f610b781..a68f47cbd5 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/specifying_types_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/specifying_types_2.ts @@ -14,7 +14,7 @@ */ /**--- description: > - Parentheses are required around union, intersection, function, or constructor types when they are used as array element types + Parentheses are required around union, intersection, function, or constructor types when they are used as array element types module: ESNext isCurrent: true ---*/ @@ -22,11 +22,10 @@ import { Assert } from '../../../../suite/assert.js' -var h_arr: (string | number)[] = ['10', 5]; +let h_arr: (string | number)[] = ['10', 5]; Assert.equal(typeof h_arr, 'object'); - -var m_fun = function func(x: number) { +let m_fun = function func(x: number) { return x; } -var h_func: ((h_x: string) => string) | ((h_x: number) => number) = m_fun; +let h_func: ((h_x: string) => string) | ((h_x: number) => number) = m_fun; Assert.equal(typeof h_func, 'function'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/this_type_references/this_type_references_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/this_type_references/this_type_references_1.ts index 49a1d1d845..f46dffe594 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/this_type_references/this_type_references_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/this_type_references/this_type_references_1.ts @@ -14,9 +14,9 @@ */ /**--- description: > - The meaning of a ThisType depends on the closest enclosing FunctionDeclaration, - FunctionExpression, PropertyDefinition, ClassElement, or TypeMember, known as the root declaration of the ThisType, - when the root declaration is an instance member or constructor of a class, the ThisType references the this-type of that class. + The meaning of a ThisType depends on the closest enclosing FunctionDeclaration, + FunctionExpression, PropertyDefinition, ClassElement, or TypeMember, known as the root declaration of the ThisType, + when the root declaration is an instance member or constructor of a class, the ThisType references the this-type of that class. module: ESNext isCurrent: true ---*/ @@ -29,10 +29,10 @@ class myClass { constructor(num: number) { this.num = num; } - get() { - return this; + getnu() { + return this.num; } } -var my_c = new myClass(10); -Assert.equal(typeof my_c.get(), 'object'); \ No newline at end of file +let my_c = new myClass(10); +Assert.equal(my_c.getnu(), 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/this_type_references/this_type_references_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/this_type_references/this_type_references_2.ts index fa4e379064..2d935990b2 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/this_type_references/this_type_references_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/this_type_references/this_type_references_2.ts @@ -14,9 +14,9 @@ */ /**--- description: > - The meaning of a ThisType depends on the closest enclosing FunctionDeclaration, - FunctionExpression, PropertyDefinition, ClassElement, or TypeMember, known as the root declaration of the ThisType, - when the root declaration is a member of an interface type, the ThisType references the this-type of that interface. + The meaning of a ThisType depends on the closest enclosing FunctionDeclaration, + FunctionExpression, PropertyDefinition, ClassElement, or TypeMember, known as the root declaration of the ThisType, + when the root declaration is a member of an interface type, the ThisType references the this-type of that interface. module: ESNext isCurrent: true ---*/ @@ -28,8 +28,7 @@ interface h_inter { name: string; getN(this: h_inter): string; } - -var h_i: h_inter = { +let h_i: h_inter = { name: 'xiao', getN() { return this.name; diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/tuple_type_literals/tuple_type_literals.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/tuple_type_literals/tuple_type_literals.ts index 5e7b54f616..30f35ee178 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/tuple_type_literals/tuple_type_literals.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/tuple_type_literals/tuple_type_literals.ts @@ -14,8 +14,8 @@ */ /**--- description: > - A tuple type literal is written as a sequence of element types, separated by commas and enclosed in square brackets. - A tuple type literal references a tuple type. + A tuple type literal is written as a sequence of element types, separated by commas and enclosed in square brackets. + A tuple type literal references a tuple type. module: ESNext isCurrent: true ---*/ @@ -23,7 +23,7 @@ import { Assert } from '../../../../../suite/assert.js' -var t_arr: [number, string, boolean] = [3, 'a', true] +let t_arr: [number, string, boolean] = [3, 'a', true] Assert.isNumber(t_arr[0]); Assert.isString(t_arr[1]); Assert.isBoolean(t_arr[2]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_queries/type_queries_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_queries/type_queries_1.ts index 18c1c0b7aa..aea0866fa1 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_queries/type_queries_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_queries/type_queries_1.ts @@ -14,8 +14,8 @@ */ /**--- description: > - A type query obtains the type of an expression. - A type query consists of the keyword typeof followed by an expression. + A type query obtains the type of an expression. + A type query consists of the keyword typeof followed by an expression. module: ESNext isCurrent: true ---*/ diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_queries/type_queries_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_queries/type_queries_2.ts index 7f985c810a..7ce1b35da2 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_queries/type_queries_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_queries/type_queries_2.ts @@ -14,8 +14,8 @@ */ /**--- description: > - Type queries are useful for capturing anonymous types that are generated by various constructs - such as object literals, function declarations, and namespace declarations. + Type queries are useful for capturing anonymous types that are generated by letious constructs + such as object literals, function declarations, and namespace declarations. module: ESNext isCurrent: true ---*/ @@ -23,9 +23,9 @@ import { Assert } from '../../../../../suite/assert.js' -var h_a: { h_x: number, h_y: string }; +let h_a: { h_x: number, h_y: string }; -var h_b: typeof h_a; +let h_b: typeof h_a; h_b = { h_x: 10, h_y: 'h_y' diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_1.ts index 8992952e77..95aa3f28fb 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_1.ts @@ -14,8 +14,8 @@ */ /**--- description: > - A type reference references a named type or type parameter through its name and, in the case of a generic type, supplies a type argument list. - A TypeReference consists of a TypeName that a references a named type or type parameter. A reference to a generic type must be followed by a list of TypeArguments. + A type reference references a named type or type parameter through its name and, in the case of a generic type, supplies a type argument list. + A TypeReference consists of a TypeName that a references a named type or type parameter. A reference to a generic type must be followed by a list of TypeArguments. module: ESNext isCurrent: true ---*/ @@ -23,7 +23,7 @@ import { Assert } from '../../../../../suite/assert.js' -var h_obj: { +let h_obj: { month: number; day: number; } = { @@ -32,7 +32,6 @@ var h_obj: { } Assert.equal(h_obj.month, 5); Assert.equal(h_obj.day, 15); - function identity1(value: T, message: U): [T, U] { return [value, message]; } diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_2.ts index 4b30ddc016..290bc01e41 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_2.ts @@ -14,8 +14,8 @@ */ /**--- description: > - A type reference to a generic type is required to specify exactly one type argument for each type parameter - of the referenced generic type, and each type argument must be assignable to the constraint of the corresponding type parameter. + A type reference to a generic type is required to specify exactly one type argument for each type parameter + of the referenced generic type, and each type argument must be assignable to the constraint of the corresponding type parameter. module: ESNext isCurrent: true ---*/ @@ -37,7 +37,7 @@ interface h_G { h_y: U; } -var h_v: h_G = { +let h_v: h_G = { h_x: { h_a: 'h_a' }, h_y: { h_a: 'h_a', diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_3.ts index 75d3de9dc9..4771022fad 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_3.ts @@ -14,9 +14,9 @@ */ /**--- description: > - A type argument is simply a Type and may itself be a type reference to a generic type. - A type reference to a generic type G designates a type wherein all occurrences of G's type parameters have been replaced - with the actual type arguments supplied in the type reference. + A type argument is simply a Type and may itself be a type reference to a generic type. + A type reference to a generic type G designates a type wherein all occurrences of G's type parameters have been replaced + with the actual type arguments supplied in the type reference. module: ESNext isCurrent: true ---*/ @@ -37,8 +37,7 @@ interface h_G { h_x: T; h_y: U; } - -var h_v: h_G, h_C> = { +let h_v: h_G, h_C> = { h_x: { h_x: { h_a: 'h_a' }, h_y: { diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/union_type_literals/union_type_literals.ts b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/union_type_literals/union_type_literals.ts index 274586615f..76018c6cfd 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/union_type_literals/union_type_literals.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/union_type_literals/union_type_literals.ts @@ -14,8 +14,8 @@ */ /**--- description: > - A union type literal is written as a sequence of types separated by vertical bars. - A union type literal references a union type. + A union type literal is written as a sequence of types separated by vertical bars. + A union type literal references a union type. module: ESNext isCurrent: true ---*/ @@ -23,7 +23,7 @@ import { Assert } from '../../../../../suite/assert.js' -var t_union: string | number; +let t_union: string | number; t_union = 's'; Assert.isString(t_union); t_union = 5; diff --git a/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_1.ts b/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_1.ts index e308e2cb12..f245dc5f8c 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_1.ts @@ -23,13 +23,12 @@ ---*/ -import {Assert} from '../../../../suite/assert.js' +import { Assert } from '../../../../suite/assert.js' -var x: any; +let x: any; x = 12; -Assert.isNumber(x); +Assert.equal(x, 12); x = "abc"; -Assert.isString(x); +Assert.equal(x, "abc"); x = true; -Assert.isBoolean(x); - +Assert.equal(x, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_2.ts b/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_2.ts index f6ea162cae..d02ee66334 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_2.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_2.ts @@ -23,9 +23,9 @@ ---*/ -import {Assert} from '../../../../suite/assert.js' +import { Assert } from '../../../../suite/assert.js' -var a; +let a; a = 25.25; Assert.isNumber(a); a = "narc"; @@ -47,4 +47,4 @@ if (a === null) { } Assert.isTrue(flag); a = undefined; -Assert.isUndefined(a); +Assert.isUndefined(a); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_3.ts b/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_3.ts index ed46bf3ef3..9521493864 100644 --- a/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_3.ts +++ b/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_3.ts @@ -21,15 +21,15 @@ ---*/ -import {Assert} from '../../../../suite/assert.js' +import { Assert } from '../../../../suite/assert.js' -var x: any +let x: any x = 1024; x.toString(); Assert.isString(x.toString()); x = "AAA"; x.length; -Assert.isNumber(x.length); -var fun3: any; -fun3 = () => { }; -fun3(); +Assert.equal(x.length, 3); +let fun: any; +fun = (a: number) => a; +Assert.equal(fun(5), 5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity.ts b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity.ts new file mode 100644 index 0000000000..f56301825f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the variables 'a' and 'b' are of identical types because the two type references to 'C' create types with a private member 'x' that originates in the same declaration, + and because the two private 'x' members have types with identical sets of members once the type arguments 'X' and 'Y' are substituted. + module: ESNext + isCurrent: true + ---*/ + + +import {Assert} from '../../../../../suite/assert.js' + +class Teacher { + private x: T; + constructor(t:T) { + this.x = t; + } + +} + +interface student1 { f(): string; } + +interface student2 { f(): string; } + +class Person implements student1,student2 { + f() { + return "X+Y" + } +} + +let Hwa: Teacher = new Teacher(new Person); +let Hwb: Teacher = new Teacher(new Person); + +Assert.isObject(Hwa); +Assert.isObject(Hwb); +Assert.equal(typeof Hwa,typeof Hwb) -- Gitee From 8ea5b5c0f2821f1081fa7cd60b4b43a79d4c56a3 Mon Sep 17 00:00:00 2001 From: tanglizhen Date: Fri, 2 Jun 2023 11:42:50 +0800 Subject: [PATCH 03/18] =?UTF-8?q?Ts=20test=20cases=20Issues=EF=BC=9Ahttps:?= =?UTF-8?q?//gitee.com/openharmony/arkcompiler=5Fets=5Ffrontend/issues/I78?= =?UTF-8?q?HJU=3Ffrom=3Dproject-issue=20Signed-off-by:=20tanglizhen=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cannot_be_type_name/string_cannot_be_type_name_1.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_1.ts b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_1.ts index b4f75864c2..12b23f8e42 100644 --- a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_1.ts +++ b/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_1.ts @@ -24,4 +24,4 @@ import { Assert } from '../../../../../../suite/assert.js' function string(): number { return 10; } -Assert.equal(string, 10); +Assert.equal(string(), 10); -- Gitee From 10231f9b5350c906d696585ddc57fcecdb267bd2 Mon Sep 17 00:00:00 2001 From: tanglizhen Date: Fri, 2 Jun 2023 13:38:55 +0800 Subject: [PATCH 04/18] =?UTF-8?q?Ts=20test=20cases=20Issues=EF=BC=9Ahttps:?= =?UTF-8?q?//gitee.com/openharmony/arkcompiler=5Fets=5Ffrontend/issues/I78?= =?UTF-8?q?HJU=3Ffrom=3Dproject-issue=20Signed-off-by:=20tanglizhen=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es2panda/test/ts_extra_tests/run_ts_case.py | 4 ++-- .../abstract_properties_and_accessors.ts | 0 .../allow_duplicate_identifiers_across_declarations_1.ts | 0 .../control_flow_based_type_analysis1.ts | 0 .../control_flow_based_type_analysis2.ts | 0 .../control_flow_based_type_analysis3.ts | 0 .../dotted_names_in_type_guards_1.ts | 0 .../2.0/expression_operators/expression_operators_1.ts | 0 .../2.0/expression_operators/expression_operators_2.ts | 0 .../implicit_index_signatures/implicit_index_signatures.ts | 0 .../module_identifiers_allow_for_js_extension_1.ts | 0 .../test_js_extension.ts | 0 .../module_resolution_enhancements_1.ts | 0 .../module_resolution_enhancements_2.ts | 0 .../module_resolution_enhancements_3.ts | 0 .../non_null_assertion_operator.ts | 0 .../optional_class_properties/optional_class_properties.ts | 0 .../optional_parameters_and_properties.ts | 0 .../private_and_protected_constructor.ts | 0 .../read-only_properties_and_index_signatures.ts | 0 .../shorthand_ambient_module_declarations/hot-new-module.ts | 0 .../shorthand_ambient_module_declarations_1.ts | 0 .../specifying_the_type_of_this_for_functions_1.ts | 0 .../specifying_the_type_of_this_for_functions_2.ts | 0 .../2.0/support_for_UMD_module_definitions/math-lib.ts | 0 .../support_for_UMD_module_definitions_1.ts | 0 .../2.0/tagged_union_types/tagged_union_types_1.ts | 0 .../{test => test_ts_cases}/2.0/test_base_url.ts | 0 .../2.0/test_virtual_directories_with_rootDirs/view1.ts | 0 .../2.0/test_virtual_directories_with_rootDirs/view2.ts | 0 .../better_inference_for_literal_types_1.ts | 0 .../better_inference_for_literal_types_2.ts | 0 .../better_inference_for_literal_types_3.ts | 0 .../downlevel_async_functions/downlevel_async_functions_1.ts | 0 .../2.1/improved_any_inference/improved_any_inference_1.ts | 0 .../2.1/improved_any_inference/improved_any_inference_2.ts | 0 .../2.1/keyof_and_lookup_types/keyof_and_lookup_types_1.ts | 0 .../2.1/keyof_and_lookup_types/keyof_and_lookup_types_2.ts | 0 .../2.1/mapped_types/mapped_types_1.ts | 0 .../2.1/mapped_types/mapped_types_2.ts | 0 .../2.1/mapped_types/mapped_types_3.ts | 0 .../2.1/mapped_types/mapped_types_4.ts | 0 .../2.1/object_spread_and_rest/object_spread_and_rest_1.ts | 0 .../2.1/object_spread_and_rest/object_spread_and_rest_2.ts | 0 .../2.1/object_spread_and_rest/object_spread_and_rest_3.ts | 0 .../use_returned_values_from_super_call_as_this_1.ts | 0 .../dotted_property_for_types_with_string_index_signatures.ts | 0 .../{test => test_ts_cases}/2.2/object_type/object_type.ts | 0 .../support_for_mix_in_classes_1.ts | 0 .../support_for_mix_in_classes_2.ts | 0 .../2.2/support_for_new.target/support_for_new.target_1.ts | 0 .../2.2/support_for_new.target/support_for_new.target_2.ts | 0 .../2.3/async_iteration/async_generators/async_generators.ts | 0 .../2.3/async_iteration/async_iterators/async_iterators_1.ts | 0 .../2.3/async_iteration/async_iterators/async_iterators_2.ts | 0 .../generators/generators_1.ts | 0 .../generators/generators_2.ts | 0 .../iterators/iterators_1.ts | 0 .../iterators/iterators_2.ts | 0 .../generic_parameter_defaults_1.ts | 0 .../generic_parameter_defaults_2.ts | 0 .../generic_parameter_defaults_3.ts | 0 .../1_dynamic_import_expressions.ts | 0 .../2.4/1_dynamic_import_expressions/lib.ts | 0 .../2.4/2_string_enums/string_enums_1.ts | 0 .../3_improved_inference_for_generics.ts | 0 .../4_strict_contravariance_for_callback_parameters.ts | 0 .../2.4/5_weak_type_detection/5_weak_type_detection.ts | 0 .../2.5/1_optional_catch_clause_variables.ts | 0 .../suppress_errors_in_ts_files_using_ts_ignore_comments.ts | 0 .../2.7/10_numeric_separators/10_numeric_separators.ts | 0 .../1_constant_named_properties.ts | 0 .../2.7/2_unique_symbol/2_unique_symbol.ts | 0 .../3_strict_class_initialization.ts | 0 .../4_definite_assignment_assertions.ts | 0 .../2.7/5_fixed_length_tuples/5_fixed_length_tuples.ts | 0 .../6_improved_type_inference_for_object_literals.ts | 0 .../2.7/7_improved_handling/7_improved_handling.ts | 0 .../8_Type_guards_inferred_from_in_operator.ts | 0 .../2.8/Improved_keyof_with_intersection_types.ts | 0 .../{test => test_ts_cases}/2.8/conditional_types.ts | 0 .../2.8/distributive_conditional_types.ts | 0 .../{test => test_ts_cases}/2.8/filter_union_types.ts | 0 .../2.8/improved_control_over_mapped_type_modifiers.ts | 0 .../2.8/predefined_conditional_types.ts | 0 .../{test => test_ts_cases}/2.8/prototype_assignment.ts | 0 .../{test => test_ts_cases}/2.8/type_inference.ts | 0 .../1_support_number_and_symbol_nam_1.ts | 0 .../1_support_number_and_symbol_nam_2.ts | 0 .../1_support_number_and_symbol_nam_3.ts | 0 .../2.9/3_generic_type_arguments_in_tt.ts | 0 .../{test => test_ts_cases}/2.9/4_import_types.ts | 0 .../test/ts_extra_tests/{test => test_ts_cases}/2.9/module.ts | 0 .../3.0/new_unknown_top_type/new_unknown_top_type.ts | 0 .../3.0/reference_lib/reference_lib.ts | 0 .../generic_rest_parameters/generic_rest_parameters.ts | 0 .../optional_elements_in_tuple_types.ts | 0 .../rest_elements_in_tuple_types.ts | 0 .../rest_parameters_with_tuple_types.ts | 0 .../spread_expressions_with_tuple_types.ts | 0 .../mapped_types_on_tuples_and_arrays_1.ts | 0 .../properties_declarations_on_functions_1.ts | 0 .../{test => test_ts_cases}/3.2/bigint/bigint_1.ts | 0 .../{test => test_ts_cases}/3.2/bigint/bigint_2.ts | 0 .../{test => test_ts_cases}/3.2/bigint/bigint_3.ts | 0 .../generic_object_rest_variables_and_parameters.ts | 0 .../generic_spread_expressions_in_object_literals_1.ts | 0 .../generic_spread_expressions_in_object_literals_2.ts | 0 .../generic_spread_expressions_in_object_literals_3.ts | 0 .../non-unit_types_as_union_discriminants.ts | 0 .../3.3/improved_behavior_for_calling_union_types.ts | 0 .../3.4/a_new_syntax_for_readonly_array.ts | 0 .../{test => test_ts_cases}/3.4/const_assertions.ts | 0 .../3.4/higher_order_type_inference.ts | 0 .../{test => test_ts_cases}/3.4/readonly_tuples.ts | 0 .../3.5/higher_order_type_inference.ts | 0 .../3.5/improved_excess_property_checks_in_union_types.ts | 0 .../{test => test_ts_cases}/3.5/omit_helper_type.ts | 0 .../3.5/smarter_union_type_checking.ts | 0 .../better_unicode_support_for_identifiers_1.ts | 0 ...get_and_set_accessors_are_allowed_in_ambient_contexts_1.ts | 0 .../test.ts | 0 .../more_accurate_array_spread_1.ts | 0 .../3.6/stricter_generators/stricter_generators_1.ts | 0 .../3.6/stricter_generators/stricter_generators_2.ts | 0 .../3.6/stricter_generators/stricter_generators_3.ts | 0 .../3.6/stricter_generators/stricter_generators_4.ts | 0 .../3.6/stricter_generators/stricter_generators_5.ts | 0 .../3.7/assertion_functions/assertion_functions_1.ts | 0 .../3.7/nullish_coalescing/nullish_coalescing_1.ts | 0 .../3.7/nullish_coalescing/nullish_coalescing_2.ts | 0 .../3.7/optional_chaining/optional_chaining_1.ts | 0 .../3.7/optional_chaining/optional_chaining_2.ts | 0 .../3.7/optional_chaining/optional_chaining_3.ts | 0 .../3.7/optional_chaining/optional_chaining_4.ts | 0 .../3.7/optional_chaining/optional_chaining_5.ts | 0 .../3.7/recursive_type_aliases/recursive_type_aliases_1.ts | 0 .../ts_nocheck_in_typescript_files.ts | 0 .../3.8/1_type_only_imports_and_export.ts | 0 .../2_ecmsscript_private_fields_1.ts | 0 .../2_ecmsscript_private_fields_2.ts | 0 .../2_ecmsscript_private_fields_3.ts | 0 .../{test => test_ts_cases}/3.8/3_which_should_i_use.ts | 0 .../{test => test_ts_cases}/3.8/4_export_star_as_ns_syntax.ts | 0 .../ts_extra_tests/{test => test_ts_cases}/3.8/export_star.ts | 0 .../ts_extra_tests/{test => test_ts_cases}/3.8/my_module.ts | 0 .../ts_extra_tests/{test => test_ts_cases}/3.8/some_module.ts | 0 .../improvements_in_inference_and_Promise.all.ts | 0 .../3.9/ts-expect-error_comments/ts-expect-error_comments.ts | 0 .../class_property_Inference_from_constructors_1.ts | 0 .../4.0/labeled_tuple_elements/labeled_tuple_elements_1.ts | 0 .../4.0/labeled_tuple_elements/labeled_tuple_elements_2.ts | 0 .../4.0/labeled_tuple_elements/labeled_tuple_elements_3.ts | 0 .../4.0/labeled_tuple_elements/labeled_tuple_elements_4.ts | 0 .../short_circuiting_assignment_operators_1.ts | 0 .../short_circuiting_assignment_operators_2.ts | 0 .../short_circuiting_assignment_operators_3.ts | 0 .../unknow_on_catch_clause_bindings_1.ts | 0 .../unknow_on_catch_clause_bindings_2.ts | 0 .../4.0/variadic_tuple_types/variadic_tuple_types_1.ts | 0 .../4.0/variadic_tuple_types/variadic_tuple_types_2.ts | 0 .../4.0/variadic_tuple_types/variadic_tuple_types_3.ts | 0 .../4.0/variadic_tuple_types/variadic_tuple_types_4.ts | 0 .../4.0/variadic_tuple_types/variadic_tuple_types_5.ts | 0 .../4.0/variadic_tuple_types/variadic_tuple_types_6.ts | 0 .../4.1/Checked_Indexed_Accesses/Checked_Indexed_Accesses.ts | 0 .../4.1/Checked_Indexed_Accesses/for_each_index.ts | 0 .../4.1/Checked_Indexed_Accesses/for_of_index.ts | 0 .../4.1/Checked_Indexed_Accesses/for_traversal_index.ts | 0 .../abstract_members_can_not_be_marked_async.ts | 0 .../any_or_unknown_are_propagated_in_falsy_positions.ts | 0 .../conditional_spreads_create_optional_properties_1.ts | 0 .../key_remapping_in_mapped_types_1.ts | 0 .../key_remapping_in_mapped_types_2.ts | 0 .../recursive_conditional_types.ts | 0 .../resolves_parameters_are_no_longer_optional_in_promises.ts | 0 .../4.1/template_literal_types/template_literal_types_1.ts | 0 .../4.1/template_literal_types/template_literal_types_2.ts | 0 .../4.1/template_literal_types/template_literal_types_3.ts | 0 .../Reverting_Template_Literal_Inference.ts | 0 .../abstract_construct_signatures.ts | 0 .../abstract_construct_signatures_1.ts | 0 .../abstract_construct_signatures_2.ts | 0 .../abstract_construct_signatures_3.ts | 0 .../leading_middle_rest_elements_in_tuple_types1.ts | 0 .../leading_middle_rest_elements_in_tuple_types2.ts | 0 .../leading_middle_rest_elements_in_tuple_types3.ts | 0 .../smarter_type_alias_preservation1.ts | 0 .../smarter_type_alias_preservation2.ts | 0 .../always-truthy_promise_checks.ts | 0 .../constructorParameters_works_on_abstract_class.ts | 0 .../contextual_narrowing_for_generics.ts | 0 .../ecmascript_private_calss_elements.ts | 0 .../override_and_the_noImplicitOverride_Flag.ts | 0 .../separate_write_types_on_properties_1.ts | 0 .../separate_write_types_on_properties_2.ts | 0 .../4.3/static_index_signatures/static_index_signatures.ts | 0 .../template_string_type_improvements_1.ts | 0 .../template_string_type_improvements_2.ts | 0 .../template_string_type_improvements_3.ts | 0 .../template_string_type_improvements_4.ts | 0 .../union_enums_cannot_be_compared_to_arbitrary_numbers.ts | 0 ...flow_analysis_of_aliased_conditions_and_discriminants_1.ts | 0 ...flow_analysis_of_aliased_conditions_and_discriminants_2.ts | 0 ...flow_analysis_of_aliased_conditions_and_discriminants_3.ts | 0 ...flow_analysis_of_aliased_conditions_and_discriminants_4.ts | 0 .../defaulting_to_the_unknown_type_in_catch_variables_1.ts | 0 .../defaulting_to_the_unknown_type_in_catch_variables_2.ts | 0 .../defaulting_to_the_unknown_type_in_catch_variables_3.ts | 0 .../exact_optional_property_types_1.ts | 0 .../4.4/static_blocks_in_classe/static_blocks_in_classes1.ts | 0 .../4.4/static_blocks_in_classe/static_blocks_in_classes2.ts | 0 .../symbol_and_templates_string_pattern_index_signatures_1.ts | 0 .../symbol_and_templates_string_pattern_index_signatures_2.ts | 0 .../symbol_and_templates_string_pattern_index_signatures_3.ts | 0 .../symbol_and_templates_string_pattern_index_signatures_4.ts | 0 .../symbol_and_templates_string_pattern_index_signatures_5.ts | 0 .../4.5/disabling_import_elision/animal.ts | 0 .../disabling_import_elision/disabling_import_elision_1.ts | 0 .../private_field_presence_checks_1.ts | 0 .../tail_recursion_elimination_on_conditional_types1.ts | 0 .../tail_recursion_elimination_on_conditional_types2.ts | 0 .../template_string_types_as_discriminants_1.ts | 0 .../the_awaited_type_and_promise_improvements_1.ts | 0 .../4.5/type_modifiers_on_import_names/some-module.ts | 0 .../type_modifiers_on_import_names_1.ts | 0 .../4.6/1_allowing_code_in_constructors.ts | 0 .../{test => test_ts_cases}/4.6/2_control_flow_analysis.ts | 0 .../4.6/3_improved_recursion_depth_checks.ts | 0 .../4.6/4_indexed_access_inference_improvements.ts | 0 .../4.6/5_control_flow_analysis_for_dependent_parameters.ts | 0 .../control-flow_analysis_for_bracketed_element_access.ts | 0 .../control-flow_analysis_for_bracketed_element_access_1.ts | 0 .../extends_constraints_on_infer_type_variables.ts | 0 .../improved_function_inference_in_objects_and_methods.ts | 0 .../instantiation_expressions/instantiation_expressions.ts | 0 .../optional_variance_annotations_for_type_parameters.ts | 0 .../readonly_tuples_have_a_readonly_length_property.ts | 0 ...tersection_Reduction_Union_Compatibility,_and_Narrowing.ts | 0 ...oved_inference_for_infer_types_in_template_string_types.ts | 0 .../auto_accessors_in_classes/auto_accessors_in_classes.ts | 0 .../checks_for_equality_on_NaN/checks_for_equality_on_NaN.ts | 0 .../4.9/the_satisfies_operator/the_satisfies_operator.ts | 0 .../unlisted_property_narrowing_with_the_in_operator.ts | 0 .../ambient_function_declarations.ts | 0 .../ambient_namespace_declarations.ts | 0 .../ambient_module_declarations_1.ts | 0 .../ambient_module_declarations_3.ts | 0 .../spec/basic_concepts/declarations/declarations_1.ts | 0 .../spec/basic_concepts/declarations/declarations_2.ts | 0 .../computed_property_names/computed_property_names_1.ts | 0 .../basic_concepts/names/property_names/property_names_1.ts | 0 .../cannot_be_type_name/any_cannot_be_type_name_1.ts | 0 .../cannot_be_type_name/any_cannot_be_type_name_2.ts | 0 .../cannot_be_type_name/boolean_cannot_be_type_name_1.ts | 0 .../cannot_be_type_name/boolean_cannot_be_type_name_2.ts | 0 .../cannot_be_type_name/number_cannot_be_type_name_1.ts | 0 .../cannot_be_type_name/number_cannot_be_type_name_2.ts | 0 .../cannot_be_type_name/string_cannot_be_type_name_1.ts | 0 .../cannot_be_type_name/string_cannot_be_type_name_2.ts | 0 .../cannot_be_type_name/symbol_cannot_be_type_name_1.ts | 0 .../cannot_be_type_name/symbol_cannot_be_type_name_2.ts | 0 .../abstract_is_valid_identifier_1.ts | 0 .../abstract_is_valid_identifier_2.ts | 0 .../abstract_is_valid_identifier_3.ts | 0 .../abstract_is_valid_identifier_4.ts | 0 .../as_is_valid_identifier_1.ts | 0 .../as_is_valid_identifier_2.ts | 0 .../as_is_valid_identifier_3.ts | 0 .../as_is_valid_identifier_4.ts | 0 .../async_is_valid_identifier_1.ts | 0 .../async_is_valid_identifier_2.ts | 0 .../async_is_valid_identifier_3.ts | 0 .../async_is_valid_identifier_4.ts | 0 .../constructor_is_valid_identifier_1.ts | 0 .../constructor_is_valid_identifier_2.ts | 0 .../constructor_is_valid_identifier_3.ts | 0 .../constructor_is_valid_identifier_4.ts | 0 .../declare_is_valid_identifier_1.ts | 0 .../declare_is_valid_identifier_2.ts | 0 .../declare_is_valid_identifier_3.ts | 0 .../declare_is_valid_identifier_4.ts | 0 .../from_is_valid_identifier_1.ts | 0 .../from_is_valid_identifier_2.ts | 0 .../from_is_valid_identifier_3.ts | 0 .../from_is_valid_identifier_4.ts | 0 .../get_is_valid_identifier_1.ts | 0 .../get_is_valid_identifier_2.ts | 0 .../get_is_valid_identifier_3.ts | 0 .../get_is_valid_identifier_4.ts | 0 .../is_is_valid_identifier_1.ts | 0 .../is_is_valid_identifier_2.ts | 0 .../is_is_valid_identifier_3.ts | 0 .../is_is_valid_identifier_4.ts | 0 .../module_is_valid_identifier_1.ts | 0 .../module_is_valid_identifier_2.ts | 0 .../module_is_valid_identifier_3.ts | 0 .../module_is_valid_identifier_4.ts | 0 .../namespace_is_valid_identifier_1.ts | 0 .../namespace_is_valid_identifier_2.ts | 0 .../namespace_is_valid_identifier_3.ts | 0 .../namespace_is_valid_identifier_4.ts | 0 .../of_is_valid_identifier_1.ts | 0 .../of_is_valid_identifier_2.ts | 0 .../of_is_valid_identifier_3.ts | 0 .../of_is_valid_identifier_4.ts | 0 .../require_is_valid_identifier_1.ts | 0 .../set_is_valid_identifier_1.ts | 0 .../set_is_valid_identifier_2.ts | 0 .../set_is_valid_identifier_3.ts | 0 .../set_is_valid_identifier_4.ts | 0 .../type_is_valid_identifier_1.ts | 0 .../type_is_valid_identifier_2.ts | 0 .../type_is_valid_identifier_3.ts | 0 .../type_is_valid_identifier_4.ts | 0 .../spec/basic_concepts/scopes/let_scope.ts | 0 .../spec/basic_concepts/scopes/namespace.ts | 0 .../spec/basic_concepts/scopes/scopes_1.ts | 0 .../spec/basic_concepts/scopes/scopes_2.ts | 0 .../spec/basic_concepts/scopes/scopes_2_m.ts | 0 .../spec/basic_concepts/scopes/scopes_3.ts | 0 .../spec/basic_concepts/scopes/scopes_4.ts | 0 .../spec/basic_concepts/scopes/var_scope.ts | 0 .../spec/classes/class_declarations/class_body/class_body.ts | 0 .../spec/classes/class_declarations/class_declarations_1.ts | 0 .../spec/classes/class_declarations/class_declarations_2.ts | 0 .../spec/classes/class_declarations/class_declarations_3.ts | 0 .../class_heritage_specification_1.ts | 0 .../class_heritage_specification_2.ts | 0 .../class_heritage_specification_3.ts | 0 .../class_heritage_specification_4.ts | 0 .../class_heritage_specification_5.ts | 0 .../class_heritage_specification_6.ts | 0 .../automatic_constructors/automatic_constructors_1.ts | 0 .../automatic_constructors/automatic_constructors_2.ts | 0 .../automatic_constructors/automatic_constructors_3.ts | 0 .../constructor_parameters/constructor_parameters_1.ts | 0 .../constructor_parameters/constructor_parameters_2.ts | 0 .../constructor_parameters/constructor_parameters_3.ts | 0 .../constructor_parameters/constructor_parameters_4.ts | 0 .../constructor_parameters/constructor_parameters_5.ts | 0 .../constructor_parameters/constructor_parameters_6.ts | 0 .../constructor_declarations/super_calls/super_calls.ts | 0 .../index_member_declarations/index_member_declarations.ts | 0 .../spec/classes/members/accessibility/accessibility_1.ts | 0 .../spec/classes/members/accessibility/accessibility_2.ts | 0 .../spec/classes/members/accessibility/accessibility_3.ts | 0 .../spec/classes/members/class_types/class_types_1.ts | 0 .../spec/classes/members/class_types/class_types_2.ts | 0 .../spec/classes/members/class_types/class_types_3.ts | 0 .../constructor_function_types_1.ts | 0 .../constructor_function_types_2.ts | 0 .../constructor_function_types_3.ts | 0 .../constructor_function_types_4.ts | 0 .../constructor_function_types_5.ts | 0 .../constructor_function_types_6.ts | 0 .../constructor_function_types_7.ts | 0 .../constructor_function_types_8.ts | 0 .../inheritance_and_overriding_1.ts | 0 .../inheritance_and_overriding_2.ts | 0 .../inheritance_and_overriding_3.ts | 0 .../inheritance_and_overriding_4.ts | 0 .../inheritance_and_overriding_5.ts | 0 .../instance_and_static_members_1.ts | 0 .../instance_and_static_members_2.ts | 0 .../instance_and_static_members_3.ts | 0 .../member_accessor_declarations.ts | 0 .../member_function_declarations_1.ts | 0 .../member_function_declarations_2.ts | 0 .../member_function_declarations_3.ts | 0 .../member_function_declarations_4.ts | 0 .../member_function_declarations_5.ts | 0 .../member_variable_declarations_1.ts | 0 .../member_variable_declarations_2.ts | 0 .../member_variable_declarations_3.ts | 0 .../member_variable_declarations_4.ts | 0 .../property_member_declarations_1.ts | 0 .../property_member_declarations_2.ts | 0 .../property_member_declarations_3.ts | 0 .../constant_enum_declarations/constant_enum_declarations.ts | 0 .../spec/enums/declaration_merging/declaration_merging_1.ts | 0 .../spec/enums/declaration_merging/declaration_merging_2.ts | 0 .../spec/enums/enum_declarations/enum_declarations_1.ts | 0 .../spec/enums/enum_declarations/enum_declarations_2.ts | 0 .../spec/enums/enum_declarations/enum_declarations_3.ts | 0 .../spec/enums/enum_members/enum_members_1.ts | 0 .../spec/expressions/array_literals/array_literal_1.ts | 0 .../spec/expressions/array_literals/array_literal_2.ts | 0 .../spec/expressions/array_literals/array_literal_3.ts | 0 .../spec/expressions/array_literals/array_literal_4.ts | 0 .../spec/expressions/array_literals/array_literal_5.ts | 0 .../spec/expressions/array_literals/array_literal_6.ts | 0 .../spec/expressions/arrow_function/arrow_function_1.ts | 0 .../spec/expressions/arrow_function/arrow_function_2.ts | 0 .../spec/expressions/arrow_function/arrow_function_3.ts | 0 .../spec/expressions/arrow_function/arrow_function_4.ts | 0 .../assignment_operators/assignment_operator_1.ts | 0 .../assignment_operators/assignment_operator_2.ts | 0 .../assignment_operators/assignment_operator_3.ts | 0 .../destructing_assignment/destructing_assignment_1.ts | 0 .../destructing_assignment/destructing_assignment_2.ts | 0 .../destructing_assignment/destructing_assignment_3.ts | 0 .../destructing_assignment/destructing_assignment_4.ts | 0 .../destructing_assignment/destructing_assignment_5.ts | 0 .../destructing_assignment/destructing_assignment_6.ts | 0 .../destructing_assignment/destructing_assignment_7.ts | 0 .../destructing_assignment/destructing_assignment_8.ts | 0 .../binary_operators/the_add_operator/the_add_operator_1.ts | 0 .../binary_operators/the_add_operator/the_add_operator_2.ts | 0 .../binary_operators/the_add_operator/the_add_operator_3.ts | 0 .../binary_operators/the_and_operator/the_and_operator.ts | 0 .../the_greater_less_lessEqual/the_congruence_operator.ts | 0 .../the_greater_less_lessEqual/the_equal_operator.ts | 0 .../the_greater_less_lessEqual/the_greater_operator.ts | 0 .../the_greater_or_equal_operator.ts | 0 .../the_greater_less_lessEqual/the_incongruence_operator.ts | 0 .../the_greater_less_lessEqual/the_less_operator.ts | 0 .../the_greater_less_lessEqual/the_less_or_equal_operator.ts | 0 .../the_greater_less_lessEqual/the_unequal_operator.ts | 0 .../binary_operators/the_in_operator/the_in_operator.ts | 0 .../the_instanceof_operator/the_instanceof_operator.ts | 0 .../binary_operators/the_mul_div_rem/the_and_operator.ts | 0 .../the_mul_div_rem/the_division_method_operator.ts | 0 .../the_mul_div_rem/the_left_shift_operator.ts | 0 .../the_mul_div_rem/the_multiplication_operator.ts | 0 .../binary_operators/the_mul_div_rem/the_or_operator.ts | 0 .../the_mul_div_rem/the_remainder_operator.ts | 0 .../the_mul_div_rem/the_right_shift_operator.ts | 0 .../the_mul_div_rem/the_subtraction_operator.ts | 0 .../the_mul_div_rem/the_unsigned_shift_to_the_right.ts | 0 .../binary_operators/the_mul_div_rem/the_xor_operator.ts | 0 .../binary_operators/the_or_operator/the_or_operator_1.ts | 0 .../binary_operators/the_or_operator/the_or_operator_2.ts | 0 .../spec/expressions/class_expressions/class_expressions_1.ts | 0 .../contextually_typed_expressions_1.ts | 0 .../contextually_typed_expressions_10.ts | 0 .../contextually_typed_expressions_11.ts | 0 .../contextually_typed_expressions_12.ts | 0 .../contextually_typed_expressions_13.ts | 0 .../contextually_typed_expressions_14.ts | 0 .../contextually_typed_expressions_15.ts | 0 .../contextually_typed_expressions_16.ts | 0 .../contextually_typed_expressions_2.ts | 0 .../contextually_typed_expressions_3.ts | 0 .../contextually_typed_expressions_4.ts | 0 .../contextually_typed_expressions_5.ts | 0 .../contextually_typed_expressions_6.ts | 0 .../contextually_typed_expressions_7.ts | 0 .../contextually_typed_expressions_8.ts | 0 .../contextually_typed_expressions_9.ts | 0 .../function_calls/grammar_ambiguities/grammar_ambiguities.ts | 0 .../overload_resolution/overload_resolution_1.ts | 0 .../overload_resolution/overload_resolution_2.ts | 0 .../overload_resolution/overload_resolution_3.ts | 0 .../overload_resolution/overload_resolution_4.ts | 0 .../type_argument_inference/type_argument_inference_1.ts | 0 .../type_argument_inference/type_argument_inference_2.ts | 0 .../type_argument_inference/type_argument_inference_3.ts | 0 .../type_argument_inference/type_argument_inference_4.ts | 0 .../expressions/function_expression/function_expressions_1.ts | 0 .../expressions/function_expression/function_expressions_2.ts | 0 .../expressions/function_expression/function_expressions_3.ts | 0 .../spec/expressions/identifiers/class.ts | 0 .../spec/expressions/identifiers/enum.ts | 0 .../spec/expressions/identifiers/function.ts | 0 .../spec/expressions/identifiers/name_space.ts | 0 .../spec/expressions/identifiers/parameter.ts | 0 .../spec/expressions/identifiers/variable.ts | 0 .../spec/expressions/literals/boolean.ts | 0 .../{test => test_ts_cases}/spec/expressions/literals/null.ts | 0 .../spec/expressions/literals/number.ts | 0 .../spec/expressions/literals/regexp.ts | 0 .../spec/expressions/literals/string.ts | 0 .../spec/expressions/object_literal/object_literal_3.ts | 0 .../spec/expressions/object_literal/object_literal_4.ts | 0 .../spec/expressions/object_literal/object_literal_5.ts | 0 .../spec/expressions/object_literal/object_literal_6.ts | 0 .../spec/expressions/object_literal/object_literal_7.ts | 0 .../spec/expressions/parentheses/parentheses.ts | 0 .../spec/expressions/property_access/object_access_2.ts | 0 .../spec/expressions/property_access/object_any_1.ts | 0 .../spec/expressions/property_access/object_any_type_6.ts | 0 .../spec/expressions/property_access/object_apprent_5.ts | 0 .../spec/expressions/property_access/object_index_4.ts | 0 .../expressions/property_access/object_string_number_3.ts | 0 .../spec/expressions/property_access/property_access_1.ts | 0 .../spec/expressions/property_access/property_access_2.ts | 0 .../spec/expressions/the_comma_operator/the_comma_operator.ts | 0 .../the_conditional_operator/the_conditional_operator_1.ts | 0 .../the_conditional_operator/the_conditional_operator_2.ts | 0 .../spec/expressions/the_new_operator/new_operator_1.ts | 0 .../spec/expressions/the_new_operator/new_operator_2.ts | 0 .../spec/expressions/the_new_operator/new_operator_3.ts | 0 .../spec/expressions/the_new_operator/new_operator_4.ts | 0 .../expressions/the_super_keyword/super_calls/arguments.ts | 0 .../the_super_keyword/super_calls/gengric_extends.ts | 0 .../expressions/the_super_keyword/super_calls/super_calls.ts | 0 .../super_property_access/derived_class_access.ts | 0 .../super_property_access/static_member_access.ts | 0 .../spec/expressions/this_key_word/this_key_word_1.ts | 0 .../spec/expressions/type_assertion/type_assertion_1.ts | 0 .../spec/expressions/type_assertion/type_assertion_2.ts | 0 .../spec/expressions/type_assertion/type_assertion_3.ts | 0 .../spec/expressions/type_guards/type_guards_1.ts | 0 .../spec/expressions/type_guards/type_guards_10.ts | 0 .../spec/expressions/type_guards/type_guards_11.ts | 0 .../spec/expressions/type_guards/type_guards_12.ts | 0 .../spec/expressions/type_guards/type_guards_13.ts | 0 .../spec/expressions/type_guards/type_guards_14.ts | 0 .../spec/expressions/type_guards/type_guards_15.ts | 0 .../spec/expressions/type_guards/type_guards_2.ts | 0 .../spec/expressions/type_guards/type_guards_3.ts | 0 .../spec/expressions/type_guards/type_guards_4.ts | 0 .../spec/expressions/type_guards/type_guards_5.ts | 0 .../spec/expressions/type_guards/type_guards_6.ts | 0 .../spec/expressions/type_guards/type_guards_7.ts | 0 .../spec/expressions/type_guards/type_guards_8.ts | 0 .../spec/expressions/type_guards/type_guards_9.ts | 0 .../spec/expressions/unary_operators/the_!_operator.ts | 0 .../expressions/unary_operators/the_++_and_--_operators.ts | 0 .../spec/expressions/unary_operators/the_+_and_~_operators.ts | 0 .../spec/expressions/unary_operators/the_delete_operator.ts | 0 .../spec/expressions/unary_operators/the_typeof_operator.ts | 0 .../spec/expressions/unary_operators/the_void_operator.ts | 0 .../asynchronous_functions/asynchronous_functions_1.ts | 0 .../asynchronous_functions/asynchronous_functions_2.ts | 0 .../asynchronous_functions/asynchronous_functions_3.ts | 0 .../asynchronous_functions/asynchronous_functions_4.ts | 0 .../destructuring_parameter_declarations_1.ts | 0 .../destructuring_parameter_declarations_2.ts | 0 .../destructuring_parameter_declarations_3.ts | 0 .../destructuring_parameter_declarations_4.ts | 0 .../destructuring_parameter_declarations_5.ts | 0 .../destructuring_parameter_declarations_6.ts | 0 .../destructuring_parameter_declarations_7.ts | 0 .../function_declarations/function_declarations_1.ts | 0 .../function_declarations/function_declarations_2.ts | 0 .../function_implementations/function_implementations_1.ts | 0 .../function_implementations/function_implementations_2.ts | 0 .../function_implementations/function_implementations_3.ts | 0 .../function_implementations/function_implementations_4.ts | 0 .../function_implementations/function_implementations_5.ts | 0 .../spec/functions/function_overloads/function_overloads_1.ts | 0 .../functions/generator_functions/generator_functions_1.ts | 0 .../functions/generator_functions/generator_functions_2.ts | 0 .../functions/generator_functions/generator_functions_3.ts | 0 .../spec/functions/generic_functions/generic_functions_1.ts | 0 .../spec/functions/generic_functions/generic_functions_2.ts | 0 .../functions/type_guard_functions/type_guard_functions_1.ts | 0 .../{test => test_ts_cases}/spec/grammar/classes/classes.ts | 0 .../{test => test_ts_cases}/spec/grammar/enums/enums.ts | 0 .../spec/grammar/expressions/expressions.ts | 0 .../spec/grammar/functions/functions.ts | 0 .../spec/grammar/interfaces/interfaces.ts | 0 .../spec/grammar/namespaces/namespaces.ts | 0 .../spec/grammar/scripts_and_modules/scripts_and_modules.ts | 0 .../spec/grammar/scripts_and_modules/source_file_1.ts | 0 .../spec/grammar/scripts_and_modules/source_file_2.ts | 0 .../spec/grammar/scripts_and_modules/source_file_3.ts | 0 .../spec/grammar/scripts_and_modules/source_file_4.ts | 0 .../spec/grammar/statements/statements.ts | 0 .../{test => test_ts_cases}/spec/grammar/types/types.ts | 0 .../1_interface_declarations/interface_declarations_1.ts | 0 .../1_interface_declarations/interface_declarations_2.ts | 0 .../1_interface_declarations/interface_declarations_3.ts | 0 .../interfaces/2_declaration_merging/declaration_merging_1.ts | 0 .../interfaces/2_declaration_merging/declaration_merging_2.ts | 0 .../interfaces_extending_classes_1.ts | 0 .../interfaces_extending_classes_2.ts | 0 .../interfaces/4_dynamic_type_checks/dynamic_type_checks_1.ts | 0 .../namespaces/declaration_merging/declaration_merging_1_1.ts | 0 .../namespaces/declaration_merging/declaration_merging_1_2.ts | 0 .../namespaces/declaration_merging/declaration_merging_1_3.ts | 0 .../namespaces/declaration_merging/declaration_merging_2.ts | 0 .../namespaces/export_declarations/export_declarations_1.ts | 0 .../namespaces/export_declarations/export_declarations_2.ts | 0 .../namespaces/export_declarations/export_declarations_3.ts | 0 .../import_alias_declarations/import_alias_declarations_1.ts | 0 .../import_alias_declarations/import_alias_declarations_3.ts | 0 .../spec/namespaces/namespace_body/namespace_body.ts | 0 .../namespace_declarations/namespace_declarations_1.ts | 0 .../namespace_declarations/namespace_declarations_2.ts | 0 .../namespace_declarations/namespace_declarations_3.ts | 0 .../namespace_declarations/namespace_declarations_4.ts | 0 .../1_source_files_dependencies/source_00.ts | 0 .../1_source_files_dependencies/source_files_dependencies.ts | 0 .../1_programs_and_source_files/source_1.ts | 0 .../1_programs_and_source_files/source_10.ts | 0 .../1_programs_and_source_files/source_2.ts | 0 .../1_programs_and_source_files/source_3.ts | 0 .../1_programs_and_source_files/source_4.ts | 0 .../1_programs_and_source_files/source_5.ts | 0 .../1_programs_and_source_files/source_6.ts | 0 .../1_programs_and_source_files/source_7.ts | 0 .../1_programs_and_source_files/source_8.ts | 0 .../1_programs_and_source_files/source_9.ts | 0 .../spec/scripts_and_modules/2_modules/modules_1.ts | 0 .../3_import_declarations/import_declarations_1.ts | 0 .../3_import_declarations/import_declarations_2.ts | 0 .../3_import_declarations/import_declarations_3.ts | 0 .../3_import_declarations/import_declarations_4.ts | 0 .../import_require_declarations_1.ts | 0 .../5_export_declarations/export_declarations_1.ts | 0 .../5_export_declarations/export_declarations_2.ts | 0 .../5_export_declarations/export_declarations_3.ts | 0 .../5_export_declarations/export_declarations_4.ts | 0 .../5_export_declarations/export_declarations_5.ts | 0 .../6_export_assignments/export_assignments_1.ts | 0 .../7_commonJS_modules/commonJS_modules_1.ts | 0 .../7_commonJS_modules/commonJS_modules_2.ts | 0 .../if_do_and_while_Statements_1.ts | 0 .../if_do_and_while_Statements_2.ts | 0 .../spec/statements/blocks/blocks_1.ts | 0 .../spec/statements/blocks/blocks_2.ts | 0 .../spec/statements/blocks/blocks_3.ts | 0 .../spec/statements/blocks/blocks_4.ts | 0 .../spec/statements/break_statements/break_statements.ts | 0 .../statements/continue_statements/continue_statements.ts | 0 .../spec/statements/for_in_statements/for_in_statements.ts | 0 .../spec/statements/for_of_statements/for_of_statements.ts | 0 .../spec/statements/for_statements/for_statements.ts | 0 .../let_and_const_declarations/let_and_const_declarations.ts | 0 .../spec/statements/return_statements/return_statements.ts | 0 .../spec/statements/switch_statements/switch_statements.ts | 0 .../spec/statements/throw_statements/throw_statements.ts | 0 .../spec/statements/try_statements/try_statements.ts | 0 .../simple_variable_declarations_1.ts | 0 .../simple_variable_declarations_2.ts | 0 .../simple_variable_declarations_3.ts | 0 .../destructuring_variable_declarations_1.ts | 0 .../destructuring_variable_declarations_2.ts | 0 .../destructuring_variable_declarations_3.ts | 0 .../variable_statements/3_implied_type/implied_type.ts | 0 .../spec/types/Intersection_Types/Intersection_types_1.ts | 0 .../spec/types/Intersection_Types/intersection_types_2.ts | 0 .../spec/types/named_types/named_types_1.ts | 0 .../spec/types/named_types/named_types_2.ts | 0 .../spec/types/named_types/named_types_3.ts | 0 .../spec/types/named_types/named_types_4.ts | 0 .../spec/types/object_types/array_types/array_types_1.ts | 0 .../spec/types/object_types/array_types/array_types_2.ts | 0 .../spec/types/object_types/array_types/array_types_3.ts | 0 .../object_types/constructor_types/constructor_types_1.ts | 0 .../object_types/constructor_types/constructor_types_2.ts | 0 .../object_types/constructor_types/constructor_types_3.ts | 0 .../object_types/constructor_types/constructor_types_4.ts | 0 .../types/object_types/function_types/function_types_1.ts | 0 .../types/object_types/function_types/function_types_2.ts | 0 .../spec/types/object_types/members/members_1.ts | 0 .../spec/types/object_types/members/members_2.ts | 0 .../object_types/named_type_reference/named_type_reference.ts | 0 .../spec/types/object_types/tuple_types/tuple_types_1.ts | 0 .../spec/types/object_types/tuple_types/tuple_types_2.ts | 0 .../spec/types/object_types/tuple_types/tuple_types_3.ts | 0 .../primitive_types/the_boolean_type/the_boolean_type_1.ts | 0 .../primitive_types/the_boolean_type/the_boolean_type_2.ts | 0 .../primitive_types/the_boolean_type/the_boolean_type_3.ts | 0 .../types/primitive_types/the_enum_type/the_enum_type_1.ts | 0 .../types/primitive_types/the_null_type/the_null_type_1.ts | 0 .../primitive_types/the_number_type/the_number_type_1.ts | 0 .../primitive_types/the_number_type/the_number_type_2.ts | 0 .../primitive_types/the_number_type/the_number_type_3.ts | 0 .../the_string_literal_type/the_string_literal_type_1.ts | 0 .../the_string_literal_type/the_string_literal_type_2.ts | 0 .../the_string_literal_type/the_string_literal_type_3.ts | 0 .../primitive_types/the_string_type/the_string_type_1.ts | 0 .../primitive_types/the_string_type/the_string_type_2.ts | 0 .../primitive_types/the_string_type/the_string_type_3.ts | 0 .../primitive_types/the_symbol_type/the_symbol_type_1.ts | 0 .../primitive_types/the_symbol_type/the_symbol_type_2.ts | 0 .../primitive_types/the_symbol_type/the_symbol_type_3.ts | 0 .../the_undefined_type/the_undefined_type_1.ts | 0 .../types/primitive_types/the_void_type/the_void_type_1.ts | 0 .../types/primitive_types/the_void_type/the_void_type_2.ts | 0 .../types/primitive_types/the_void_type/the_void_type_3.ts | 0 .../call_signatures/parameter_list/parameter_list_1.ts | 0 .../call_signatures/parameter_list/parameter_list_2.ts | 0 .../call_signatures/parameter_list/parameter_list_3.ts | 0 .../call_signatures/parameter_list/parameter_list_4.ts | 0 .../call_signatures/parameter_list/parameter_list_5.ts | 0 .../call_signatures/parameter_list/parameter_list_6.ts | 0 .../call_signatures/return_type/return_type_1.ts | 0 .../call_signatures/return_type/return_type_2.ts | 0 .../call_signatures/return_type/return_type_3.ts | 0 .../specialized_signatures/specialized_signatures_1.ts | 0 .../call_signatures/type_parameters/type_parameters_1.ts | 0 .../call_signatures/type_parameters/type_parameters_2.ts | 0 .../construct_signatures/construct_signatures.ts | 0 .../specifying_members/index_signatures/index_signatures.ts | 0 .../method_signatures/method_signatures_1.ts | 0 .../method_signatures/method_signatures_2.ts | 0 .../property_signatures/property_signatures.ts | 0 .../array_type_literals/array_type_literals_1.ts | 0 .../array_type_literals/array_type_literals_2.ts | 0 .../array_type_literals/array_type_literals_3.ts | 0 .../array_type_literals/array_type_literals_4.ts | 0 .../function_type_literals/function_type_literals_3.ts | 0 .../intersection_type_literals/intersection_type_literals.ts | 0 .../object_type_literals/object_type_literals.ts | 0 .../specifying_types/predefined_types/predefined_types.ts | 0 .../spec/types/specifying_types/specifying_types_1.ts | 0 .../spec/types/specifying_types/specifying_types_2.ts | 0 .../this_type_references/this_type_references_1.ts | 0 .../this_type_references/this_type_references_2.ts | 0 .../tuple_type_literals/tuple_type_literals.ts | 0 .../types/specifying_types/type_queries/type_queries_1.ts | 0 .../types/specifying_types/type_queries/type_queries_2.ts | 0 .../specifying_types/type_references/type_references_1.ts | 0 .../specifying_types/type_references/type_references_2.ts | 0 .../specifying_types/type_references/type_references_3.ts | 0 .../union_type_literals/union_type_literals.ts | 0 .../spec/types/the_any_type/any_type_1.ts | 0 .../spec/types/the_any_type/any_type_2.ts | 0 .../spec/types/the_any_type/any_type_3.ts | 0 .../spec/types/type_aliases/type_aliases_1.ts | 0 .../spec/types/type_aliases/type_aliases_2.ts | 0 .../spec/types/type_aliases/type_aliases_3.ts | 0 .../spec/types/type_parameters/this_types/this_types.ts | 0 .../spec/types/type_parameters/this_types/this_types_1.ts | 0 .../spec/types/type_parameters/this_types/this_types_2.ts | 0 .../type_argument_lists/type_argument_lists_1.ts | 0 .../type_argument_lists/type_argument_lists_2.ts | 0 .../type_argument_lists/type_argument_lists_3.ts | 0 .../type_argument_lists/type_argument_lists_4.ts | 0 .../type_parameter_lists/type_parameter_lists_1.ts | 0 .../type_parameter_lists/type_parameter_lists_2.ts | 0 .../type_parameter_lists/type_parameter_lists_3.ts | 0 .../type_parameter_lists/type_parameter_lists_4.ts | 0 .../type_parameter_lists/type_parameter_lists_5.ts | 0 .../type_parameter_lists/type_parameter_lists_6.ts | 0 .../Type_and_Member_Identity/Type_and_Member_Identity.ts | 0 .../type_relationships/apparent_members/apparent_members_1.ts | 0 .../type_relationships/apparent_members/apparent_members_2.ts | 0 .../type_relationships/apparent_members/apparent_members_3.ts | 0 .../type_relationships/apparent_members/apparent_members_4.ts | 0 .../type_relationships/apparent_members/apparent_members_5.ts | 0 .../type_relationships/apparent_members/apparent_members_6.ts | 0 .../type_relationships/apparent_members/apparent_members_7.ts | 0 .../type_relationships/apparent_members/apparent_members_8.ts | 0 .../assignment_compatibility/assignment_compatibility_1.ts | 0 .../assignment_compatibility/assignment_compatibility_10.ts | 0 .../assignment_compatibility/assignment_compatibility_11.ts | 0 .../assignment_compatibility/assignment_compatibility_12.ts | 0 .../assignment_compatibility/assignment_compatibility_13.ts | 0 .../assignment_compatibility/assignment_compatibility_14.ts | 0 .../assignment_compatibility/assignment_compatibility_15.ts | 0 .../assignment_compatibility/assignment_compatibility_16.ts | 0 .../assignment_compatibility/assignment_compatibility_17.ts | 0 .../assignment_compatibility/assignment_compatibility_18.ts | 0 .../assignment_compatibility/assignment_compatibility_2.ts | 0 .../assignment_compatibility/assignment_compatibility_3.ts | 0 .../assignment_compatibility/assignment_compatibility_4.ts | 0 .../assignment_compatibility/assignment_compatibility_5.ts | 0 .../assignment_compatibility/assignment_compatibility_6.ts | 0 .../assignment_compatibility/assignment_compatibility_7.ts | 0 .../assignment_compatibility/assignment_compatibility_8.ts | 0 .../assignment_compatibility/assignment_compatibility_9.ts | 0 .../contextual_signature_instantiation.ts | 0 .../excess_properties/excess_properties_1.ts | 0 .../excess_properties/excess_properties_2.ts | 0 .../excess_properties/excess_properties_3.ts | 0 .../type_relationships/recursive_types/recursive_types.ts | 0 .../subtypes_and_supertypes/subtypes_and_supertypes_1.ts | 0 .../subtypes_and_supertypes/subtypes_and_supertypes_10.ts | 0 .../subtypes_and_supertypes/subtypes_and_supertypes_11.ts | 0 .../subtypes_and_supertypes/subtypes_and_supertypes_12.ts | 0 .../subtypes_and_supertypes/subtypes_and_supertypes_13.ts | 0 .../subtypes_and_supertypes/subtypes_and_supertypes_14.ts | 0 .../subtypes_and_supertypes/subtypes_and_supertypes_15.ts | 0 .../subtypes_and_supertypes/subtypes_and_supertypes_16.ts | 0 .../subtypes_and_supertypes/subtypes_and_supertypes_2.ts | 0 .../subtypes_and_supertypes/subtypes_and_supertypes_3.ts | 0 .../subtypes_and_supertypes/subtypes_and_supertypes_4.ts | 0 .../subtypes_and_supertypes/subtypes_and_supertypes_5.ts | 0 .../subtypes_and_supertypes/subtypes_and_supertypes_6.ts | 0 .../subtypes_and_supertypes/subtypes_and_supertypes_7.ts | 0 .../subtypes_and_supertypes/subtypes_and_supertypes_8.ts | 0 .../subtypes_and_supertypes/subtypes_and_supertypes_9.ts | 0 .../type_relationships/type_inference/type_inference_1.ts | 0 .../type_relationships/type_inference/type_inference_2.ts | 0 .../type_relationships/type_inference/type_inference_3.ts | 0 .../type_relationships/type_inference/type_inference_4.ts | 0 .../type_relationships/type_inference/type_inference_5.ts | 0 .../type_relationships/type_inference/type_inference_6.ts | 0 .../type_relationships/type_inference/type_inference_7.ts | 0 .../spec/types/union_types/union_types_1.ts | 0 .../spec/types/union_types/union_types_2.ts | 0 .../spec/types/union_types/union_types_3.ts | 0 .../spec/types/union_types/union_types_4.ts | 0 .../spec/types/union_types/union_types_5.ts | 0 .../spec/types/union_types/union_types_6.ts | 0 .../spec/types/union_types/union_types_7.ts | 0 .../spec/types/widend_types/widend_types_1.ts | 0 .../spec/types/widend_types/widend_types_2.ts | 0 .../spec/types/widend_types/widend_types_3.ts | 0 es2panda/test/ts_extra_tests/tool/testcfg.py | 2 +- 796 files changed, 3 insertions(+), 3 deletions(-) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/allow_duplicate_identifiers_across_declarations/allow_duplicate_identifiers_across_declarations_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/dotted_names_in_type_guards/dotted_names_in_type_guards_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/expression_operators/expression_operators_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/expression_operators/expression_operators_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/implicit_index_signatures/implicit_index_signatures.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/module_identifiers_allow_for_js_extension/module_identifiers_allow_for_js_extension_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/module_identifiers_allow_for_js_extension/test_js_extension.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/module_resolution_enhancements/module_resolution_enhancements_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/module_resolution_enhancements/module_resolution_enhancements_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/module_resolution_enhancements/module_resolution_enhancements_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/non_null_assertion_operator/non_null_assertion_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/optional_class_properties/optional_class_properties.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/optional_parameters_and_properties/optional_parameters_and_properties.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/private_and_protected_constructor/private_and_protected_constructor.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/read-only_properties_and_index_signatures/read-only_properties_and_index_signatures.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/shorthand_ambient_module_declarations/hot-new-module.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/shorthand_ambient_module_declarations/shorthand_ambient_module_declarations_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/support_for_UMD_module_definitions/math-lib.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/support_for_UMD_module_definitions/support_for_UMD_module_definitions_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/tagged_union_types/tagged_union_types_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/test_base_url.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/test_virtual_directories_with_rootDirs/view1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.0/test_virtual_directories_with_rootDirs/view2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.1/better_inference_for_literal_types/better_inference_for_literal_types_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.1/better_inference_for_literal_types/better_inference_for_literal_types_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.1/better_inference_for_literal_types/better_inference_for_literal_types_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.1/downlevel_async_functions/downlevel_async_functions_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.1/improved_any_inference/improved_any_inference_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.1/improved_any_inference/improved_any_inference_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.1/keyof_and_lookup_types/keyof_and_lookup_types_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.1/keyof_and_lookup_types/keyof_and_lookup_types_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.1/mapped_types/mapped_types_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.1/mapped_types/mapped_types_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.1/mapped_types/mapped_types_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.1/mapped_types/mapped_types_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.1/object_spread_and_rest/object_spread_and_rest_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.1/object_spread_and_rest/object_spread_and_rest_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.1/object_spread_and_rest/object_spread_and_rest_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.1/use_returned_values_from_super_call_as_this/use_returned_values_from_super_call_as_this_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.2/dotted_property_for_types_with_string_index_signatures/dotted_property_for_types_with_string_index_signatures.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.2/object_type/object_type.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.2/support_for_mix_in_classes/support_for_mix_in_classes_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.2/support_for_mix_in_classes/support_for_mix_in_classes_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.2/support_for_new.target/support_for_new.target_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.2/support_for_new.target/support_for_new.target_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.3/async_iteration/async_generators/async_generators.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.3/async_iteration/async_iterators/async_iterators_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.3/async_iteration/async_iterators/async_iterators_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.3/generic_parameter_defaults/generic_parameter_defaults_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.3/generic_parameter_defaults/generic_parameter_defaults_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.3/generic_parameter_defaults/generic_parameter_defaults_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.4/1_dynamic_import_expressions/1_dynamic_import_expressions.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.4/1_dynamic_import_expressions/lib.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.4/2_string_enums/string_enums_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.4/4_strict_contravariance_for_callback_parameters/4_strict_contravariance_for_callback_parameters.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.4/5_weak_type_detection/5_weak_type_detection.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.5/1_optional_catch_clause_variables.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.6/suppress_errors_in_ts_files_using_ts_ignore_comments/suppress_errors_in_ts_files_using_ts_ignore_comments.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.7/10_numeric_separators/10_numeric_separators.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.7/1_constant_named_properties/1_constant_named_properties.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.7/2_unique_symbol/2_unique_symbol.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.7/3_strict_class_initialization/3_strict_class_initialization.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.7/4_definite_assignment_assertions/4_definite_assignment_assertions.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.7/5_fixed_length_tuples/5_fixed_length_tuples.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.7/6_improved_type_inference_for_object_literals/6_improved_type_inference_for_object_literals.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.7/7_improved_handling/7_improved_handling.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.7/8_Type_guards_inferred_from_in_operator/8_Type_guards_inferred_from_in_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.8/Improved_keyof_with_intersection_types.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.8/conditional_types.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.8/distributive_conditional_types.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.8/filter_union_types.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.8/improved_control_over_mapped_type_modifiers.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.8/predefined_conditional_types.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.8/prototype_assignment.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.8/type_inference.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.9/3_generic_type_arguments_in_tt.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.9/4_import_types.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/2.9/module.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.0/new_unknown_top_type/new_unknown_top_type.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.0/reference_lib/reference_lib.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.0/tuples_in_rest_parameters_and_spread_expressions/generic_rest_parameters/generic_rest_parameters.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.0/tuples_in_rest_parameters_and_spread_expressions/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_elements_in_tuple_types/rest_elements_in_tuple_types.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.0/tuples_in_rest_parameters_and_spread_expressions/spread_expressions_with_tuple_types/spread_expressions_with_tuple_types.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.1/mapped_types_on_tuples_and_arrays/mapped_types_on_tuples_and_arrays_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.1/properties_declarations_on_functions/properties_declarations_on_functions_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.2/bigint/bigint_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.2/bigint/bigint_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.2/bigint/bigint_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.2/generic_object_rest_variables_and_parameters/generic_object_rest_variables_and_parameters.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.2/non-unit_types_as_union_discriminants/non-unit_types_as_union_discriminants.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.3/improved_behavior_for_calling_union_types.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.4/a_new_syntax_for_readonly_array.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.4/const_assertions.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.4/higher_order_type_inference.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.4/readonly_tuples.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.5/higher_order_type_inference.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.5/improved_excess_property_checks_in_union_types.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.5/omit_helper_type.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.5/smarter_union_type_checking.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.6/better_unicode_support_for_identifiers/better_unicode_support_for_identifiers_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/get_and_set_accessors_are_allowed_in_ambient_contexts_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/test.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.6/more_accurate_array_spread/more_accurate_array_spread_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.6/stricter_generators/stricter_generators_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.6/stricter_generators/stricter_generators_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.6/stricter_generators/stricter_generators_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.6/stricter_generators/stricter_generators_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.6/stricter_generators/stricter_generators_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.7/assertion_functions/assertion_functions_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.7/nullish_coalescing/nullish_coalescing_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.7/nullish_coalescing/nullish_coalescing_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.7/optional_chaining/optional_chaining_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.7/optional_chaining/optional_chaining_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.7/optional_chaining/optional_chaining_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.7/optional_chaining/optional_chaining_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.7/optional_chaining/optional_chaining_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.7/recursive_type_aliases/recursive_type_aliases_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.7/ts_nocheck_in_typescript_files/ts_nocheck_in_typescript_files.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.8/1_type_only_imports_and_export.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.8/3_which_should_i_use.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.8/4_export_star_as_ns_syntax.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.8/export_star.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.8/my_module.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.8/some_module.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.9/improvements_in_inference_and_Promise.all/improvements_in_inference_and_Promise.all.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/3.9/ts-expect-error_comments/ts-expect-error_comments.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.0/class_property_Inference_from_constructors/class_property_Inference_from_constructors_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.0/labeled_tuple_elements/labeled_tuple_elements_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.0/labeled_tuple_elements/labeled_tuple_elements_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.0/labeled_tuple_elements/labeled_tuple_elements_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.0/labeled_tuple_elements/labeled_tuple_elements_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.0/variadic_tuple_types/variadic_tuple_types_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.0/variadic_tuple_types/variadic_tuple_types_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.0/variadic_tuple_types/variadic_tuple_types_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.0/variadic_tuple_types/variadic_tuple_types_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.0/variadic_tuple_types/variadic_tuple_types_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.0/variadic_tuple_types/variadic_tuple_types_6.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.1/Checked_Indexed_Accesses/Checked_Indexed_Accesses.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.1/Checked_Indexed_Accesses/for_each_index.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.1/Checked_Indexed_Accesses/for_of_index.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.1/Checked_Indexed_Accesses/for_traversal_index.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.1/abstract_members_can_not_be_marked_async/abstract_members_can_not_be_marked_async.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.1/any_or_unknown_are_propagated_in_falsy_positions/any_or_unknown_are_propagated_in_falsy_positions.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.1/conditional_spreads_create_optional_properties/conditional_spreads_create_optional_properties_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.1/recursive_conditional_types/recursive_conditional_types.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.1/resolvers_parameters_are_no_longer_optional_in_promises/resolves_parameters_are_no_longer_optional_in_promises.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.1/template_literal_types/template_literal_types_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.1/template_literal_types/template_literal_types_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.1/template_literal_types/template_literal_types_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.2/Reverting_Template_Literal_Inference/Reverting_Template_Literal_Inference.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.2/abstract_construct_signatures/abstract_construct_signatures.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.2/abstract_construct_signatures/abstract_construct_signatures_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.2/abstract_construct_signatures/abstract_construct_signatures_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.2/abstract_construct_signatures/abstract_construct_signatures_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.3/always-truthy_promise_checks/always-truthy_promise_checks.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.3/constructorParameters_works_on_abstract_class/constructorParameters_works_on_abstract_class.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.3/contextual_narrowing_for_generic/contextual_narrowing_for_generics.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.3/ecmascript_private_class_elements/ecmascript_private_calss_elements.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.3/override_and_the_noImplicitOverride_Flag/override_and_the_noImplicitOverride_Flag.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.3/separate_write_types_on_properties/separate_write_types_on_properties_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.3/separate_write_types_on_properties/separate_write_types_on_properties_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.3/static_index_signatures/static_index_signatures.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.3/template_string_type_improvements/template_string_type_improvements_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.3/template_string_type_improvements/template_string_type_improvements_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.3/template_string_type_improvements/template_string_type_improvements_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.3/template_string_type_improvements/template_string_type_improvements_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.3/union_enums_cannot_be_compared_to_arbitrary_numbers/union_enums_cannot_be_compared_to_arbitrary_numbers.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.4/exact_optional_property_types/exact_optional_property_types_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.4/static_blocks_in_classe/static_blocks_in_classes1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.4/static_blocks_in_classe/static_blocks_in_classes2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.5/disabling_import_elision/animal.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.5/disabling_import_elision/disabling_import_elision_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.5/private_field_presence_checks/private_field_presence_checks_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.5/template_string_types_as_discriminants/template_string_types_as_discriminants_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.5/the_awaited_type_and_promise_improvements/the_awaited_type_and_promise_improvements_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.5/type_modifiers_on_import_names/some-module.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.6/1_allowing_code_in_constructors.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.6/2_control_flow_analysis.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.6/3_improved_recursion_depth_checks.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.6/4_indexed_access_inference_improvements.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.6/5_control_flow_analysis_for_dependent_parameters.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.7/extends_constraints_on_infer_type_variables/extends_constraints_on_infer_type_variables.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.7/improved_function_inference_in_objects_and_methods/improved_function_inference_in_objects_and_methods.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.7/instantiation_expressions/instantiation_expressions.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.7/optional_variance_annotations_for_type_parameters/optional_variance_annotations_for_type_parameters.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.7/readonly_tuples_have_a_readonly_length_property/readonly_tuples_have_a_readonly_length_property.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.8/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.8/improved_inference_for_infer_types_in_template_string_types/improved_inference_for_infer_types_in_template_string_types.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.9/auto_accessors_in_classes/auto_accessors_in_classes.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.9/checks_for_equality_on_NaN/checks_for_equality_on_NaN.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.9/the_satisfies_operator/the_satisfies_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/4.9/unlisted_property_narrowing_with_the_in_operator/unlisted_property_narrowing_with_the_in_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/ambients/ambient_declarations/ambient_namespace_declarations/ambient_namespace_declarations.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/ambients/ambient_module_declarations/ambient_module_declarations_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/declarations/declarations_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/declarations/declarations_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/computed_property_names/computed_property_names_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/property_names/property_names_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/require_is_valid_identifier_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/scopes/let_scope.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/scopes/namespace.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/scopes/scopes_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/scopes/scopes_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/scopes/scopes_2_m.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/scopes/scopes_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/scopes/scopes_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/basic_concepts/scopes/var_scope.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/class_declarations/class_body/class_body.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/class_declarations/class_declarations_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/class_declarations/class_declarations_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/class_declarations/class_declarations_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_6.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_6.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/constructor_declarations/super_calls/super_calls.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/index_member_declarations/index_member_declarations.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/members/accessibility/accessibility_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/members/accessibility/accessibility_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/members/accessibility/accessibility_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/members/class_types/class_types_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/members/class_types/class_types_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/members/class_types/class_types_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/members/constructorc_function_types/constructor_function_types_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/members/constructorc_function_types/constructor_function_types_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/members/constructorc_function_types/constructor_function_types_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/members/constructorc_function_types/constructor_function_types_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/members/constructorc_function_types/constructor_function_types_6.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/members/constructorc_function_types/constructor_function_types_7.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/members/constructorc_function_types/constructor_function_types_8.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/members/instance_and_static_members/instance_and_static_members_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/property_member_declarations/member_accessor_declarations/member_accessor_declarations.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/property_member_declarations/property_member_declarations_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/property_member_declarations/property_member_declarations_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/classes/property_member_declarations/property_member_declarations_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/enums/constant_enum_declarations/constant_enum_declarations.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/enums/declaration_merging/declaration_merging_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/enums/declaration_merging/declaration_merging_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/enums/enum_declarations/enum_declarations_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/enums/enum_declarations/enum_declarations_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/enums/enum_declarations/enum_declarations_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/enums/enum_members/enum_members_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/array_literals/array_literal_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/array_literals/array_literal_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/array_literals/array_literal_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/array_literals/array_literal_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/array_literals/array_literal_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/array_literals/array_literal_6.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/arrow_function/arrow_function_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/arrow_function/arrow_function_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/arrow_function/arrow_function_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/arrow_function/arrow_function_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/assignment_operators/assignment_operators/assignment_operator_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/assignment_operators/assignment_operators/assignment_operator_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_6.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_7.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_8.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_greater_less_lessEqual/the_congruence_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_greater_less_lessEqual/the_equal_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_greater_less_lessEqual/the_greater_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_greater_less_lessEqual/the_greater_or_equal_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_greater_less_lessEqual/the_incongruence_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_greater_less_lessEqual/the_less_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_greater_less_lessEqual/the_less_or_equal_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_greater_less_lessEqual/the_unequal_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_instanceof_operator/the_instanceof_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_mul_div_rem/the_and_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_mul_div_rem/the_division_method_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_mul_div_rem/the_left_shift_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_mul_div_rem/the_multiplication_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_mul_div_rem/the_or_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_mul_div_rem/the_remainder_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_mul_div_rem/the_right_shift_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_mul_div_rem/the_subtraction_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_mul_div_rem/the_unsigned_shift_to_the_right.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_mul_div_rem/the_xor_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/binary_operators/the_or_operator/the_or_operator_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/class_expressions/class_expressions_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_10.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_11.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_13.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_15.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_16.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_6.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_9.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/function_calls/overload_resolution/overload_resolution_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/function_calls/overload_resolution/overload_resolution_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/function_expression/function_expressions_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/function_expression/function_expressions_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/function_expression/function_expressions_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/identifiers/class.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/identifiers/enum.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/identifiers/function.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/identifiers/name_space.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/identifiers/parameter.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/identifiers/variable.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/literals/boolean.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/literals/null.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/literals/number.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/literals/regexp.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/literals/string.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/object_literal/object_literal_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/object_literal/object_literal_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/object_literal/object_literal_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/object_literal/object_literal_6.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/object_literal/object_literal_7.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/parentheses/parentheses.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/property_access/object_access_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/property_access/object_any_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/property_access/object_any_type_6.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/property_access/object_apprent_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/property_access/object_index_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/property_access/object_string_number_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/property_access/property_access_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/property_access/property_access_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/the_comma_operator/the_comma_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/the_conditional_operator/the_conditional_operator_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/the_new_operator/new_operator_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/the_new_operator/new_operator_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/the_new_operator/new_operator_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/the_new_operator/new_operator_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/the_super_keyword/super_calls/arguments.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/the_super_keyword/super_calls/super_calls.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/the_super_keyword/super_property_access/derived_class_access.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/the_super_keyword/super_property_access/static_member_access.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/this_key_word/this_key_word_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/type_assertion/type_assertion_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/type_assertion/type_assertion_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/type_assertion/type_assertion_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/type_guards/type_guards_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/type_guards/type_guards_10.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/type_guards/type_guards_11.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/type_guards/type_guards_12.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/type_guards/type_guards_13.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/type_guards/type_guards_14.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/type_guards/type_guards_15.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/type_guards/type_guards_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/type_guards/type_guards_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/type_guards/type_guards_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/type_guards/type_guards_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/type_guards/type_guards_6.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/type_guards/type_guards_7.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/type_guards/type_guards_8.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/type_guards/type_guards_9.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/unary_operators/the_!_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/unary_operators/the_++_and_--_operators.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/unary_operators/the_+_and_~_operators.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/unary_operators/the_delete_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/unary_operators/the_typeof_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/expressions/unary_operators/the_void_operator.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/asynchronous_functions/asynchronous_functions_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/asynchronous_functions/asynchronous_functions_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/asynchronous_functions/asynchronous_functions_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/asynchronous_functions/asynchronous_functions_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_6.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/function_declarations/function_declarations_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/function_declarations/function_declarations_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/function_implementations/function_implementations_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/function_implementations/function_implementations_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/function_implementations/function_implementations_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/function_implementations/function_implementations_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/function_implementations/function_implementations_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/function_overloads/function_overloads_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/generator_functions/generator_functions_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/generator_functions/generator_functions_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/generator_functions/generator_functions_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/generic_functions/generic_functions_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/generic_functions/generic_functions_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/functions/type_guard_functions/type_guard_functions_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/grammar/classes/classes.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/grammar/enums/enums.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/grammar/expressions/expressions.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/grammar/functions/functions.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/grammar/interfaces/interfaces.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/grammar/namespaces/namespaces.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/grammar/scripts_and_modules/scripts_and_modules.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/grammar/scripts_and_modules/source_file_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/grammar/scripts_and_modules/source_file_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/grammar/scripts_and_modules/source_file_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/grammar/scripts_and_modules/source_file_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/grammar/statements/statements.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/grammar/types/types.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/interfaces/1_interface_declarations/interface_declarations_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/interfaces/1_interface_declarations/interface_declarations_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/interfaces/1_interface_declarations/interface_declarations_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/interfaces/2_declaration_merging/declaration_merging_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/interfaces/2_declaration_merging/declaration_merging_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/interfaces/4_dynamic_type_checks/dynamic_type_checks_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/namespaces/declaration_merging/declaration_merging_1_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/namespaces/declaration_merging/declaration_merging_1_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/namespaces/declaration_merging/declaration_merging_1_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/namespaces/declaration_merging/declaration_merging_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/namespaces/export_declarations/export_declarations_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/namespaces/export_declarations/export_declarations_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/namespaces/export_declarations/export_declarations_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/namespaces/import_alias_declarations/import_alias_declarations_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/namespaces/import_alias_declarations/import_alias_declarations_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/namespaces/namespace_body/namespace_body.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/namespaces/namespace_declarations/namespace_declarations_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/namespaces/namespace_declarations/namespace_declarations_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/namespaces/namespace_declarations/namespace_declarations_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/namespaces/namespace_declarations/namespace_declarations_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_00.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_files_dependencies.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/1_programs_and_source_files/source_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/1_programs_and_source_files/source_10.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/1_programs_and_source_files/source_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/1_programs_and_source_files/source_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/1_programs_and_source_files/source_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/1_programs_and_source_files/source_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/1_programs_and_source_files/source_6.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/1_programs_and_source_files/source_7.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/1_programs_and_source_files/source_8.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/1_programs_and_source_files/source_9.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/2_modules/modules_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/3_import_declarations/import_declarations_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/3_import_declarations/import_declarations_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/3_import_declarations/import_declarations_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/3_import_declarations/import_declarations_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/4_import_require_declarations/import_require_declarations_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/5_export_declarations/export_declarations_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/5_export_declarations/export_declarations_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/5_export_declarations/export_declarations_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/5_export_declarations/export_declarations_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/5_export_declarations/export_declarations_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/6_export_assignments/export_assignments_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/blocks/blocks_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/blocks/blocks_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/blocks/blocks_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/blocks/blocks_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/break_statements/break_statements.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/continue_statements/continue_statements.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/for_in_statements/for_in_statements.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/for_of_statements/for_of_statements.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/for_statements/for_statements.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/let_and_const_declarations/let_and_const_declarations.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/return_statements/return_statements.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/switch_statements/switch_statements.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/throw_statements/throw_statements.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/try_statements/try_statements.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/statements/variable_statements/3_implied_type/implied_type.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/Intersection_Types/Intersection_types_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/Intersection_Types/intersection_types_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/named_types/named_types_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/named_types/named_types_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/named_types/named_types_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/named_types/named_types_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/object_types/array_types/array_types_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/object_types/array_types/array_types_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/object_types/array_types/array_types_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/object_types/constructor_types/constructor_types_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/object_types/constructor_types/constructor_types_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/object_types/constructor_types/constructor_types_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/object_types/constructor_types/constructor_types_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/object_types/function_types/function_types_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/object_types/function_types/function_types_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/object_types/members/members_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/object_types/members/members_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/object_types/named_type_reference/named_type_reference.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/object_types/tuple_types/tuple_types_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/object_types/tuple_types/tuple_types_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/object_types/tuple_types/tuple_types_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/primitive_types/the_boolean_type/the_boolean_type_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/primitive_types/the_boolean_type/the_boolean_type_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/primitive_types/the_boolean_type/the_boolean_type_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/primitive_types/the_enum_type/the_enum_type_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/primitive_types/the_null_type/the_null_type_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/primitive_types/the_number_type/the_number_type_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/primitive_types/the_number_type/the_number_type_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/primitive_types/the_number_type/the_number_type_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/primitive_types/the_string_type/the_string_type_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/primitive_types/the_string_type/the_string_type_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/primitive_types/the_string_type/the_string_type_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/primitive_types/the_symbol_type/the_symbol_type_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/primitive_types/the_symbol_type/the_symbol_type_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/primitive_types/the_symbol_type/the_symbol_type_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/primitive_types/the_undefined_type/the_undefined_type_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/primitive_types/the_void_type/the_void_type_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/primitive_types/the_void_type/the_void_type_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/primitive_types/the_void_type/the_void_type_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_6.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_members/call_signatures/return_type/return_type_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_members/call_signatures/return_type/return_type_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_members/call_signatures/return_type/return_type_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_members/call_signatures/specialized_signatures/specialized_signatures_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_members/construct_signatures/construct_signatures.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_members/index_signatures/index_signatures.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_members/method_signatures/method_signatures_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_members/method_signatures/method_signatures_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_members/property_signatures/property_signatures.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_types/array_type_literals/array_type_literals_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_types/array_type_literals/array_type_literals_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_types/array_type_literals/array_type_literals_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_types/array_type_literals/array_type_literals_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_types/function_type_literals/function_type_literals_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_types/intersection_type_literals/intersection_type_literals.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_types/object_type_literals/object_type_literals.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_types/predefined_types/predefined_types.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_types/specifying_types_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_types/specifying_types_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_types/this_type_references/this_type_references_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_types/this_type_references/this_type_references_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_types/tuple_type_literals/tuple_type_literals.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_types/type_queries/type_queries_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_types/type_queries/type_queries_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_types/type_references/type_references_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_types/type_references/type_references_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_types/type_references/type_references_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/specifying_types/union_type_literals/union_type_literals.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/the_any_type/any_type_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/the_any_type/any_type_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/the_any_type/any_type_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_aliases/type_aliases_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_aliases/type_aliases_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_aliases/type_aliases_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_parameters/this_types/this_types.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_parameters/this_types/this_types_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_parameters/this_types/this_types_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_parameters/type_argument_lists/type_argument_lists_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_parameters/type_argument_lists/type_argument_lists_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_parameters/type_argument_lists/type_argument_lists_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_parameters/type_argument_lists/type_argument_lists_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_6.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/apparent_members/apparent_members_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/apparent_members/apparent_members_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/apparent_members/apparent_members_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/apparent_members/apparent_members_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/apparent_members/apparent_members_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/apparent_members/apparent_members_6.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/apparent_members/apparent_members_7.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/apparent_members/apparent_members_8.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_10.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_11.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_12.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_13.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_14.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_15.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_16.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_17.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_18.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_6.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_7.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_8.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_9.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/contextual_signature_instantiation/contextual_signature_instantiation.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/excess_properties/excess_properties_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/excess_properties/excess_properties_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/excess_properties/excess_properties_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/recursive_types/recursive_types.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_10.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_11.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_12.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_13.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_14.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_15.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_16.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_6.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_7.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_8.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_9.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/type_inference/type_inference_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/type_inference/type_inference_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/type_inference/type_inference_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/type_inference/type_inference_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/type_inference/type_inference_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/type_inference/type_inference_6.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/type_relationships/type_inference/type_inference_7.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/union_types/union_types_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/union_types/union_types_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/union_types/union_types_3.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/union_types/union_types_4.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/union_types/union_types_5.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/union_types/union_types_6.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/union_types/union_types_7.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/widend_types/widend_types_1.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/widend_types/widend_types_2.ts (100%) rename es2panda/test/ts_extra_tests/{test => test_ts_cases}/spec/types/widend_types/widend_types_3.ts (100%) diff --git a/es2panda/test/ts_extra_tests/run_ts_case.py b/es2panda/test/ts_extra_tests/run_ts_case.py index 1cda104e93..7b40383814 100644 --- a/es2panda/test/ts_extra_tests/run_ts_case.py +++ b/es2panda/test/ts_extra_tests/run_ts_case.py @@ -126,7 +126,7 @@ for file_path in args.release: if not test_case.is_test_case: test_case.create_abc(file_paths) - for file_paths in get_path_file("test", None, True): + for file_paths in get_path_file("test_ts_cases", None, True): if file_paths.endswith(".ts"): test_case = TestCase(file_paths) if not test_case.is_test_case: @@ -161,7 +161,7 @@ for file_path in args.release: if not test_case.is_test_case: test_case.create_abc(file_paths) - for file_paths in get_path_file("test", None, True): + for file_paths in get_path_file("test_ts_cases", None, True): if file_paths.endswith(".abc"): if os.path.exists(file_paths): os.remove(file_paths) diff --git a/es2panda/test/ts_extra_tests/test/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/allow_duplicate_identifiers_across_declarations/allow_duplicate_identifiers_across_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/allow_duplicate_identifiers_across_declarations/allow_duplicate_identifiers_across_declarations_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/allow_duplicate_identifiers_across_declarations/allow_duplicate_identifiers_across_declarations_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/allow_duplicate_identifiers_across_declarations/allow_duplicate_identifiers_across_declarations_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis2.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis3.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/dotted_names_in_type_guards/dotted_names_in_type_guards_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/dotted_names_in_type_guards/dotted_names_in_type_guards_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/dotted_names_in_type_guards/dotted_names_in_type_guards_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/dotted_names_in_type_guards/dotted_names_in_type_guards_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/expression_operators/expression_operators_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/expression_operators/expression_operators_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/expression_operators/expression_operators_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/expression_operators/expression_operators_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/expression_operators/expression_operators_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/expression_operators/expression_operators_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/expression_operators/expression_operators_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/expression_operators/expression_operators_2.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/implicit_index_signatures/implicit_index_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/implicit_index_signatures/implicit_index_signatures.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/implicit_index_signatures/implicit_index_signatures.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/implicit_index_signatures/implicit_index_signatures.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/module_identifiers_allow_for_js_extension/module_identifiers_allow_for_js_extension_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_identifiers_allow_for_js_extension/module_identifiers_allow_for_js_extension_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/module_identifiers_allow_for_js_extension/module_identifiers_allow_for_js_extension_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_identifiers_allow_for_js_extension/module_identifiers_allow_for_js_extension_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/module_identifiers_allow_for_js_extension/test_js_extension.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_identifiers_allow_for_js_extension/test_js_extension.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/module_identifiers_allow_for_js_extension/test_js_extension.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_identifiers_allow_for_js_extension/test_js_extension.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/module_resolution_enhancements/module_resolution_enhancements_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_resolution_enhancements/module_resolution_enhancements_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/module_resolution_enhancements/module_resolution_enhancements_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_resolution_enhancements/module_resolution_enhancements_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/module_resolution_enhancements/module_resolution_enhancements_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_resolution_enhancements/module_resolution_enhancements_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/module_resolution_enhancements/module_resolution_enhancements_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_resolution_enhancements/module_resolution_enhancements_2.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/module_resolution_enhancements/module_resolution_enhancements_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_resolution_enhancements/module_resolution_enhancements_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/module_resolution_enhancements/module_resolution_enhancements_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_resolution_enhancements/module_resolution_enhancements_3.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/non_null_assertion_operator/non_null_assertion_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/non_null_assertion_operator/non_null_assertion_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/non_null_assertion_operator/non_null_assertion_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/non_null_assertion_operator/non_null_assertion_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/optional_class_properties/optional_class_properties.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/optional_class_properties/optional_class_properties.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/optional_class_properties/optional_class_properties.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/optional_class_properties/optional_class_properties.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/optional_parameters_and_properties/optional_parameters_and_properties.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/optional_parameters_and_properties/optional_parameters_and_properties.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/optional_parameters_and_properties/optional_parameters_and_properties.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/optional_parameters_and_properties/optional_parameters_and_properties.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/private_and_protected_constructor/private_and_protected_constructor.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/private_and_protected_constructor/private_and_protected_constructor.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/private_and_protected_constructor/private_and_protected_constructor.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/private_and_protected_constructor/private_and_protected_constructor.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/read-only_properties_and_index_signatures/read-only_properties_and_index_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/read-only_properties_and_index_signatures/read-only_properties_and_index_signatures.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/read-only_properties_and_index_signatures/read-only_properties_and_index_signatures.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/read-only_properties_and_index_signatures/read-only_properties_and_index_signatures.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/shorthand_ambient_module_declarations/hot-new-module.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/shorthand_ambient_module_declarations/hot-new-module.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/shorthand_ambient_module_declarations/hot-new-module.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/shorthand_ambient_module_declarations/hot-new-module.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/shorthand_ambient_module_declarations/shorthand_ambient_module_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/shorthand_ambient_module_declarations/shorthand_ambient_module_declarations_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/shorthand_ambient_module_declarations/shorthand_ambient_module_declarations_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/shorthand_ambient_module_declarations/shorthand_ambient_module_declarations_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_2.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/support_for_UMD_module_definitions/math-lib.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/support_for_UMD_module_definitions/math-lib.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/support_for_UMD_module_definitions/math-lib.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/support_for_UMD_module_definitions/math-lib.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/support_for_UMD_module_definitions/support_for_UMD_module_definitions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/support_for_UMD_module_definitions/support_for_UMD_module_definitions_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/support_for_UMD_module_definitions/support_for_UMD_module_definitions_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/support_for_UMD_module_definitions/support_for_UMD_module_definitions_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/tagged_union_types/tagged_union_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/tagged_union_types/tagged_union_types_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/tagged_union_types/tagged_union_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/tagged_union_types/tagged_union_types_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/test_base_url.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/test_base_url.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/test_base_url.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/test_base_url.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/test_virtual_directories_with_rootDirs/view1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/test_virtual_directories_with_rootDirs/view1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/test_virtual_directories_with_rootDirs/view1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/test_virtual_directories_with_rootDirs/view1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.0/test_virtual_directories_with_rootDirs/view2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/test_virtual_directories_with_rootDirs/view2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.0/test_virtual_directories_with_rootDirs/view2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/test_virtual_directories_with_rootDirs/view2.ts diff --git a/es2panda/test/ts_extra_tests/test/2.1/better_inference_for_literal_types/better_inference_for_literal_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.1/better_inference_for_literal_types/better_inference_for_literal_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.1/better_inference_for_literal_types/better_inference_for_literal_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.1/better_inference_for_literal_types/better_inference_for_literal_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_2.ts diff --git a/es2panda/test/ts_extra_tests/test/2.1/better_inference_for_literal_types/better_inference_for_literal_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.1/better_inference_for_literal_types/better_inference_for_literal_types_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_3.ts diff --git a/es2panda/test/ts_extra_tests/test/2.1/downlevel_async_functions/downlevel_async_functions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/downlevel_async_functions/downlevel_async_functions_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.1/downlevel_async_functions/downlevel_async_functions_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.1/downlevel_async_functions/downlevel_async_functions_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.1/improved_any_inference/improved_any_inference_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/improved_any_inference/improved_any_inference_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.1/improved_any_inference/improved_any_inference_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.1/improved_any_inference/improved_any_inference_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.1/improved_any_inference/improved_any_inference_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/improved_any_inference/improved_any_inference_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.1/improved_any_inference/improved_any_inference_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.1/improved_any_inference/improved_any_inference_2.ts diff --git a/es2panda/test/ts_extra_tests/test/2.1/keyof_and_lookup_types/keyof_and_lookup_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/keyof_and_lookup_types/keyof_and_lookup_types_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.1/keyof_and_lookup_types/keyof_and_lookup_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.1/keyof_and_lookup_types/keyof_and_lookup_types_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.1/keyof_and_lookup_types/keyof_and_lookup_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/keyof_and_lookup_types/keyof_and_lookup_types_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.1/keyof_and_lookup_types/keyof_and_lookup_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.1/keyof_and_lookup_types/keyof_and_lookup_types_2.ts diff --git a/es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_2.ts diff --git a/es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_3.ts diff --git a/es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.1/mapped_types/mapped_types_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_4.ts diff --git a/es2panda/test/ts_extra_tests/test/2.1/object_spread_and_rest/object_spread_and_rest_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.1/object_spread_and_rest/object_spread_and_rest_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.1/object_spread_and_rest/object_spread_and_rest_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.1/object_spread_and_rest/object_spread_and_rest_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_2.ts diff --git a/es2panda/test/ts_extra_tests/test/2.1/object_spread_and_rest/object_spread_and_rest_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.1/object_spread_and_rest/object_spread_and_rest_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_3.ts diff --git a/es2panda/test/ts_extra_tests/test/2.1/use_returned_values_from_super_call_as_this/use_returned_values_from_super_call_as_this_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/use_returned_values_from_super_call_as_this/use_returned_values_from_super_call_as_this_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.1/use_returned_values_from_super_call_as_this/use_returned_values_from_super_call_as_this_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.1/use_returned_values_from_super_call_as_this/use_returned_values_from_super_call_as_this_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.2/dotted_property_for_types_with_string_index_signatures/dotted_property_for_types_with_string_index_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/dotted_property_for_types_with_string_index_signatures/dotted_property_for_types_with_string_index_signatures.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.2/dotted_property_for_types_with_string_index_signatures/dotted_property_for_types_with_string_index_signatures.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.2/dotted_property_for_types_with_string_index_signatures/dotted_property_for_types_with_string_index_signatures.ts diff --git a/es2panda/test/ts_extra_tests/test/2.2/object_type/object_type.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.2/object_type/object_type.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type.ts diff --git a/es2panda/test/ts_extra_tests/test/2.2/support_for_mix_in_classes/support_for_mix_in_classes_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_mix_in_classes/support_for_mix_in_classes_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.2/support_for_mix_in_classes/support_for_mix_in_classes_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_mix_in_classes/support_for_mix_in_classes_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.2/support_for_mix_in_classes/support_for_mix_in_classes_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_mix_in_classes/support_for_mix_in_classes_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.2/support_for_mix_in_classes/support_for_mix_in_classes_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_mix_in_classes/support_for_mix_in_classes_2.ts diff --git a/es2panda/test/ts_extra_tests/test/2.2/support_for_new.target/support_for_new.target_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_new.target/support_for_new.target_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.2/support_for_new.target/support_for_new.target_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_new.target/support_for_new.target_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.2/support_for_new.target/support_for_new.target_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_new.target/support_for_new.target_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.2/support_for_new.target/support_for_new.target_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_new.target/support_for_new.target_2.ts diff --git a/es2panda/test/ts_extra_tests/test/2.3/async_iteration/async_generators/async_generators.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.3/async_iteration/async_generators/async_generators.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.3/async_iteration/async_generators/async_generators.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.3/async_iteration/async_generators/async_generators.ts diff --git a/es2panda/test/ts_extra_tests/test/2.3/async_iteration/async_iterators/async_iterators_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.3/async_iteration/async_iterators/async_iterators_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.3/async_iteration/async_iterators/async_iterators_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.3/async_iteration/async_iterators/async_iterators_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.3/async_iteration/async_iterators/async_iterators_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.3/async_iteration/async_iterators/async_iterators_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.3/async_iteration/async_iterators/async_iterators_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.3/async_iteration/async_iterators/async_iterators_2.ts diff --git a/es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_2.ts diff --git a/es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_2.ts diff --git a/es2panda/test/ts_extra_tests/test/2.3/generic_parameter_defaults/generic_parameter_defaults_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generic_parameter_defaults/generic_parameter_defaults_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.3/generic_parameter_defaults/generic_parameter_defaults_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.3/generic_parameter_defaults/generic_parameter_defaults_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.3/generic_parameter_defaults/generic_parameter_defaults_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generic_parameter_defaults/generic_parameter_defaults_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.3/generic_parameter_defaults/generic_parameter_defaults_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.3/generic_parameter_defaults/generic_parameter_defaults_2.ts diff --git a/es2panda/test/ts_extra_tests/test/2.3/generic_parameter_defaults/generic_parameter_defaults_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generic_parameter_defaults/generic_parameter_defaults_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.3/generic_parameter_defaults/generic_parameter_defaults_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.3/generic_parameter_defaults/generic_parameter_defaults_3.ts diff --git a/es2panda/test/ts_extra_tests/test/2.4/1_dynamic_import_expressions/1_dynamic_import_expressions.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/1_dynamic_import_expressions/1_dynamic_import_expressions.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.4/1_dynamic_import_expressions/1_dynamic_import_expressions.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.4/1_dynamic_import_expressions/1_dynamic_import_expressions.ts diff --git a/es2panda/test/ts_extra_tests/test/2.4/1_dynamic_import_expressions/lib.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/1_dynamic_import_expressions/lib.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.4/1_dynamic_import_expressions/lib.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.4/1_dynamic_import_expressions/lib.ts diff --git a/es2panda/test/ts_extra_tests/test/2.4/2_string_enums/string_enums_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/2_string_enums/string_enums_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.4/2_string_enums/string_enums_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.4/2_string_enums/string_enums_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts diff --git a/es2panda/test/ts_extra_tests/test/2.4/4_strict_contravariance_for_callback_parameters/4_strict_contravariance_for_callback_parameters.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/4_strict_contravariance_for_callback_parameters/4_strict_contravariance_for_callback_parameters.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.4/4_strict_contravariance_for_callback_parameters/4_strict_contravariance_for_callback_parameters.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.4/4_strict_contravariance_for_callback_parameters/4_strict_contravariance_for_callback_parameters.ts diff --git a/es2panda/test/ts_extra_tests/test/2.4/5_weak_type_detection/5_weak_type_detection.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/5_weak_type_detection/5_weak_type_detection.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.4/5_weak_type_detection/5_weak_type_detection.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.4/5_weak_type_detection/5_weak_type_detection.ts diff --git a/es2panda/test/ts_extra_tests/test/2.5/1_optional_catch_clause_variables.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.5/1_optional_catch_clause_variables.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.5/1_optional_catch_clause_variables.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.5/1_optional_catch_clause_variables.ts diff --git a/es2panda/test/ts_extra_tests/test/2.6/suppress_errors_in_ts_files_using_ts_ignore_comments/suppress_errors_in_ts_files_using_ts_ignore_comments.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.6/suppress_errors_in_ts_files_using_ts_ignore_comments/suppress_errors_in_ts_files_using_ts_ignore_comments.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.6/suppress_errors_in_ts_files_using_ts_ignore_comments/suppress_errors_in_ts_files_using_ts_ignore_comments.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.6/suppress_errors_in_ts_files_using_ts_ignore_comments/suppress_errors_in_ts_files_using_ts_ignore_comments.ts diff --git a/es2panda/test/ts_extra_tests/test/2.7/10_numeric_separators/10_numeric_separators.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/10_numeric_separators/10_numeric_separators.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.7/10_numeric_separators/10_numeric_separators.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.7/10_numeric_separators/10_numeric_separators.ts diff --git a/es2panda/test/ts_extra_tests/test/2.7/1_constant_named_properties/1_constant_named_properties.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/1_constant_named_properties/1_constant_named_properties.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.7/1_constant_named_properties/1_constant_named_properties.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.7/1_constant_named_properties/1_constant_named_properties.ts diff --git a/es2panda/test/ts_extra_tests/test/2.7/2_unique_symbol/2_unique_symbol.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/2_unique_symbol/2_unique_symbol.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.7/2_unique_symbol/2_unique_symbol.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.7/2_unique_symbol/2_unique_symbol.ts diff --git a/es2panda/test/ts_extra_tests/test/2.7/3_strict_class_initialization/3_strict_class_initialization.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/3_strict_class_initialization/3_strict_class_initialization.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.7/3_strict_class_initialization/3_strict_class_initialization.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.7/3_strict_class_initialization/3_strict_class_initialization.ts diff --git a/es2panda/test/ts_extra_tests/test/2.7/4_definite_assignment_assertions/4_definite_assignment_assertions.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/4_definite_assignment_assertions/4_definite_assignment_assertions.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.7/4_definite_assignment_assertions/4_definite_assignment_assertions.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.7/4_definite_assignment_assertions/4_definite_assignment_assertions.ts diff --git a/es2panda/test/ts_extra_tests/test/2.7/5_fixed_length_tuples/5_fixed_length_tuples.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/5_fixed_length_tuples/5_fixed_length_tuples.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.7/5_fixed_length_tuples/5_fixed_length_tuples.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.7/5_fixed_length_tuples/5_fixed_length_tuples.ts diff --git a/es2panda/test/ts_extra_tests/test/2.7/6_improved_type_inference_for_object_literals/6_improved_type_inference_for_object_literals.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/6_improved_type_inference_for_object_literals/6_improved_type_inference_for_object_literals.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.7/6_improved_type_inference_for_object_literals/6_improved_type_inference_for_object_literals.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.7/6_improved_type_inference_for_object_literals/6_improved_type_inference_for_object_literals.ts diff --git a/es2panda/test/ts_extra_tests/test/2.7/7_improved_handling/7_improved_handling.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/7_improved_handling/7_improved_handling.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.7/7_improved_handling/7_improved_handling.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.7/7_improved_handling/7_improved_handling.ts diff --git a/es2panda/test/ts_extra_tests/test/2.7/8_Type_guards_inferred_from_in_operator/8_Type_guards_inferred_from_in_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/8_Type_guards_inferred_from_in_operator/8_Type_guards_inferred_from_in_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.7/8_Type_guards_inferred_from_in_operator/8_Type_guards_inferred_from_in_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.7/8_Type_guards_inferred_from_in_operator/8_Type_guards_inferred_from_in_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/2.8/Improved_keyof_with_intersection_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/Improved_keyof_with_intersection_types.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.8/Improved_keyof_with_intersection_types.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.8/Improved_keyof_with_intersection_types.ts diff --git a/es2panda/test/ts_extra_tests/test/2.8/conditional_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/conditional_types.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.8/conditional_types.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.8/conditional_types.ts diff --git a/es2panda/test/ts_extra_tests/test/2.8/distributive_conditional_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/distributive_conditional_types.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.8/distributive_conditional_types.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.8/distributive_conditional_types.ts diff --git a/es2panda/test/ts_extra_tests/test/2.8/filter_union_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/filter_union_types.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.8/filter_union_types.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.8/filter_union_types.ts diff --git a/es2panda/test/ts_extra_tests/test/2.8/improved_control_over_mapped_type_modifiers.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/improved_control_over_mapped_type_modifiers.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.8/improved_control_over_mapped_type_modifiers.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.8/improved_control_over_mapped_type_modifiers.ts diff --git a/es2panda/test/ts_extra_tests/test/2.8/predefined_conditional_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/predefined_conditional_types.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.8/predefined_conditional_types.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.8/predefined_conditional_types.ts diff --git a/es2panda/test/ts_extra_tests/test/2.8/prototype_assignment.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/prototype_assignment.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.8/prototype_assignment.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.8/prototype_assignment.ts diff --git a/es2panda/test/ts_extra_tests/test/2.8/type_inference.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/type_inference.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.8/type_inference.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.8/type_inference.ts diff --git a/es2panda/test/ts_extra_tests/test/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts diff --git a/es2panda/test/ts_extra_tests/test/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts diff --git a/es2panda/test/ts_extra_tests/test/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_3.ts diff --git a/es2panda/test/ts_extra_tests/test/2.9/3_generic_type_arguments_in_tt.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/3_generic_type_arguments_in_tt.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.9/3_generic_type_arguments_in_tt.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.9/3_generic_type_arguments_in_tt.ts diff --git a/es2panda/test/ts_extra_tests/test/2.9/4_import_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/4_import_types.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.9/4_import_types.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.9/4_import_types.ts diff --git a/es2panda/test/ts_extra_tests/test/2.9/module.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/module.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/2.9/module.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.9/module.ts diff --git a/es2panda/test/ts_extra_tests/test/3.0/new_unknown_top_type/new_unknown_top_type.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/new_unknown_top_type/new_unknown_top_type.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.0/new_unknown_top_type/new_unknown_top_type.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.0/new_unknown_top_type/new_unknown_top_type.ts diff --git a/es2panda/test/ts_extra_tests/test/3.0/reference_lib/reference_lib.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/reference_lib/reference_lib.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.0/reference_lib/reference_lib.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.0/reference_lib/reference_lib.ts diff --git a/es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/generic_rest_parameters/generic_rest_parameters.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/generic_rest_parameters/generic_rest_parameters.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/generic_rest_parameters/generic_rest_parameters.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/generic_rest_parameters/generic_rest_parameters.ts diff --git a/es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts diff --git a/es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_elements_in_tuple_types/rest_elements_in_tuple_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_elements_in_tuple_types/rest_elements_in_tuple_types.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_elements_in_tuple_types/rest_elements_in_tuple_types.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_elements_in_tuple_types/rest_elements_in_tuple_types.ts diff --git a/es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts diff --git a/es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/spread_expressions_with_tuple_types/spread_expressions_with_tuple_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/spread_expressions_with_tuple_types/spread_expressions_with_tuple_types.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.0/tuples_in_rest_parameters_and_spread_expressions/spread_expressions_with_tuple_types/spread_expressions_with_tuple_types.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/spread_expressions_with_tuple_types/spread_expressions_with_tuple_types.ts diff --git a/es2panda/test/ts_extra_tests/test/3.1/mapped_types_on_tuples_and_arrays/mapped_types_on_tuples_and_arrays_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.1/mapped_types_on_tuples_and_arrays/mapped_types_on_tuples_and_arrays_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.1/mapped_types_on_tuples_and_arrays/mapped_types_on_tuples_and_arrays_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.1/mapped_types_on_tuples_and_arrays/mapped_types_on_tuples_and_arrays_1.ts diff --git a/es2panda/test/ts_extra_tests/test/3.1/properties_declarations_on_functions/properties_declarations_on_functions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.1/properties_declarations_on_functions/properties_declarations_on_functions_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.1/properties_declarations_on_functions/properties_declarations_on_functions_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.1/properties_declarations_on_functions/properties_declarations_on_functions_1.ts diff --git a/es2panda/test/ts_extra_tests/test/3.2/bigint/bigint_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/bigint/bigint_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.2/bigint/bigint_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.2/bigint/bigint_1.ts diff --git a/es2panda/test/ts_extra_tests/test/3.2/bigint/bigint_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/bigint/bigint_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.2/bigint/bigint_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.2/bigint/bigint_2.ts diff --git a/es2panda/test/ts_extra_tests/test/3.2/bigint/bigint_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/bigint/bigint_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.2/bigint/bigint_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.2/bigint/bigint_3.ts diff --git a/es2panda/test/ts_extra_tests/test/3.2/generic_object_rest_variables_and_parameters/generic_object_rest_variables_and_parameters.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_object_rest_variables_and_parameters/generic_object_rest_variables_and_parameters.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.2/generic_object_rest_variables_and_parameters/generic_object_rest_variables_and_parameters.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_object_rest_variables_and_parameters/generic_object_rest_variables_and_parameters.ts diff --git a/es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_1.ts diff --git a/es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts diff --git a/es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_3.ts diff --git a/es2panda/test/ts_extra_tests/test/3.2/non-unit_types_as_union_discriminants/non-unit_types_as_union_discriminants.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/non-unit_types_as_union_discriminants/non-unit_types_as_union_discriminants.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.2/non-unit_types_as_union_discriminants/non-unit_types_as_union_discriminants.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.2/non-unit_types_as_union_discriminants/non-unit_types_as_union_discriminants.ts diff --git a/es2panda/test/ts_extra_tests/test/3.3/improved_behavior_for_calling_union_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.3/improved_behavior_for_calling_union_types.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.3/improved_behavior_for_calling_union_types.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.3/improved_behavior_for_calling_union_types.ts diff --git a/es2panda/test/ts_extra_tests/test/3.4/a_new_syntax_for_readonly_array.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.4/a_new_syntax_for_readonly_array.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.4/a_new_syntax_for_readonly_array.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.4/a_new_syntax_for_readonly_array.ts diff --git a/es2panda/test/ts_extra_tests/test/3.4/const_assertions.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.4/const_assertions.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.4/const_assertions.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.4/const_assertions.ts diff --git a/es2panda/test/ts_extra_tests/test/3.4/higher_order_type_inference.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.4/higher_order_type_inference.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.4/higher_order_type_inference.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.4/higher_order_type_inference.ts diff --git a/es2panda/test/ts_extra_tests/test/3.4/readonly_tuples.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.4/readonly_tuples.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.4/readonly_tuples.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.4/readonly_tuples.ts diff --git a/es2panda/test/ts_extra_tests/test/3.5/higher_order_type_inference.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.5/higher_order_type_inference.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.5/higher_order_type_inference.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.5/higher_order_type_inference.ts diff --git a/es2panda/test/ts_extra_tests/test/3.5/improved_excess_property_checks_in_union_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.5/improved_excess_property_checks_in_union_types.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.5/improved_excess_property_checks_in_union_types.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.5/improved_excess_property_checks_in_union_types.ts diff --git a/es2panda/test/ts_extra_tests/test/3.5/omit_helper_type.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.5/omit_helper_type.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.5/omit_helper_type.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.5/omit_helper_type.ts diff --git a/es2panda/test/ts_extra_tests/test/3.5/smarter_union_type_checking.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.5/smarter_union_type_checking.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.5/smarter_union_type_checking.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.5/smarter_union_type_checking.ts diff --git a/es2panda/test/ts_extra_tests/test/3.6/better_unicode_support_for_identifiers/better_unicode_support_for_identifiers_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/better_unicode_support_for_identifiers/better_unicode_support_for_identifiers_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.6/better_unicode_support_for_identifiers/better_unicode_support_for_identifiers_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.6/better_unicode_support_for_identifiers/better_unicode_support_for_identifiers_1.ts diff --git a/es2panda/test/ts_extra_tests/test/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/get_and_set_accessors_are_allowed_in_ambient_contexts_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/get_and_set_accessors_are_allowed_in_ambient_contexts_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/get_and_set_accessors_are_allowed_in_ambient_contexts_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/get_and_set_accessors_are_allowed_in_ambient_contexts_1.ts diff --git a/es2panda/test/ts_extra_tests/test/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/test.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/test.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/test.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/test.ts diff --git a/es2panda/test/ts_extra_tests/test/3.6/more_accurate_array_spread/more_accurate_array_spread_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/more_accurate_array_spread/more_accurate_array_spread_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.6/more_accurate_array_spread/more_accurate_array_spread_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.6/more_accurate_array_spread/more_accurate_array_spread_1.ts diff --git a/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_1.ts diff --git a/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_2.ts diff --git a/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_3.ts diff --git a/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_4.ts diff --git a/es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.6/stricter_generators/stricter_generators_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_5.ts diff --git a/es2panda/test/ts_extra_tests/test/3.7/assertion_functions/assertion_functions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/assertion_functions/assertion_functions_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.7/assertion_functions/assertion_functions_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.7/assertion_functions/assertion_functions_1.ts diff --git a/es2panda/test/ts_extra_tests/test/3.7/nullish_coalescing/nullish_coalescing_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/nullish_coalescing/nullish_coalescing_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.7/nullish_coalescing/nullish_coalescing_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.7/nullish_coalescing/nullish_coalescing_1.ts diff --git a/es2panda/test/ts_extra_tests/test/3.7/nullish_coalescing/nullish_coalescing_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/nullish_coalescing/nullish_coalescing_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.7/nullish_coalescing/nullish_coalescing_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.7/nullish_coalescing/nullish_coalescing_2.ts diff --git a/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_1.ts diff --git a/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_2.ts diff --git a/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_3.ts diff --git a/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_4.ts diff --git a/es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.7/optional_chaining/optional_chaining_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_5.ts diff --git a/es2panda/test/ts_extra_tests/test/3.7/recursive_type_aliases/recursive_type_aliases_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/recursive_type_aliases/recursive_type_aliases_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.7/recursive_type_aliases/recursive_type_aliases_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.7/recursive_type_aliases/recursive_type_aliases_1.ts diff --git a/es2panda/test/ts_extra_tests/test/3.7/ts_nocheck_in_typescript_files/ts_nocheck_in_typescript_files.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/ts_nocheck_in_typescript_files/ts_nocheck_in_typescript_files.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.7/ts_nocheck_in_typescript_files/ts_nocheck_in_typescript_files.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.7/ts_nocheck_in_typescript_files/ts_nocheck_in_typescript_files.ts diff --git a/es2panda/test/ts_extra_tests/test/3.8/1_type_only_imports_and_export.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/1_type_only_imports_and_export.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.8/1_type_only_imports_and_export.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.8/1_type_only_imports_and_export.ts diff --git a/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_1.ts diff --git a/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_2.ts diff --git a/es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_3.ts diff --git a/es2panda/test/ts_extra_tests/test/3.8/3_which_should_i_use.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/3_which_should_i_use.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.8/3_which_should_i_use.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.8/3_which_should_i_use.ts diff --git a/es2panda/test/ts_extra_tests/test/3.8/4_export_star_as_ns_syntax.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/4_export_star_as_ns_syntax.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.8/4_export_star_as_ns_syntax.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.8/4_export_star_as_ns_syntax.ts diff --git a/es2panda/test/ts_extra_tests/test/3.8/export_star.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/export_star.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.8/export_star.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.8/export_star.ts diff --git a/es2panda/test/ts_extra_tests/test/3.8/my_module.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/my_module.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.8/my_module.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.8/my_module.ts diff --git a/es2panda/test/ts_extra_tests/test/3.8/some_module.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/some_module.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.8/some_module.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.8/some_module.ts diff --git a/es2panda/test/ts_extra_tests/test/3.9/improvements_in_inference_and_Promise.all/improvements_in_inference_and_Promise.all.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.9/improvements_in_inference_and_Promise.all/improvements_in_inference_and_Promise.all.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.9/improvements_in_inference_and_Promise.all/improvements_in_inference_and_Promise.all.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.9/improvements_in_inference_and_Promise.all/improvements_in_inference_and_Promise.all.ts diff --git a/es2panda/test/ts_extra_tests/test/3.9/ts-expect-error_comments/ts-expect-error_comments.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.9/ts-expect-error_comments/ts-expect-error_comments.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/3.9/ts-expect-error_comments/ts-expect-error_comments.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.9/ts-expect-error_comments/ts-expect-error_comments.ts diff --git a/es2panda/test/ts_extra_tests/test/4.0/class_property_Inference_from_constructors/class_property_Inference_from_constructors_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/class_property_Inference_from_constructors/class_property_Inference_from_constructors_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.0/class_property_Inference_from_constructors/class_property_Inference_from_constructors_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.0/class_property_Inference_from_constructors/class_property_Inference_from_constructors_1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_2.ts diff --git a/es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_3.ts diff --git a/es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.0/labeled_tuple_elements/labeled_tuple_elements_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_4.ts diff --git a/es2panda/test/ts_extra_tests/test/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_2.ts diff --git a/es2panda/test/ts_extra_tests/test/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_3.ts diff --git a/es2panda/test/ts_extra_tests/test/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_2.ts diff --git a/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_2.ts diff --git a/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_3.ts diff --git a/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_4.ts diff --git a/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_5.ts diff --git a/es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_6.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.0/variadic_tuple_types/variadic_tuple_types_6.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_6.ts diff --git a/es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/Checked_Indexed_Accesses.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/Checked_Indexed_Accesses.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/Checked_Indexed_Accesses.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/Checked_Indexed_Accesses.ts diff --git a/es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/for_each_index.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_each_index.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/for_each_index.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_each_index.ts diff --git a/es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/for_of_index.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_of_index.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/for_of_index.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_of_index.ts diff --git a/es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/for_traversal_index.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_traversal_index.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.1/Checked_Indexed_Accesses/for_traversal_index.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_traversal_index.ts diff --git a/es2panda/test/ts_extra_tests/test/4.1/abstract_members_can_not_be_marked_async/abstract_members_can_not_be_marked_async.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/abstract_members_can_not_be_marked_async/abstract_members_can_not_be_marked_async.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.1/abstract_members_can_not_be_marked_async/abstract_members_can_not_be_marked_async.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.1/abstract_members_can_not_be_marked_async/abstract_members_can_not_be_marked_async.ts diff --git a/es2panda/test/ts_extra_tests/test/4.1/any_or_unknown_are_propagated_in_falsy_positions/any_or_unknown_are_propagated_in_falsy_positions.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/any_or_unknown_are_propagated_in_falsy_positions/any_or_unknown_are_propagated_in_falsy_positions.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.1/any_or_unknown_are_propagated_in_falsy_positions/any_or_unknown_are_propagated_in_falsy_positions.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.1/any_or_unknown_are_propagated_in_falsy_positions/any_or_unknown_are_propagated_in_falsy_positions.ts diff --git a/es2panda/test/ts_extra_tests/test/4.1/conditional_spreads_create_optional_properties/conditional_spreads_create_optional_properties_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/conditional_spreads_create_optional_properties/conditional_spreads_create_optional_properties_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.1/conditional_spreads_create_optional_properties/conditional_spreads_create_optional_properties_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.1/conditional_spreads_create_optional_properties/conditional_spreads_create_optional_properties_1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_2.ts diff --git a/es2panda/test/ts_extra_tests/test/4.1/recursive_conditional_types/recursive_conditional_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/recursive_conditional_types/recursive_conditional_types.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.1/recursive_conditional_types/recursive_conditional_types.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.1/recursive_conditional_types/recursive_conditional_types.ts diff --git a/es2panda/test/ts_extra_tests/test/4.1/resolvers_parameters_are_no_longer_optional_in_promises/resolves_parameters_are_no_longer_optional_in_promises.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/resolvers_parameters_are_no_longer_optional_in_promises/resolves_parameters_are_no_longer_optional_in_promises.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.1/resolvers_parameters_are_no_longer_optional_in_promises/resolves_parameters_are_no_longer_optional_in_promises.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.1/resolvers_parameters_are_no_longer_optional_in_promises/resolves_parameters_are_no_longer_optional_in_promises.ts diff --git a/es2panda/test/ts_extra_tests/test/4.1/template_literal_types/template_literal_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.1/template_literal_types/template_literal_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.1/template_literal_types/template_literal_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.1/template_literal_types/template_literal_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_2.ts diff --git a/es2panda/test/ts_extra_tests/test/4.1/template_literal_types/template_literal_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.1/template_literal_types/template_literal_types_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_3.ts diff --git a/es2panda/test/ts_extra_tests/test/4.2/Reverting_Template_Literal_Inference/Reverting_Template_Literal_Inference.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/Reverting_Template_Literal_Inference/Reverting_Template_Literal_Inference.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.2/Reverting_Template_Literal_Inference/Reverting_Template_Literal_Inference.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.2/Reverting_Template_Literal_Inference/Reverting_Template_Literal_Inference.ts diff --git a/es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures.ts diff --git a/es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures_1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures_2.ts diff --git a/es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.2/abstract_construct_signatures/abstract_construct_signatures_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures_3.ts diff --git a/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types2.ts diff --git a/es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types3.ts diff --git a/es2panda/test/ts_extra_tests/test/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation2.ts diff --git a/es2panda/test/ts_extra_tests/test/4.3/always-truthy_promise_checks/always-truthy_promise_checks.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/always-truthy_promise_checks/always-truthy_promise_checks.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.3/always-truthy_promise_checks/always-truthy_promise_checks.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.3/always-truthy_promise_checks/always-truthy_promise_checks.ts diff --git a/es2panda/test/ts_extra_tests/test/4.3/constructorParameters_works_on_abstract_class/constructorParameters_works_on_abstract_class.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/constructorParameters_works_on_abstract_class/constructorParameters_works_on_abstract_class.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.3/constructorParameters_works_on_abstract_class/constructorParameters_works_on_abstract_class.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.3/constructorParameters_works_on_abstract_class/constructorParameters_works_on_abstract_class.ts diff --git a/es2panda/test/ts_extra_tests/test/4.3/contextual_narrowing_for_generic/contextual_narrowing_for_generics.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/contextual_narrowing_for_generic/contextual_narrowing_for_generics.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.3/contextual_narrowing_for_generic/contextual_narrowing_for_generics.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.3/contextual_narrowing_for_generic/contextual_narrowing_for_generics.ts diff --git a/es2panda/test/ts_extra_tests/test/4.3/ecmascript_private_class_elements/ecmascript_private_calss_elements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/ecmascript_private_class_elements/ecmascript_private_calss_elements.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.3/ecmascript_private_class_elements/ecmascript_private_calss_elements.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.3/ecmascript_private_class_elements/ecmascript_private_calss_elements.ts diff --git a/es2panda/test/ts_extra_tests/test/4.3/override_and_the_noImplicitOverride_Flag/override_and_the_noImplicitOverride_Flag.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/override_and_the_noImplicitOverride_Flag/override_and_the_noImplicitOverride_Flag.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.3/override_and_the_noImplicitOverride_Flag/override_and_the_noImplicitOverride_Flag.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.3/override_and_the_noImplicitOverride_Flag/override_and_the_noImplicitOverride_Flag.ts diff --git a/es2panda/test/ts_extra_tests/test/4.3/separate_write_types_on_properties/separate_write_types_on_properties_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.3/separate_write_types_on_properties/separate_write_types_on_properties_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.3/separate_write_types_on_properties/separate_write_types_on_properties_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.3/separate_write_types_on_properties/separate_write_types_on_properties_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_2.ts diff --git a/es2panda/test/ts_extra_tests/test/4.3/static_index_signatures/static_index_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/static_index_signatures/static_index_signatures.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.3/static_index_signatures/static_index_signatures.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.3/static_index_signatures/static_index_signatures.ts diff --git a/es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_2.ts diff --git a/es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_3.ts diff --git a/es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.3/template_string_type_improvements/template_string_type_improvements_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_4.ts diff --git a/es2panda/test/ts_extra_tests/test/4.3/union_enums_cannot_be_compared_to_arbitrary_numbers/union_enums_cannot_be_compared_to_arbitrary_numbers.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/union_enums_cannot_be_compared_to_arbitrary_numbers/union_enums_cannot_be_compared_to_arbitrary_numbers.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.3/union_enums_cannot_be_compared_to_arbitrary_numbers/union_enums_cannot_be_compared_to_arbitrary_numbers.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.3/union_enums_cannot_be_compared_to_arbitrary_numbers/union_enums_cannot_be_compared_to_arbitrary_numbers.ts diff --git a/es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_2.ts diff --git a/es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_3.ts diff --git a/es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_4.ts diff --git a/es2panda/test/ts_extra_tests/test/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_2.ts diff --git a/es2panda/test/ts_extra_tests/test/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_3.ts diff --git a/es2panda/test/ts_extra_tests/test/4.4/exact_optional_property_types/exact_optional_property_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/exact_optional_property_types/exact_optional_property_types_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.4/exact_optional_property_types/exact_optional_property_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.4/exact_optional_property_types/exact_optional_property_types_1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.4/static_blocks_in_classe/static_blocks_in_classes1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/static_blocks_in_classe/static_blocks_in_classes1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.4/static_blocks_in_classe/static_blocks_in_classes1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.4/static_blocks_in_classe/static_blocks_in_classes1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.4/static_blocks_in_classe/static_blocks_in_classes2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/static_blocks_in_classe/static_blocks_in_classes2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.4/static_blocks_in_classe/static_blocks_in_classes2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.4/static_blocks_in_classe/static_blocks_in_classes2.ts diff --git a/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_2.ts diff --git a/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_3.ts diff --git a/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_4.ts diff --git a/es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_5.ts diff --git a/es2panda/test/ts_extra_tests/test/4.5/disabling_import_elision/animal.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/disabling_import_elision/animal.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.5/disabling_import_elision/animal.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.5/disabling_import_elision/animal.ts diff --git a/es2panda/test/ts_extra_tests/test/4.5/disabling_import_elision/disabling_import_elision_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/disabling_import_elision/disabling_import_elision_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.5/disabling_import_elision/disabling_import_elision_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.5/disabling_import_elision/disabling_import_elision_1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.5/private_field_presence_checks/private_field_presence_checks_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/private_field_presence_checks/private_field_presence_checks_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.5/private_field_presence_checks/private_field_presence_checks_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.5/private_field_presence_checks/private_field_presence_checks_1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts diff --git a/es2panda/test/ts_extra_tests/test/4.5/template_string_types_as_discriminants/template_string_types_as_discriminants_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/template_string_types_as_discriminants/template_string_types_as_discriminants_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.5/template_string_types_as_discriminants/template_string_types_as_discriminants_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.5/template_string_types_as_discriminants/template_string_types_as_discriminants_1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.5/the_awaited_type_and_promise_improvements/the_awaited_type_and_promise_improvements_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/the_awaited_type_and_promise_improvements/the_awaited_type_and_promise_improvements_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.5/the_awaited_type_and_promise_improvements/the_awaited_type_and_promise_improvements_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.5/the_awaited_type_and_promise_improvements/the_awaited_type_and_promise_improvements_1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.5/type_modifiers_on_import_names/some-module.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/some-module.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.5/type_modifiers_on_import_names/some-module.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/some-module.ts diff --git a/es2panda/test/ts_extra_tests/test/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.6/1_allowing_code_in_constructors.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/1_allowing_code_in_constructors.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.6/1_allowing_code_in_constructors.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.6/1_allowing_code_in_constructors.ts diff --git a/es2panda/test/ts_extra_tests/test/4.6/2_control_flow_analysis.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/2_control_flow_analysis.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.6/2_control_flow_analysis.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.6/2_control_flow_analysis.ts diff --git a/es2panda/test/ts_extra_tests/test/4.6/3_improved_recursion_depth_checks.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/3_improved_recursion_depth_checks.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.6/3_improved_recursion_depth_checks.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.6/3_improved_recursion_depth_checks.ts diff --git a/es2panda/test/ts_extra_tests/test/4.6/4_indexed_access_inference_improvements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/4_indexed_access_inference_improvements.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.6/4_indexed_access_inference_improvements.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.6/4_indexed_access_inference_improvements.ts diff --git a/es2panda/test/ts_extra_tests/test/4.6/5_control_flow_analysis_for_dependent_parameters.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/5_control_flow_analysis_for_dependent_parameters.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.6/5_control_flow_analysis_for_dependent_parameters.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.6/5_control_flow_analysis_for_dependent_parameters.ts diff --git a/es2panda/test/ts_extra_tests/test/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access.ts diff --git a/es2panda/test/ts_extra_tests/test/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access_1.ts diff --git a/es2panda/test/ts_extra_tests/test/4.7/extends_constraints_on_infer_type_variables/extends_constraints_on_infer_type_variables.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/extends_constraints_on_infer_type_variables/extends_constraints_on_infer_type_variables.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.7/extends_constraints_on_infer_type_variables/extends_constraints_on_infer_type_variables.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.7/extends_constraints_on_infer_type_variables/extends_constraints_on_infer_type_variables.ts diff --git a/es2panda/test/ts_extra_tests/test/4.7/improved_function_inference_in_objects_and_methods/improved_function_inference_in_objects_and_methods.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/improved_function_inference_in_objects_and_methods/improved_function_inference_in_objects_and_methods.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.7/improved_function_inference_in_objects_and_methods/improved_function_inference_in_objects_and_methods.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.7/improved_function_inference_in_objects_and_methods/improved_function_inference_in_objects_and_methods.ts diff --git a/es2panda/test/ts_extra_tests/test/4.7/instantiation_expressions/instantiation_expressions.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/instantiation_expressions/instantiation_expressions.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.7/instantiation_expressions/instantiation_expressions.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.7/instantiation_expressions/instantiation_expressions.ts diff --git a/es2panda/test/ts_extra_tests/test/4.7/optional_variance_annotations_for_type_parameters/optional_variance_annotations_for_type_parameters.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/optional_variance_annotations_for_type_parameters/optional_variance_annotations_for_type_parameters.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.7/optional_variance_annotations_for_type_parameters/optional_variance_annotations_for_type_parameters.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.7/optional_variance_annotations_for_type_parameters/optional_variance_annotations_for_type_parameters.ts diff --git a/es2panda/test/ts_extra_tests/test/4.7/readonly_tuples_have_a_readonly_length_property/readonly_tuples_have_a_readonly_length_property.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/readonly_tuples_have_a_readonly_length_property/readonly_tuples_have_a_readonly_length_property.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.7/readonly_tuples_have_a_readonly_length_property/readonly_tuples_have_a_readonly_length_property.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.7/readonly_tuples_have_a_readonly_length_property/readonly_tuples_have_a_readonly_length_property.ts diff --git a/es2panda/test/ts_extra_tests/test/4.8/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.8/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.8/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.8/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing.ts diff --git a/es2panda/test/ts_extra_tests/test/4.8/improved_inference_for_infer_types_in_template_string_types/improved_inference_for_infer_types_in_template_string_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.8/improved_inference_for_infer_types_in_template_string_types/improved_inference_for_infer_types_in_template_string_types.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.8/improved_inference_for_infer_types_in_template_string_types/improved_inference_for_infer_types_in_template_string_types.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.8/improved_inference_for_infer_types_in_template_string_types/improved_inference_for_infer_types_in_template_string_types.ts diff --git a/es2panda/test/ts_extra_tests/test/4.9/auto_accessors_in_classes/auto_accessors_in_classes.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.9/auto_accessors_in_classes/auto_accessors_in_classes.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.9/auto_accessors_in_classes/auto_accessors_in_classes.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.9/auto_accessors_in_classes/auto_accessors_in_classes.ts diff --git a/es2panda/test/ts_extra_tests/test/4.9/checks_for_equality_on_NaN/checks_for_equality_on_NaN.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.9/checks_for_equality_on_NaN/checks_for_equality_on_NaN.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.9/checks_for_equality_on_NaN/checks_for_equality_on_NaN.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.9/checks_for_equality_on_NaN/checks_for_equality_on_NaN.ts diff --git a/es2panda/test/ts_extra_tests/test/4.9/the_satisfies_operator/the_satisfies_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.9/the_satisfies_operator/the_satisfies_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.9/the_satisfies_operator/the_satisfies_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.9/the_satisfies_operator/the_satisfies_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/4.9/unlisted_property_narrowing_with_the_in_operator/unlisted_property_narrowing_with_the_in_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.9/unlisted_property_narrowing_with_the_in_operator/unlisted_property_narrowing_with_the_in_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/4.9/unlisted_property_narrowing_with_the_in_operator/unlisted_property_narrowing_with_the_in_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.9/unlisted_property_narrowing_with_the_in_operator/unlisted_property_narrowing_with_the_in_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/ambients/ambient_declarations/ambient_namespace_declarations/ambient_namespace_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_namespace_declarations/ambient_namespace_declarations.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/ambients/ambient_declarations/ambient_namespace_declarations/ambient_namespace_declarations.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_namespace_declarations/ambient_namespace_declarations.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/ambients/ambient_module_declarations/ambient_module_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/ambients/ambient_module_declarations/ambient_module_declarations_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/declarations/declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/declarations/declarations_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/declarations/declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/declarations/declarations_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/computed_property_names/computed_property_names_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/computed_property_names/computed_property_names_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/computed_property_names/computed_property_names_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/computed_property_names/computed_property_names_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/property_names/property_names_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/property_names/property_names_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/property_names/property_names_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/property_names/property_names_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/require_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/require_is_valid_identifier_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/require_is_valid_identifier_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/require_is_valid_identifier_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/let_scope.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/let_scope.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/let_scope.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/let_scope.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/namespace.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/namespace.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/namespace.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/namespace.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_2_m.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_2_m.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_2_m.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_2_m.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/scopes_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/var_scope.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/var_scope.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/basic_concepts/scopes/var_scope.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/var_scope.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_body/class_body.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_body/class_body.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_body/class_body.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_body/class_body.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_declarations_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_declarations_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_declarations_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_6.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_6.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_6.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_6.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_6.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_6.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/super_calls/super_calls.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/super_calls/super_calls.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/constructor_declarations/super_calls/super_calls.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/super_calls/super_calls.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/index_member_declarations/index_member_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/index_member_declarations/index_member_declarations.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/index_member_declarations/index_member_declarations.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/index_member_declarations/index_member_declarations.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/accessibility/accessibility_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/class_types/class_types_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_6.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_6.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_6.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_7.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_7.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_7.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_8.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/constructorc_function_types/constructor_function_types_8.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_8.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_accessor_declarations/member_accessor_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_accessor_declarations/member_accessor_declarations.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_accessor_declarations/member_accessor_declarations.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_accessor_declarations/member_accessor_declarations.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/property_member_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/property_member_declarations_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/property_member_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/property_member_declarations_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/property_member_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/classes/property_member_declarations/property_member_declarations_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/enums/constant_enum_declarations/constant_enum_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/constant_enum_declarations/constant_enum_declarations.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/enums/constant_enum_declarations/constant_enum_declarations.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/constant_enum_declarations/constant_enum_declarations.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/enums/declaration_merging/declaration_merging_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/enums/declaration_merging/declaration_merging_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/enums/declaration_merging/declaration_merging_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/enums/declaration_merging/declaration_merging_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/enums/enum_declarations/enum_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/enums/enum_declarations/enum_declarations_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/enums/enum_declarations/enum_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/enums/enum_declarations/enum_declarations_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/enums/enum_declarations/enum_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/enums/enum_declarations/enum_declarations_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/enums/enum_members/enum_members_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_members/enum_members_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/enums/enum_members/enum_members_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_members/enum_members_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_6.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/array_literals/array_literal_6.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_6.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/arrow_function/arrow_function_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/assignment_operators/assignment_operator_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/assignment_operators/assignment_operator_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/assignment_operators/assignment_operator_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/assignment_operators/assignment_operator_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_6.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_6.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_6.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_7.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_7.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_7.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_8.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_8.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_8.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_congruence_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_congruence_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_congruence_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_congruence_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_equal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_equal_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_equal_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_equal_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_greater_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_greater_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_greater_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_greater_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_greater_or_equal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_greater_or_equal_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_greater_or_equal_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_greater_or_equal_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_incongruence_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_incongruence_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_incongruence_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_incongruence_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_less_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_less_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_less_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_less_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_less_or_equal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_less_or_equal_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_less_or_equal_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_less_or_equal_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_unequal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_unequal_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_greater_less_lessEqual/the_unequal_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_unequal_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_instanceof_operator/the_instanceof_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_instanceof_operator/the_instanceof_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_instanceof_operator/the_instanceof_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_instanceof_operator/the_instanceof_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_and_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_and_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_and_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_and_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_division_method_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_division_method_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_division_method_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_division_method_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_left_shift_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_left_shift_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_left_shift_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_left_shift_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_multiplication_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_multiplication_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_multiplication_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_multiplication_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_or_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_or_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_or_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_or_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_remainder_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_remainder_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_remainder_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_remainder_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_right_shift_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_right_shift_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_right_shift_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_right_shift_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_subtraction_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_subtraction_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_subtraction_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_subtraction_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_unsigned_shift_to_the_right.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_unsigned_shift_to_the_right.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_unsigned_shift_to_the_right.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_unsigned_shift_to_the_right.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_xor_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_xor_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_mul_div_rem/the_xor_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_xor_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_or_operator/the_or_operator_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/binary_operators/the_or_operator/the_or_operator_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/class_expressions/class_expressions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/class_expressions/class_expressions_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/class_expressions/class_expressions_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/class_expressions/class_expressions_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_10.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_10.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_10.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_10.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_11.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_11.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_11.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_11.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_13.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_13.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_13.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_13.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_15.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_15.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_15.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_15.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_16.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_16.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_16.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_16.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_6.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_6.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_6.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_9.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_9.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_9.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/overload_resolution/overload_resolution_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/function_expression/function_expressions_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/class.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/class.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/class.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/class.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/enum.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/enum.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/enum.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/enum.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/function.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/function.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/function.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/function.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/name_space.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/name_space.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/name_space.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/name_space.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/parameter.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/parameter.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/parameter.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/parameter.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/variable.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/variable.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/identifiers/variable.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/variable.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/literals/boolean.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/boolean.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/literals/boolean.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/boolean.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/literals/null.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/null.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/literals/null.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/null.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/literals/number.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/number.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/literals/number.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/number.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/literals/regexp.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/regexp.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/literals/regexp.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/regexp.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/literals/string.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/string.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/literals/string.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/string.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_6.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_6.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_6.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_7.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/object_literal/object_literal_7.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_7.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/parentheses/parentheses.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/parentheses/parentheses.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/parentheses/parentheses.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/parentheses/parentheses.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_access_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_access_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_access_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_access_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_any_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_any_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_any_type_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_type_6.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_any_type_6.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_type_6.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_apprent_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_apprent_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_apprent_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_apprent_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_index_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_index_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_index_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_index_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_string_number_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_string_number_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/property_access/object_string_number_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_string_number_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/property_access_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/property_access/property_access_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/property_access/property_access_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/property_access/property_access_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_comma_operator/the_comma_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_comma_operator/the_comma_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/the_comma_operator/the_comma_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_comma_operator/the_comma_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_conditional_operator/the_conditional_operator_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/the_conditional_operator/the_conditional_operator_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/the_new_operator/new_operator_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_calls/arguments.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/arguments.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_calls/arguments.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/arguments.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_calls/super_calls.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/super_calls.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_calls/super_calls.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/super_calls.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_property_access/derived_class_access.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/derived_class_access.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_property_access/derived_class_access.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/derived_class_access.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_property_access/static_member_access.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/static_member_access.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/the_super_keyword/super_property_access/static_member_access.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/static_member_access.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/this_key_word/this_key_word_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/this_key_word/this_key_word_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_assertion/type_assertion_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/type_assertion/type_assertion_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_assertion/type_assertion_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/type_assertion/type_assertion_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_assertion/type_assertion_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/type_assertion/type_assertion_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_10.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_10.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_10.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_10.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_11.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_11.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_11.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_11.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_12.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_12.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_12.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_12.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_13.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_13.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_13.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_13.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_14.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_14.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_14.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_14.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_15.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_15.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_15.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_15.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_6.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_6.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_6.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_7.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_7.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_7.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_8.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_8.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_8.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_9.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/type_guards/type_guards_9.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_9.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_!_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_!_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_!_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_!_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_++_and_--_operators.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_++_and_--_operators.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_++_and_--_operators.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_++_and_--_operators.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_+_and_~_operators.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_+_and_~_operators.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_+_and_~_operators.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_+_and_~_operators.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_delete_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_delete_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_delete_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_delete_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_typeof_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_typeof_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_typeof_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_typeof_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_void_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_void_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/expressions/unary_operators/the_void_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_void_operator.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/asynchronous_functions/asynchronous_functions_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_6.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_6.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_6.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/function_declarations/function_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/function_declarations/function_declarations_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/function_declarations/function_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/function_declarations/function_declarations_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/function_implementations/function_implementations_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/function_overloads/function_overloads_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_overloads/function_overloads_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/function_overloads/function_overloads_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_overloads/function_overloads_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/generator_functions/generator_functions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/generator_functions/generator_functions_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/generator_functions/generator_functions_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/generator_functions/generator_functions_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/generator_functions/generator_functions_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/generator_functions/generator_functions_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/generic_functions/generic_functions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/generic_functions/generic_functions_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/generic_functions/generic_functions_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/generic_functions/generic_functions_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/functions/type_guard_functions/type_guard_functions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/type_guard_functions/type_guard_functions_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/functions/type_guard_functions/type_guard_functions_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/type_guard_functions/type_guard_functions_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/classes/classes.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/classes/classes.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/grammar/classes/classes.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/classes/classes.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/enums/enums.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/enums/enums.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/grammar/enums/enums.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/enums/enums.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/expressions/expressions.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/expressions/expressions.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/grammar/expressions/expressions.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/expressions/expressions.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/functions/functions.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/functions/functions.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/grammar/functions/functions.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/functions/functions.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/interfaces/interfaces.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/interfaces/interfaces.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/grammar/interfaces/interfaces.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/interfaces/interfaces.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/namespaces/namespaces.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/namespaces/namespaces.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/grammar/namespaces/namespaces.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/namespaces/namespaces.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/scripts_and_modules.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/scripts_and_modules.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/scripts_and_modules.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/scripts_and_modules.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/grammar/scripts_and_modules/source_file_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/statements/statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/statements/statements.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/grammar/statements/statements.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/statements/statements.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/grammar/types/types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/types/types.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/grammar/types/types.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/types/types.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/interfaces/1_interface_declarations/interface_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/interfaces/1_interface_declarations/interface_declarations_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/interfaces/1_interface_declarations/interface_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/interfaces/1_interface_declarations/interface_declarations_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/interfaces/1_interface_declarations/interface_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/interfaces/1_interface_declarations/interface_declarations_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/interfaces/2_declaration_merging/declaration_merging_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/interfaces/2_declaration_merging/declaration_merging_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/interfaces/2_declaration_merging/declaration_merging_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/interfaces/2_declaration_merging/declaration_merging_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/interfaces/4_dynamic_type_checks/dynamic_type_checks_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/4_dynamic_type_checks/dynamic_type_checks_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/interfaces/4_dynamic_type_checks/dynamic_type_checks_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/4_dynamic_type_checks/dynamic_type_checks_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_1_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_1_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_1_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_1_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_1_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_1_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/namespaces/declaration_merging/declaration_merging_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/export_declarations/export_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/namespaces/export_declarations/export_declarations_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/export_declarations/export_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/namespaces/export_declarations/export_declarations_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/export_declarations/export_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/namespaces/export_declarations/export_declarations_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/import_alias_declarations/import_alias_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/import_alias_declarations/import_alias_declarations_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/namespaces/import_alias_declarations/import_alias_declarations_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/import_alias_declarations/import_alias_declarations_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/import_alias_declarations/import_alias_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/import_alias_declarations/import_alias_declarations_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/namespaces/import_alias_declarations/import_alias_declarations_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/import_alias_declarations/import_alias_declarations_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_body/namespace_body.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_body/namespace_body.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_body/namespace_body.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_body/namespace_body.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/namespaces/namespace_declarations/namespace_declarations_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_00.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_00.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_00.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_00.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_files_dependencies.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_files_dependencies.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_files_dependencies.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_files_dependencies.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_10.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_10.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_10.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_10.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_6.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_6.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_6.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_7.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_7.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_7.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_8.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_8.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_8.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_9.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/1_programs_and_source_files/source_9.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_9.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/2_modules/modules_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/2_modules/modules_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/2_modules/modules_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/2_modules/modules_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/3_import_declarations/import_declarations_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/4_import_require_declarations/import_require_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/4_import_require_declarations/import_require_declarations_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/4_import_require_declarations/import_require_declarations_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/4_import_require_declarations/import_require_declarations_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_declarations_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_declarations_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_declarations_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_declarations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_declarations_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_declarations_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/5_export_declarations/export_declarations_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/6_export_assignments/export_assignments_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/6_export_assignments/export_assignments_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/6_export_assignments/export_assignments_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/6_export_assignments/export_assignments_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/blocks/blocks_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/break_statements/break_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/break_statements/break_statements.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/break_statements/break_statements.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/break_statements/break_statements.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/continue_statements/continue_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/continue_statements/continue_statements.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/continue_statements/continue_statements.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/continue_statements/continue_statements.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/for_in_statements/for_in_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_in_statements/for_in_statements.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/for_in_statements/for_in_statements.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_in_statements/for_in_statements.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/for_of_statements/for_of_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_of_statements/for_of_statements.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/for_of_statements/for_of_statements.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_of_statements/for_of_statements.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/for_statements/for_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_statements/for_statements.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/for_statements/for_statements.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_statements/for_statements.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/let_and_const_declarations/let_and_const_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/let_and_const_declarations/let_and_const_declarations.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/let_and_const_declarations/let_and_const_declarations.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/let_and_const_declarations/let_and_const_declarations.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/return_statements/return_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/return_statements/return_statements.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/return_statements/return_statements.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/return_statements/return_statements.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/switch_statements/switch_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/switch_statements/switch_statements.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/switch_statements/switch_statements.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/switch_statements/switch_statements.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/throw_statements/throw_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/throw_statements/throw_statements.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/throw_statements/throw_statements.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/throw_statements/throw_statements.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/try_statements/try_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/try_statements/try_statements.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/try_statements/try_statements.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/try_statements/try_statements.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/3_implied_type/implied_type.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/3_implied_type/implied_type.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/statements/variable_statements/3_implied_type/implied_type.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/3_implied_type/implied_type.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/Intersection_Types/Intersection_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/Intersection_Types/Intersection_types_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/Intersection_Types/Intersection_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/Intersection_Types/Intersection_types_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/Intersection_Types/intersection_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/Intersection_Types/intersection_types_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/Intersection_Types/intersection_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/Intersection_Types/intersection_types_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/named_types/named_types_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/object_types/array_types/array_types_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/object_types/constructor_types/constructor_types_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/function_types/function_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/function_types/function_types_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/object_types/function_types/function_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/function_types/function_types_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/function_types/function_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/function_types/function_types_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/object_types/function_types/function_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/function_types/function_types_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/members/members_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/object_types/members/members_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/members/members_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/object_types/members/members_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/named_type_reference/named_type_reference.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/named_type_reference/named_type_reference.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/object_types/named_type_reference/named_type_reference.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/named_type_reference/named_type_reference.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/tuple_types/tuple_types_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/tuple_types/tuple_types_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/tuple_types/tuple_types_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/tuple_types/tuple_types_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/tuple_types/tuple_types_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/object_types/tuple_types/tuple_types_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/tuple_types/tuple_types_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_boolean_type/the_boolean_type_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_enum_type/the_enum_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_enum_type/the_enum_type_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_enum_type/the_enum_type_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_enum_type/the_enum_type_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_null_type/the_null_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_null_type/the_null_type_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_null_type/the_null_type_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_null_type/the_null_type_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_number_type/the_number_type_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_type/the_string_type_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_type/the_string_type_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_type/the_string_type_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_type/the_string_type_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_type/the_string_type_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_string_type/the_string_type_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_type/the_string_type_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_symbol_type/the_symbol_type_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_symbol_type/the_symbol_type_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_symbol_type/the_symbol_type_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_symbol_type/the_symbol_type_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_symbol_type/the_symbol_type_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_symbol_type/the_symbol_type_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_symbol_type/the_symbol_type_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_undefined_type/the_undefined_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_undefined_type/the_undefined_type_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_undefined_type/the_undefined_type_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_undefined_type/the_undefined_type_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/primitive_types/the_void_type/the_void_type_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_6.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_6.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_6.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/return_type/return_type_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/return_type/return_type_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/return_type/return_type_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/return_type/return_type_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/return_type/return_type_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/return_type/return_type_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/return_type/return_type_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/specialized_signatures/specialized_signatures_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/specialized_signatures/specialized_signatures_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/specialized_signatures/specialized_signatures_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/specialized_signatures/specialized_signatures_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/construct_signatures/construct_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/construct_signatures/construct_signatures.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_members/construct_signatures/construct_signatures.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/construct_signatures/construct_signatures.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/index_signatures/index_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/index_signatures/index_signatures.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_members/index_signatures/index_signatures.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/index_signatures/index_signatures.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/method_signatures/method_signatures_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_members/method_signatures/method_signatures_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/method_signatures/method_signatures_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_members/method_signatures/method_signatures_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_members/property_signatures/property_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/property_signatures/property_signatures.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_members/property_signatures/property_signatures.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/property_signatures/property_signatures.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_types/array_type_literals/array_type_literals_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/function_type_literals/function_type_literals_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/function_type_literals/function_type_literals_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_types/function_type_literals/function_type_literals_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/function_type_literals/function_type_literals_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/intersection_type_literals/intersection_type_literals.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/intersection_type_literals/intersection_type_literals.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_types/intersection_type_literals/intersection_type_literals.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/intersection_type_literals/intersection_type_literals.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/object_type_literals/object_type_literals.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/object_type_literals/object_type_literals.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_types/object_type_literals/object_type_literals.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/object_type_literals/object_type_literals.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/predefined_types/predefined_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/predefined_types/predefined_types.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_types/predefined_types/predefined_types.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/predefined_types/predefined_types.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/specifying_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/specifying_types_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_types/specifying_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/specifying_types_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/specifying_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/specifying_types_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_types/specifying_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/specifying_types_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/this_type_references/this_type_references_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/this_type_references/this_type_references_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_types/this_type_references/this_type_references_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/this_type_references/this_type_references_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/this_type_references/this_type_references_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/this_type_references/this_type_references_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_types/this_type_references/this_type_references_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/this_type_references/this_type_references_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/tuple_type_literals/tuple_type_literals.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/tuple_type_literals/tuple_type_literals.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_types/tuple_type_literals/tuple_type_literals.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/tuple_type_literals/tuple_type_literals.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_queries/type_queries_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_queries/type_queries_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_queries/type_queries_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_queries/type_queries_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_queries/type_queries_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_queries/type_queries_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_queries/type_queries_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_queries/type_queries_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_types/type_references/type_references_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/specifying_types/union_type_literals/union_type_literals.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/union_type_literals/union_type_literals.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/specifying_types/union_type_literals/union_type_literals.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/union_type_literals/union_type_literals.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/the_any_type/any_type_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_aliases/type_aliases_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_aliases/type_aliases_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_aliases/type_aliases_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_aliases/type_aliases_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_aliases/type_aliases_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_aliases/type_aliases_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/this_types/this_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_parameters/this_types/this_types.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/this_types/this_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_parameters/this_types/this_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/this_types/this_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_parameters/this_types/this_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_argument_lists/type_argument_lists_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_6.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_6.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_6.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_6.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_6.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_6.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_7.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_7.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_7.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_8.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/apparent_members/apparent_members_8.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_8.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_10.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_10.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_10.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_10.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_11.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_11.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_11.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_11.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_12.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_12.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_12.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_12.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_13.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_13.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_13.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_13.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_14.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_14.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_14.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_14.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_15.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_15.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_15.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_15.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_16.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_16.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_16.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_16.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_17.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_17.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_17.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_17.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_18.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_18.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_18.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_18.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_6.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_6.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_6.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_7.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_7.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_7.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_8.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_8.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_8.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_9.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_9.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_9.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/contextual_signature_instantiation/contextual_signature_instantiation.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/contextual_signature_instantiation/contextual_signature_instantiation.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/contextual_signature_instantiation/contextual_signature_instantiation.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/contextual_signature_instantiation/contextual_signature_instantiation.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/excess_properties/excess_properties_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/excess_properties/excess_properties_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/excess_properties/excess_properties_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/excess_properties/excess_properties_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/excess_properties/excess_properties_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/excess_properties/excess_properties_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/recursive_types/recursive_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/recursive_types/recursive_types.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/recursive_types/recursive_types.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/recursive_types/recursive_types.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_10.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_10.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_10.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_10.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_11.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_11.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_11.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_11.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_12.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_12.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_12.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_12.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_13.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_13.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_13.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_13.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_14.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_14.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_14.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_14.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_15.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_15.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_15.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_15.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_16.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_16.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_16.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_16.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_6.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_6.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_6.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_7.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_7.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_7.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_8.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_8.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_8.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_9.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_9.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_9.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_6.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_6.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_6.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_7.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/type_relationships/type_inference/type_inference_7.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_7.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_3.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_4.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_4.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_5.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_5.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_6.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_6.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_6.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_7.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/union_types/union_types_7.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_7.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/widend_types/widend_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/widend_types/widend_types_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/widend_types/widend_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/widend_types/widend_types_1.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/widend_types/widend_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/widend_types/widend_types_2.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/widend_types/widend_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/widend_types/widend_types_2.ts diff --git a/es2panda/test/ts_extra_tests/test/spec/types/widend_types/widend_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/widend_types/widend_types_3.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test/spec/types/widend_types/widend_types_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/widend_types/widend_types_3.ts diff --git a/es2panda/test/ts_extra_tests/tool/testcfg.py b/es2panda/test/ts_extra_tests/tool/testcfg.py index 5fbd205e56..7b6456a800 100644 --- a/es2panda/test/ts_extra_tests/tool/testcfg.py +++ b/es2panda/test/ts_extra_tests/tool/testcfg.py @@ -161,7 +161,7 @@ class TestCase(): def __get_js_basename(self): sp = '/' - return "test" + sp + self.path.split(sp+"test"+sp)[1].replace('.ts', '.js') + return "test_ts_cases" + sp + self.path.split(sp+"test_ts_cases"+sp)[1].replace('.ts', '.js') def __is_strict(self): if 'strict' in self.declaration: -- Gitee From 1b8d090dfddd6def857368082ad04c1d88f773e3 Mon Sep 17 00:00:00 2001 From: tanglizhen Date: Fri, 2 Jun 2023 16:46:39 +0800 Subject: [PATCH 05/18] =?UTF-8?q?Ts=20test=20cases=20Issues=EF=BC=9Ahttps:?= =?UTF-8?q?//gitee.com/openharmony/arkcompiler=5Fets=5Ffrontend/issues/I78?= =?UTF-8?q?HJU=3Ffrom=3Dproject-issue=20Signed-off-by:=20tanglizhen=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es2panda/test/ts_extra_tests/run_ts_case.py | 12 ++++++++---- es2panda/test/ts_extra_tests/tool/test_helper.py | 4 ++-- es2panda/test/ts_extra_tests/tool/testcfg.py | 3 ++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/es2panda/test/ts_extra_tests/run_ts_case.py b/es2panda/test/ts_extra_tests/run_ts_case.py index 7b40383814..fa19b3c342 100644 --- a/es2panda/test/ts_extra_tests/run_ts_case.py +++ b/es2panda/test/ts_extra_tests/run_ts_case.py @@ -100,6 +100,9 @@ parser.add_argument( parser.add_argument( '--es2abc', dest='es2abc', default=None, help='ES2ABC_PATH') +parser.add_argument( + '-tsc', dest='tsc', default="tsc", help='tsc') + # parse the arguments from standard input args = parser.parse_args() if args.js_runtime_path: @@ -109,6 +112,8 @@ if args.ld_library_path: if args.es2abc: TestCase.es2abc = args.es2abc +TestCase.tsc = args.tsc + disable_list = [] if args.disable_list: disable_list = get_disable_list(args.disable_list) @@ -156,10 +161,9 @@ for file_path in args.release: # delete abc files if args.arkruntime: for file_paths in get_path_file("suite", None, True): - if file_paths.endswith(".ts"): - test_case = TestCase(file_paths) - if not test_case.is_test_case: - test_case.create_abc(file_paths) + if file_paths.endswith(".abc"): + if os.path.exists(file_paths): + os.remove(file_paths) for file_paths in get_path_file("test_ts_cases", None, True): if file_paths.endswith(".abc"): diff --git a/es2panda/test/ts_extra_tests/tool/test_helper.py b/es2panda/test/ts_extra_tests/tool/test_helper.py index 890bd9b9e2..7e95369641 100644 --- a/es2panda/test/ts_extra_tests/tool/test_helper.py +++ b/es2panda/test/ts_extra_tests/tool/test_helper.py @@ -36,14 +36,14 @@ def read_declaration(path): return context # LIMIT_VERSION = 4.2 -ROOT_FOLDER = 'test' +ROOT_FOLDER = 'test_ts_cases' def get_path_file(dir_path, all_file_path=None, is_root=False, limit_version=None): if all_file_path is None: all_file_path = [] file_or_dir = os.listdir(dir_path) file_or_dir_results = [] - if dir_path.endswith("test") or dir_path.endswith("test/"): + if dir_path.endswith("test_ts_cases") or dir_path.endswith("test_ts_cases/"): is_root = True else: is_root = False diff --git a/es2panda/test/ts_extra_tests/tool/testcfg.py b/es2panda/test/ts_extra_tests/tool/testcfg.py index 7b6456a800..dc49245ead 100644 --- a/es2panda/test/ts_extra_tests/tool/testcfg.py +++ b/es2panda/test/ts_extra_tests/tool/testcfg.py @@ -38,6 +38,7 @@ class TestCase(): ld_library_path = "" js_runtime_path = "" es2abc = "" + tsc = "" def __init__(self, path): self.path = path @@ -104,7 +105,7 @@ class TestCase(): if platform.system().lower() == 'windows': cmd = ['cmd', '/c', 'tsc', '--target', 'es2020'] else: - cmd = ['tsc', '--target', 'es2020'] + cmd = [TestCase.tsc, '--target', 'es2020'] if self.__is_strict(): cmd.extend(STRICT_ON) else: -- Gitee From 59a0c03bb7138537273b51869ab05ffad72dc294 Mon Sep 17 00:00:00 2001 From: tanglizhen Date: Fri, 2 Jun 2023 17:24:42 +0800 Subject: [PATCH 06/18] =?UTF-8?q?Ts=20test=20cases=20fix=20Issues=EF=BC=9A?= =?UTF-8?q?https://gitee.com/openharmony/arkcompiler=5Fets=5Ffrontend/issu?= =?UTF-8?q?es/I78HJU=3Ffrom=3Dproject-issue=20Signed-off-by:=20tanglizhen?= =?UTF-8?q?=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../overload_resolution/overload_resolution_2.ts | 2 +- .../overload_resolution/overload_resolution_3.ts | 6 +++--- .../expressions/property_access/object_index_4.ts | 4 +--- .../index_signatures/index_signatures.ts | 14 +------------- 4 files changed, 6 insertions(+), 20 deletions(-) diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts index 156ff59674..ba79874724 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts @@ -32,7 +32,7 @@ interface IFnCall { interface IFnCall { (func: (str: S) => T, name: string): T } -const foo: IFnCall = function (fn) { +const foo: IFnCall = function (fn:any) { return fn('xiao') } const res = foo((name) => { diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_3.ts index 6da42897a5..c08c0e56c8 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_3.ts @@ -26,13 +26,13 @@ import { Assert } from '../../../../../suite/assert.js' interface IfnCall { - (name: string, age: number): string + (name: string, age: string): string } interface IfnCall { (str: string, num: string): string } -const foo: IfnCall = function (name, age) { +const foo: IfnCall = function (name: string, age: string) { return name + ":" + age } -var f = foo("xiao", 18) +var f = foo("xiao", "18") Assert.isString(f); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_index_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_index_4.ts index 9bd3f9e7a8..bd5f6d03f8 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_index_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_index_4.ts @@ -36,6 +36,4 @@ const obj: MyObj = { Assert.equal(obj[0], "foo"); Assert.equal(obj[1], "bar"); Assert.equal(obj[2], "baz"); -Assert.equal(obj["0"], "foo"); -Assert.equal(obj["1"], "bar"); -Assert.equal(obj["2"], "baz"); + diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/index_signatures/index_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/index_signatures/index_signatures.ts index 42b66ba780..0dd50020f7 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/index_signatures/index_signatures.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/index_signatures/index_signatures.ts @@ -31,14 +31,7 @@ let ni: { [key: number]: boolean } = { 0: false, 1: true }; ni[-1] = true; Assert.isBoolean(ni[0]); Assert.equal(ni[-1], true); -interface UnionKey { - [key: string | number]: string | number; -} -let uk: UnionKey = { Name: "UnionKey", 0: "NARC", 0x0a: 10 }; -Assert.equal(uk["Name"], "UnionKey"); -Assert.equal(uk[0], "NARC"); -Assert.equal(uk[0x0a], 10); -Assert.equal(uk[0xff], undefined); + interface StringKey { [key: string]: string; } @@ -52,8 +45,3 @@ interface NumberKey { let nk: NumberKey = { 1: "0x01", 2: "0x02", "3": "0x03", 4: "0x04" }; Assert.equal(nk[1], "0x01"); Assert.equal(nk[2], "0x02"); -Assert.equal(nk["3"], "0x03"); -let rk1: Record = { one: 1, two: 2, three: 3 }; -Assert.equal(rk1["one"], 1); -let rk2: Record<"a" | "b" | "c", string> = { a: "A", b: "B", c: "C" }; -Assert.equal(rk2["a"], "A"); \ No newline at end of file -- Gitee From 60a8fb2cb6965a42f1b7a388bd4628d669fda965 Mon Sep 17 00:00:00 2001 From: tanglizhen Date: Mon, 5 Jun 2023 11:55:58 +0800 Subject: [PATCH 07/18] =?UTF-8?q?Ts=20test=20cases=20fix=20Issues=EF=BC=9A?= =?UTF-8?q?https://gitee.com/openharmony/arkcompiler=5Fets=5Ffrontend/issu?= =?UTF-8?q?es/I78HJU=3Ffrom=3Dproject-issue=20Signed-off-by:=20tanglizhen?= =?UTF-8?q?=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es2panda/test/ts_extra_tests/run_ts_case.py | 9 +++++++++ .../3.7/optional_chaining/optional_chaining_4.ts | 14 ++++++++++---- es2panda/test/ts_extra_tests/tool/testcfg.py | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/es2panda/test/ts_extra_tests/run_ts_case.py b/es2panda/test/ts_extra_tests/run_ts_case.py index fa19b3c342..330590a1d8 100644 --- a/es2panda/test/ts_extra_tests/run_ts_case.py +++ b/es2panda/test/ts_extra_tests/run_ts_case.py @@ -169,6 +169,15 @@ for file_path in args.release: if file_paths.endswith(".abc"): if os.path.exists(file_paths): os.remove(file_paths) + if file_paths.endswith(".ts"): + if os.path.exists(file_paths): + file = open(file_paths, 'r') + lines = file.readlines() + if lines[-1] == 'print("TESTCASE SUCCESS");': + lines.pop() + file = open(file_paths, 'w') + file.writelines(lines) + file.close() print("TOTAL CASE COUNT:%d" % total_case) print("FAILED CASE COUNT:%d" % failed_case) diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_4.ts index 8275e3b116..5970e1f4c8 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_4.ts @@ -32,12 +32,18 @@ class C{ return this.mem; } } -async function func(str: string, arg?: (str: string) => void): Promise{ +async function method(str: string): Promise { + return str; +} + +async function func(str: string, arg?: (str: string) => void): Promise{ let c = new C('member'); let para = c.func('member'); - arg?.(para); - const result: Promise = ((await func(str)).json()); - arg?.(para); + let x = arg?.(para); + Assert.isUndefined(x); + const result: string = await method(str); + let y = arg?.(para); + Assert.isUndefined(y); return result; } func('string').then(res => { diff --git a/es2panda/test/ts_extra_tests/tool/testcfg.py b/es2panda/test/ts_extra_tests/tool/testcfg.py index dc49245ead..9be3546be2 100644 --- a/es2panda/test/ts_extra_tests/tool/testcfg.py +++ b/es2panda/test/ts_extra_tests/tool/testcfg.py @@ -61,7 +61,7 @@ class TestCase(): return if arkruntime: with open(self.path, 'a') as fileAdded: - fileAdded.write('print("TESTCASE SUCCESS");') + fileAdded.write('\rprint("TESTCASE SUCCESS");') self.__test_es2abc() if(os.path.exists(self.abc_file_path)): os.remove(self.abc_file_path) -- Gitee From 5ef4ccd12b11ace6ead32a48c7b6b570921a9406 Mon Sep 17 00:00:00 2001 From: tanglizhen Date: Tue, 6 Jun 2023 18:02:01 +0800 Subject: [PATCH 08/18] =?UTF-8?q?Ts=20test=20cases=20fix=20Issues=EF=BC=9A?= =?UTF-8?q?https://gitee.com/openharmony/arkcompiler=5Fets=5Ffrontend/issu?= =?UTF-8?q?es/I78HJU=3Ffrom=3Dproject-issue=20Signed-off-by:=20tanglizhen?= =?UTF-8?q?=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../abstract_properties_and_accessors.ts | 4 +- ...icate_identifiers_across_declarations_1.ts | 4 +- .../control_flow_based_type_analysis1.ts | 14 ++-- .../control_flow_based_type_analysis2.ts | 2 +- .../control_flow_based_type_analysis3.ts | 1 - .../dotted_names_in_type_guards_1.ts | 4 +- .../expression_operators_1.ts | 9 ++- .../implicit_index_signatures.ts | 2 +- .../module_resolution_enhancements_3.ts | 1 - .../view1.ts => never_type/never_type.ts} | 24 +++++- .../non_null_and_non_undefined.ts | 42 ++++++++++ .../non_null_assertion_operator.ts | 6 +- .../null_and_undefined_aware_types.ts | 40 ++++++++++ .../optional_class_properties.ts | 6 +- .../private_and_protected_constructor.ts | 13 ++- ...ad-only_properties_and_index_signatures.ts | 30 ++++--- ...shorthand_ambient_module_declarations_1.ts | 6 +- .../{hot-new-module.ts => test_ts.ts} | 0 ...ifying_the_type_of_this_for_functions_2.ts | 11 +-- .../tagged_union_types_1.ts | 4 +- ...iling_commas_in_parameter_and_argument.ts} | 17 ++-- .../better_inference_for_literal_types_1.ts | 4 + .../better_inference_for_literal_types_2.ts | 20 ++--- .../better_inference_for_literal_types_3.ts | 44 +++++----- .../downlevel_async_functions_1.ts | 6 +- .../improved_any_inference_1.ts | 14 ++-- .../improved_any_inference_2.ts | 9 ++- .../keyof_and_lookup_types_1.ts | 17 ++-- .../keyof_and_lookup_types_2.ts | 6 +- .../2.1/mapped_types/mapped_types_1.ts | 32 ++++---- .../2.1/mapped_types/mapped_types_2.ts | 19 +++-- .../object_spread_and_rest_1.ts | 28 +++---- .../object_spread_and_rest_2.ts | 10 +-- .../object_spread_and_rest_3.ts | 10 +-- ...turned_values_from_super_call_as_this_1.ts | 14 ++-- .../{object_type.ts => object_type_1.ts} | 0 .../2.2/object_type/object_type_2.ts | 32 ++++++++ .../support_for_mix_in_classes_1.ts | 12 +-- .../support_for_mix_in_classes_2.ts | 8 +- .../1_dynamic_import_expressions.ts | 4 +- .../2.4/2_string_enums/string_enums_1.ts | 8 +- .../3_improved_inference_for_generics.ts | 10 +-- ..._contravariance_for_callback_parameters.ts | 26 +++--- .../5_weak_type_detection.ts | 36 ++++----- .../2.5/1_optional_catch_clause_variables.ts | 8 +- .../1_constant_named_properties.ts | 3 +- .../2.7/2_unique_symbol/2_unique_symbol.ts | 3 +- .../4_definite_assignment_assertions.ts | 1 - ...oved_type_inference_for_object_literals.ts | 6 +- ...proved_keyof_with_intersection_types_1.ts} | 0 ...proved_keyof_with_intersection_types_2.ts} | 29 ++++--- .../2.8/distributive_conditional_types.ts | 48 +++++------ ...ed_control_over_mapped_type_modifiers_1.ts | 33 ++++++++ ...ed_control_over_mapped_type_modifiers_2.ts | 32 ++++++++ .../test_ts_cases/2.8/type_inference.ts | 39 ++++----- .../generic_type_arguments_in_tt.ts} | 32 +++----- .../import_types.ts} | 18 ++--- .../1_support_number_and_symbol_nam_1.ts | 44 ++++------ .../1_support_number_and_symbol_nam_2.ts | 18 ++--- .../1_support_number_and_symbol_nam_3.ts | 62 ++++++-------- .../new_unknown_top_type.ts | 21 ++--- .../3.0/reference_lib/reference_lib.ts | 2 +- .../generic_rest_parameters.ts | 24 +++--- .../optional_elements_in_tuple_types.ts | 23 +++--- .../rest_elements_in_tuple_types.ts | 10 +-- .../spread_expressions_with_tuple_types.ts | 12 +-- .../mapped_types_on_tuples_and_arrays_1.ts | 8 +- ...ic_object_rest_variables_and_parameters.ts | 21 +++-- ...spread_expressions_in_object_literals_1.ts | 8 +- ...spread_expressions_in_object_literals_2.ts | 2 - ...spread_expressions_in_object_literals_3.ts | 23 +++--- .../non-unit_types_as_union_discriminants.ts | 34 ++++++-- ...proved_behavior_for_calling_union_types.ts | 6 +- .../test_ts_cases/3.4/Caveats.ts | 44 ++++++++++ .../3.4/Type_checking_for_globalThis.ts | 36 +++++++++ .../3.5/smarter_union_type_checking.ts | 4 +- ...etter_unicode_support_for_identifiers_1.ts | 4 +- ...ssors_are_allowed_in_ambient_contexts_1.ts | 6 +- .../test.ts | 4 +- .../improved_UX_Around_Promises.ts | 62 ++++++++++++++ .../more_accurate_array_spread_1.ts | 3 + .../stricter_generators_2.ts | 2 +- .../stricter_generators_5.ts | 4 +- .../2_ecmsscript_private_fields_1.ts | 6 +- .../2_ecmsscript_private_fields_2.ts | 10 +-- .../2_ecmsscript_private_fields_3.ts | 6 +- .../test_ts_cases/3.8/3_which_should_i_use.ts | 10 +-- .../labeled_tuple_elements_1.ts | 8 +- .../labeled_tuple_elements_4.ts | 4 +- .../unknow_on_catch_clause_bindings_1.ts | 4 +- .../unknow_on_catch_clause_bindings_2.ts | 9 ++- .../variadic_tuple_types_1.ts | 8 +- .../variadic_tuple_types_2.ts | 10 +-- .../variadic_tuple_types_3.ts | 10 +-- .../variadic_tuple_types_4.ts | 4 +- .../variadic_tuple_types_5.ts | 6 +- .../variadic_tuple_types_6.ts | 10 +-- .../Checked_Indexed_Accesses.ts | 23 +++--- .../for_each_index.ts | 8 +- .../Checked_Indexed_Accesses/for_of_index.ts | 6 +- .../for_traversal_index.ts | 16 ++-- ...known_are_propagated_in_falsy_positions.ts | 12 +-- ...al_spreads_create_optional_properties_1.ts | 38 ++++----- .../key_remapping_in_mapped_types_1.ts | 22 ++--- .../key_remapping_in_mapped_types_2.ts | 16 ++-- .../recursive_conditional_types.ts | 10 +-- ...ters_are_no_longer_optional_in_promises.ts | 15 +++- ...ng_middle_rest_elements_in_tuple_types3.ts | 8 +- ...ng_middle_rest_elements_in_tuple_types4.ts | 40 ++++++++++ ...roperties_and_string_index_signatures_1.ts | 41 ++++++++++ .../smarter_type_alias_preservation1.ts | 21 +++-- .../smarter_type_alias_preservation2.ts | 6 +- .../always-truthy_promise_checks.ts | 4 +- .../contextual_narrowing_for_generics.ts | 38 +++------ .../ecmascript_private_calss_elements.ts | 22 ++--- .../separate_write_types_on_properties_1.ts | 41 ++++++---- .../separate_write_types_on_properties_2.ts | 43 ++++++---- .../static_index_signatures.ts | 12 +-- .../template_string_type_improvements_1.ts | 22 ++--- .../template_string_type_improvements_2.ts | 5 +- .../template_string_type_improvements_4.ts | 20 ++--- ..._aliased_conditions_and_discriminants_1.ts | 53 +++++++++--- ..._aliased_conditions_and_discriminants_2.ts | 35 ++++---- ..._aliased_conditions_and_discriminants_3.ts | 6 +- ..._aliased_conditions_and_discriminants_4.ts | 41 ++++++++-- ...o_the_unknown_type_in_catch_variables_1.ts | 4 +- ...o_the_unknown_type_in_catch_variables_2.ts | 4 +- ...o_the_unknown_type_in_catch_variables_3.ts | 4 +- .../exact_optional_property_types_1.ts | 23 +++--- .../static_blocks_in_classes1.ts | 20 ++--- .../static_blocks_in_classes2.ts | 23 +++--- ...lates_string_pattern_index_signatures_1.ts | 4 +- ...lates_string_pattern_index_signatures_2.ts | 14 ++-- ...lates_string_pattern_index_signatures_3.ts | 23 +++--- ...lates_string_pattern_index_signatures_4.ts | 9 +-- ...lates_string_pattern_index_signatures_5.ts | 17 ++-- .../private_field_presence_checks_1.ts | 10 +-- ...rsion_elimination_on_conditional_types1.ts | 6 +- ...rsion_elimination_on_conditional_types2.ts | 14 ++-- ...emplate_string_types_as_discriminants_1.ts | 38 ++++----- ...awaited_type_and_promise_improvements_1.ts | 8 +- .../type_modifiers_on_import_names_1.ts | 4 +- .../4.6/1_allowing_code_in_constructors.ts | 17 +--- .../4.6/2_control_flow_analysis.ts | 80 ++++++++----------- .../4.6/3_improved_recursion_depth_checks.ts | 24 +----- ...4_indexed_access_inference_improvements.ts | 27 +++---- ..._flow_analysis_for_dependent_parameters.ts | 10 +-- ...w_analysis_for_bracketed_element_access.ts | 12 ++- ...nction_inference_in_objects_and_methods.ts | 28 ++++--- .../instantiation_expressions.ts | 66 ++++++++------- ...ariance_annotations_for_type_parameters.ts | 7 +- ..._tuples_have_a_readonly_length_property.ts | 4 +- ...tion_Union_Compatibility,_and_Narrowing.ts | 39 +++++---- ...or_infer_types_in_template_string_types.ts | 22 ++--- .../ambient_function_declarations.ts | 5 +- .../ambient_namespace_declarations.ts | 2 +- .../ambient_module_declarations_1.ts | 5 +- .../ambient_module_declarations_3.ts | 3 +- .../declarations/declarations_1.ts | 19 ++--- .../declarations/declarations_2.ts | 18 ++--- .../computed_property_names_1.ts | 6 +- .../names/property_names/property_names_1.ts | 1 - .../any_cannot_be_type_name_1.ts | 2 +- .../any_cannot_be_type_name_2.ts | 2 +- .../boolean_cannot_be_type_name_1.ts | 2 +- .../boolean_cannot_be_type_name_2.ts | 2 +- .../number_cannot_be_type_name_1.ts | 2 +- .../number_cannot_be_type_name_2.ts | 2 +- .../string_cannot_be_type_name_1.ts | 2 +- .../string_cannot_be_type_name_2.ts | 2 +- .../symbol_cannot_be_type_name_1.ts | 2 +- .../symbol_cannot_be_type_name_2.ts | 2 +- .../module_is_valid_identifier_2.ts | 4 +- .../spec/basic_concepts/scopes/let_scope.ts | 1 - .../spec/basic_concepts/scopes/scopes_1.ts | 4 +- .../spec/basic_concepts/scopes/scopes_10.ts | 43 ++++++++++ .../spec/basic_concepts/scopes/scopes_11.ts | 50 ++++++++++++ .../spec/basic_concepts/scopes/scopes_12.ts | 40 ++++++++++ .../spec/basic_concepts/scopes/scopes_13_1.ts | 32 ++++++++ .../spec/basic_concepts/scopes/scopes_13_2.ts | 30 +++++++ .../spec/basic_concepts/scopes/scopes_13_3.ts | 43 ++++++++++ .../scopes/{namespace.ts => scopes_14.ts} | 25 +++--- .../spec/basic_concepts/scopes/scopes_2.ts | 2 +- .../spec/basic_concepts/scopes/scopes_2_m.ts | 1 - .../spec/basic_concepts/scopes/scopes_5.ts | 44 ++++++++++ .../basic_concepts/scopes/scopes_6.ts} | 22 +++-- .../spec/basic_concepts/scopes/scopes_7.ts | 36 +++++++++ .../spec/basic_concepts/scopes/scopes_8.ts | 40 ++++++++++ .../spec/basic_concepts/scopes/scopes_9.ts | 33 ++++++++ .../spec/basic_concepts/scopes/var_scope.ts | 1 - .../class_body/class_body.ts | 17 ++-- .../class_declarations_1.ts | 3 - .../class_declarations_3.ts | 15 ++-- .../class_heritage_specification_1.ts | 13 ++- .../class_heritage_specification_2.ts | 22 ++--- .../class_heritage_specification_3.ts | 4 +- .../class_heritage_specification_4.ts | 12 +-- .../automatic_constructors_2.ts | 2 +- .../automatic_constructors_3.ts | 2 +- .../constructor_parameters_1.ts | 4 +- .../super_calls/super_calls.ts | 2 +- .../members/class_types/class_types_1.ts | 8 +- .../members/class_types/class_types_2.ts | 16 ++-- .../members/class_types/class_types_3.ts | 8 +- .../constructor_function_types_4.ts | 2 +- .../constructor_function_types_5.ts | 10 ++- .../inheritance_and_overriding_4.ts | 1 - .../instance_and_static_members_2.ts | 10 ++- .../instance_and_static_members_3.ts | 4 +- .../member_variable_declarations_3.ts | 2 +- .../member_variable_declarations_4.ts | 1 - .../property_member_declarations_1.ts | 18 ++--- .../property_member_declarations_3.ts | 10 +-- .../constant_enum_declarations.ts | 3 +- .../declaration_merging_1.ts | 2 +- .../declaration_merging_2.ts | 3 +- .../enum_declarations/enum_declarations_1.ts | 17 ++-- .../enum_declarations/enum_declarations_2.ts | 16 ++-- .../enum_declarations/enum_declarations_3.ts | 2 - .../spec/enums/enum_members/enum_members_1.ts | 1 - .../array_literals/array_literal_1.ts | 2 +- .../array_literals/array_literal_2.ts | 3 +- .../array_literals/array_literal_3.ts | 6 +- .../array_literals/array_literal_4.ts | 3 +- .../array_literals/array_literal_5.ts | 3 +- .../array_literals/array_literal_6.ts | 1 - .../arrow_function/arrow_function_1.ts | 4 +- .../arrow_function/arrow_function_2.ts | 5 +- .../arrow_function/arrow_function_4.ts | 19 +++-- .../assignment_operator_1.ts | 3 +- .../the_add_operator/the_add_operator_1.ts | 1 + .../the_add_operator/the_add_operator_2.ts | 1 - .../the_and_operator/the_and_operator.ts | 1 - .../the_congruence_operator.ts | 0 .../the_equal_operator.ts | 0 .../the_greater_operator.ts | 0 .../the_greater_or_equal_operator.ts | 0 .../the_incongruence_operator.ts | 0 .../the_less_operator.ts | 0 .../the_less_or_equal_operator.ts | 0 .../the_unequal_operator.ts | 0 .../the_in_operator/the_in_operator.ts | 7 +- .../the_and_operator.ts | 0 .../the_division_method_operator.ts | 0 .../the_left_shift_operator.ts | 0 .../the_multiplication_operator.ts | 0 .../the_or_operator.ts | 0 .../the_remainder_operator.ts | 0 .../the_right_shift_operator.ts | 0 .../the_subtraction_operator.ts | 0 .../the_unsigned_shift_to_the_right.ts | 0 .../the_xor_operator.ts | 0 .../the_or_operator/the_or_operator_1.ts | 1 - .../class_expressions/class_expressions_1.ts | 4 +- .../contextually_typed_expressions_1.ts | 5 -- .../contextually_typed_expressions_12.ts | 1 - .../contextually_typed_expressions_14.ts | 1 - .../contextually_typed_expressions_4.ts | 2 - .../contextually_typed_expressions_7.ts | 35 ++++---- .../contextually_typed_expressions_8.ts | 32 ++++---- .../grammar_ambiguities.ts | 5 -- .../overload_resolution_1.ts | 2 - .../overload_resolution_2.ts | 2 +- .../overload_resolution_3.ts | 6 +- .../type_argument_inference_1.ts | 1 - .../type_argument_inference_2.ts | 2 - .../type_argument_inference_3.ts | 13 ++- .../type_argument_inference_4.ts | 17 ++-- .../function_expressions_1.ts | 2 +- .../function_expressions_2.ts | 4 +- .../function_expressions_3.ts | 3 +- .../spec/expressions/identifiers/class.ts | 4 +- .../expressions/identifiers/name_space.ts | 3 +- .../spec/expressions/identifiers/parameter.ts | 2 + .../spec/expressions/identifiers/variable.ts | 3 +- .../spec/expressions/literals/boolean.ts | 2 +- .../spec/expressions/literals/null.ts | 1 - .../spec/expressions/literals/regexp.ts | 2 +- .../object_literal/object_literal_3.ts | 2 +- .../object_literal/object_literal_4.ts | 2 +- .../object_literal/object_literal_5.ts | 2 +- .../object_literal/object_literal_6.ts | 2 +- .../expressions/parentheses/parentheses.ts | 3 - .../property_access/object_access_2.ts | 3 +- .../property_access/object_any_1.ts | 7 +- .../property_access/object_any_type_6.ts | 8 +- .../property_access/object_apprent_5.ts | 4 +- .../property_access/object_index_4.ts | 5 +- .../property_access/object_string_number_3.ts | 6 +- .../property_access/property_access_1.ts | 1 - .../the_comma_operator/the_comma_operator.ts | 19 +++-- .../the_conditional_operator_1.ts | 1 - .../the_new_operator/new_operator_1.ts | 2 +- .../the_new_operator/new_operator_2.ts | 3 +- .../the_new_operator/new_operator_3.ts | 4 +- .../the_new_operator/new_operator_4.ts | 12 +-- .../super_calls/arguments.ts | 2 +- .../super_calls/gengric_extends.ts | 2 +- .../super_calls/super_calls.ts | 3 +- .../derived_class_access.ts | 7 +- .../this_key_word/this_key_word_1.ts | 6 -- .../type_assertion/type_assertion_1.ts | 5 +- .../type_assertion/type_assertion_2.ts | 1 - .../expressions/type_guards/type_guards_1.ts | 12 ++- .../expressions/type_guards/type_guards_10.ts | 1 - .../expressions/type_guards/type_guards_11.ts | 16 ++-- .../expressions/type_guards/type_guards_12.ts | 16 ++-- .../expressions/type_guards/type_guards_13.ts | 20 ++--- .../expressions/type_guards/type_guards_14.ts | 20 ++--- .../expressions/type_guards/type_guards_15.ts | 7 +- .../expressions/type_guards/type_guards_2.ts | 6 +- .../expressions/type_guards/type_guards_3.ts | 6 +- .../expressions/type_guards/type_guards_4.ts | 9 ++- .../expressions/type_guards/type_guards_5.ts | 9 ++- .../expressions/type_guards/type_guards_6.ts | 3 +- .../expressions/type_guards/type_guards_8.ts | 1 - .../expressions/type_guards/type_guards_9.ts | 16 ++-- .../unary_operators/the_!_operator.ts | 5 +- .../the_++_and_--_operators.ts | 29 ++++--- .../unary_operators/the_+_and_~_operators.ts | 5 +- .../unary_operators/the_typeof_operator.ts | 10 +-- .../asynchronous_functions_1.ts | 8 +- .../asynchronous_functions_3.ts | 4 +- .../destructuring_parameter_declarations_1.ts | 4 +- .../destructuring_parameter_declarations_2.ts | 3 +- .../destructuring_parameter_declarations_3.ts | 2 +- .../destructuring_parameter_declarations_4.ts | 5 +- .../destructuring_parameter_declarations_5.ts | 3 +- .../destructuring_parameter_declarations_6.ts | 4 +- .../destructuring_parameter_declarations_7.ts | 2 +- .../function_declarations_1.ts | 3 +- .../function_declarations_2.ts | 9 +-- .../function_implementations_1.ts | 3 +- .../function_implementations_2.ts | 3 +- .../function_implementations_3.ts | 2 +- .../function_implementations_4.ts | 3 +- .../function_implementations_5.ts | 18 ++--- .../function_overloads_1.ts | 3 +- .../generator_functions_1.ts | 3 +- .../generator_functions_2.ts | 2 +- .../generic_functions/generic_functions_1.ts | 4 +- .../generic_functions/generic_functions_2.ts | 2 +- .../type_guard_functions_1.ts | 5 +- .../return_statements/return_statements.ts | 2 - .../switch_statements/switch_statements.ts | 2 - .../3_implied_type/implied_type.ts | 4 - .../Intersection_types_1.ts | 28 +++---- .../spec/types/named_types/named_types_3.ts | 12 +-- .../spec/types/named_types/named_types_4.ts | 8 +- .../object_types/array_types/array_types_3.ts | 3 +- .../constructor_types/constructor_types_2.ts | 2 +- .../constructor_types/constructor_types_3.ts | 6 +- .../constructor_types/constructor_types_4.ts | 10 +-- .../types/object_types/members/members_1.ts | 16 ++-- .../types/object_types/members/members_2.ts | 4 +- .../named_type_reference.ts | 30 +++---- .../the_boolean_type/the_boolean_type_1.ts | 4 - .../the_boolean_type/the_boolean_type_2.ts | 6 +- .../the_enum_type/the_enum_type_1.ts | 1 - .../the_null_type/the_null_type_1.ts | 4 +- .../the_number_type/the_number_type_1.ts | 5 -- .../the_number_type/the_number_type_2.ts | 6 +- .../the_number_type/the_number_type_3.ts | 2 - .../the_string_literal_type_2.ts | 1 - .../the_string_literal_type_3.ts | 10 +-- .../the_symbol_type/the_symbol_type_3.ts | 12 +-- .../the_undefined_type_1.ts | 21 ++++- .../the_void_type/the_void_type_2.ts | 1 - .../the_void_type/the_void_type_3.ts | 1 - .../parameter_list/parameter_list_5.ts | 1 - .../parameter_list/parameter_list_6.ts | 4 +- .../type_parameters/type_parameters_1.ts | 18 ++--- .../type_parameters/type_parameters_2.ts | 14 ++-- .../index_signatures/index_signatures.ts | 30 ++++--- .../method_signatures/method_signatures_1.ts | 3 +- .../array_type_literals_3.ts | 20 ++--- .../array_type_literals_4.ts | 10 +-- .../function_type_literals_3.ts | 18 ++--- .../intersection_type_literals.ts | 6 +- .../object_type_literals.ts | 16 ++-- .../predefined_types/predefined_types.ts | 16 ++-- .../specifying_types/specifying_types_1.ts | 20 ++--- .../specifying_types/specifying_types_2.ts | 8 +- .../this_type_references_2.ts | 8 +- .../tuple_type_literals.ts | 8 +- .../type_queries/type_queries_2.ts | 12 +-- .../type_references/type_references_1.ts | 6 +- .../type_references/type_references_2.ts | 38 ++++----- .../type_references/type_references_3.ts | 48 +++++------ .../union_type_literals.ts | 10 +-- .../spec/types/the_any_type/any_type_1.ts | 12 ++- .../spec/types/the_any_type/any_type_3.ts | 25 +++++- .../spec/types/type_aliases/type_aliases_1.ts | 20 ++--- .../spec/types/type_aliases/type_aliases_2.ts | 4 +- .../spec/types/type_aliases/type_aliases_3.ts | 6 +- .../type_parameters/this_types/this_types.ts | 8 +- .../this_types/this_types_1.ts | 15 ++-- .../this_types/this_types_2.ts | 7 +- .../type_argument_lists_2.ts | 10 +-- .../type_argument_lists_4.ts | 4 +- .../type_parameter_lists_1.ts | 7 +- .../type_parameter_lists_2.ts | 7 +- .../type_parameter_lists_3.ts | 19 +++-- .../type_parameter_lists_5.ts | 4 +- .../Type_and_Member_Identity.ts | 17 ++-- .../apparent_members/apparent_members_3.ts | 5 +- .../apparent_members/apparent_members_4.ts | 4 +- .../apparent_members/apparent_members_5.ts | 4 +- .../apparent_members/apparent_members_6.ts | 4 +- .../apparent_members/apparent_members_7.ts | 4 +- .../apparent_members/apparent_members_8.ts | 4 +- .../assignment_compatibility_13.ts | 6 +- .../assignment_compatibility_18.ts | 4 +- .../assignment_compatibility_6.ts | 4 +- .../contextual_signature_instantiation.ts | 17 ++-- .../excess_properties/excess_properties_1.ts | 18 ++--- .../excess_properties/excess_properties_2.ts | 23 +++--- .../excess_properties/excess_properties_3.ts | 5 +- .../recursive_types/recursive_types.ts | 2 +- .../subtypes_and_supertypes_10.ts | 4 +- .../subtypes_and_supertypes_12.ts | 4 +- .../subtypes_and_supertypes_13.ts | 8 +- .../subtypes_and_supertypes_14.ts | 7 +- .../subtypes_and_supertypes_15.ts | 7 +- .../subtypes_and_supertypes_2.ts | 4 +- .../subtypes_and_supertypes_3.ts | 4 +- .../subtypes_and_supertypes_4.ts | 4 +- .../subtypes_and_supertypes_5.ts | 2 +- .../subtypes_and_supertypes_6.ts | 4 +- .../subtypes_and_supertypes_7.ts | 8 +- .../subtypes_and_supertypes_8.ts | 4 +- .../subtypes_and_supertypes_9.ts | 8 +- .../type_inference/type_inference_1.ts | 16 ++-- .../type_inference/type_inference_2.ts | 4 +- .../type_inference/type_inference_3.ts | 6 +- .../type_inference/type_inference_4.ts | 4 +- .../type_inference/type_inference_6.ts | 5 +- .../spec/types/union_types/union_types_1.ts | 25 +++--- .../spec/types/union_types/union_types_2.ts | 22 ++--- .../spec/types/union_types/union_types_3.ts | 21 ++--- .../spec/types/union_types/union_types_4.ts | 62 ++++++-------- .../spec/types/union_types/union_types_5.ts | 63 +++++++-------- .../spec/types/union_types/union_types_6.ts | 10 +-- 443 files changed, 2916 insertions(+), 2184 deletions(-) rename es2panda/test/ts_extra_tests/test_ts_cases/2.0/{test_virtual_directories_with_rootDirs/view1.ts => never_type/never_type.ts} (62%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/non_null_and_non_undefined/non_null_and_non_undefined.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/null_and_undefined_aware_types/null_and_undefined_aware_types.ts rename es2panda/test/ts_extra_tests/test_ts_cases/2.0/shorthand_ambient_module_declarations/{hot-new-module.ts => test_ts.ts} (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/2.0/{support_for_UMD_module_definitions/support_for_UMD_module_definitions_1.ts => trailing_commas_in_parameter_and_argument/trailing_commas_in_parameter_and_argument.ts} (74%) rename es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/{object_type.ts => object_type_1.ts} (100%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type_2.ts rename es2panda/test/ts_extra_tests/test_ts_cases/2.8/{Improved_keyof_with_intersection_types.ts => Improved_keyof_with_intersection_types_1.ts} (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/2.8/{improved_control_over_mapped_type_modifiers.ts => Improved_keyof_with_intersection_types_2.ts} (80%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.8/improved_control_over_mapped_type_modifiers_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.8/improved_control_over_mapped_type_modifiers_2.ts rename es2panda/test/ts_extra_tests/test_ts_cases/2.9/{3_generic_type_arguments_in_tt.ts => generic_type_arguments_in_tt/generic_type_arguments_in_tt.ts} (62%) rename es2panda/test/ts_extra_tests/test_ts_cases/2.9/{4_import_types.ts => import_types/import_types.ts} (78%) rename es2panda/test/ts_extra_tests/test_ts_cases/2.9/{1_support_number_and_symbol_nam => support_number_and_symbol_nam}/1_support_number_and_symbol_nam_1.ts (64%) rename es2panda/test/ts_extra_tests/test_ts_cases/2.9/{1_support_number_and_symbol_nam => support_number_and_symbol_nam}/1_support_number_and_symbol_nam_2.ts (86%) rename es2panda/test/ts_extra_tests/test_ts_cases/2.9/{1_support_number_and_symbol_nam => support_number_and_symbol_nam}/1_support_number_and_symbol_nam_3.ts (65%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.4/Caveats.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.4/Type_checking_for_globalThis.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.6/improved_UX_Around_Promises/improved_UX_Around_Promises.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types4.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.2/relaxed_rules/relaxed_rules_between_optional_properties_and_string_index_signatures_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_10.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_11.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_12.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_3.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/{namespace.ts => scopes_14.ts} (74%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_5.ts rename es2panda/test/ts_extra_tests/test_ts_cases/{2.0/support_for_UMD_module_definitions/math-lib.ts => spec/basic_concepts/scopes/scopes_6.ts} (64%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_7.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_8.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_9.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_greater_less_lessEqual => the_greater_less}/the_congruence_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_greater_less_lessEqual => the_greater_less}/the_equal_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_greater_less_lessEqual => the_greater_less}/the_greater_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_greater_less_lessEqual => the_greater_less}/the_greater_or_equal_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_greater_less_lessEqual => the_greater_less}/the_incongruence_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_greater_less_lessEqual => the_greater_less}/the_less_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_greater_less_lessEqual => the_greater_less}/the_less_or_equal_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_greater_less_lessEqual => the_greater_less}/the_unequal_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_mul_div_rem => the_mul_div_rem_sub}/the_and_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_mul_div_rem => the_mul_div_rem_sub}/the_division_method_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_mul_div_rem => the_mul_div_rem_sub}/the_left_shift_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_mul_div_rem => the_mul_div_rem_sub}/the_multiplication_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_mul_div_rem => the_mul_div_rem_sub}/the_or_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_mul_div_rem => the_mul_div_rem_sub}/the_remainder_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_mul_div_rem => the_mul_div_rem_sub}/the_right_shift_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_mul_div_rem => the_mul_div_rem_sub}/the_subtraction_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_mul_div_rem => the_mul_div_rem_sub}/the_unsigned_shift_to_the_right.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_mul_div_rem => the_mul_div_rem_sub}/the_xor_operator.ts (100%) diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts index 32b910779f..866652e0af 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts @@ -24,8 +24,8 @@ isCurrent: true import { Assert } from "../../../suite/assert.js" abstract class Skill { - name: string = "derive"; - damage:number = 1; + abstract name: string; + abstract damage:number; } class Divied extends Skill { name = "derived"; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/allow_duplicate_identifiers_across_declarations/allow_duplicate_identifiers_across_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/allow_duplicate_identifiers_across_declarations/allow_duplicate_identifiers_across_declarations_1.ts index 18da4923d1..6b6f3bf2cc 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/allow_duplicate_identifiers_across_declarations/allow_duplicate_identifiers_across_declarations_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/allow_duplicate_identifiers_across_declarations/allow_duplicate_identifiers_across_declarations_1.ts @@ -21,7 +21,7 @@ import { Assert } from "../../../suite/assert.js" -interface Weapon { +interface Skill { damage?: number; } @@ -31,7 +31,7 @@ interface Skill { damage?: number; } -let sa: Weapon = { +let sa: Skill = { damage: 1024, }; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis1.ts index 23b7306a7c..5e5619f1ec 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis1.ts @@ -28,15 +28,17 @@ if (typeof arg === 'string') { arg = 3; Assert.isNumber(arg); } -arg; + Assert.isNumber(arg); -function func(x: string | number): void { +function func(x: string | number) { if (typeof x === "number") { - return; + return "10"; } - x; - Assert.isNumber(x); + + return 10 } -func(10); + +Assert.isNumber(func("10")); +Assert.isString(func(10)); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis2.ts index 5cd0cce7bf..99374a56ec 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis2.ts @@ -26,7 +26,7 @@ function testFun(x: string | null): void { if (x === null) { return; } - x; + Assert.isString(x); } diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis3.ts index 84cf6671d2..7e7d38f213 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis3.ts @@ -22,7 +22,6 @@ import { Assert } from "../../../suite/assert.js" -// Compiled with --strictNullChecks function tFun(c: boolean): void { let x: number; if (c) { diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/dotted_names_in_type_guards/dotted_names_in_type_guards_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/dotted_names_in_type_guards/dotted_names_in_type_guards_1.ts index 6891d01249..30186c31c7 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/dotted_names_in_type_guards/dotted_names_in_type_guards_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/dotted_names_in_type_guards/dotted_names_in_type_guards_1.ts @@ -22,7 +22,7 @@ import { Assert } from "../../../suite/assert.js" type StrObj = - | { + { strobj?: { str1?: string; str2?: string; @@ -60,3 +60,5 @@ so = { strobj: {} }; Assert.equal(funSO(so), "so.strobj.str1 === undefined"); so = { strobj: { str1: "str1" } }; Assert.equal(funSO(so), "str1"); +so = { strobj: {str2: "str2"} }; +Assert.equal(funSO(so), "str2"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/expression_operators/expression_operators_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/expression_operators/expression_operators_1.ts index 587bf97ab4..4881985ea6 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/expression_operators/expression_operators_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/expression_operators/expression_operators_1.ts @@ -21,11 +21,12 @@ import { Assert } from "../../../suite/assert.js" -var x: number | undefined; -var y: string | null; -var method: string | number | undefined | null; +let x: number | undefined; +let y: string | null; +let method: string | number | undefined | null; x = undefined; y = 'a'; -method = x + y; +method = null +method = x + y + method; Assert.isString(method); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/implicit_index_signatures/implicit_index_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/implicit_index_signatures/implicit_index_signatures.ts index 187d0b9a90..e49b071acc 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/implicit_index_signatures/implicit_index_signatures.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/implicit_index_signatures/implicit_index_signatures.ts @@ -23,7 +23,7 @@ import { Assert } from "../../../suite/assert.js" -function func(path: string, arg: { [x: string]: string }) { +function func(str: string, arg: { [x: string]: string }) { return JSON.stringify(arg); } const arg = { diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_resolution_enhancements/module_resolution_enhancements_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_resolution_enhancements/module_resolution_enhancements_3.ts index a7c264d3ea..f4b2dd70e5 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_resolution_enhancements/module_resolution_enhancements_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_resolution_enhancements/module_resolution_enhancements_3.ts @@ -25,7 +25,6 @@ isCurrent: true import { Assert } from '../../../suite/assert.js' -import '../test_virtual_directories_with_rootDirs/view2.js' import { Directions } from '../test_virtual_directories_with_rootDirs/view2.js' Assert.equal(Directions.Left, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/test_virtual_directories_with_rootDirs/view1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/never_type/never_type.ts similarity index 62% rename from es2panda/test/ts_extra_tests/test_ts_cases/2.0/test_virtual_directories_with_rootDirs/view1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/never_type/never_type.ts index 8ae0a9a186..28d93a7c67 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/test_virtual_directories_with_rootDirs/view1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/never_type/never_type.ts @@ -12,6 +12,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/**--- + description: > + never type + module: ESNext + isCurrent: true + ---*/ -import './module_resolution_enhancements_3.js' \ No newline at end of file +import { Assert } from "../../../suite/assert.js" + +function testError():never { + throw new Error("testError"); +} + +try { + testError(); +} catch (e:any) { + Assert.equal(e.message, "testError"); +} + +function test():never { + return "ok" as never +} + +Assert.equal(typeof test(), "string"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/non_null_and_non_undefined/non_null_and_non_undefined.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/non_null_and_non_undefined/non_null_and_non_undefined.ts new file mode 100644 index 0000000000..eebda7ab58 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/non_null_and_non_undefined/non_null_and_non_undefined.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Non-null and non-undefined type guards + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +function testNullAndUndefined(x: number): string { + return x.toString(); +} + +let x: number | null | undefined; +x = 1; + +Assert.equal(testNullAndUndefined(x), '1'); + +let y: number | null | undefined; + +let ad = y && testNullAndUndefined(y) ; +ad = "1" +Assert.equal(ad, "1"); +ad = undefined +Assert.equal(ad, undefined); +ad = null; +Assert.equal(ad, null); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/non_null_assertion_operator/non_null_assertion_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/non_null_assertion_operator/non_null_assertion_operator.ts index 608a13b8bf..45bd994f48 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/non_null_assertion_operator/non_null_assertion_operator.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/non_null_assertion_operator/non_null_assertion_operator.ts @@ -22,9 +22,9 @@ isCurrent: true import { Assert } from "../../../suite/assert.js" -function hwfStr(x?: string, y?: number | string): string { +function testStr(x?: string, y?: number | string): string { let z: number | string = x! + y!; return z; } -Assert.equal(hwfStr("A"), "Aundefined"); -Assert.equal(hwfStr("B", 5), "B5"); +Assert.equal(testStr("A"), "Aundefined"); +Assert.equal(testStr("B", 5), "B5"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/null_and_undefined_aware_types/null_and_undefined_aware_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/null_and_undefined_aware_types/null_and_undefined_aware_types.ts new file mode 100644 index 0000000000..9291b75e83 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/null_and_undefined_aware_types/null_and_undefined_aware_types.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Null- and undefined-aware types + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +let a: number; +let b: number | undefined; +let c: number | null | undefined; + +a = 0; +Assert.equal(a,0); +b = 0; +Assert.equal(b,0); +b = undefined; +Assert.equal(b,undefined); +c = 0; +Assert.equal(c,0); +c = undefined; +Assert.equal(c,undefined); +c = null; +Assert.equal(c,null); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/optional_class_properties/optional_class_properties.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/optional_class_properties/optional_class_properties.ts index 0331889f94..d8e5a35e47 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/optional_class_properties/optional_class_properties.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/optional_class_properties/optional_class_properties.ts @@ -21,19 +21,19 @@ import { Assert } from '../../../suite/assert.js' -class myClass { +class Demo { a: number = 0; b?: number; func() { return this.a; } - // Body of optional method can be omitted + get?(): number; handle?() { return this.b; } } -let c = new myClass(); +let c = new Demo(); c.a = 1024; c.b = 1408; Assert.equal(c.func(), 1024); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/private_and_protected_constructor/private_and_protected_constructor.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/private_and_protected_constructor/private_and_protected_constructor.ts index 02e1b14b7d..dda0fb44a3 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/private_and_protected_constructor/private_and_protected_constructor.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/private_and_protected_constructor/private_and_protected_constructor.ts @@ -22,20 +22,19 @@ import { Assert } from '../../../suite/assert.js' class Box { - [x: string]: any; - private static subBox: Box = { - cname: "Box", - }; + s!:string; + private static subBox: Box; private constructor() { } - static getSubBos() { + static getSubBos(s:string) { if (!Box.subBox) { Box.subBox = new Box(); + Box.subBox.s = s; } return Box.subBox; } } -let v: Box = Box.getSubBos(); -Assert.equal(v.cname, "Box"); +let v: Box = Box.getSubBos("s"); +Assert.equal(v.s, "s"); class myBox{ arg: string; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/read-only_properties_and_index_signatures/read-only_properties_and_index_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/read-only_properties_and_index_signatures/read-only_properties_and_index_signatures.ts index 4e73b5088e..0a7e42b76a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/read-only_properties_and_index_signatures/read-only_properties_and_index_signatures.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/read-only_properties_and_index_signatures/read-only_properties_and_index_signatures.ts @@ -23,18 +23,30 @@ import { Assert } from '../../../suite/assert.js' -interface Point { +interface Demo { readonly x: number; readonly y: number; } -var p1: Point = { x: 10, y: 20 }; -var p2 = { x: 1, y: 1 }; +let d2 = { x: 1, y: 1 }; -var p3: Point = p2; -Assert.equal(JSON.stringify(p3), '{"x":1,"y":1}'); +let d3: Demo = d2; +Assert.equal(JSON.stringify(d3), '{"x":1,"y":1}'); -p2.x = 5; +d2.x = 5; -let a: Array = [0, 1, 2, 3, 4]; -let b: ReadonlyArray = a; -Assert.equal(JSON.stringify(b), '[0,1,2,3,4]'); +Assert.equal(d3.x, 5) + +let x: Array = [0, 1, 2]; +let y: ReadonlyArray = x; +Assert.equal(JSON.stringify(y), '[0,1,2]'); + +class Demo2 { + readonly x = 1; + readonly y: string; + constructor() { + this.y = "demo"; + } + +} + +Assert.equal(new Demo2().y, "demo"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/shorthand_ambient_module_declarations/shorthand_ambient_module_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/shorthand_ambient_module_declarations/shorthand_ambient_module_declarations_1.ts index 14787aa358..14c73669a0 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/shorthand_ambient_module_declarations/shorthand_ambient_module_declarations_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/shorthand_ambient_module_declarations/shorthand_ambient_module_declarations_1.ts @@ -22,8 +22,6 @@ isCurrent: true import { Assert } from "../../../suite/assert.js" -import hwexpNumAdd15, { y } from "./hot-new-module.js" +import hwexpNumAdd15, { y } from "./test_ts.js" -hwexpNumAdd15(y); - -Assert.equal(typeof hwexpNumAdd15, "function"); \ No newline at end of file +Assert.equal(hwexpNumAdd15(y), 25); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/shorthand_ambient_module_declarations/hot-new-module.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/shorthand_ambient_module_declarations/test_ts.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/2.0/shorthand_ambient_module_declarations/hot-new-module.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/shorthand_ambient_module_declarations/test_ts.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_2.ts index 33992f5262..9348bd0d1f 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_2.ts @@ -23,7 +23,7 @@ isCurrent: true import { Assert } from "../../../suite/assert.js" -interface WebElement { +interface Web { Click(onclick: (this: void, e: Event) => void): void; } @@ -33,12 +33,13 @@ class NetLink { this.info = info; } onClickGood(this: void, e: Event) { - Assert.equal(this, undefined); } } -let webElement: WebElement = { - Click(Onclick: (this: void, e: Event) => void) { } +let web: Web = { + Click(Onclick: (this: void, e: Event) => void) { + Assert.equal(typeof this, "object"); + } }; let onAir = new NetLink("OnAir"); -webElement.Click(onAir.onClickGood); \ No newline at end of file +web.Click(onAir.onClickGood); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/tagged_union_types/tagged_union_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/tagged_union_types/tagged_union_types_1.ts index 1f6d3c69ba..607723bc9a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/tagged_union_types/tagged_union_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/tagged_union_types/tagged_union_types_1.ts @@ -38,7 +38,7 @@ interface Level { type ColorPoint = Color | Point | Level; -function area(s: ColorPoint) { +function test(s: ColorPoint) { switch (s.name) { case "Color": return s.rgb; @@ -78,6 +78,6 @@ let level: Level = { level: 10 }; -Assert.equal(JSON.stringify(area(color)), '[255,0,0]'); +Assert.equal(JSON.stringify(test(color)), '[255,0,0]'); Assert.equal(test1(point).name, 'Point'); Assert.equal(test2(level)?.level, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/support_for_UMD_module_definitions/support_for_UMD_module_definitions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/trailing_commas_in_parameter_and_argument/trailing_commas_in_parameter_and_argument.ts similarity index 74% rename from es2panda/test/ts_extra_tests/test_ts_cases/2.0/support_for_UMD_module_definitions/support_for_UMD_module_definitions_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.0/trailing_commas_in_parameter_and_argument/trailing_commas_in_parameter_and_argument.ts index 0ee5f11177..28859f9abb 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/support_for_UMD_module_definitions/support_for_UMD_module_definitions_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/trailing_commas_in_parameter_and_argument/trailing_commas_in_parameter_and_argument.ts @@ -13,14 +13,17 @@ * limitations under the License. */ /**--- -description: > - These UMD libraries can be accessed through either an import. -module: ESNext -isCurrent: true ----*/ + description: Trailing commas in function parameter and argument lists + module: ESNext + isCurrent: true + ---*/ import { Assert } from "../../../suite/assert.js" -import { isPrime } from "./math-lib.js"; -Assert.equal(isPrime(2), true); \ No newline at end of file +function point(x:number, y:number,) { + return x+y +} + +Assert.equal(3,point(1,2 )) +Assert.equal(3,point(1,2, )) diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_1.ts index 30dc59cd9a..d276b7f620 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_1.ts @@ -24,10 +24,14 @@ import { Assert } from '../../../suite/assert.js' const a = 1; let aa: typeof a = 1; +Assert.equal(typeof aa , "number"); const b = false; let bb: typeof b = false; +Assert.equal(typeof bb , "boolean"); const c = "hello"; let cc: typeof c = "hello"; +Assert.equal(typeof cc , "string"); + class Test { static readonly age = 12; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_2.ts index 42f7f24585..497649f49c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_2.ts @@ -26,22 +26,22 @@ import { Assert } from '../../../suite/assert.js' let a = 1; -let aa: typeof a = 12; -Assert.isNumber(aa); +let newA: typeof a = 12; +Assert.isNumber(newA); -var b = 1; -var bb: typeof b = 12; -Assert.isNumber(bb); +let b = 1; +let newB: typeof b = 12; +Assert.isNumber(newB); -function test(a = true) { +function test(a:boolean = true) { return a; } -let tt: ReturnType = false; -Assert.isBoolean(tt); +let newT: ReturnType = false; +Assert.isBoolean(newT); class Test { static job = "coder"; } -let cc: typeof Test.job = "driver"; -Assert.isString(cc); \ No newline at end of file +let newC: typeof Test.job = "driver"; +Assert.isString(newC); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_3.ts index 244e9c3875..efe57c6d4d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_3.ts @@ -21,28 +21,28 @@ import { Assert } from '../../../suite/assert.js' -const c1 = "hello"; +const newString = "hello"; -let v1 = c1; -v1 = "world"; -const c2: "hello" = "hello"; -let v2 = c2; -Assert.equal(v2, "hello"); +let newV = newString; +newV = "world"; +const newS2: "hello" = "hello"; +let newV2 = newS2; +Assert.equal(newV2, "hello"); -const c3 = 1; -let c4 = c3; -c4 = 10; -Assert.equal(c4, 10); -const c5: 1 = 1; -let c6 = c5; -c6 = 1; -Assert.equal(c6, 1); +const newN = 1; +let n4 = newN; +n4 = 10; +Assert.equal(n4, 10); +const n5: 1 = 1; +let n6 = n5; +n6 = 1; +Assert.equal(n6, 1); -const c7 = false; -let c8 = c7; -c8 = true; -Assert.equal(c8, true); -const c9: false = false; -let c10 = c9; -c10 = false; -Assert.equal(c10, false); \ No newline at end of file +const newB = false; +let b8 = newB; +b8 = true; +Assert.equal(b8, true); +const b9: false = false; +let b10 = b9; +b10 = false; +Assert.equal(b10, false); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/downlevel_async_functions/downlevel_async_functions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/downlevel_async_functions/downlevel_async_functions_1.ts index 44170db19e..2987c40354 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/downlevel_async_functions/downlevel_async_functions_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/downlevel_async_functions/downlevel_async_functions_1.ts @@ -26,15 +26,15 @@ import { Assert } from '../../../suite/assert.js' -function delayTime(milli: number) { +function dTime(milli: number) { return new Promise((resolve) => { setTimeout(resolve, milli); }); } async function showMsg(a: number, b: string) { Assert.equal(a, 12); - for (let i = 0; i < 3; i++) { - await delayTime(500); + for (let i = 0; i < 5; i++) { + await dTime(300); Assert.equal(b, "New"); } Assert.equal(b, "New"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/improved_any_inference/improved_any_inference_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/improved_any_inference/improved_any_inference_1.ts index b67e71a8db..c5a618c9a7 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/improved_any_inference/improved_any_inference_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/improved_any_inference/improved_any_inference_1.ts @@ -23,12 +23,12 @@ import { Assert } from '../../../suite/assert.js' -let x; -x = (a: number) => a + 1; +let win; +win = (a: number) => a + 1; -let y = x; -Assert.equal(y(12), 13); +let fail = win; +Assert.equal(fail(12), 13); -x = "abc"; -Assert.isString(x); -Assert.equal(x.toUpperCase(), "ABC"); +win = "abc"; +Assert.isString(win); +Assert.equal(win.toUpperCase(), "ABC"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/improved_any_inference/improved_any_inference_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/improved_any_inference/improved_any_inference_2.ts index c3800f7fa0..3ee331afe7 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/improved_any_inference/improved_any_inference_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/improved_any_inference/improved_any_inference_2.ts @@ -24,7 +24,8 @@ import { Assert } from '../../../suite/assert.js' -function func() { + +function funcT() { let arr = []; arr[0] = 0; arr.push("true"); @@ -32,7 +33,7 @@ function func() { return arr; } -type c = ReturnType; +type newF = ReturnType; -let cc: c = ["hello", 12]; -Assert.equal(JSON.stringify(cc), '["hello",12]'); +let funC: newF = ["hello", 12]; +Assert.equal(JSON.stringify(funC), '["hello",12]'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/keyof_and_lookup_types/keyof_and_lookup_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/keyof_and_lookup_types/keyof_and_lookup_types_1.ts index 5ea94a09aa..efbc1da5aa 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/keyof_and_lookup_types/keyof_and_lookup_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/keyof_and_lookup_types/keyof_and_lookup_types_1.ts @@ -23,7 +23,7 @@ import { Assert } from '../../../suite/assert.js' -class TestPerson { +class TestHuman { name: string; age: number; private job: string; @@ -33,26 +33,31 @@ class TestPerson { this.job = job; } } -type TestName = Pick; +type TestName = Pick; let nn: TestName = { - name: "nn", + name: "ayw", }; Assert.notEqual(nn.name, undefined); +Assert.equal(nn.name, "ayw"); -type TestAge = Pick; +type TestAge = Pick; let aa: TestAge = { age: 20, }; Assert.notEqual(aa.age, undefined); +Assert.equal(aa.age, 20); -type Test = Pick; +type Test = Pick; let cc: Test = { - name: "cc", + name: "cool", age: 15, }; Assert.notEqual(cc.name, undefined); Assert.notEqual(cc.age, undefined); +Assert.equal(cc.name, "cool"); +Assert.equal(cc.age, 15); + type TestString = keyof { [x: string]: number }; let str: TestString = "abc"; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/keyof_and_lookup_types/keyof_and_lookup_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/keyof_and_lookup_types/keyof_and_lookup_types_2.ts index 110f5e6669..47410ddcb1 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/keyof_and_lookup_types/keyof_and_lookup_types_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/keyof_and_lookup_types/keyof_and_lookup_types_2.ts @@ -21,7 +21,7 @@ import { Assert } from '../../../suite/assert.js' -class TestPerson { +class TestHuman { name: string; age: number; constructor(name: string, age: number, job: string) { @@ -30,13 +30,13 @@ class TestPerson { } } -type TestName = TestPerson["name"]; +type TestName = TestHuman["name"]; let test1: TestName = ""; Assert.equal(typeof test1, "string"); Assert.notEqual(typeof test1, "number"); Assert.notEqual(typeof test1, "boolean"); -type TestAge = TestPerson["age"]; +type TestAge = TestHuman["age"]; let test2: TestAge = 0; Assert.equal(typeof test2, "number"); Assert.notEqual(typeof test2, "string"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_1.ts index 4d943d2a04..1556bb11b5 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_1.ts @@ -24,43 +24,41 @@ import { Assert } from '../../../suite/assert.js' -interface PersonTest { +interface HumanTest { name: string; age: number; - location: string; + destination: string; } -type PersonType = Partial; +type PersonType = Partial; -let pt1: PersonTest = { +let pt1: HumanTest = { name: "caihua", age: 20, - location: "earth", + destination: "earth", }; let pt2: PersonType; pt2 = {}; Assert.equal(pt2.name, undefined); Assert.equal(pt2.age, undefined); -Assert.equal(pt2.location, undefined); +Assert.equal(pt2.destination, undefined); pt2 = { name: "caihua" }; Assert.equal(pt2.name, "caihua"); Assert.equal(pt2.age, undefined); -Assert.equal(pt2.location, undefined); +Assert.equal(pt2.destination, undefined); pt2 = { age: 20 }; Assert.equal(pt2.name, undefined); Assert.equal(pt2.age, 20); -Assert.equal(pt2.location, undefined); -pt2 = { location: "earth" }; +Assert.equal(pt2.destination, undefined); +pt2 = { destination: "earth" }; Assert.equal(pt2.name, undefined); Assert.equal(pt2.age, undefined); -Assert.equal(pt2.location, "earth"); +Assert.equal(pt2.destination, "earth"); pt2 = { name: "caihua", age: 20 }; Assert.equal(pt2.name, "caihua"); Assert.equal(pt2.age, 20); -Assert.equal(pt2.location, undefined); -pt2 = { name: "caihua", location: "earth" }; -pt2 = { age: 20, location: "earth" }; -pt2 = { name: "caihua", age: 20, location: "earth" }; -Assert.equal(pt2.name, "caihua"); -Assert.equal(pt2.age, 20); -Assert.equal(pt2.location, "earth"); \ No newline at end of file +Assert.equal(pt2.destination, undefined); +pt2 = { name: "lwx", age: 27, destination: "nanj" }; +Assert.equal(pt2.name, "lwx"); +Assert.equal(pt2.age, 27); +Assert.equal(pt2.destination, "nanj"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_2.ts index 18f8158bb7..bb4e1c8314 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_2.ts @@ -24,27 +24,26 @@ import { Assert } from '../../../suite/assert.js' -interface PersonTest { +interface HumanTest { name: string; age: number; - location: string; + destination: string; } -type PersonType = Readonly; +type PersonType = Readonly; -let pt1: PersonTest = { +let pt1: HumanTest = { name: "caihua", age: 20, - location: "earth", + destination: "earth", }; pt1.name = "caihua1"; Assert.notEqual(pt1.name, "caihua"); pt1.age = 15; Assert.notEqual(pt1.age, 20); -pt1.location = "Mars"; -Assert.notEqual(pt1.location, "earth"); - +pt1.destination = "Mars"; +Assert.notEqual(pt1.destination, "earth"); let pt2: PersonType = { name: "caihua", age: 20, - location: "earth", -}; + destination: "earth", +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_1.ts index a8893a0a0a..33bbe63b23 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_1.ts @@ -34,18 +34,18 @@ let data = { }, }; -let copy = { ...humen, ...job, ...data }; +let combine = { ...humen, ...job, ...data }; -Assert.equal(copy.name, humen.name); -Assert.equal(copy.age, humen.age); -Assert.equal(copy.job, job.job); -Assert.equal(copy.location, data.location); -Assert.equal(copy.pets.name, data.pets.name); -Assert.equal(copy.pets.type, data.pets.type); -Assert.equal(copy.name == humen.name, true); -Assert.equal(copy.age == humen.age, true); -Assert.equal(copy.job == job.job, true); -Assert.equal(copy.location == data.location, true); -Assert.equal(copy.pets == data.pets, true); -Assert.equal(copy.pets.type == data.pets.type, true); -Assert.equal(copy.pets.name == data.pets.name, true); +Assert.equal(combine.name, humen.name); +Assert.equal(combine.age, humen.age); +Assert.equal(combine.job, job.job); +Assert.equal(combine.location, data.location); +Assert.equal(combine.pets.name, data.pets.name); +Assert.equal(combine.pets.type, data.pets.type); +Assert.equal(combine.name == humen.name, true); +Assert.equal(combine.age == humen.age, true); +Assert.equal(combine.job == job.job, true); +Assert.equal(combine.location == data.location, true); +Assert.equal(combine.pets == data.pets, true); +Assert.equal(combine.pets.type == data.pets.type, true); +Assert.equal(combine.pets.name == data.pets.name, true); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_2.ts index 0e3ed3045c..5b1976e764 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_2.ts @@ -29,10 +29,10 @@ let humen = { age: 20, }; -let copy = { ...humen, name: "huahua", job: "teacher" }; +let combine = { ...humen, name: "huahua", job: "teacher" }; -Assert.equal(copy.age, humen.age); -Assert.equal(copy.age == humen.age, true); -Assert.equal(copy.name != humen.name, true); +Assert.equal(combine.age, humen.age); +Assert.equal(combine.age == humen.age, true); +Assert.equal(combine.name != humen.name, true); -Assert.equal(copy.job != undefined, true); +Assert.equal(combine.job != undefined, true); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_3.ts index 2c1b6c21d0..83fadffad5 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_3.ts @@ -29,9 +29,9 @@ let humen = { age: 20, }; -let copy = { ...humen, name: "huahua", job: "teacher" }; +let combine = { ...humen, name: "huahua", job: "teacher" }; -let { job, ...restProperties } = copy; -Assert.equal(job, copy.job); -Assert.equal(restProperties.age, copy.age); -Assert.equal(restProperties.name, copy.name); +let { job, ...restProperties } = combine; +Assert.equal(job, combine.job); +Assert.equal(restProperties.age, combine.age); +Assert.equal(restProperties.name, combine.name); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/use_returned_values_from_super_call_as_this/use_returned_values_from_super_call_as_this_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/use_returned_values_from_super_call_as_this/use_returned_values_from_super_call_as_this_1.ts index 6f43f2be59..1cbabba767 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/use_returned_values_from_super_call_as_this/use_returned_values_from_super_call_as_this_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/use_returned_values_from_super_call_as_this/use_returned_values_from_super_call_as_this_1.ts @@ -24,11 +24,11 @@ import { Assert } from '../../../suite/assert.js' class Test { - x: number; - constructor(x: number) { - this.x = x; + one: number; + constructor(one: number) { + this.one = one; return { - x: 1, + one: 1, }; } } @@ -37,6 +37,6 @@ class Test_sub extends Test { super(x); } } -let cc = new Test_sub(12); -Assert.equal(cc.x, 1); -Assert.notEqual(cc.x, 12); +let newC = new Test_sub(12); +Assert.equal(newC.one, 1); +Assert.notEqual(newC.one, 12); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type_1.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type_2.ts new file mode 100644 index 0000000000..63fe0025e2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type_2.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + typeScript did not have a type that represents the non-primitive type, i.e. any thing that is not number, string, + boolean, symbol, null, or undefined. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +let obj2 = { num: 1 }; +let obj3 = { str: "OBJ" }; +let obj4 = { num: 1 }; +Assert.equal(typeof obj2, 'object'); +Assert.equal(typeof obj3, 'object'); +Assert.isTrue(typeof obj2 === typeof obj3); +Assert.isFalse(obj2 === obj4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_mix_in_classes/support_for_mix_in_classes_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_mix_in_classes/support_for_mix_in_classes_1.ts index b8c15597b7..a1a2eea523 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_mix_in_classes/support_for_mix_in_classes_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_mix_in_classes/support_for_mix_in_classes_1.ts @@ -32,14 +32,14 @@ class PointXY { this.y = y; } toString() { - return `(${this.x}, ${this.y})`; + return '(' + this.x + ', ' + this.y + ')'; } } -type MIXType = new (...args: any[]) => T; -function mixC>(Base: T) { - return class extends Base { - constructor(...args: any[]) { - super(...args); +type MIXType = new (...members: any[]) => T; +function mixC>(BC: T) { + return class extends BC { + constructor(...members: any[]) { + super(...members); } public pname: string = ""; setPname(pname: string) { diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_mix_in_classes/support_for_mix_in_classes_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_mix_in_classes/support_for_mix_in_classes_2.ts index f0a4830425..3a83122940 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_mix_in_classes/support_for_mix_in_classes_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_mix_in_classes/support_for_mix_in_classes_2.ts @@ -32,12 +32,12 @@ class Color { this.Blue = blue; } toString() { - return `Color(${this.Red}, ${this.Green}, ${this.Blue})`; + return 'Color(' + this.Red + ', ' + this.Green + ', ' + this.Blue + ')'; } } -type MIXTypeCopy = new (...args: any[]) => T; -function ColorClassMix>(Base: T) { - return class extends Base { +type MIXTypeCopy = new (...members: any[]) => T; +function ColorClassMix>(BC: T) { + return class extends BC { getColors(): [number, number, number] { return [this.Red, this.Green, this.Blue]; } diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/1_dynamic_import_expressions/1_dynamic_import_expressions.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/1_dynamic_import_expressions/1_dynamic_import_expressions.ts index 74feec7a4b..fd34d118ee 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/1_dynamic_import_expressions/1_dynamic_import_expressions.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/1_dynamic_import_expressions/1_dynamic_import_expressions.ts @@ -20,12 +20,12 @@ isCurrent: true import { Assert } from '../../../suite/assert.js' -async function getSumAsyn(x: number, y: number): Promise { +async function func(x: number, y: number): Promise { const add = await import("./lib.js"); const sum = add.add(x, y); return sum; } -getSumAsyn(10, 20).then((sum) => { +func(10, 20).then((sum) => { Assert.equal(30, sum); }); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/2_string_enums/string_enums_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/2_string_enums/string_enums_1.ts index 25f9be8420..c4b851149f 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/2_string_enums/string_enums_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/2_string_enums/string_enums_1.ts @@ -23,8 +23,10 @@ import { Assert } from '../../../suite/assert.js' enum Option { END = "End", - START = "Start", - STOP = "BLUE" + START = "START", + STOP = "STOP" }; -Assert.equal(Option.END, "End"); \ No newline at end of file +Assert.equal(Option.END, "End"); +Assert.equal(Option.START, "START"); +Assert.equal(Option.STOP, "STOP"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts index d59d0e39ba..a21ebea758 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts @@ -31,18 +31,18 @@ Assert.equal(2, len(["s", "ss", "sss"])[1]); Assert.equal(3, len(["s", "ss", "sss"])[2]); -type A = (x: T, y: U) => [T, U]; -type B = (x: S, y: S) => [S, S]; +type T1 = (x: T, y: U) => [T, U]; +type T2 = (x: S, y: S) => [S, S]; -function f(a: A, b: B) { +function f(a: T1, b: T2) { b = a; Assert.isTrue(b == a); } -let a: A = function funA(x: T, y: U): [T, U] { +let a: T1 = function funA(x: T, y: U): [T, U] { return [x, y]; } -let b: B = function funB(x: S, y: S): [S, S] { +let b: T2 = function funB(x: S, y: S): [S, S] { return [x, x]; } f(a, b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/4_strict_contravariance_for_callback_parameters/4_strict_contravariance_for_callback_parameters.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/4_strict_contravariance_for_callback_parameters/4_strict_contravariance_for_callback_parameters.ts index dc2b02c130..2fd1f237b2 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/4_strict_contravariance_for_callback_parameters/4_strict_contravariance_for_callback_parameters.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/4_strict_contravariance_for_callback_parameters/4_strict_contravariance_for_callback_parameters.ts @@ -21,21 +21,27 @@ import { Assert } from '../../../suite/assert.js' -interface TestI { - add_10(t: T): T; +interface I { + add(t: T): T; } - -class CA implements TestI { - add_10(n: number) { +class C implements I { + add(n: number) { return n += 10; } } -let a: TestI; -let b: TestI; - -a = new CA(); +let a: I; +let b: I; +a = new C(); b = a; +Assert.equal(20, b.add(10)); + +function func(arg: T): T{ + return arg; +} +let f1 = func(5); +let f2 = func('a'); -Assert.equal(20, b.add_10(10)); \ No newline at end of file +f2 = f1; +Assert.equal(f1, f2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/5_weak_type_detection/5_weak_type_detection.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/5_weak_type_detection/5_weak_type_detection.ts index 1d8aa346e4..3b27b4915e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/5_weak_type_detection/5_weak_type_detection.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/5_weak_type_detection/5_weak_type_detection.ts @@ -21,39 +21,33 @@ import { Assert } from '../../../suite/assert.js' -interface Options { - data?: string; +interface I { + month?: string; type?: number; value?: number; } -function check(options: Options) { - if (options !== undefined && options !== null) { +function check(i: I) { + if (i !== undefined && i !== null) { return true; } else { return false; } } -const opts1 = { - str: "hello world!", - retryOnFail: true +const obj1 = { + month: "January" }; +Assert.isTrue(check(obj1)); -const opts2 = { - data: "hello world!" -}; -Assert.isTrue(check(opts2)); - - -const opts3: { - [index: string]: { data: string }; +const obj2: { + [index: string]: { mem: string }; } = {}; -Assert.isTrue(check(opts3)); +Assert.isTrue(check(obj2)); -const opts4 = { - payload: "hello world!", - retryOnFail: true -} as Options; -Assert.isTrue(check(opts4)); +const obj3 = { + str: "string", + trueOrFalse: true +} as I; +Assert.isTrue(check(obj3)); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.5/1_optional_catch_clause_variables.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.5/1_optional_catch_clause_variables.ts index 126baff724..587a946674 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.5/1_optional_catch_clause_variables.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.5/1_optional_catch_clause_variables.ts @@ -21,12 +21,12 @@ import { Assert } from '../../suite/assert.js' -function func(arg: string) { +function func(str: string) { try { - JSON.parse(arg); + return JSON.parse(str); } catch { - Assert.equal(arg, "string"); + return str + " is Error JSON"; } } let str: string = 'string'; -func(str); \ No newline at end of file +Assert.equal(func(str), 'string is Error JSON'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/1_constant_named_properties/1_constant_named_properties.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/1_constant_named_properties/1_constant_named_properties.ts index 533af9dadd..417bd39528 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/1_constant_named_properties/1_constant_named_properties.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/1_constant_named_properties/1_constant_named_properties.ts @@ -30,10 +30,9 @@ class C implements I{ return func; } } -var f = new C(); +let f = new C(); Assert.isFunction(f[sym]); -// This also applies to numeric and string literals. const num = 5; const str = 'a'; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/2_unique_symbol/2_unique_symbol.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/2_unique_symbol/2_unique_symbol.ts index f5f3f96b36..cf3251ec6c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/2_unique_symbol/2_unique_symbol.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/2_unique_symbol/2_unique_symbol.ts @@ -23,8 +23,7 @@ import { Assert } from '../../../suite/assert.js' const usym1: unique symbol = Symbol(); const usym2: unique symbol = Symbol.for("Bar"); - -// in order to reference a specific unique symbol, you’ll have to use the typeof operator. + let t1: typeof usym1 = usym1; let t2: typeof usym2 = usym2; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/4_definite_assignment_assertions/4_definite_assignment_assertions.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/4_definite_assignment_assertions/4_definite_assignment_assertions.ts index 67f4f82ff5..20eb817087 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/4_definite_assignment_assertions/4_definite_assignment_assertions.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/4_definite_assignment_assertions/4_definite_assignment_assertions.ts @@ -32,7 +32,6 @@ let x: number; let add = x! + x!; Assert.isTrue(Number.isNaN(add)); -// The definite assignment assertion operator is the dual of the non-null assertion operator let num1: number; later1(); let sum1 = num1! + num1!; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/6_improved_type_inference_for_object_literals/6_improved_type_inference_for_object_literals.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/6_improved_type_inference_for_object_literals/6_improved_type_inference_for_object_literals.ts index 9f53e3b046..e4531e8768 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/6_improved_type_inference_for_object_literals/6_improved_type_inference_for_object_literals.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/6_improved_type_inference_for_object_literals/6_improved_type_inference_for_object_literals.ts @@ -22,14 +22,13 @@ import { Assert } from '../../../suite/assert.js' let obj1 = [{ a: 1, b: 2 }, { a: "abc" }, {}][0]; -// The type of a is number|string|undefined obj1.a = 5; Assert.isNumber(obj1.a); obj1.a = 'a'; Assert.isString(obj1.a); obj1.a = undefined; Assert.isUndefined(obj1.a); -// The type of b is number|undefined + obj1.b = 6; Assert.isNumber(obj1.b); obj1.b = undefined; @@ -40,14 +39,13 @@ function fun(...args: T[]): T { }; let obj2 = fun({ a: 1, b: 2 }, { a: "abc", b: "ABC" }, {}); -// The type of a is number|string|undefined obj2.a = 5; Assert.isNumber(obj2.a); obj2.a = 'a'; Assert.isString(obj2.a); obj2.a = undefined; Assert.isUndefined(obj2.a); -// The type of a is number|string|undefined + obj2.b = 6; Assert.isNumber(obj2.b); obj2.b = 'b'; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/Improved_keyof_with_intersection_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/Improved_keyof_with_intersection_types_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/2.8/Improved_keyof_with_intersection_types.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.8/Improved_keyof_with_intersection_types_1.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/improved_control_over_mapped_type_modifiers.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/Improved_keyof_with_intersection_types_2.ts similarity index 80% rename from es2panda/test/ts_extra_tests/test_ts_cases/2.8/improved_control_over_mapped_type_modifiers.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.8/Improved_keyof_with_intersection_types_2.ts index 29c8a0499f..77c1f130f2 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/improved_control_over_mapped_type_modifiers.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/Improved_keyof_with_intersection_types_2.ts @@ -25,32 +25,31 @@ import { Assert } from '../../suite/assert.js' { type myType1 = 'a' | 4; type myType2 = { str: string }; - interface I{ + interface I { mem: string; } - type T1 = keyof (myType1 & myType2); - type T2 = keyof (T & myType2); - type T3 = keyof (myType1 & U); - type T4 = keyof (T & U); - type T5 = T2; - type T6 = T3; - type T7 = T4; + type TA = keyof (myType1 & myType2); + type TB = keyof (T & myType2); + type TC = keyof (myType1 & U); + type TD = keyof (T & U); + type TE = TB; + type TF = TC; + type TG = TD; - // The type of a,b,c,d is "toString" | "valueOf" | "str" - let a: T1 = 'str'; + let a: TA = 'str'; a = 'toString'; a = 'valueOf'; Assert.equal(a, 'valueOf'); - let b: T5 = "str"; + let b: TE = "str"; b = 'toString'; b = 'valueOf'; Assert.equal(b, 'valueOf'); - let c: T6 = "str"; + let c: TF = "str"; c = 'toString'; c = 'valueOf'; Assert.equal(c, 'valueOf'); - let d: T7 = "str"; + let d: TG = "str"; d = 'toString'; d = 'valueOf'; Assert.equal(d, 'valueOf'); @@ -66,7 +65,7 @@ import { Assert } from '../../suite/assert.js' let aa: T11 = 'mem'; aa = 'str'; Assert.equal(aa, 'str'); - let bb: T55 = 'mem'; + let bb: T55 = 'mem'; bb = 'str'; Assert.equal(bb, 'str'); let cc: T66 = 'mem'; @@ -75,5 +74,5 @@ import { Assert } from '../../suite/assert.js' let dd: T77 = 'mem'; dd = 'str'; Assert.equal(dd, 'str'); - + }; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/distributive_conditional_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/distributive_conditional_types.ts index 85ecfbd659..d0b067b48f 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/distributive_conditional_types.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/distributive_conditional_types.ts @@ -23,37 +23,36 @@ isCurrent: true import { Assert } from "../../suite/assert.js" type TypeGather = T extends string ? string : - T extends number ? number : - T extends boolean ? boolean : - T extends undefined ? undefined : - T extends Function ? Function : - object; + T extends number ? number : + T extends boolean ? boolean : + T extends undefined ? undefined : + T extends Function ? Function : + object; -type T0 = TypeGather void)>; -type T2 = TypeGather; -type T1 = TypeGather; +type TSF = TypeGather void)>; +type TSSA = TypeGather; +type TSANA = TypeGather; type GatherValue = { value: T }; type GatherArray = { array: T[] }; type Gather = T extends any[] ? GatherArray : GatherValue; -type T20 = Gather; -type T21 = Gather; -type T22 = Gather; +type TGS = Gather; +type TGNA = Gather; +type TGSNA = Gather; -let a: T0 = 's'; -let b: T0 = (() => { -}); -let c: T2 = 's'; -let d: T2 = ['s']; -let e: T2 = undefined; -let f: T1 = ['s']; -let g: T1 = [1]; -let h: T20 = { value: "s" }; -let i: T21 = { array: [1] }; -let j: T22 = { value: "s" }; -let k: T22 = { array: [1] }; +let a: TSF = 's'; +let b: TSF = (() => { }); +let c: TSSA = 's'; +let d: TSSA = ['s']; +let e: TSSA = undefined; +let f: TSANA = ['s']; +let g: TSANA = [1]; +let h: TGS = { value: "s" }; +let i: TGNA = { array: [1] }; +let j: TGSNA = { value: "s" }; +let k: TGSNA = { array: [1] }; Assert.equal(typeof a, 'string'); Assert.equal(typeof b, 'function'); @@ -66,6 +65,3 @@ Assert.equal(typeof h, 'object'); Assert.equal(typeof i, 'object'); Assert.equal(typeof j, 'object'); Assert.equal(typeof k, 'object'); - - - diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/improved_control_over_mapped_type_modifiers_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/improved_control_over_mapped_type_modifiers_1.ts new file mode 100644 index 0000000000..bf24b3e123 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/improved_control_over_mapped_type_modifiers_1.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript 2.8 adds the ability for a mapped type to either add or remove a particular modifier. + Specifically, a readonly or ? property modifier in a mapped type can now be prefixed with either + or - to indicate that the modifier should be added or removed. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../suite/assert.js"; + +type RU = { +readonly [key in "A" | "B" | "C"]-?: number }; +type NR = { -readonly [key in 1 | 2 | 3]+?: string }; + +let ru: RU = { 'A': 1, 'B': 2, 'C': 3 }; +let nr: NR = { 1: 'A', 3: 'C' }; +nr[1] = 'Z'; +Assert.equal(JSON.stringify(ru), '{"A":1,"B":2,"C":3}'); +Assert.equal(JSON.stringify(nr), '{"1":"Z","3":"C"}'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/improved_control_over_mapped_type_modifiers_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/improved_control_over_mapped_type_modifiers_2.ts new file mode 100644 index 0000000000..3813580fec --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/improved_control_over_mapped_type_modifiers_2.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Using this ability, lib.d.ts now has a new Required type. + This type strips ? modifiers from all properties of T, thus making all properties required. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../suite/assert.js"; + +type ABCU = { 'A'?: number, 'B'?: number, 'C'?: number, 'D'?: number }; +type ABC = Required; + +let abcu: ABCU = { 'C': 3 }; +let abc: ABC = { A: 1, B: 2, C: 3, D: 4 }; +Assert.equal(JSON.stringify(abcu), '{"C":3}'); +Assert.equal(JSON.stringify(abc), '{"A":1,"B":2,"C":3,"D":4}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/type_inference.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/type_inference.ts index 001e1052ff..acbaa22bfe 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/type_inference.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/type_inference.ts @@ -29,22 +29,17 @@ import { Assert } from '../../suite/assert.js' T extends Promise ? U : T; - // string - type Type0 = Type00; - // string - type Type1 = Type00; - // string - type Type2 = Type00<() => string>; - // string - type Type3 = Type00>; - // string - type Type4 = Type00[]>>; - - let a: Type0 = 's'; - let b: Type1 = 's'; - let c: Type2 = 's'; - let d: Type3 = 's'; - let e: Type4 = 's'; + type TS = Type00; + type TSA = Type00; + type TF = Type00<() => string>; + type TPS = Type00>; + type TTPS = Type00[]>>; + + let a: TS = 's'; + let b: TSA = 's'; + let c: TF = 's'; + let d: TPS = 's'; + let e: TTPS = 's'; Assert.equal(typeof a, 'string'); Assert.equal(typeof b, 'string'); @@ -53,14 +48,12 @@ import { Assert } from '../../suite/assert.js' Assert.equal(typeof e, 'string'); type F = T extends { a: infer U, b: infer U } ? U : never; - // string - type Type5 = F<{ a: string, b: string }>; - // string | number - type Type6 = F<{ a: string, b: number }>; + type TF1 = F<{ a: string, b: string }>; + type TF2 = F<{ a: string, b: number }>; - let f: Type5 = 's'; - let g: Type6 = 's'; - let h: Type6 = 1; + let f: TF1 = 's'; + let g: TF2 = 's'; + let h: TF2 = 1; Assert.equal(typeof f, 'string'); Assert.equal(typeof g, 'string'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/3_generic_type_arguments_in_tt.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/generic_type_arguments_in_tt/generic_type_arguments_in_tt.ts similarity index 62% rename from es2panda/test/ts_extra_tests/test_ts_cases/2.9/3_generic_type_arguments_in_tt.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.9/generic_type_arguments_in_tt/generic_type_arguments_in_tt.ts index ae8784c1cc..e635600b33 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/3_generic_type_arguments_in_tt.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/generic_type_arguments_in_tt/generic_type_arguments_in_tt.ts @@ -19,27 +19,21 @@ ---*/ -import { Assert } from '../../suite/assert.js' +import { Assert } from '../../../suite/assert.js' -let jianbing = '煎饼' - -function kitchen(strings: TemplateStringsArray, value: string) { - Assert.equal(2, strings.length); +let jianbing = "jianbing" +function kitchen(xx: TemplateStringsArray, value: string) { + Assert.equal(2, xx.length); } - -let zaocan = kitchen`今天的早餐是${jianbing}!`; - - - -function tag(strs: TemplateStringsArray, args: T): T { - Assert.equal(2, strs.length); +kitchen`lunch_is${jianbing}!`; +function f(yy: TemplateStringsArray, args: T): T { + Assert.equal(2, yy.length); return args; }; - - -let a = tag `今天的午餐是${jianbing}!`; -Assert.equal("煎饼", a); - -let b = tag `今天的午餐是${"dessert"}!`; - +let a = f `lunch_is${jianbing}!`; +Assert.equal("jianbing", a); +let b = f `lunch_is${"dessert"}!`; +Assert.equal("dessert", b); Assert.equal("dessert", b); +let c = f`sss${2}`; +Assert.equal(2, c); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/4_import_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/import_types/import_types.ts similarity index 78% rename from es2panda/test/ts_extra_tests/test_ts_cases/2.9/4_import_types.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.9/import_types/import_types.ts index a07ebe3760..7306d9cd8d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/4_import_types.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/import_types/import_types.ts @@ -21,23 +21,21 @@ ---*/ -import { Assert } from '../../suite/assert.js' +import { Assert } from '../../../suite/assert.js' -function func1(i: import("./module").I) { +function func1(i: import("../module").I) { Assert.equal(5, `${i.num}`); Assert.equal(5, i.num); } -let i: import("./module.js").I = { +let i: import("../module.js").I = { num: 5 } func1(i); - -function func(p: import("./module").C) { - Assert.equal('puppy', `${p.str}`); - Assert.equal('puppy', p.str); +function func(p: import("../module").C) { + Assert.equal('aa', `${p.str}`); + Assert.equal('aa', p.str); } - -let p: import("./module.js").C = { - str: "puppy", +let p: import("../module.js").C = { + str: "aa", }; func(p); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts similarity index 64% rename from es2panda/test/ts_extra_tests/test_ts_cases/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts index 940a470d1d..3f38cafb22 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts @@ -21,36 +21,26 @@ import { Assert } from '../../../suite/assert.js' -const str = "c"; -const num = 10; +const str = "x"; +const num = 1; const sym = Symbol(); - -const enum ABC { A, B, C } -const enum ABCStr { A = "A", B = "B", C = "C" } - - +const enum NUM { ONE, TWO, THREE } +const enum XYZStr { X = "X", Y = "Y", Z = "Z" } type TypeObj = { - a: string; - 5: string; - + y: string; + 2: string; [str]: string; [num]: string; [sym]: string; - - [ABC.A]: string; - [ABCStr.A]: string; + [NUM.ONE]: string; + [XYZStr.X]: string; } - - -type KEY1 = keyof TypeObj; -type KEY2 = Extract; -type KEY3 = Extract; -type KEY4 = Extract; - - -let key1: KEY1 = 'c'; -let key2: KEY2 = ABCStr.A; -let key3: KEY3 = 10; -Assert.equal("c", key1); -Assert.equal(ABCStr.A, key2); -Assert.equal(10, key3); \ No newline at end of file +type X1 = keyof TypeObj; +type X2 = Extract; +type X3 = Extract; +let x1: X1 = "x"; +let x2: X2 = XYZStr.X; +let x3: X3 = 1; +Assert.equal("x", x1); +Assert.equal(XYZStr.X, x2); +Assert.equal(1, x3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts similarity index 86% rename from es2panda/test/ts_extra_tests/test_ts_cases/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts index 1d422f73fe..ad50c7756e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts @@ -21,21 +21,17 @@ import { Assert } from '../../../suite/assert.js' -type ArrayAny = { - length: number; - [x: number]: T; +type TYPE1 = { + a: number; + [b: number]: T; } - -type RAA = Readonly>; - -let arr: RAA = { +type TYPE2 = Readonly>; +let arr: TYPE2 = { [1]: "b", [2]: "a", - length: 2, + a: 2, }; - - -let len = arr.length; +let len = arr.a; let x = arr[1]; Assert.equal(2, len); Assert.equal("b", x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_3.ts similarity index 65% rename from es2panda/test/ts_extra_tests/test_ts_cases/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_3.ts index 144fa4fa88..3f5efb00e2 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/1_support_number_and_symbol_nam/1_support_number_and_symbol_nam_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_3.ts @@ -21,61 +21,47 @@ import { Assert } from '../../../suite/assert.js' -const enum Enum { - A, - B, - C, +const enum E1 { + ONE, + TWO, + THREE, } - const ets = { - [Enum.A]: "Name A", - [Enum.B]: "Name B", - [Enum.C]: "Name C", + [E1.ONE]: "ONE", + [E1.TWO]: "TWO", + [E1.THREE]: "THREE", }; - -const sym1 = Symbol(); -const sym2 = Symbol(); -const sym3 = Symbol(); - +const x = Symbol(); +const y = Symbol(); +const z = Symbol(); const etn = { - [sym1]: 1, - [sym2]: 2, - [sym3]: 3, + [x]: 1, + [y]: 2, + [z]: 3, }; - -type KE = keyof typeof ets; -type KS = keyof typeof etn; - function getValue(obj: T, key: K): T[K] { return obj[key]; } - -let x1 = getValue(ets, Enum.C); -let x2 = getValue(etn, sym3); -Assert.equal("Name C", x1); +let x1 = getValue(ets, E1.THREE); +let x2 = getValue(etn, z); +Assert.equal("THREE", x1); Assert.equal(3, x2); - - - -function useKey1>(o: T, k: K) { - var name: string = k; - return name; +function fun1>(o: T, k: K) { + let m: string = k; + return m; } - const stringMap = { a: "mystring" }; -let x3 = useKey1(stringMap, "a"); +let x3 = fun1(stringMap, "a"); Assert.equal("a", x3); - - -function useKey2(o: T, k: K) { - var name: string | number | symbol = k; - return name; +function fun2(o: T, k: K) { + let m: string | number | symbol = k; + return m; } const uniteMap = { a: "mystring", b: 1 }; -let x4 = useKey2(uniteMap, "b"); +let x4 = fun2(uniteMap, "b"); Assert.equal("b", x4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/new_unknown_top_type/new_unknown_top_type.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/new_unknown_top_type/new_unknown_top_type.ts index 89366a764d..d13540ea67 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/new_unknown_top_type/new_unknown_top_type.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/new_unknown_top_type/new_unknown_top_type.ts @@ -30,7 +30,6 @@ Assert.isUndefined(t1); type T2 = unknown & string; let t2: T2 = 'a'; Assert.isString(t2); - type T3 = unknown | undefined; let t3: T3 = undefined; Assert.isUndefined(t3); @@ -41,7 +40,6 @@ Assert.isUndefined(t4); type T5 = unknown | string; let t5: T5 = 'a'; Assert.isString(t5); - type T6 = T & {}; let t6: T6 = { arg: 'arg' }; Assert.isObject(t6); @@ -55,7 +53,6 @@ Assert.isNumber(t8); type T9 = T | unknown; let t9: T9 = 10; Assert.isNumber(t9); - type T10 = unknown extends T ? true : false; let t10: T10 = false; Assert.isFalse(t10); @@ -68,18 +65,15 @@ Assert.isTrue(t12); type T13 = T extends never ? true : false; let t13: T13 = false; Assert.isFalse(t13); - function func1(x: unknown): unknown { x = 10; return x; } Assert.equal(func1(0), 10); - function func2(x: unknown) { return typeof x; } Assert.equal(func2("N"), "string"); - function func3(x: unknown) { if (x instanceof Error) { return 0; @@ -88,7 +82,6 @@ function func3(x: unknown) { } let e: Error = Error(); Assert.isNumber(func3(e)); - type T14 = { [P in keyof T]: number }; type T15 = T14; type T16 = T14; @@ -96,7 +89,6 @@ let t15: T15 = {}; Assert.isObject(t15); let t16: T16 = {}; Assert.isObject(t16); - function func4(pAny: any, pundefined: undefined, pT: T) { let x: unknown; x = 123; @@ -111,12 +103,15 @@ function func4(pAny: any, pundefined: undefined, pT: T) { x = pT; } func4(1024, undefined, "A"); - function fun5(x: unknown) { let v: unknown = x; - return v; + return v; } Assert.equal(fun5(1024), 1024); - -let x: number = 1024; -(x as unknown as string).length; +function fun6() { + let a: unknown; + let b = a; + b = 2; + return b; +} +Assert.equal(fun6(), 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/reference_lib/reference_lib.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/reference_lib/reference_lib.ts index 906ce35a04..8f4d332536 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/reference_lib/reference_lib.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/reference_lib/reference_lib.ts @@ -23,4 +23,4 @@ import { Assert } from "../../../suite/assert.js"; let sym: symbol = Symbol("es2015"); -Assert.isSymbol(sym); +Assert.isSymbol(sym); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/generic_rest_parameters/generic_rest_parameters.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/generic_rest_parameters/generic_rest_parameters.ts index 57f4e4e1c9..f64b88960f 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/generic_rest_parameters/generic_rest_parameters.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/generic_rest_parameters/generic_rest_parameters.ts @@ -22,23 +22,23 @@ import { Assert } from '../../../../suite/assert.js' -function hwfun01(f: (x: T, ...args: U) => V): (...args: U) => V { - function frm(...args: U) { let json = JSON.stringify(args); return json as unknown as V; } - return frm; +function fun1(f: (x: T, ...args: U) => V): (...args: U) => V { + function f2(...args: U) { let json = JSON.stringify(args); return json as unknown as V; } + return f2; }; -function getArrJson(x: number, y: string, z: boolean): string { +function fun2(x: number, y: string, z: boolean): string { let a: any[] = [x, y, z]; let json = JSON.stringify(a); return json; } -let a = getArrJson(5, "A", true); -let gf1 = hwfun01(getArrJson); -let b = gf1("B", true); -let gf2 = hwfun01(gf1); -let c = gf2(true); -let gf3 = hwfun01(gf2); -let d = gf3(); +let a = fun2(5, "A", true); +let ff1 = fun1(fun2); +let b = ff1("B", true); +let ff2 = fun1(ff1); +let c = ff2(true); +let ff3 = fun1(ff2); +let d = ff3(); Assert.equal(a, "[5,\"A\",true]"); Assert.equal(b, "[\"B\",true]"); Assert.equal(c, "[true]"); -Assert.equal(d, "[]"); +Assert.equal(d, "[]"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts index 217ce6100f..7dd6d242cc 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts @@ -24,13 +24,16 @@ import { Assert } from '../../../../suite/assert.js' -let test: [number, string?, boolean?]; -test = [1024, "hello", true]; -Assert.equal(JSON.stringify(test), "[1024,\"hello\",true]"); -Assert.equal(test.length, 3); -test = [1408, "N"]; -Assert.equal(JSON.stringify(test), "[1408,\"N\"]"); -Assert.equal(test.length, 2); -test = [0]; -Assert.equal(JSON.stringify(test), "[0]"); -Assert.equal(test.length, 1); \ No newline at end of file +let opt: [number, string?, boolean?, number[]?]; +opt = [1024, "str", true, [1, 2]]; +Assert.equal(JSON.stringify(opt), "[1024,\"str\",true,[1,2]]"); +Assert.equal(opt.length, 4); +opt = [1024, "str", true]; +Assert.equal(JSON.stringify(opt), "[1024,\"str\",true]"); +Assert.equal(opt.length, 3); +opt = [1408, "N"]; +Assert.equal(JSON.stringify(opt), "[1408,\"N\"]"); +Assert.equal(opt.length, 2); +opt = [0]; +Assert.equal(JSON.stringify(opt), "[0]"); +Assert.equal(opt.length, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_elements_in_tuple_types/rest_elements_in_tuple_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_elements_in_tuple_types/rest_elements_in_tuple_types.ts index e5f29f6cd7..447825ad5a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_elements_in_tuple_types/rest_elements_in_tuple_types.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_elements_in_tuple_types/rest_elements_in_tuple_types.ts @@ -23,19 +23,19 @@ import { Assert } from '../../../../suite/assert.js' -function test(...args: T): T { +function fun1(...args: T): T { return args; } -function getArrayOfNumbers0_10() { +function fun2() { let arr: number[] = []; for (let i = 0; i <= 10; i++) { arr.push(i); } return arr; } -const numbers: number[] = getArrayOfNumbers0_10(); -const t1 = test("AAA", 1, true); -const t2 = test("BBB", ...numbers); +const numbers: number[] = fun2(); +const t1 = fun1("AAA", 1, true); +const t2 = fun1("BBB", ...numbers); const t3 = ["A", true, ...numbers, false]; Assert.equal(JSON.stringify(t1), "[\"AAA\",1,true]"); Assert.equal(JSON.stringify(t2), "[\"BBB\",0,1,2,3,4,5,6,7,8,9,10]"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/spread_expressions_with_tuple_types/spread_expressions_with_tuple_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/spread_expressions_with_tuple_types/spread_expressions_with_tuple_types.ts index 8e0d0559dd..532a39263a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/spread_expressions_with_tuple_types/spread_expressions_with_tuple_types.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/spread_expressions_with_tuple_types/spread_expressions_with_tuple_types.ts @@ -22,13 +22,13 @@ import { Assert } from '../../../../suite/assert.js' -function sfun(...v: [number, string, boolean]) { +function fun1(...v: [number, string, boolean]) { return { number: v[0], string: v[1], boolean: v[2] }; } -const args: [number, string, boolean] = [42, "hello", true]; -var v1 = sfun(...args); -var v2 = sfun(args[0], args[1], args[2]); -var v3 = sfun(42, "hello", true); +const args: [number, string, boolean] = [11, "str", true]; +var v1 = fun1(...args); +var v2 = fun1(args[0], args[1], args[2]); +var v3 = fun1(11, "str", true); var jv1 = JSON.stringify(v1); var jv2 = JSON.stringify(v2); var jv3 = JSON.stringify(v3); @@ -36,4 +36,4 @@ var flag = false; if (jv1 === jv2 && jv2 === jv3 && jv3 === jv1) { flag = true; } -Assert.isTrue(flag); +Assert.isTrue(flag); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.1/mapped_types_on_tuples_and_arrays/mapped_types_on_tuples_and_arrays_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.1/mapped_types_on_tuples_and_arrays/mapped_types_on_tuples_and_arrays_1.ts index a43204ead9..a18fba4537 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.1/mapped_types_on_tuples_and_arrays/mapped_types_on_tuples_and_arrays_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.1/mapped_types_on_tuples_and_arrays/mapped_types_on_tuples_and_arrays_1.ts @@ -23,11 +23,11 @@ import { Assert } from '../../../suite/assert.js' -type Test = { +type Type = { [k in keyof T]: Array; }; -type tupleTest = [number, string, boolean]; -type tt = Test; +type tuple = [number, string, boolean]; +type tt = Type; let cc: tt = [ [0, 1, 2, 3], ["a", "b", "c", "d"], @@ -39,7 +39,7 @@ cc.push([1, 2, 3]); cc.push([false, false]); cc.push(["hello", "world"]); Assert.equal(cc.length, 6); -// pop + let vv: any = cc.pop(); Assert.equal(vv[0], "hello"); Assert.equal(vv[1], "world"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_object_rest_variables_and_parameters/generic_object_rest_variables_and_parameters.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_object_rest_variables_and_parameters/generic_object_rest_variables_and_parameters.ts index 5c704caaf3..78a4d19001 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_object_rest_variables_and_parameters/generic_object_rest_variables_and_parameters.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_object_rest_variables_and_parameters/generic_object_rest_variables_and_parameters.ts @@ -24,12 +24,21 @@ import { Assert } from "../../../suite/assert.js" -function hwfun(obj: T) { - let { tag, ...rest } = obj; - return rest; +function func1(arg: T) { + let { ...restPara } = arg; + return restPara; } +const obj1 = { x: 10, y: 'a' }; +const o1 = func1(obj1); +Assert.isObject(o1); +Assert.equal(JSON.stringify(o1), '{"x":10,"y":"a"}'); -const point = { x: 10, y: 20, tag: "point" }; -const p = hwfun(point); +function func2(obj: T) { + let { str, ...rest } = obj; + return rest; +} -Assert.equal(JSON.stringify(p), '{"x":10,"y":20}'); +const obj2 = { x: 10, y: 20, str: "string" }; +const o2 = func2(obj2); +Assert.isObject(o2); +Assert.equal(JSON.stringify(o2), '{"x":10,"y":20}'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_1.ts index 924a5b135f..cff47c0606 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_1.ts @@ -23,11 +23,11 @@ import { Assert } from "../../../suite/assert.js" -function func(arg: T) { - return { ...arg }; +function func(arg: T, other: U) { + return { ...arg, other }; } let f1 = { num: 5, str: 'a' }; let f2 = { num: 8, str: 'b', boo: true }; -Assert.isObject(func(f1)); -Assert.isObject(func(f2)); \ No newline at end of file +Assert.isObject(func(f1, 'a')); +Assert.isObject(func(f2, 'b')); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts index 3dc60a6482..ede86b4ea5 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts @@ -26,7 +26,6 @@ function func(arg1: T, arg2: { str: string }, arg3:{num: number}) { let obj = { n: 5, ...arg2, ...arg1, s: 's', ...arg3 }; return obj; } - let o1 = { str: 'a' }; @@ -34,5 +33,4 @@ let o2 = { num: 10 }; var f = func({ s: "string" }, o1, o2); - Assert.isObject(f); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_3.ts index 05030d9c8d..27fa8ad98b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_3.ts @@ -26,18 +26,19 @@ import { Assert } from "../../../suite/assert.js" -function hwfun3(t: T, u: U) { - return { ...t, ...u }; +function func(arg1: T, arg2: U) { + return { ...arg1, ...arg2 }; } -let x: { a: string; b: number } = { a: "a", b: 1 }; -let y: { b: string; c: boolean } = { b: "b", c: true }; +let x: { mem1: string; mem2: { num: number } } = { mem1: "a", mem2: { num: 10 } }; +let y: { mem1: string; mem2: object } = { mem1: "b", mem2: { str: 'a' } }; let s1 = { ...x, ...y }; -Assert.equal(typeof s1, "object"); -let s2 = hwfun3(x, y); -Assert.equal(typeof s2, "object"); -let b1 = s1.b; -Assert.isString(b1); -let b2 = s2.b; -Assert.isString(b2); +Assert.isObject(s1); +let s2 = func(x, y); +Assert.isObject(s2); +let b1 = s1.mem2; +Assert.isObject(b1); +let b2 = s2.mem2; +b2 = { num: 20 }; +Assert.isObject(b2); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/non-unit_types_as_union_discriminants/non-unit_types_as_union_discriminants.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/non-unit_types_as_union_discriminants/non-unit_types_as_union_discriminants.ts index c8b88b43dc..550e160720 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/non-unit_types_as_union_discriminants/non-unit_types_as_union_discriminants.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/non-unit_types_as_union_discriminants/non-unit_types_as_union_discriminants.ts @@ -23,17 +23,39 @@ import { Assert } from "../../../suite/assert.js" -type R = { error: Error; data: null } | { error: null; data: T }; +interface I{ + mem: { x: Error, y: undefined } | { x: undefined, y: T }; +} +function fun(arg: I) { + if (arg.mem.x) { + throw arg.mem.x; + } + return arg.mem.y; +} + +let i1 = { + mem: { x: undefined, y: undefined, } +}; +let result1 = fun(i1); +Assert.isUndefined(result1); + +let i2 = { + mem: { x: undefined, y: 10 } +}; +let result2 = fun(i2); +Assert.isNumber(result2); + +type R = { e: Error; data: null } | { e: null; data: T }; function func(result: R) { - if (result.error) { - throw result.error; + if (result.e) { + throw result.e; } return result.data; } var a = { - error: null, + e: null, data: null, }; var b = func(a); @@ -44,8 +66,8 @@ if (b == null) { Assert.isTrue(f); var c = { - error: null, + e: null, data: 10, }; var d = func(c); -Assert.equal(d, "10"); +Assert.equal(d, 10); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.3/improved_behavior_for_calling_union_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.3/improved_behavior_for_calling_union_types.ts index 6eff873669..60bbc2c964 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.3/improved_behavior_for_calling_union_types.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.3/improved_behavior_for_calling_union_types.ts @@ -24,15 +24,15 @@ import { Assert } from '../../suite/assert.js' { type DamageType = "XO" | "EXP"; - type Color = "red" | "green" | "blue"; + type ColorType = "red" | "green" | "blue"; type ATK = (atk: DamageType) => number; let s: ATK = (atk: DamageType) => 1; - type ColorConsumer = (color: Color) => string; + type newColorConstructor = (color: ColorType) => string; - let sp: ColorConsumer = (color: Color) => 'good'; + let sp: newColorConstructor = (color: ColorType) => 'good'; Assert.equal(s("XO"), 1) Assert.equal(sp("green"), 'good') diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.4/Caveats.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.4/Caveats.ts new file mode 100644 index 0000000000..6f9ae0fabd --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.4/Caveats.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + One thing to note is that const assertions can only be applied immediately on simple literal expressions. + Another thing to keep in mind is that const contexts don’t immediately convert an expression to be fully immutable. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../suite/assert.js" + +let math = 1/3; +let compare = math<0.5? 1 as const:3 as const; +Assert.isNumber(compare); +Assert.equal(compare,1); + +let list = [9,8,7,6,5]; + +let bar = { + name: "foo", + age:1, + contents: list, +} as const; + +bar.contents.push(21); +Assert.equal(list[5],21); + +bar.contents.pop(); +Assert.equal(list.length,5); +Assert.equal(list[5],undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.4/Type_checking_for_globalThis.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.4/Type_checking_for_globalThis.ts new file mode 100644 index 0000000000..224330f3e1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.4/Type_checking_for_globalThis.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + globalThis provides a standard way for accessing the global scope which can be used across different environments. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../suite/assert.js" + +var nm = 10010; +let gt:any = globalThis +gt.nm = 10086; +Assert.equal(gt.nm,10086); +Assert.equal(typeof gt.nm,"number"); + +var np = "sss"; +let gp:any = globalThis +gp.np = "nanj"; +Assert.equal(gp.np,"nanj"); +Assert.notEqual(typeof gp.np,"number"); +Assert.isString(gp.np); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.5/smarter_union_type_checking.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.5/smarter_union_type_checking.ts index 5444045108..03e60b4220 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.5/smarter_union_type_checking.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.5/smarter_union_type_checking.ts @@ -24,10 +24,10 @@ import { Assert } from '../../suite/assert.js' { - type T = { mem: string } | { mem: number }; + type newTest = { mem: string } | { mem: number }; interface I1{ num: number; - boo: T; + boo: newTest; } interface I2{ num: number; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/better_unicode_support_for_identifiers/better_unicode_support_for_identifiers_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/better_unicode_support_for_identifiers/better_unicode_support_for_identifiers_1.ts index 67e00fb71d..37a080fd4c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/better_unicode_support_for_identifiers/better_unicode_support_for_identifiers_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/better_unicode_support_for_identifiers/better_unicode_support_for_identifiers_1.ts @@ -23,5 +23,5 @@ import { Assert } from '../../../suite/assert.js' -const 𝓱𝓮𝓵𝓵𝓸 = "world"; -Assert.equal(𝓱𝓮𝓵𝓵𝓸, "world"); +const 𝓱𝓮 = "ok"; +Assert.equal(𝓱𝓮, "ok"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/get_and_set_accessors_are_allowed_in_ambient_contexts_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/get_and_set_accessors_are_allowed_in_ambient_contexts_1.ts index eec2489326..f25d224be1 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/get_and_set_accessors_are_allowed_in_ambient_contexts_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/get_and_set_accessors_are_allowed_in_ambient_contexts_1.ts @@ -22,11 +22,11 @@ isCurrent: true import { Assert } from "../../../suite/assert.js" import { C } from "./test.js" -let obj: C = { x: 1 }; +let obj: C = { m: 1 }; -Assert.equal(1, obj.x); +Assert.equal(1, obj.m); -class mC{ +class mC { mem: string; constructor(mem: string) { this.mem = mem; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/test.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/test.ts index 8eb109acba..8c3cbedea9 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/test.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/test.ts @@ -15,7 +15,7 @@ declare class C { - get x(): number; - set x(val: number); + get m(): number; + set m(value: number); } export { C }; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/improved_UX_Around_Promises/improved_UX_Around_Promises.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/improved_UX_Around_Promises/improved_UX_Around_Promises.ts new file mode 100644 index 0000000000..3c7addaed1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/improved_UX_Around_Promises/improved_UX_Around_Promises.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: For example, it’s often very common to forget to .then() or await the contents of a Promise before passing + it to another function. TypeScript’s error messages are now specialized, and inform the user that perhaps they should + consider using the await keyword. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +let s = 1; +let t = 1; +function d1() { + s = 2 +} +let i = 0; +async function d2(this:any):Promise { + s = 3; + return s; +} +async function d3(this:any):Promise { + t = 3; + return t; +} + + + +async function d4() { + d1(); + Assert.equal(s, 2); + d2().then( + () => { + s = 5 + } + ); + Assert.equal(s, 3); + await d3().then( + () => { + t = 5 + } + ); + Assert.equal(t, 5); +} +d4().then(r => {}); + + + diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/more_accurate_array_spread/more_accurate_array_spread_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/more_accurate_array_spread/more_accurate_array_spread_1.ts index d6dd3e1f0c..075f30c799 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/more_accurate_array_spread/more_accurate_array_spread_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/more_accurate_array_spread/more_accurate_array_spread_1.ts @@ -28,3 +28,6 @@ Assert.equal("name" in t3, true); Assert.equal("age" in t3, true); Assert.equal("skills" in t3, true); Assert.equal("isJob" in t3, false); + +let arr = [...Array(3)]; +Assert.equal(arr[0], undefined); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_2.ts index db3b2d533c..b13864663e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_2.ts @@ -38,7 +38,7 @@ class C { let c1 = new C("caihua", 12, false); const keys = Object.keys(c1); -var nextIndex = 0; +let nextIndex = 0; let x: Iterator = { next() { return nextIndex < keys.length diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_5.ts index 5117cb9163..d2a21ffb7d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_5.ts @@ -37,8 +37,8 @@ function* func(): Generator { return "done!"; } -var t1 = func(); -var t2 = t1.next(); +let t1 = func(); +let t2 = t1.next(); while (!t2.done) { t2 = t1.next(t2.value === 5); }; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_1.ts index e3b0c286dd..892d70d776 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_1.ts @@ -21,7 +21,7 @@ import { Assert } from '../../../suite/assert.js' -class C { +class student { #name: string; constructor(name: string) { this.#name = name; @@ -32,5 +32,5 @@ class C { } } -let c = new C("NARC"); -Assert.equal("NARC", c.getName()); +let students = new student("NARC"); +Assert.equal("NARC", students.getName()); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_2.ts index cb87b21577..fb3b26cc3e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_2.ts @@ -21,21 +21,21 @@ import { Assert } from '../../../suite/assert.js' -class C { +class stu { #x = 10; getX() { return this.#x; } } -class D extends C { +class Dtu extends stu { #y = 20; getY() { return this.#y; } } -let d = new D(); +let dt = new Dtu(); -Assert.equal(10, d.getX()); -Assert.equal(20, d.getY()); \ No newline at end of file +Assert.equal(10, dt.getX()); +Assert.equal(20, dt.getY()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_3.ts index 8b465aca43..74b146fe49 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_3.ts @@ -21,7 +21,7 @@ import { Assert } from '../../../suite/assert.js' -class S { +class stu { #len: number; constructor(len: number) { this.#len = len; @@ -31,8 +31,8 @@ class S { } } -const a = new S(100); -const c = new S(100); +const a = new stu(300); +const c = new stu(300); Assert.isTrue(a.compare(c)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/3_which_should_i_use.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/3_which_should_i_use.ts index 46ec8d9ba1..1cb4dec00e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/3_which_should_i_use.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/3_which_should_i_use.ts @@ -21,13 +21,13 @@ import { Assert } from '../../suite/assert.js' -class C1 { +class One { private x = 10; } -Assert.equal(10, new C1()["x"]); +Assert.equal(10, new One()["x"]); -class C2 { +class Two { #x: number; constructor(x: number) { this.#x = x; @@ -37,5 +37,5 @@ class C2 { } } -let c = new C2(5); -Assert.equal(c.getX(), 5); +let three = new Two(5); +Assert.equal(three.getX(), 5); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_1.ts index f759ab47bf..ce576222cb 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_1.ts @@ -23,15 +23,15 @@ import { Assert } from '../../../suite/assert.js' -function hwtest01(...args: [string, number]): void { +function funLTE01(...args: [string, number]): void { const newArr = [args[0].toUpperCase(), args[1] * 2]; Assert.equal(newArr[0], "HELLO"); Assert.equal(newArr[1], 10); } -hwtest01("hello", 5); -function hwtest02(arg0: string, arg1: number): void { +funLTE01("hello", 5); +function funLTE02(arg0: string, arg1: number): void { const Arrb = [arg0.toUpperCase(), arg1 * 2]; Assert.equal(Arrb[0], "HELLO"); Assert.equal(Arrb[1], 10); } -hwtest02("hello", 5); +funLTE02("hello", 5); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_4.ts index 67f70f611a..44a74e138c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_4.ts @@ -23,9 +23,9 @@ import { Assert } from '../../../suite/assert.js' -function hwtest01(x: [first: string, second: number]) { +function funLTE01(x: [first: string, second: number]) { const [a, b] = x; Assert.equal(a, "hello"); Assert.equal(b, 42); } -hwtest01(["hello", 42]); +funLTE01(["hello", 42]); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_1.ts index ca84854f2b..d99ffb1e81 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_1.ts @@ -23,11 +23,11 @@ import { Assert } from '../../../suite/assert.js' -function hw_throwError(): never { +function h_throwError(): never { throw new Error("An error occurred"); } try { - hw_throwError(); + h_throwError(); } catch (error: any) { Assert.equal(error.message, "An error occurred"); }; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_2.ts index 8d6ca59910..7e94e895f2 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_2.ts @@ -25,15 +25,20 @@ import { Assert } from '../../../suite/assert.js' -function hw_throwError(): never { +let flag: boolean = false; + +function h_throwError(): never { throw new Error("An error occurred"); } try { - hw_throwError(); + h_throwError(); } catch (error: unknown) { if (error instanceof Error) { + flag = true; Assert.equal(error.message, "An error occurred"); } else { + flag = false; let errString = "An unknow error occurred"; } }; +Assert.isTrue(flag); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_1.ts index 2f28c933ba..a45266399f 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_1.ts @@ -22,19 +22,19 @@ import { Assert } from '../../../suite/assert.js' -function hwtest01(arr1: any, arr2: any) { +function funVTT01(arr1: any, arr2: any) { return [...arr1, ...arr2]; } const arrA: any = [1, 2, 3]; const arrB: any = [4, 5, 6]; -let len01 = hwtest01(arrA, arrB).length; +let len01 = funVTT01(arrA, arrB).length; Assert.equal(len01, 6); -function hwtest02(arg: any) { +function funVTT02(arg: any) { const [_, ...result] = arg; return result; } const arrC: any = [1, 2, 3, 4, 5]; -let len02 = hwtest02(arrC).length; +let len02 = funVTT02(arrC).length; Assert.equal(len02, 4); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_2.ts index c09e8c33a5..6ec22e852b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_2.ts @@ -24,12 +24,12 @@ import { Assert } from '../../../suite/assert.js' -function hwtest01(arr1: [T1, T2], arr2: []): [T1, T2]; -function hwtest01(arr1: T[], arr2: T[]): T[] { +function funVTT01(arr1: [T1, T2], arr2: []): [T1, T2]; +function funVTT01(arr1: T[], arr2: T[]): T[] { return arr1.concat(arr2); } const t0: [] = []; -const tns: [number, string] = hwtest01([1, "a"], t0); +const tns: [number, string] = funVTT01([1, "a"], t0); Assert.equal(tns[0], 1); Assert.equal(tns[1], "a"); @@ -42,11 +42,11 @@ const arr1: [number, string, boolean, number[], object, string] = [ "AAAA", ]; const arr2: [] = []; -function hwtest02( +function funVTT02( arr1: [A, B, C, D, E, F], arr2: [] ): [A, B, C, D, E, F] { return [...arr1, ...arr2]; } -const result = hwtest02(arr1, arr2); +const result = funVTT02(arr1, arr2); Assert.equal(result.length, 6); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_3.ts index 8911aea129..43d07f66b2 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_3.ts @@ -24,19 +24,19 @@ import { Assert } from '../../../suite/assert.js' -function hwtest01(arr1: T[], arr2: U[]): Array { +function funVTT01(arr1: T[], arr2: U[]): Array { return [...arr1, ...arr2] } const arr1: string[] = ["hello", "world"]; const arr2: number[] = [1, 2, 3]; -const arrsn: Array = hwtest01(arr1, arr2); -function hwtest02(arg: any) { +const arrsn: Array = funVTT01(arr1, arr2); +function funVTT02(arg: any) { const [_, ...result] = arg; return result; } const myTuple: any = [1, 2, 3, 4] as const; const newArr: any = ["hello", "world"]; -const r1 = hwtest02(myTuple); -const r2 = hwtest02([...myTuple, ...newArr] as const); +const r1 = funVTT02(myTuple); +const r2 = funVTT02([...myTuple, ...newArr] as const); const Arrlength = r2.length; Assert.equal(Arrlength, 5); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_4.ts index 6d137c2dcc..aaca1f3ed2 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_4.ts @@ -23,7 +23,7 @@ import { Assert } from "../../../suite/assert.js" -function hwtest01( +function funVTT01( arr1: [A1, B1, C1, D1, E1, F1, A2], arr2: [A3] ): [A1, B1, C1, D1, E1, F1, A2, A3] { @@ -39,5 +39,5 @@ const arr1: [string, number, boolean, number, null, undefined, string] = [ "tom", ]; const arr2: [string] = ["world"]; -const result = hwtest01(arr1, arr2); +const result = funVTT01(arr1, arr2); Assert.equal(result.length, 8); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_5.ts index 6c37bdbd4e..7a4c1e42a1 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_5.ts @@ -24,14 +24,14 @@ import { Assert } from '../../../suite/assert.js' -function hwtest01(arr: readonly [any, ...T]) { +function funVTT01(arr: readonly [any, ...T]) { const [_ignored, ...rest] = arr; return rest; } const anum = [1, 2, 3, 4] as const; const astr = ["hello", "world"]; -const r1 = hwtest01(anum); -const r2 = hwtest01([...anum, ...astr] as const); +const r1 = funVTT01(anum); +const r2 = funVTT01([...anum, ...astr] as const); Assert.equal(r2.length, 5); Assert.equal(r2[0], 2); Assert.equal(r2[1], 3); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_6.ts index b732f41dd5..8672a43c71 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_6.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_6.ts @@ -29,26 +29,26 @@ type ASN = [...ArrStr, ...ArrNum, boolean]; const asn: ASN = ["hello", "world", 1, 2, true]; Assert.equal(asn.length, 5); type Arr = readonly any[]; -function hwtest01(arr1: T, arr2: U): [...T, ...U] { +function funVTT01(arr1: T, arr2: U): [...T, ...U] { return [...arr1, ...arr2]; } const arr1 = [1, 2, 3]; const arr2 = ["a", "b", "c"]; -const arr3 = hwtest01(arr1, arr2); +const arr3 = funVTT01(arr1, arr2); Assert.equal(arr3.length, 6); type Arry = readonly unknown[]; -function hwtest02( +function funVTT02( f: (...args: [...T, ...U]) => R, ...headArgs: T ) { return (...tailArgs: U) => f(...headArgs, ...tailArgs); } -function hwtest03(a: number, b: number, c: number): number { +function funVTT03(a: number, b: number, c: number): number { return a + b + c; } -const add2And3 = hwtest02(hwtest03, 2, 3); +const add2And3 = funVTT02(funVTT03, 2, 3); const result = add2And3(4); Assert.equal(result, 9); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/Checked_Indexed_Accesses.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/Checked_Indexed_Accesses.ts index 4e88b0a4cf..4bf3596b59 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/Checked_Indexed_Accesses.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/Checked_Indexed_Accesses.ts @@ -22,23 +22,22 @@ import { Assert } from '../../../suite/assert.js' -interface HwStaff{ - name:string; - age:number; - - [propName: string]: string|number; +interface I1 { + name: string; + age: number; + [pName: string]: string | number; } -let env:HwStaff = { - name:"lll", +let env: I1 = { + name: "lll", age: 22, }; -function check(op?:HwStaff): HwStaff|undefined { - if (op){ +function fun(op?: I1): I1 | undefined { + if (op) { Assert.isString(op.name); Assert.isNumber(op.age); }; return op; }; -let env2 = check(env); -Assert.equal(env2!.name,"lll"); -Assert.equal(env2!.age,22); \ No newline at end of file +let env2 = fun(env); +Assert.equal(env2!.name, "lll"); +Assert.equal(env2!.age, 22); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_each_index.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_each_index.ts index 3b875c2276..c06681cff9 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_each_index.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_each_index.ts @@ -22,9 +22,9 @@ import { Assert } from '../../../suite/assert.js' -let str:string[] =["3","4"]; -function indexs(strs:string[]) { - strs.forEach((str:string) =>{ +let x: string[] = ["3", "4"]; +function fun(y: string[]) { + y.forEach((str: string) => { if (str == "3") { Assert.equal(str, "3"); } else { @@ -32,4 +32,4 @@ function indexs(strs:string[]) { } }) } -indexs(str); \ No newline at end of file +fun(x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_of_index.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_of_index.ts index e57088e71e..b476b18586 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_of_index.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_of_index.ts @@ -22,8 +22,8 @@ import { Assert } from '../../../suite/assert.js' -let str:string[] =["1","2"]; -function indexs(strs:string[]) { +let x: string[] = ["1", "2"]; +function fun(strs: string[]) { for (let str of strs) { if (str == "1") { Assert.equal(str, "1"); @@ -32,4 +32,4 @@ function indexs(strs:string[]) { } } } -indexs(str); \ No newline at end of file +fun(x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_traversal_index.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_traversal_index.ts index 20758ec8f2..4124efd187 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_traversal_index.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_traversal_index.ts @@ -14,7 +14,7 @@ */ /**--- description: > - You can traverse the index. + You can traverse the fun. module: ESNext isCurrent: true ---*/ @@ -22,14 +22,14 @@ import { Assert } from '../../../suite/assert.js' -let str:string[] =["1","2"]; -function index(strs: string[]) { - for (let i:number = 0; i < strs.length; i++) { - if (i<1) { +let x: string[] = ["1", "2"]; +function fun(strs: string[]) { + for (let i: number = 0; i < strs.length; i++) { + if (i < 1) { Assert.equal(strs[i], "1"); - }else{ - Assert.equal(strs[i],"2"); + } else { + Assert.equal(strs[i], "2"); } } } -index(str); +fun(x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/any_or_unknown_are_propagated_in_falsy_positions/any_or_unknown_are_propagated_in_falsy_positions.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/any_or_unknown_are_propagated_in_falsy_positions/any_or_unknown_are_propagated_in_falsy_positions.ts index eb023e6b93..b78c766086 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/any_or_unknown_are_propagated_in_falsy_positions/any_or_unknown_are_propagated_in_falsy_positions.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/any_or_unknown_are_propagated_in_falsy_positions/any_or_unknown_are_propagated_in_falsy_positions.ts @@ -23,11 +23,11 @@ import { Assert } from '../../../suite/assert.js' -let unk: unknown; -declare let hwobj: { someProp: string }; -let anyx = unk && hwobj; -function isThing(x: any): boolean { +let x: unknown; +declare let obj: { str: string }; +let y = x && obj; +function fun(x: any): boolean { return x && typeof x === "object" && x.blah === "foo"; } -let y = isThing(anyx); -Assert.isUndefined(y); +let z = fun(y); +Assert.isUndefined(z); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/conditional_spreads_create_optional_properties/conditional_spreads_create_optional_properties_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/conditional_spreads_create_optional_properties/conditional_spreads_create_optional_properties_1.ts index da625e1bfa..462ce5b402 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/conditional_spreads_create_optional_properties/conditional_spreads_create_optional_properties_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/conditional_spreads_create_optional_properties/conditional_spreads_create_optional_properties_1.ts @@ -22,31 +22,31 @@ import { Assert } from '../../../suite/assert.js' -interface HWPerson { - name: string; - age: number; - location: string; +interface I1 { + x: string; + y: number; + z: string; } -interface HWAnimal { - name: string; - owner: HWPerson; +interface I2 { + x: string; + owner: I1; } -function hwtest01(pet?: HWAnimal) { +function fun(other?: I2) { return { - ...(pet && pet.owner), + ...(other && other.owner), otherStuff: 123, }; } -let pet: HWAnimal = { - name: "qiqi", +let pet: I2 = { + x: "qiqi", owner: { - name: "owner", - age: 11, - location: "qingdao", + x: "owner", + y: 11, + z: "qingdao", }, }; -let pet2 = hwtest01(pet); -Assert.equal(pet2.age, 11); -Assert.equal(pet2.name, "owner"); -Assert.equal(pet2.location, "qingdao"); -Assert.equal(pet2.otherStuff, 123); +let pet2 = fun(pet); +Assert.equal(pet2.y, 11); +Assert.equal(pet2.x, "owner"); +Assert.equal(pet2.z, "qingdao"); +Assert.equal(pet2.otherStuff, 123); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_1.ts index 8c35c30de0..0da690c619 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_1.ts @@ -22,26 +22,26 @@ import { Assert } from '../../../suite/assert.js' -type HWGetters = { +type G = { [K in keyof T as `get${Capitalize}`]: () => T[K]; }; -interface HWPerson { +interface I1 { name: string; - age: number; - location: string; + id: number; + lo: string; } -type HWPersonType = HWGetters; -let k1: HWPersonType = { +type I1Type = G; +let k1: I1Type = { getName() { return "honny"; }, - getAge() { - return 22; + getId() { + return 2; }, - getLocation() { + getLo() { return "qingdao"; }, }; Assert.equal(k1.getName(), "honny"); -Assert.equal(k1.getAge(), 22); -Assert.equal(k1.getLocation(), "qingdao"); +Assert.equal(k1.getId(), 2); +Assert.equal(k1.getLo(), "qingdao"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_2.ts index ac77c09fc5..67d448fbc4 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_2.ts @@ -22,13 +22,13 @@ import { Assert } from '../../../suite/assert.js' -type HWRemoveKindField = { - [K in keyof T as Exclude]: T[K]; +type TYPE1 = { + [K in keyof T as Exclude]: T[K]; }; -interface Circle { - kind: "circle"; - radius: number; +interface I1 { + name: "ww"; + id: number; } -type HWKindlessCircle = HWRemoveKindField; -let k: HWKindlessCircle = { radius: 10 }; -Assert.equal(k.radius, 10); +type TYPE2 = TYPE1; +let k: TYPE2 = { id: 10 }; +Assert.equal(k.id, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/recursive_conditional_types/recursive_conditional_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/recursive_conditional_types/recursive_conditional_types.ts index c6193f36c4..44909b8282 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/recursive_conditional_types/recursive_conditional_types.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/recursive_conditional_types/recursive_conditional_types.ts @@ -22,20 +22,20 @@ import { Assert } from '../../../suite/assert.js' -type HWElementType = T extends ReadonlyArray ? HWElementType : T; +type TYPE1 = T extends ReadonlyArray ? TYPE1 : T; -function hwtest01(x: T): HWElementType[] { +function fun1(x: T): TYPE1[] { return []; } -let d1 = hwtest01([1, 2, 3]); +let d1 = fun1([1, 2, 3]); type typeofx = typeof d1; let nx1: typeofx = [1, 2, 3]; Assert.isNumber(nx1[0]); -let d2 = hwtest01([[1], [2, 3]]); +let d2 = fun1([[1], [2, 3]]); type typeofx2 = typeof d2; let nx2: typeofx2 = [4, 5, 6]; Assert.isNumber(nx2[0]); -let d3 = hwtest01([[1], [[2]], [[[3]]]]); +let d3 = fun1([[1], [[2]], [[[3]]]]); type typeofx3 = typeof d3; let nx3: typeofx3 = [7, 8, 9]; Assert.isNumber(nx3[0]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/resolvers_parameters_are_no_longer_optional_in_promises/resolves_parameters_are_no_longer_optional_in_promises.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/resolvers_parameters_are_no_longer_optional_in_promises/resolves_parameters_are_no_longer_optional_in_promises.ts index e445c585ce..4dab20ad9d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/resolvers_parameters_are_no_longer_optional_in_promises/resolves_parameters_are_no_longer_optional_in_promises.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/resolvers_parameters_are_no_longer_optional_in_promises/resolves_parameters_are_no_longer_optional_in_promises.ts @@ -22,7 +22,18 @@ import { Assert } from '../../../suite/assert.js' -var p = Promise.resolve(); var count: number = 1; - Assert.equal(count, 1); +let a: number = 10; +setTimeout(function () { + a = 1; +}, 0); +Promise.resolve().then(function () { + a = 2; +}); +Assert.equal(a, 10); +const p = Promise.resolve(1); +p.then(function (s) { + a = a + s; +}); +Assert.equal(a, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types3.ts index 4ebee21e95..7327dd2258 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types3.ts @@ -37,11 +37,15 @@ tup1 = [{ num: 10 }, true]; tup1 = [{ num: 10 }, { str: 'string' }, true]; let tup2: [string, ...myType[], boolean]; - tup2 = ['a', false]; tup2 = ['a', { num: 10 }, false]; tup2 = ['a', { num: 10 }, { str: 'string' }, false]; +let tup3: [string, boolean, ...myType[]]; +tup3 = ['a', false]; +tup3 = ['a', false, { num: 10 }]; +tup3 = ['a', false, { num: 10 }, { str: 'string' }]; + Assert.equal(JSON.stringify(tup1), "[{\"num\":10},{\"str\":\"string\"},true]"); Assert.equal(JSON.stringify(tup2), "[\"a\",{\"num\":10},{\"str\":\"string\"},false]"); - +Assert.equal(JSON.stringify(tup3), "[\"a\",false,{\"num\":10},{\"str\":\"string\"}]"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types4.ts new file mode 100644 index 0000000000..7166f27057 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types4.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + These non-trailing rest elements can be used to model functions that take any number of leading arguments, + followed by a few fixed ones. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +function func1(...arg: [...arr: unknown[], num: number]) { + return { ...arg }; +} +let result1 = func1(10); +Assert.equal(JSON.stringify(result1), '{"0":10}'); +let result2 = func1(5, 's', true, 10); +Assert.equal(JSON.stringify(result2), '{"0":5,"1":"s","2":true,"3":10}'); + +function func2(...arg: [str:string, ...arr: unknown[], num: number]) { + return { ...arg }; +} +let result3 = func2('a', 10); +Assert.equal(JSON.stringify(result3), '{"0":"a","1":10}'); +let result4 = func2('s', true, 10); +Assert.equal(JSON.stringify(result4), '{"0":"s","1":true,"2":10}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/relaxed_rules/relaxed_rules_between_optional_properties_and_string_index_signatures_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/relaxed_rules/relaxed_rules_between_optional_properties_and_string_index_signatures_1.ts new file mode 100644 index 0000000000..655eba6671 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/relaxed_rules/relaxed_rules_between_optional_properties_and_string_index_signatures_1.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Previous versions of TypeScript treated optional object properties as + unassignable to otherwise compatible index signatures, due to the presence of undefined. + TypeScript 4.2 allows this assignment. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../suite/assert.js' + +interface I{ + [key: string]: number; +} + +type myType = { + 'a'?: number; + 'b'?: number; + 'c'?: number; +} +const eg: myType = { 'a': 10 }; +const i: I = eg; +Assert.isObject(i); + +const obj: { [key: string]: number } = eg; +Assert.isObject(obj); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation1.ts index 5af91e419e..244f511368 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation1.ts @@ -24,10 +24,21 @@ import { Assert } from '../../../suite/assert.js' type NumStrBool = number | string | boolean; -function hwtest01(value: NumStrBool): NumStrBool { - let x = value; - return x; +function func(value: NumStrBool): NumStrBool { + return value; } - let arr = [1, "hello", false]; -Assert.equal(typeof hwtest01(arr[0]), "number"); \ No newline at end of file +Assert.equal(typeof func(arr[0]), "number"); + +class C{ + mem: NumStrBool; + constructor(mem: NumStrBool) { + this.mem = mem; + } +} +let c = new C(10); +Assert.isNumber(c.mem); +c.mem = 'a'; +Assert.isString(c.mem); +c.mem = true; +Assert.isBoolean(c.mem); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation2.ts index d443f765f2..9d99a29f24 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation2.ts @@ -14,7 +14,7 @@ */ /**--- description: > - If we hover our mouse over x in an editor like Visual Studio, Visual Studio Code, or the TypeScript Playground, we’ll get a quick info panel that shows the type BasicPrimitive. Likewise, if we get the declaration file output (.d.ts output) for this file, TypeScript will say that doStuff returns BasicPrimitive. + If we hover our mouse over value in an editor like Visual Studio, Visual Studio Code, or the TypeScript Playground, we’ll get a quick info panel that shows the type BasicPrimitive. Likewise, if we get the declaration file output (.d.ts output) for this file, TypeScript will say that doStuff returns BasicPrimitive. module: ESNext isCurrent: true ---*/ @@ -24,9 +24,9 @@ import { Assert } from '../../../suite/assert.js' type NumStrBool = number | string | boolean; -function hwtest02(value: NumStrBool) { +function func(value: NumStrBool) { return value; } let arr = [10, "hello", false]; -Assert.equal(typeof hwtest02(arr[0]), "number"); \ No newline at end of file +Assert.equal(typeof func(arr[0]), "number"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/always-truthy_promise_checks/always-truthy_promise_checks.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/always-truthy_promise_checks/always-truthy_promise_checks.ts index 91902ee008..ee1719ad8c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/always-truthy_promise_checks/always-truthy_promise_checks.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/always-truthy_promise_checks/always-truthy_promise_checks.ts @@ -28,12 +28,12 @@ async function getFalse(): Promise { return false; } -async function hwtest(): Promise { +async function funPromise(): Promise { if (!getFalse()) { return 'false'; } return 'true'; } -var b = hwtest(); +var b = funPromise(); Assert.equal(b, '[object Promise]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/contextual_narrowing_for_generic/contextual_narrowing_for_generics.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/contextual_narrowing_for_generic/contextual_narrowing_for_generics.ts index 812e751234..a1ee16262d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/contextual_narrowing_for_generic/contextual_narrowing_for_generics.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/contextual_narrowing_for_generic/contextual_narrowing_for_generics.ts @@ -23,32 +23,20 @@ import { Assert } from "../../../suite/assert.js" -function hwtest01 | T[]>( - collection: C, - comparer: (x: T, y: T) => number -): C { - if (collection instanceof Set) { - return collection; - } - collection.sort(comparer); - for (let i = 0; i < collection.length; i++) { - let j = i; - while ( - j < collection.length && - comparer(collection[i], collection[j + 1]) === 0 - ) { - j++; - } - collection.splice(i + 1, j - i); - } +function funSetorArray | T[]>(collection: C): C { + if (collection instanceof Set) { return collection; + } + return collection; } let num: number[] = [1, 3, 2, 2, 4]; -function hwtest02(a: number, b: number) { - if (a == b) { - return 0; - } - return 1; -} -Assert.equal(hwtest01(num, hwtest02), "1,3,2,4"); +let n = funSetorArray(num); +Assert.equal(JSON.stringify(funSetorArray(num)), "[1,3,2,2,4]"); + +let ss = new Set(); +ss.add("NARC"); +ss.add("TypeScript"); +let ts = funSetorArray(ss); +Assert.isTrue(ts.has("NARC")); +Assert.isTrue(ts.has("TypeScript")); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/ecmascript_private_class_elements/ecmascript_private_calss_elements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/ecmascript_private_class_elements/ecmascript_private_calss_elements.ts index a876b85f39..8437bc5d29 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/ecmascript_private_class_elements/ecmascript_private_calss_elements.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/ecmascript_private_class_elements/ecmascript_private_calss_elements.ts @@ -27,28 +27,28 @@ import { Assert } from "../../../suite/assert.js" class HWC { - #someMethod() { + #FUN() { return 1; } - test1() { - return this.#someMethod(); + F1() { + return this.#FUN(); } static #something(num: number) { return num; } - test2() { + F2() { return HWC.#something(10); } - get #someValue() { + get #V() { return 100; } - publicMethod() { - this.#someMethod(); - return this.#someValue; + mFUN() { + this.#FUN(); + return this.#V; } } let c = new HWC(); -Assert.equal(c.test1(), 1); -Assert.equal(c.test2(), 10); -Assert.equal(c.publicMethod(), 100); +Assert.equal(c.F1(), 1); +Assert.equal(c.F2(), 10); +Assert.equal(c.mFUN(), 100); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_1.ts index 689e771181..e56668065b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_1.ts @@ -28,25 +28,38 @@ import { Assert } from "../../../suite/assert.js" class HWC { - #size = 0; - get size(): number { - return this.#size; + #data = 0; + get data(): number { + return this.#data; } - set size(value: string | number | boolean) { - let num = Number(value); - if (!Number.isFinite(num)) { - this.#size = 0; - return; + set data(val: string | number | boolean) { + if (val === undefined || val === null) { + this.#data = NaN; + } else if (typeof val === "number") { + this.#data = val; + } else if (typeof val === "string") { + this.#data = val.length; + } else if (typeof val === "boolean") { + if (val === false) { + this.#data = 0; + } else if (val === true) { + this.#data = 1; + } } - this.#size = num; } } let c = new HWC(); +let n: number = 0; -c.size = "hello"; -c.size = 42; -c.size = true; +c.data = "hello"; +n = c.data; +Assert.equal(n, 5); -let n: number = c.size; -Assert.equal(typeof n, "number"); +c.data = 42; +n = c.data; +Assert.equal(n, 42); + +c.data = true; +n = c.data; +Assert.equal(n, 1); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_2.ts index 7658edf31d..a078e41f35 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_2.ts @@ -25,27 +25,40 @@ import { Assert } from "../../../suite/assert.js" interface HWC { - get size(): number; - set size(value: number | string | boolean); + get data(): number; + set data(val: number | string | boolean); } -function hwtest(): HWC { - let size = 0; +function funSW(): HWC { + let data = 0; return { - get size(): number { - return size; + get data(): number { + return data; }, - set size(value: string | number | boolean) { - let num = Number(value); - - if (!Number.isFinite(num)) { - size = 0; - return; + set data(val: string | number | boolean) { + if (val === undefined || val === null) { + data = NaN; + } else if (typeof val === "number") { + data = val; + } else if (typeof val === "string") { + data = val.length; + } else if (typeof val === "boolean") { + if (val === false) { + data = 0; + } else if (val === true) { + data = 1; + } } - size = num; }, }; } -let t = hwtest(); -Assert.equal(t.size, 0); +let t = funSW(); +t.data = "NARC"; +Assert.equal(t.data, 4); + +t.data = true; +Assert.equal(t.data, 1); + +t.data = 1024; +Assert.equal(t.data, 1024); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/static_index_signatures/static_index_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/static_index_signatures/static_index_signatures.ts index a150462843..e1bb7faebb 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/static_index_signatures/static_index_signatures.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/static_index_signatures/static_index_signatures.ts @@ -30,10 +30,10 @@ class HWC { } let hwc = new HWC(); -hwc["whatever"] = 42; -Assert.equal(hwc["whatever"], 42); +hwc["Yes!Yes!Yes!"] = 42; +Assert.equal(hwc["Yes!Yes!Yes!"], 42); -let x = hwc["something"]; +let x = hwc["No!No!No!"]; x = undefined; Assert.isUndefined(x); x = 20; @@ -47,10 +47,10 @@ class HWB { static [propName: string]: string | number | undefined; } -HWB["whatever"] = 42; -Assert.equal(HWB["whatever"], 42); +HWB["Yes!Yes!Yes!"] = 42; +Assert.equal(HWB["Yes!Yes!Yes!"], 42); -let y = HWB["something"]; +let y = HWB["No!No!No!"]; y = "y"; Assert.equal(y, "y"); y = 10; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_1.ts index bc330388c6..ff93498ef3 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_1.ts @@ -23,19 +23,19 @@ import { Assert } from "../../../suite/assert.js" -type Color = "red" | "blue"; +type Figure = "three-colour" | "pure color"; type Num = "one" | "two"; -type Fish1 = `${Num | Color} fish`; -type Fish2 = "one fish" | "two fish" | "red fish" | "blue fish"; -var fish1: Fish1 = "blue fish"; -var fish2: Fish2 = fish1; -fish1 = "one fish"; -fish2 = fish1; -fish1 = "red fish"; -fish2 = fish1; -fish1 = "two fish"; -fish2 = fish1; +type Cat1 = `${Num | Figure} cat`; +type Cat2 = "one cat" | "two cat" | "three-colour cat" | "pure color cat"; +var cat1: Cat1 = "pure color cat"; +var cat2: Cat2 = cat1; +cat1 = "one cat"; +cat2 = cat1; +cat1 = "three-colour cat"; +cat2 = cat1; +cat1 = "two cat"; +cat2 = cat1; let s1: `${number}-${number}-${number}`; let s2: `1-2-3` = `1-2-3`; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_2.ts index 503181dcf6..d957eb3f4f 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_2.ts @@ -23,11 +23,10 @@ import { Assert } from "../../../suite/assert.js" -function hwtest(s: string): `hello ${string}` { - // Previously an error, now works +function funStr(s: string): `hello ${string}` { return `hello ${s}`; } -var b = hwtest("s"); +var b = funStr("s"); Assert.equal(b, "hello s"); let s: string = "s"; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_4.ts index e08e6ea8f1..71d4db250f 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_4.ts @@ -22,30 +22,30 @@ import { Assert } from "../../../suite/assert.js" -function hwtest01(arg: `*${V}*`): `*${V}*` { +function funStr01(arg: `*${V}*`): `*${V}*` { return arg; } -function hwtest02(s: string, n: number, b: boolean, t: T) { - let x1 = hwtest01("*hello*"); +function funStr02(s: string, n: number, b: boolean, t: T) { + let x1 = funStr01("*hello*"); Assert.equal(x1, "*hello*"); - let x2 = hwtest01("**hello**"); + let x2 = funStr01("**hello**"); Assert.equal(x2, "**hello**"); - let x3 = hwtest01(`*${s}*` as const); + let x3 = funStr01(`*${s}*` as const); Assert.equal(x3, "*s*"); - let x4 = hwtest01(`*${n}*` as const); + let x4 = funStr01(`*${n}*` as const); Assert.equal(x4, "*5*"); - let x5 = hwtest01(`*${b}*` as const); + let x5 = funStr01(`*${b}*` as const); Assert.equal(x5, "*true*"); - let x6 = hwtest01(`*${t}*` as const); + let x6 = funStr01(`*${t}*` as const); Assert.equal(x6, "*t*"); - let x7 = hwtest01(`**${s}**` as const); + let x7 = funStr01(`**${s}**` as const); Assert.equal(x7, "**s**"); } -hwtest02("s", 5, true, "t"); +funStr02("s", 5, true, "t"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_1.ts index 1ad37b10ed..bfe2bf2e4e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_1.ts @@ -24,28 +24,55 @@ import { Assert } from '../../../suite/assert.js' -function hwtest01(arg: unknown) { - const argIsString = typeof arg === "string"; - if (argIsString) { - Assert.equal(arg.toUpperCase(), "C"); +function fun01(a: unknown) { + if (typeof a === "string") { + Assert.equal(a[0], "c"); + } + if (typeof a === "number") { + Assert.equal(a, 11); + } + if (typeof a === "boolean") { + Assert.equal(a, true); + } + if (typeof a === "undefined") { + Assert.isUndefined(a); + } + if (typeof a === "function") { + Assert.isFunction(a); + } + if (typeof a === "object") { + Assert.isObject(a); + } + if (typeof a === "symbol") { + Assert.isSymbol(a); } } -hwtest01("c"); - -interface HWTestType { +fun01("c"); +fun01(11); +fun01(true); +let x: undefined; +fun01(x); +let f = (a: number) => { a = 0; return a; }; +fun01(f); +let obj: object = { + x: 1 +} +fun01(obj); +let sym: symbol = Symbol('a'); +fun01(sym); +interface I { readonly name: "caihua"; } -function hwtest02() { - let tt: HWTestType = { name: "caihua" }; +function fun02() { + let tt: I = { name: "caihua" }; let res = tt.name === "caihua"; if (res) { Assert.isNumber(tt.name.length); Assert.equal(tt.name[0], "c"); } } -hwtest02(); - -function hwtest03(a: number, b = "function" as const) { +fun02(); +function fun03(a: number, b = "function" as const) { let cc = typeof b === "function"; if (cc) { Assert.isNumber(b.length); @@ -55,4 +82,4 @@ function hwtest03(a: number, b = "function" as const) { Assert.equal(cc, false); } } -hwtest03(12); +fun03(12); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_2.ts index 50b5b48a74..6327ee0e6c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_2.ts @@ -21,31 +21,28 @@ import { Assert } from '../../../suite/assert.js' -type T1 = { kind: "circle"; radius: number }; -type T2 = { kind: "square"; sideLength: number }; +type T1 = { name: "x1"; size: number }; +type T2 = { name: "x2"; sideLength: number }; type T3 = T1 | T2; - -let c: T1 = { kind: "circle", radius: 2 }; -let s: T2 = { kind: "square", sideLength: 2 }; - -function hwtest01(shape: T3): number { - const isCircle = shape.kind === "circle"; - if (isCircle) { - return Math.PI * shape.radius ** 2; +let c: T1 = { name: "x1", size: 2 }; +let s: T2 = { name: "x2", sideLength: 2 }; +function fun01(shape: T3): number { + const isx1 = shape.name === "x1"; + if (isx1) { + return Math.PI * shape.size ** 2; } else { return shape.sideLength ** 2; } } -Assert.equal(Math.round(hwtest01(c)), 13); -Assert.equal(hwtest01(s), 4); - -function hwtest02(shape: T3): number { - const { kind } = shape; - if (kind === "circle") { - return Math.PI * shape.radius ** 2; +Assert.equal(Math.round(fun01(c)), 13); +Assert.equal(fun01(s), 4); +function fun02(shape: T3): number { + const { name } = shape; + if (name === "x1") { + return Math.PI * shape.size ** 2; } else { return shape.sideLength ** 2; } } -Assert.equal(Math.round(hwtest02(c)), 13); -Assert.equal(hwtest02(s), 4); +Assert.equal(Math.round(fun02(c)), 13); +Assert.equal(fun02(s), 4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_3.ts index c58f82364d..1fd1125523 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_3.ts @@ -23,7 +23,7 @@ import { Assert } from '../../../suite/assert.js' -function hwtest01(a: string | undefined, b: number | undefined, c: boolean) { +function fun01(a: string | undefined, b: number | undefined, c: boolean) { const res = a && b && c; if (res) { Assert.equal(a.toLowerCase(), "abc"); @@ -34,5 +34,5 @@ function hwtest01(a: string | undefined, b: number | undefined, c: boolean) { return 0; } } -Assert.equal(hwtest01("abc", 1, true), 1); -Assert.equal(hwtest01("abc", undefined, true), 0); +Assert.equal(fun01("abc", 1, true), 1); +Assert.equal(fun01("abc", undefined, true), 0); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_4.ts index 4a965a94e1..197743bae2 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_4.ts @@ -23,11 +23,32 @@ import { Assert } from '../../../suite/assert.js' -function isBool(x: string | number | boolean) { - const isString = typeof x === "string"; - const isNumber = typeof x === "number"; - const isStringOrNumber = isString || isNumber; - if (isStringOrNumber) { +function isBool(a: unknown) { + if (typeof a === "string") { + Assert.equal(a[0], "f"); + } + if (typeof a === "number") { + Assert.equal(a, 12); + } + if (typeof a === "boolean") { + Assert.isBoolean(a); + } + if (typeof a === "undefined") { + Assert.isUndefined(a); + } + if (typeof a === "function") { + Assert.isFunction(a); + } + if (typeof a === "object") { + Assert.isObject(a); + } + if (typeof a === "symbol") { + Assert.isSymbol(a); + } + const x = typeof a === "string"; + const y = typeof a === "number"; + const z = x || y; + if (z) { return 0; } else { return 1; @@ -36,3 +57,13 @@ function isBool(x: string | number | boolean) { Assert.equal(isBool(false), 1); Assert.equal(isBool("false"), 0); Assert.equal(isBool(12), 0); +let x: undefined; +Assert.equal(isBool(x), 1); +let f = (a: number) => { a = 0; return a; }; +Assert.equal(isBool(f), 1); +let obj: object = { + x: 1 +} +Assert.equal(isBool(obj), 1); +let sym: symbol = Symbol('a'); +Assert.equal(isBool(sym), 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_1.ts index 95ad76c567..1b32668a96 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_1.ts @@ -23,7 +23,7 @@ import { Assert } from '../../../suite/assert.js' -function hwtest(a: any) { +function fun(a: any) { if (typeof a === "number") { } else { throw new Error("type error"); @@ -31,7 +31,7 @@ function hwtest(a: any) { } try { - hwtest("string"); + fun("string"); } catch (err) { Assert.equal(err instanceof Error, true); if (err instanceof Error) { diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_2.ts index 1257509f4c..47e6410eaa 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_2.ts @@ -23,7 +23,7 @@ import { Assert } from '../../../suite/assert.js' -function hwtest(a: any) { +function fun(a: any) { if (typeof a === "number") { } else { throw new Error("type error"); @@ -31,7 +31,7 @@ function hwtest(a: any) { } try { - hwtest("string"); + fun("string"); } catch (err) { Assert.equal(err instanceof Error, true); if (err instanceof Error) { diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_3.ts index 57673d1968..7820b475cd 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_3.ts @@ -23,7 +23,7 @@ import { Assert } from '../../../suite/assert.js' -function hwtest(a: any) { +function fun(a: any) { if (typeof a === "number") { } else { throw new Error("type error"); @@ -31,7 +31,7 @@ function hwtest(a: any) { } try { - hwtest("string"); + fun("string"); } catch (err: any) { Assert.equal(err instanceof Error, true); Assert.equal(err.message, "type error"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/exact_optional_property_types/exact_optional_property_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/exact_optional_property_types/exact_optional_property_types_1.ts index 1c71d7ec00..3ec83281b8 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/exact_optional_property_types/exact_optional_property_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/exact_optional_property_types/exact_optional_property_types_1.ts @@ -24,18 +24,17 @@ import { Assert } from '../../../suite/assert.js' -interface HWPerson { - name: string; - age?: number; +interface I { + x: string; + y?: number; } -const p: HWPerson = { - name: "Daniel", +const p: I = { + x: "aaaa", }; const keys = Object.keys(p); -Assert.equal(keys.indexOf("age"), -1); -Assert.equal(typeof p.age, "undefined"); -Assert.notEqual(typeof p.age, "number"); - -p.age = 12; -Assert.equal(typeof p.age, "number"); -Assert.notEqual(typeof p.age, "undefined"); +Assert.equal(keys.indexOf("y"), -1); +Assert.equal(typeof p.y, "undefined"); +Assert.notEqual(typeof p.y, "number"); +p.y = 12; +Assert.equal(typeof p.y, "number"); +Assert.notEqual(typeof p.y, "undefined"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/static_blocks_in_classe/static_blocks_in_classes1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/static_blocks_in_classe/static_blocks_in_classes1.ts index b2b8956166..40f59e3ee2 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/static_blocks_in_classe/static_blocks_in_classes1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/static_blocks_in_classe/static_blocks_in_classes1.ts @@ -26,16 +26,16 @@ import { Assert } from '../../../suite/assert.js' -class HW_Test { - static #count = 0; +class C { + static #aa = 0; - get countValue() { - return HW_Test.#count; - } + get aaValue() { + return C.#aa; + } - static { - HW_Test.#count++; - } + static { + C.#aa++; + } } -let hwt = new HW_Test(); -Assert.equal(hwt.countValue, 1); +let x = new C(); +Assert.equal(x.aaValue, 1); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/static_blocks_in_classe/static_blocks_in_classes2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/static_blocks_in_classe/static_blocks_in_classes2.ts index beba98cd70..40a0eaa36d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/static_blocks_in_classe/static_blocks_in_classes2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/static_blocks_in_classe/static_blocks_in_classes2.ts @@ -21,23 +21,24 @@ import { Assert } from '../../../suite/assert.js' -class HW_Test { - static count = 0; +class C { + static aa = 0; - get countValue() { - return HW_Test.count; + get aaValue() { + return C.aa; } static { - HW_Test.count++; - Assert.equal(HW_Test.count, 1); + C.aa++; + Assert.equal(C.aa, 1); } static { - HW_Test.count++; - Assert.equal(HW_Test.count, 2); + C.aa++; + Assert.equal(C.aa, 2); } static { - HW_Test.count++; - Assert.equal(HW_Test.count, 3); + C.aa++; + Assert.equal(C.aa, 3); } } -new HW_Test(); +new C(); +Assert.equal(C.aa, 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_1.ts index 1e76b73f88..8c3e13e57a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_1.ts @@ -23,10 +23,10 @@ import { Assert } from '../../../suite/assert.js' -interface HWTest { +interface I { [key: string]: any; } -let t: HWTest = {}; +let t: I = {}; t["1"] = 1; t["2"] = "1"; const keys = Object.keys(t); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_2.ts index f35585ecd5..856247e66a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_2.ts @@ -21,10 +21,10 @@ import { Assert } from '../../../suite/assert.js' -let arr: Array = []; -arr[0] = "a"; -Assert.equal(arr[0], "a"); -Assert.isString(arr[0]); -arr[1] = 12; -Assert.equal(arr[1], 12); -Assert.isNumber(arr[1]); +let x: Array = []; +x[0] = "a"; +Assert.equal(x[0], "a"); +Assert.isString(x[0]); +x[1] = 12; +Assert.equal(x[1], 12); +Assert.isNumber(x[1]); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_3.ts index 3d314e9c03..4943f196de 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_3.ts @@ -23,17 +23,14 @@ import { Assert } from '../../../suite/assert.js' -interface HWColor { - [keys: number|string]: any; +interface I { + [keys: number | string]: any; } -const red:any = Symbol("red"); -const green:any = Symbol("green"); -const blue:any = Symbol("blue"); - -let c: HWColor = {}; -c[red] = 0xff0000; -c[green] = 0x00ff00; -c[blue] = 0x0000ff; -Assert.isNumber(c[red]); - - +const x: any = Symbol("x"); +const y: any = Symbol("y"); +const z: any = Symbol("z"); +let c: I = {}; +c[x] = 0xff0000; +c[y] = 0x00ff00; +c[z] = 0x0000ff; +Assert.isNumber(c[x]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_4.ts index c754460623..c169e0dcb6 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_4.ts @@ -21,17 +21,16 @@ import { Assert } from '../../../suite/assert.js' -interface HWI1 { +interface I { name: string; age: number; } -interface HWI2 extends HWI1 { +interface I2 extends I { [optName: number]: any; } -let a: HWI2 = { +let a: I2 = { name: "wangcai", age: 20 }; Assert.isString(a.name); -Assert.isNumber(a.age); - +Assert.isNumber(a.age); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_5.ts index d371bb939e..fd4ef12cf0 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_5.ts @@ -26,20 +26,19 @@ import { Assert } from '../../../suite/assert.js' -interface HWDI1 { - [key: number ]: any; +interface I1 { + [key: number]: any; } -interface HWDI2 { +interface I2 { [key: number]: any; } -interface HWDI3 extends HWDI2 { +interface I3 extends I2 { [key: number]: any; } -const one:1 = 1; -let a: HWDI1 = {}; -let b: HWDI3 = {}; +const one: 1 = 1; +let a: I1 = {}; +let b: I3 = {}; b[one] = 1; a = b; -Assert.equal(a[one], 1); - +Assert.equal(a[one], 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/private_field_presence_checks/private_field_presence_checks_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/private_field_presence_checks/private_field_presence_checks_1.ts index cf7f2ca6c2..b25dc25615 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/private_field_presence_checks/private_field_presence_checks_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/private_field_presence_checks/private_field_presence_checks_1.ts @@ -22,19 +22,19 @@ import { Assert } from '../../../suite/assert.js' -class HWP { +class RunP { #name: string; constructor(name: string) { this.#name = name; } - equals(other: any) { + combine(other: any) { return other && typeof other === "object" && this.#name === other.#name; } } -const men = new HWP('jack'); -const women = new HWP('marry'); -Assert.equal(women.equals(men), false); \ No newline at end of file +const men = new RunP('jack'); +const women = new RunP('marry'); +Assert.equal(women.combine(men), false); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types1.ts index d02f72e2ed..220fd6d951 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types1.ts @@ -22,8 +22,8 @@ import { Assert } from "../../../suite/assert.js" -type HWT1 = T extends ` ${infer Rest}` ? HWT1 : T; +type project = T extends ` ${infer Rest}` ? project : T; -type HWT2 = HWT1<" oops">; -var t: HWT2 = "oops"; +type test = project<" oops">; +var t: test = "oops"; Assert.equal(t, "oops"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts index 1cf1fc96fe..dd053e796b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts @@ -23,18 +23,18 @@ import { Assert } from "../../../suite/assert.js" -type HWGetChars = S extends `${infer Char}${infer Rest}` - ? Char | HWGetChars +type RunGetChars = S extends `${infer Char}${infer Rest}` + ? Char | RunGetChars : never; -type gc = HWGetChars<" getChar">; +type gc = RunGetChars<" getChar">; var g1: gc = "e"; Assert.isString(g1); -type HWGetChars1 = HWGetCharsHelper; -type HWGetCharsHelper = S extends `${infer Char}${infer Rest}` - ? HWGetCharsHelper +type RunGetChars1 = RunGetCharsHelper; +type RunGetCharsHelper = S extends `${infer Char}${infer Rest}` + ? RunGetCharsHelper : Acc; -type gch = HWGetCharsHelper; +type gch = RunGetCharsHelper; var g2: gch = 10; Assert.isNumber(g2); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/template_string_types_as_discriminants/template_string_types_as_discriminants_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/template_string_types_as_discriminants/template_string_types_as_discriminants_1.ts index 3704a08b34..55f6304307 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/template_string_types_as_discriminants/template_string_types_as_discriminants_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/template_string_types_as_discriminants/template_string_types_as_discriminants_1.ts @@ -23,38 +23,38 @@ isCurrent: true import { Assert } from "../../../suite/assert.js" interface Message { - type: string; - url: string; + pattern: string; + location: string; } -interface SuccessMessage { - type: `${string}Success`; - body: string; +interface SMessage { + pattern: `${string}Success`; + location: string; } -interface ErrorMessage { - type: `${string}Error`; +interface EMessage { + pattern: `${string}Error`; message: string; } -function hwtest(r: SuccessMessage | ErrorMessage) { - if (r.type === "HttpSuccess") { - let token = r.body; - Assert.equal(r.type, "HttpSuccess"); +function RunTest(r: SMessage | EMessage |Message) { + if (r.pattern === "HttpSuccess") { + let token = r.pattern; + Assert.equal(token, "HttpSuccess"); } else { - Assert.equal(r.type, "HttpError"); + Assert.equal(r.pattern, "HttpError"); } } -const successMessage: SuccessMessage = { - type: "HttpSuccess", - body: "request success" +const successMessage: SMessage = { + pattern: "HttpSuccess", + location: "request success" } -const errorMessage: ErrorMessage = { - type: "HttpError", +const errorMessage: EMessage = { + pattern: "HttpError", message: "100-continue" } -hwtest(successMessage); -hwtest(errorMessage); \ No newline at end of file +RunTest(successMessage); +RunTest(errorMessage); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/the_awaited_type_and_promise_improvements/the_awaited_type_and_promise_improvements_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/the_awaited_type_and_promise_improvements/the_awaited_type_and_promise_improvements_1.ts index 489442a606..bab72306a0 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/the_awaited_type_and_promise_improvements/the_awaited_type_and_promise_improvements_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/the_awaited_type_and_promise_improvements/the_awaited_type_and_promise_improvements_1.ts @@ -26,18 +26,18 @@ import { Assert } from "../../../suite/assert.js" -function MaybePromise(value: number): number | Promise | PromiseLike { +function ToP(value: number): number | Promise | PromiseLike { return new Promise((resolve, reject) => { resolve(Math.random()); }); } -async function doSomething(): Promise<[number, number]> { - const result = await Promise.all([MaybePromise(100), MaybePromise(200)]); +async function operate(): Promise<[number, number]> { + const result = await Promise.all([ToP(100), ToP(200)]); return result; } -let D = doSomething().then(res => { +let D = operate().then(res => { Assert.isObject(res, "object"); }); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts index e86a71c41d..6f2206ac50 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts @@ -27,10 +27,10 @@ import { someFunc, BaseType } from "./some-module.js" export class Thing implements BaseType { someMethod() { - someFunc(); + return someFunc(); } } const thing = new Thing(); Assert.isFunction(Thing); -Assert.isObject(thing); \ No newline at end of file +Assert.equal(thing.someMethod(), 15); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/1_allowing_code_in_constructors.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/1_allowing_code_in_constructors.ts index 5a6ff7e2c2..618c4e4cc0 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/1_allowing_code_in_constructors.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/1_allowing_code_in_constructors.ts @@ -21,25 +21,16 @@ import { Assert } from '../../suite/assert.js' -class HWB1 { } - -class HWB2 extends HWB1 { +class C { } +class C2 extends C { bool = true; - constructor() { super(); this.bool = false; } - getBool(): boolean { return this.bool; } - - } - - -let d = new HWB2(); - -Assert.equal(d.getBool(),false ); - +let d = new C2(); +Assert.equal(d.getBool(), false); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/2_control_flow_analysis.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/2_control_flow_analysis.ts index 0e9912e9a6..6632cb6201 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/2_control_flow_analysis.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/2_control_flow_analysis.ts @@ -13,7 +13,7 @@ * limitations under the License. */ /**--- - description: TypeScript is able to narrow types based on what’s called a discriminant property. For example, in the following code snippet, TypeScript is able to narrow the type of action based on every time we check against the value of kind. + description: TypeScript is able to narrow types based on what’s called a discriminant property. For example, in the following code snippet, TypeScript is able to narrow the type of action based on every time we check against the value of name. module: ESNext isCurrent: true ---*/ @@ -21,62 +21,48 @@ import { Assert } from '../../suite/assert.js' -type HWA = - | { kind: "NumberContents"; payload: number } - | { kind: "StringContents"; payload: string }; - -function hwtest01(action: HWA) { - if (action.kind === "NumberContents") { - // `action.payload` is a number here. - let num = action.payload * 2; +type T = + | { name: "Name"; size: number } + | { name: "Name2"; size: string }; +function fun1(action: T) { + if (action.name === "Name") { + let num = action.size * 2; return num; - } else if (action.kind === "StringContents") { - // `action.payload` is a string here. - const str = action.payload.trim(); + } else if (action.name === "Name2") { + const str = action.size.trim(); return str; } } - -let action1: HWA = { - kind: "NumberContents", - payload: 1 +let action1: T = { + name: "Name", + size: 1 } - -let action2: HWA = { - kind: "StringContents", - payload: " 1234 " +let action2: T = { + name: "Name2", + size: " 1234 " } - -Assert.equal(2, hwtest01(action1)); -Assert.equal("1234", hwtest01(action2)); - - -// you might have wanted to destructure kind and payload in the the example above. +Assert.equal(2, fun1(action1)); +Assert.equal("1234", fun1(action2)); type Action2 = - | { kind: "NumberContents"; payload: number } - | { kind: "StringContents"; payload: string }; - -function hwtest02(action: Action2) { - const { kind, payload } = action; - if (kind === "NumberContents") { - let num = payload * 2; + | { name: "Name"; size: number } + | { name: "Name2"; size: string }; +function fun2(action: Action2) { + const { name, size } = action; + if (name === "Name") { + let num = size * 2; return num; - } else if (kind === "StringContents") { - const str = payload.trim(); + } else if (name === "Name2") { + const str = size.trim(); return str; } } - - -let action3: HWA = { - kind: "NumberContents", - payload: 2 +let action3: T = { + name: "Name", + size: 2 } - -let action4: HWA = { - kind: "StringContents", - payload: " 5678 " +let action4: T = { + name: "Name2", + size: " 5678 " } - -Assert.equal(hwtest02(action3),4); -Assert.equal(hwtest02(action4),"5678"); \ No newline at end of file +Assert.equal(fun2(action3), 4); +Assert.equal(fun2(action4), "5678"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/3_improved_recursion_depth_checks.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/3_improved_recursion_depth_checks.ts index f897799b72..75da0c1a7f 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/3_improved_recursion_depth_checks.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/3_improved_recursion_depth_checks.ts @@ -21,30 +21,12 @@ import { Assert } from '../../suite/assert.js' -// In a structural type system, object types are compatible based on the members they have. -interface HWA { - prop: HWA>; -} - -interface HWB { - prop: HWB>; -} - -function hwtest(source: HWA, target: HWB) { - target = source; -} - - -interface HWC { +interface I3 { prop: T; } - -let x: HWC>>>>>; -let y: HWC>>>>; - - +let x: I3>>>>>; +let y: I3>>>>; y = { prop: { prop: { prop: { prop: { prop: "prop" } } } } } x = { prop: y }; - Assert.isString("x = y; this is error"); Assert.notEqual(JSON.stringify(x), JSON.stringify(y)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/4_indexed_access_inference_improvements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/4_indexed_access_inference_improvements.ts index fdffe32f72..df32d679b4 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/4_indexed_access_inference_improvements.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/4_indexed_access_inference_improvements.ts @@ -21,28 +21,25 @@ import { Assert } from '../../suite/assert.js' -interface HWI01 { - number: number; - string: string; - boolean: boolean; +interface I { + xx: number; + yy: string; + zz: boolean; } - -type HWI02

= { +type T

= { [K in P]: { - kind: K; - v: HWI01[K]; - f: (p: HWI01[K]) => void; + name: K; + v: I[K]; + f: (p: I[K]) => void; }; }[P]; - -function hwtest(record: HWI02) { +function fun(record: T) { record.f(record.v); } - -hwtest({ - kind: "string", +fun({ + name: "yy", v: "hello!", f: (val) => { - Assert.equal(val.toUpperCase(),"HELLO!"); + Assert.equal(val.toUpperCase(), "HELLO!"); }, }); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/5_control_flow_analysis_for_dependent_parameters.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/5_control_flow_analysis_for_dependent_parameters.ts index 58072b6aaa..2718d06002 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/5_control_flow_analysis_for_dependent_parameters.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/5_control_flow_analysis_for_dependent_parameters.ts @@ -21,9 +21,8 @@ import { Assert } from '../../suite/assert.js' -type HWT01 = (...args: ["a", number] | ["b", string]) => void; - -const hwf: HWT01 = (kind, payload) => { +type T = (...args: ["a", number] | ["b", string]) => void; +const fun: T = (kind, payload) => { if (kind === "a") { Assert.equal(42, payload.toFixed()); } @@ -31,6 +30,5 @@ const hwf: HWT01 = (kind, payload) => { Assert.equal("HELLO", payload.toUpperCase()); } }; - -hwf("a", 42); -hwf("b", "hello"); \ No newline at end of file +fun("a", 42); +fun("b", "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access.ts index 462fcc96a0..c3295e44ae 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access.ts @@ -22,18 +22,16 @@ import { Assert } from "../../../suite/assert.js" -var sym = Symbol(); - -var func = function () { +let sym = Symbol(); +let func = function () { return 5; }; - -var o = { +let o = { obj: "obejct" }; -var x = Math.random(); -var y = Math.random(); +let x = Math.random(); +let y = Math.random(); const fo = x > y ? func() : o; const key = { diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/improved_function_inference_in_objects_and_methods/improved_function_inference_in_objects_and_methods.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/improved_function_inference_in_objects_and_methods/improved_function_inference_in_objects_and_methods.ts index 0c215e39ea..3669f0076b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/improved_function_inference_in_objects_and_methods/improved_function_inference_in_objects_and_methods.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/improved_function_inference_in_objects_and_methods/improved_function_inference_in_objects_and_methods.ts @@ -43,19 +43,23 @@ function func2(arg: { member: (str: string) => T }) { var f6 = func2({ member: str => { return str; } }); var result = f6.member('a'); Assert.isString(result); -function hwtest(arg: { - produce: (n: string) => T; - consume: (x: T) => void; + +function f(arg: { + arg1: (n: string) => T; + arg2: (x: T) => void; }) { - arg.consume = function (x:T) { - Assert.equal(typeof x,"String") + arg.arg2 = function (x:T) { + Assert.equal(typeof x, "String"); } - arg.consume; - + arg.arg2; } -hwtest({ - produce: ():string => "hello", - consume: (x:string) => x.toLowerCase(), +f({ + arg1: ():string => "string", + arg2: (x:string) => x.toLowerCase(), +}); +f({ + arg1: n => n, + arg2: (x:string) => x.toLowerCase(), }); @@ -81,11 +85,11 @@ var c2 = new C({ mem() { return 'a' }, t: 't' }) -Assert.isString(c1.arg.t); +Assert.isString(c2.arg.t); var c3 = new C({ mem: str => str, t: 't' }) -Assert.isString(c1.arg.t); +Assert.isString(c3.arg.t); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/instantiation_expressions/instantiation_expressions.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/instantiation_expressions/instantiation_expressions.ts index 1f3702ba0c..0d230b89cb 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/instantiation_expressions/instantiation_expressions.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/instantiation_expressions/instantiation_expressions.ts @@ -31,45 +31,43 @@ data.set("name",new Error("TS error")) Assert.equal(data.get("name").name, 'Error'); -interface HWI1 { - value: T; -} -interface HWI2 { +interface I1 { name: string; } -interface HWI3 { +interface I2 { use: string; } -function hwtest(value: T) { - return {value}; -// Function - type myType1 = number | string; - type myType2 = { str: string } | (() => number); - - function func(arg: T) { - return arg; - } +function fc(value: T) { + return value; +} +let obj1 = fc({ name: 'xiao' }); +let obj2 = fc({ use: 'play' }); +Assert.equal(JSON.stringify(obj1), '{"name":"xiao"}'); +Assert.equal(JSON.stringify(obj2), '{"use":"play"}'); - var f1 = func(5); - Assert.isNumber(f1); - var f2 = func('a'); - Assert.isString(f2); +type myType1 = number | string; +type myType2 = { str: string } | (() => number); +function func(arg: T) { + return arg; +} - var f3 = func({str: 'str'}); - Assert.isObject(f3); - var f4 = func(() => { - return 10; - }); - Assert.isFunction(f4); +var f1 = func(5); +Assert.isNumber(f1); +var f2 = func('a'); +Assert.isString(f2); +var f3 = func({str: 'str'}); +Assert.isObject(f3); +var f4 = func(() => { + return 10; +}); +Assert.isFunction(f4); -// Constructor - let map = Map; - let map_instantiation = new map(); - map_instantiation.set('num', 8); - Assert.isNumber(map_instantiation.get('num')); +let map = Map; +let map_instantiation = new map(); +map_instantiation.set('num', 8); +Assert.isNumber(map_instantiation.get('num')); - let set = new Set([2]); - for (let arg of set) { - Assert.isNumber(arg); - } -} +let set = new Set([2]); +for (let arg of set) { + Assert.isNumber(arg); +}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/optional_variance_annotations_for_type_parameters/optional_variance_annotations_for_type_parameters.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/optional_variance_annotations_for_type_parameters/optional_variance_annotations_for_type_parameters.ts index 07b0564308..1efefdf64d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/optional_variance_annotations_for_type_parameters/optional_variance_annotations_for_type_parameters.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/optional_variance_annotations_for_type_parameters/optional_variance_annotations_for_type_parameters.ts @@ -39,9 +39,6 @@ m_ins1 = m_ins2; Assert.equal(m_ins1, m_ins2); -interface h_P{ - name: string; -} interface h_C{ name: string; age: number; @@ -49,7 +46,7 @@ interface h_C{ type myType3 = () => T; type myType4 = () => T; -var m_ins3: myType3 = () => { return { name: 'xiao' } }; -var m_ins4: myType4 = () => { return { name: 'xi', age: 18 } }; +var m_ins3: myType3 = () => { return { name: 'xiao', age: 18 } }; +var m_ins4: myType4 = () => { return { name: 'xi', age: 18, height: 18 } }; m_ins3 = m_ins4; Assert.equal(m_ins3, m_ins4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/readonly_tuples_have_a_readonly_length_property/readonly_tuples_have_a_readonly_length_property.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/readonly_tuples_have_a_readonly_length_property/readonly_tuples_have_a_readonly_length_property.ts index ebb5869458..78273286af 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/readonly_tuples_have_a_readonly_length_property/readonly_tuples_have_a_readonly_length_property.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/readonly_tuples_have_a_readonly_length_property/readonly_tuples_have_a_readonly_length_property.ts @@ -22,8 +22,8 @@ import { Assert } from '../../../suite/assert.js' -function hwtest(tuple: readonly [string, string, string]) { +function func(tuple: readonly [string, string, string]) { return tuple.length; } -var a = hwtest(['a', 'b', 'c']); +var a = func(['a', 'b', 'c']); Assert.equal(a, 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.8/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.8/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing.ts index 3990d1225a..14fe78034b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.8/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.8/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing.ts @@ -25,46 +25,43 @@ import { Assert } from '../../../suite/assert.js' type T1 = {} & string; -let Hwa:T1 = "sss"; -Assert.equal(Hwa,"sss") +let a: T1 = "sss"; +Assert.equal(a, "sss"); type T2 = {} & unknown; -let Hwb:T2 = 2; -Assert.equal(Hwb,2) +let b: T2 = 2; +Assert.equal(b,2) -let x:unknown = 1 ; +let x: unknown = 1; function f1(x: unknown) { - let y:null|undefined|{}; - y=x; + let y: null | undefined | {}; + y = x; if (x) { - Assert.equal(y,1); + Assert.equal(y, 1); } } f1(x); -let z:T1 ="Hw"; -function f2(x: T,y?:T) { - y=x; +let z: T1 = "string"; +function f2(x: T, y?: T) { + y = x; if (x) { - Assert.equal(y,"Hw"); // T & {} + Assert.equal(y, "string"); } } -f2(z,undefined); +f2(z, undefined); -let bar:unknown = 555; +let bar: unknown = 555; function f3(x: unknown, y?: {} | null | undefined) { y = x; - Assert.equal(y,555); + Assert.equal(y, 555); } -f3(bar,null); +f3(bar, null); function ensureNotNull(x: T) { if (x != null){ Assert.isNumber(x); } } -let run:unknown = 111; -ensureNotNull(run); - - - +let run: unknown = 111; +ensureNotNull(run); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.8/improved_inference_for_infer_types_in_template_string_types/improved_inference_for_infer_types_in_template_string_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.8/improved_inference_for_infer_types_in_template_string_types/improved_inference_for_infer_types_in_template_string_types.ts index bc733ae4eb..0b4e79cafc 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.8/improved_inference_for_infer_types_in_template_string_types/improved_inference_for_infer_types_in_template_string_types.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.8/improved_inference_for_infer_types_in_template_string_types/improved_inference_for_infer_types_in_template_string_types.ts @@ -24,21 +24,21 @@ import { Assert } from '../../../suite/assert.js' -type TrySetVIfFirst = T extends [infer U extends V, ...unknown[]] ? U : never; -function setFirst(arr: any[], x: TrySetVIfFirst<[T, ...any], V>) { +type myType = T extends [infer U extends V, ...unknown[]] ? U : false; +function func(arr: any[], x: myType<[T, ...any], V>) { arr[0] = x; return arr; } let arr = ["A", "B", "C"]; -let first = setFirst(arr, 65); +let first = func(arr, 65); Assert.equal(JSON.stringify(first), "[65,\"B\",\"C\"]"); -type SomeNum = "100" extends `${infer U extends number}` ? U : never; -type SomeBigInt = "100" extends `${infer U extends bigint}` ? U : never; -type SomeBool = "true" extends `${infer U extends boolean}` ? U : never; -let sn: SomeNum = 100; -let sbi: SomeBigInt = 100n; -let sbool: SomeBool = true; -Assert.equal(sn, 100); -Assert.equal(sbi, 100n); +type N = "10" extends `${infer U extends number}` ? U : false; +type Bi = "string" extends `${infer U extends string}` ? U : false; +type Bool = "true" extends `${infer U extends boolean}` ? U : false; +let sn: N = 10; +let sbi: Bi = "string"; +let sbool: Bool = true; +Assert.equal(sn, 10); +Assert.equal(sbi, "string"); Assert.equal(sbool, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts index fe0946a3fe..9d6d409248 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts @@ -30,9 +30,7 @@ declare type DF3 = (a: number, b?: number) => string; declare function fun1(): void; declare function fun2(a: number): string; const dFun1: DF1 = () => { Assert.isString("dFun1"); } - const dFun2: DF2 = (a: string, b: string) => { Assert.isString("dFun2"); return a + b; } - const dFun3: DF3 = (a: number, b?: number) => { let c: any; if (b != undefined) { @@ -44,7 +42,6 @@ const dFun3: DF3 = (a: number, b?: number) => { Assert.isString("dFun3"); return "$" + c; } - dFun1(); Assert.equal(dFun2("A", "B"), 'AB'); -Assert.equal(dFun3(10, 20), "$30"); +Assert.equal(dFun3(10, 20), "$30"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_namespace_declarations/ambient_namespace_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_namespace_declarations/ambient_namespace_declarations.ts index 50a4a5d529..ccc60c491c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_namespace_declarations/ambient_namespace_declarations.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_namespace_declarations/ambient_namespace_declarations.ts @@ -33,4 +33,4 @@ declare namespace AmbientNamespace { } } var colorI: AmbientNamespace.ColorInterface = { Red: 0, Green: 1, Blue: 2 }; -Assert.equal(JSON.stringify(colorI), '{"Red":0,"Green":1,"Blue":2}'); +Assert.equal(JSON.stringify(colorI), '{"Red":0,"Green":1,"Blue":2}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_1.ts index 2db8f0b7bc..6052602a32 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_1.ts @@ -19,7 +19,7 @@ isCurrent: true ---*/ - + import { Assert } from "../../../../suite/assert.js" declare module AMD1 { @@ -29,6 +29,5 @@ declare module AMD1 { a1_2: number; } } - var am2: AMD1.AMD1IF = { a1_1: "am2", a1_2: 123 }; -Assert.equal(JSON.stringify(am2), '{"a1_1":"am2","a1_2":123}'); +Assert.equal(JSON.stringify(am2), '{"a1_1":"am2","a1_2":123}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts index 877c0341d7..d5bc6b046c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts @@ -37,8 +37,7 @@ declare module AMD3_2 { } export var AMD2Var1: string; } - var am3_1: AMD3_1.AMD3_1IF = { a3_1: false, a3_2: 0 }; var am3_2: AMD3_2.AMD3_2IF = { a3_1: true, a3_2: "T" }; Assert.equal(JSON.stringify(am3_1), '{"a3_1":false,"a3_2":0}'); -Assert.equal(JSON.stringify(am3_2), '{"a3_1":true,"a3_2":"T"}'); +Assert.equal(JSON.stringify(am3_2), '{"a3_1":true,"a3_2":"T"}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_1.ts index 6bec3bd20b..1064bbb2b1 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_1.ts @@ -24,18 +24,13 @@ import { Assert } from '../../../../suite/assert.js' -// name denotes a value -var X: string = "X is string"; -Assert.equal("X is string1", X + "1"); - -// name denotes a type -type X = String | Number; -var x: X = "xx"; +let a: string = "a is string"; +Assert.equal("a is string1", a + "1"); +type a = String; +let x: a = "xx"; Assert.equal("xx", x); - -// name denotes a namespace -namespace X { - export type Y = string; +namespace a { + export type b = string; } -var y: X.Y = "ystr"; +let y: a.b = "ystr"; Assert.equal("ystr", y); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_2.ts index 1b4586c4ea..8452726f3c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_2.ts @@ -28,15 +28,14 @@ import { Assert } from '../../../../suite/assert.js' -class C { - x: string; - constructor(x: string) { - this.x = x; +class Myclass { + a: string; + constructor(a: string) { + this.a = a; } } -var c: C = new C("x"); -Assert.equal(c.x, "x"); - +var c: Myclass = new Myclass("x"); +Assert.equal(c.a, "x"); enum WeekDay { MON = 1, TUE, @@ -49,8 +48,7 @@ enum WeekDay { type a = WeekDay; var mon: a = WeekDay.MON; Assert.equal(mon, 1); - -namespace N { +namespace X { export let x: string = "x"; } -Assert.equal(N.x, "x"); +Assert.equal(X.x, "x"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/computed_property_names/computed_property_names_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/computed_property_names/computed_property_names_1.ts index 855ee181ed..48d8ce5dde 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/computed_property_names/computed_property_names_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/computed_property_names/computed_property_names_1.ts @@ -26,9 +26,7 @@ import { Assert } from '../../../../../suite/assert.js' class ComputedName { - // computed property name with a well-known symbol name have a simple literal type aa: 1 | undefined; - // computed property name have a simple literal type ["address"]: string; constructor(x: string, y: 1) { this.address = x; @@ -42,7 +40,5 @@ class ComputedName { var c: ComputedName = new ComputedName("address No1", 1); Assert.equal(1, c.aa); Assert.equal("address No1", c.address); - -// computed property name with in object literal var objectliteral = { ["xx" + "123".length]: 22, name: "string" }; -Assert.equal(22, objectliteral.xx3); +Assert.equal(22, objectliteral.xx3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/property_names/property_names_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/property_names/property_names_1.ts index 4dfc8a2dea..f362919197 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/property_names/property_names_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/property_names/property_names_1.ts @@ -41,7 +41,6 @@ class Property { this.as = "as"; } } - var p: Property = new Property(); Assert.equal("break", p.break); Assert.equal(12, p["with blank"]); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_1.ts index eb7ca5582b..6661d96beb 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_1.ts @@ -25,4 +25,4 @@ function any(): string { return "any"; }; Assert.isFunction(any); -Assert.equal(any(), "any"); +Assert.equal(any(), "any"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_2.ts index 765a4646cd..0af022ed9d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_2.ts @@ -22,4 +22,4 @@ import { Assert } from '../../../../../../suite/assert.js' var any: string = "any"; -Assert.equal(any, "any"); +Assert.equal(any, "any"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_1.ts index 2a84c8f1f4..ff57ecbf01 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_1.ts @@ -25,4 +25,4 @@ function boolean(): number { return 0; } Assert.isFunction(boolean); -Assert.equal(boolean(), 0); +Assert.equal(boolean(), 0); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_2.ts index 16b81ee496..9743e8b5f3 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_2.ts @@ -22,4 +22,4 @@ import { Assert } from '../../../../../../suite/assert.js' var boolean: number = 0; -Assert.equal(boolean, 0); +Assert.equal(boolean, 0); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_1.ts index 48c432e0f4..7dbc611da4 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_1.ts @@ -25,4 +25,4 @@ function number(): string { return "number"; } Assert.isFunction(number); -Assert.equal(number(), "number"); +Assert.equal(number(), "number"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_2.ts index fb82eab8a2..6de94bd7c0 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_2.ts @@ -22,4 +22,4 @@ import { Assert } from '../../../../../../suite/assert.js' var number: string = "number"; -Assert.equal(number, "number"); +Assert.equal(number, "number"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_1.ts index 12b23f8e42..d21a11ece2 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_1.ts @@ -24,4 +24,4 @@ import { Assert } from '../../../../../../suite/assert.js' function string(): number { return 10; } -Assert.equal(string(), 10); +Assert.equal(string(), 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_2.ts index ae0243b991..f45a26812e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_2.ts @@ -22,4 +22,4 @@ import { Assert } from '../../../../../../suite/assert.js' var string: number = 10; -Assert.equal(string, 10); +Assert.equal(string, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_1.ts index 291cc64563..c99b03bda8 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_1.ts @@ -24,4 +24,4 @@ import { Assert } from '../../../../../../suite/assert.js' function symbol(): string { return "symbol" } -Assert.equal(symbol(), "symbol"); +Assert.equal(symbol(), "symbol"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_2.ts index 0b2457ac18..280713ec74 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_2.ts @@ -22,4 +22,4 @@ import { Assert } from '../../../../../../suite/assert.js' var symbol: string = "any"; -Assert.equal(symbol, "any"); +Assert.equal(symbol, "any"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_2.ts index 4931884599..7cae555f33 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_2.ts @@ -21,9 +21,7 @@ import { Assert } from '../../../../../../suite/assert.js' - function module1(): string { return "module"; } - -Assert.equal(module1(), "module"); +Assert.equal(module1(), "module"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/let_scope.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/let_scope.ts index 43f18b965b..83064a87ad 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/let_scope.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/let_scope.ts @@ -24,7 +24,6 @@ import { Assert } from '../../../../suite/assert.js' let GlobalScope = 1; - function someFunc() { let FunctionScope = 2; if (true) { diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_1.ts index 3b43a9df4b..15310bd065 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_1.ts @@ -26,12 +26,10 @@ var a: number = 1024; let b: string = 'NARC'; Assert.equal(a, 1024); Assert.equal(b, 'NARC'); - function add() { return a + b; } Assert.equal(add(), '1024NARC'); - class OUT { out: string; constructor() { @@ -39,4 +37,4 @@ class OUT { } } let out = new OUT(); -Assert.equal(out.out, 'NARC1024'); +Assert.equal(out.out, 'NARC1024'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_10.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_10.ts new file mode 100644 index 0000000000..065f551a2f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_10.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The scope of a local let, const, class, interface, type alias, or enum declaration declared immediately within the body of a function-like declaration is the body of that function-like declaration. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../../suite/assert.js"; + +function sfun() { + let s = 1024; + Assert.equal(s, 1024); + const n = 'NARC' + Assert.equal(n, 'NARC'); + class C { + c: number; + constructor(c: number) { + this.c = c; + } + } + let cc = new C(5); + Assert.equal(cc.c, 5); + + type S = keyof C | keyof number & keyof string; + let ss: S = "valueOf"; + Assert.equal(ss, "valueOf"); +} +sfun(); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_11.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_11.ts new file mode 100644 index 0000000000..bbcae824b7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_11.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The scope of a local let, const, class, interface, type alias, or enum declaration declared immediately within a statement block is the body of that statement block. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../../suite/assert.js"; + +{ + var v: number = 999; + Assert.equal(v, 999); + let l: number = 333; + Assert.equal(l, 333); + const con: "NARC" = 'NARC'; + Assert.equal(con, "NARC"); + class cla { + c: number = 1024; + } + let cl = new cla(); + Assert.equal(cl.c, 1024); + + interface I { + color: [number, number, number]; + } + let i: I = { color: [255, 0, 0] }; + Assert.equal(i.color[0], 255); + + type CV = keyof I | keyof string & keyof number; + let cv: CV = "color"; + Assert.equal(cv, "color"); +} +{ + Assert.equal(v / 9, 111); +} \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_12.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_12.ts new file mode 100644 index 0000000000..b7861c07e4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_12.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Scopes may overlap, for example through nesting of namespaces and functions. When the scopes of two names overlap, + the name with the innermost declaration takes precedence and access to the outer name is either not possible or only possible by qualification. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../../suite/assert.js"; + +var x: number = -1; + +namespace X { + export var x: number = 1024; + export function X() { + var x: string = 'NARC'; + Assert.equal(x, 'NARC'); + return x; + } + Assert.equal(x, 1024); + Assert.equal(X(), 'NARC'); +} +Assert.equal(x, -1); +Assert.equal(X.x, 1024); +Assert.equal(X.X(), 'NARC'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_1.ts new file mode 100644 index 0000000000..4fd14b6b00 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_1.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When an identifier is resolved as a PrimaryExpression, only names in scope with a value meaning are considered and other names are ignored. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../../suite/assert.js"; + +var v: number = 333; +interface v { + v: string; +} +Assert.equal(v, 333); + +let v0: v = { v: "v" }; +Assert.equal(v0.v, "v"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_2.ts new file mode 100644 index 0000000000..91dd3be53d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_2.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When an identifier is resolved as a TypeName, only names in scope with a type meaning are considered and other names are ignored. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../../suite/assert.js"; + +var s: string = "TypeScript"; +type s = Number; +Assert.equal(s, "TypeScript"); + +let s0: s = 1408; +Assert.equal(s0, 1408); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_3.ts new file mode 100644 index 0000000000..0d15c523cc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_3.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When an identifier is resolved as a NamespaceName, only names in scope with a namespace meaning are considered and other names are ignored. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../../suite/assert.js"; + +var f: boolean = false; +namespace f { + export interface f { + f: boolean; + } +} +Assert.equal(f, false); + +let f0: f.f = { f: true }; +Assert.equal(f0.f, true); + +type e = String; +namespace e { + export var e: number = -1; +} +let e0: e = 'NARC'; +Assert.equal(e0, 'NARC'); + +Assert.equal(e.e, -1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/namespace.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_14.ts similarity index 74% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/namespace.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_14.ts index 956317955e..56e85d91ab 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/namespace.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_14.ts @@ -15,22 +15,23 @@ /**--- description: > locally declared entities in a namespace are closer in scope than exported entities declared in other namespace declarations for the same namespace. - module: ESNext isCurrent: true ---*/ -import { Assert } from '../../../../suite/assert.js' +import { Assert } from "../../../../suite/assert.js"; -var num = 1; -namespace ns { - export var num = 2; - Assert.equal(num, 2); +var i: number = -1; +namespace I { + export var i: number = 0; + Assert.equal(i, 0); } -namespace ns { - Assert.equal(num, 2); +namespace I { + Assert.equal(i, 0); } -namespace ns { - var num = 3; - Assert.equal(num, 3); -} \ No newline at end of file +namespace I { + var i: number = 1; + Assert.equal(i, 1); +} +Assert.equal(i, -1); +Assert.equal(I.i, 0); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_2.ts index e9923de9b8..e265a38f58 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_2.ts @@ -21,7 +21,7 @@ import { Assert } from "../../../../suite/assert.js"; -import * as m from "./scopes_2_m.js"; +import * as m from "./scopes_2_m.js"; Assert.equal(m.m3, 1970); Assert.equal(m.m4, 'EXP'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_2_m.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_2_m.ts index ede92c6b7a..5f0e91b86d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_2_m.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_2_m.ts @@ -26,7 +26,6 @@ let m1 = 1969; var m2 = 'XO'; Assert.equal(m1, 1969); Assert.equal(m2, 'XO'); - export let m3 = 1970; export var m4 = 'EXP'; Assert.equal(m3, 1970); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_5.ts new file mode 100644 index 0000000000..cfc5708d18 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_5.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The scope of a type parameter name declared in a class or interface declaration is that entire declaration, + including constraints, extends clause, implements clause, and declaration body, but not including static member declarations. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../../suite/assert.js"; + +class C { + str: string = 'NAME'; + num: number = 333; + static flag: boolean = false; + fun() { + return [this.str, this.num, C.flag]; + } +} +let c = new C(); +Assert.equal(c.str, "NAME"); +Assert.equal(c.num, 333); +Assert.equal(C.flag, false); +interface I { + s: string; + n: number; +} +let i: I = { s: 'STR', n: 999 }; +Assert.equal(i.s, "STR"); +Assert.equal(i.n, 999); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/support_for_UMD_module_definitions/math-lib.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_6.ts similarity index 64% rename from es2panda/test/ts_extra_tests/test_ts_cases/2.0/support_for_UMD_module_definitions/math-lib.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_6.ts index 5a1e8dc778..b59a100269 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/support_for_UMD_module_definitions/math-lib.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_6.ts @@ -12,18 +12,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/**--- + description: > + The scope of a type parameter name declared in a type alias declaration is that entire type alias declaration. + module: ESNext + isCurrent: true + ---*/ -export function isPrime(x: number): boolean; +import { Assert } from "../../../../suite/assert.js"; -export function isPrime(x: number): boolean { - if (x < 2) { - return false; - } - for (let i = 2; i <= x / 2; i++) { - if (x % i == 0) { - return false; - } - } - return true; -}; \ No newline at end of file +type Tp = keyof T & keyof U; +let k: Tp = "toString"; +Assert.equal(k, "toString"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_7.ts new file mode 100644 index 0000000000..acb7c4447d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_7.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The scope of a member name declared in an enum declaration is the body of that declaration and every enum declaration with the same root and the same qualified name relative to that root. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../../suite/assert.js"; + +enum E1 { + a, b, c, +} +enum E2 { + a, b, c, +} +enum E1 { + d = 0, +} +Assert.equal(E1.a, 0); +Assert.equal(E2.a, 0); +Assert.equal(E1.d, 0); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_8.ts new file mode 100644 index 0000000000..28cb75dab5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_8.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The scope of a parameter name declared in a call or construct signature is the remainder of the signature declaration. + If the signature is part of a function-like declaration with a body (including a function declaration, constructor declaration, member function declaration, member accessor declaration, function expression, or arrow function), + the scope includes the body of that function-like declaration. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../../suite/assert.js"; + +class CC { + a: number; b: number; + constructor(a: number, b: number) { + let c1: number = a + b; + let c2: number = a * b; + Assert.isNumber(c1); + Assert.isNumber(c2); + this.a = c1 + c2; + this.b = c2 - c1; + } +} +let cc = new CC(3, 5); +Assert.equal(cc.a, 23); +Assert.equal(cc.b, 7); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_9.ts new file mode 100644 index 0000000000..2b736f6a31 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_9.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The scope of a local var or function name declared anywhere in the body of a function-like declaration is the body of that function-like declaration. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../../suite/assert.js"; + +function sfun(x: number, y: number): number { + var a: number = x + y; + let b: number = x - y; + function subfun() { + return a * b; + } + return subfun(); +} +Assert.equal(sfun(3, 5), -16); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/var_scope.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/var_scope.ts index 1346a9affe..ea58de6d9a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/var_scope.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/var_scope.ts @@ -22,7 +22,6 @@ import { Assert } from '../../../../suite/assert.js' var GlobalScope = 1; - function someFunc() { var FunctionScope = 2; if (true) { diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_body/class_body.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_body/class_body.ts index 6a1e79eb5c..39d207bce6 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_body/class_body.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_body/class_body.ts @@ -23,7 +23,7 @@ import { Assert } from '../../../../../suite/assert.js' -class P { +class Compute { num1: number; num2: number; constructor(num1: number, num2: number) { @@ -33,22 +33,21 @@ class P { public hypot() { return Math.sqrt(this.num1 * this.num1 + this.num2 * this.num2); } - static initial = new P(0, 0); + static initial = new Compute(0, 0); } -let p: P = new P(10, 20); +let p: Compute = new Compute(10, 20); Assert.equal(10, p.num1); Assert.equal(20, p.num2); -Assert.equal(0, P.initial.num1); -Assert.equal(0, P.initial.num2); +Assert.equal(0, Compute.initial.num1); +Assert.equal(0, Compute.initial.num2); +let p2:Compute = new Compute(4,3) +Assert.equal(5,p2.hypot()) -// zero constructor class Circle { radius: number = 1; } let c = new Circle(); Assert.equal(c.radius, 1); - -// more constructor type TypeSummation = { width?: number; height?: number; @@ -76,4 +75,4 @@ let sun = new summation(4, 5); Assert.equal(sun.sunArea(), 20); let obj: TypeSummation = { width: 10, height: 2 }; let sun2 = new summation(obj); -Assert.equal(sun2.sunArea(), 20); +Assert.equal(sun2.sunArea(), 20); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_1.ts index adad411ecc..8f381f91de 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_1.ts @@ -21,13 +21,10 @@ import { Assert } from '../../../../suite/assert.js' class Rectangle { - // constructor constructor(public height: number, public width: number) { }; - // Getter get area() { return this.calcArea() } - // Method calcArea() { return this.height * this.width; } diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_3.ts index 4fa83ed5b0..ea990b064c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_3.ts @@ -29,7 +29,7 @@ class MyClass { return this.field; } } -class P { +class Compute { constructor(public num1: number, public num2: number) { } public hypot() { return Math.sqrt(this.num1 * this.num1 + this.num2 * this.num2); @@ -37,14 +37,19 @@ class P { } let mc1: MyClass = new MyClass("a"); Assert.equal("a", mc1.field); +Assert.equal("a",mc1.getFieldName()); let mc2: MyClass = new MyClass(1); Assert.equal(1, mc2.field); +Assert.equal(1,mc2.getFieldName()); let mc3: MyClass = new MyClass(false); Assert.equal(false, mc3.field); -let p: P = new P(10, 20); -let mc4: MyClass

= new MyClass

(p); -Assert.equal(10, mc4.field.num1); -Assert.equal(20, mc4.field.num2); +Assert.equal(false,mc3.getFieldName()); +let p: Compute = new Compute(8, 6); +let mc4: MyClass = new MyClass(p); +Assert.equal(8, mc4.field.num1); +Assert.equal(6, mc4.field.num2); +Assert.equal(10,mc4.field.hypot()); + let obj: object = { x: 1, y: 2 diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts index 791b4f0873..eb1837f98c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts @@ -22,14 +22,14 @@ import { Assert } from '../../../../../suite/assert.js' -class P { +class Compute { constructor(public num1: number, public num2: number) { } public hypot() { return Math.sqrt(this.num1 * this.num1 + this.num2 * this.num2); } - static initial = new P(0, 0); + static initial = new Compute(0, 0); } -class ChildP extends P { +class ChildP extends Compute { constructor(public x: number, public y: number) { super(x, y); } @@ -44,4 +44,9 @@ Assert.equal(20, pChild.y); pChild.move(); Assert.equal(11, pChild.x); Assert.equal(21, pChild.y); -Assert.equal(0, ChildP.initial.num1); \ No newline at end of file +Assert.equal(0, ChildP.initial.num1); + +let count:ChildP = new ChildP(4,3); +Assert.equal(4, count.x); +Assert.equal(3, count.y); +Assert.equal(5,count.hypot()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts index e04b080942..cb1f816f5e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts @@ -22,17 +22,18 @@ import { Assert } from '../../../../../suite/assert.js' -class P1 { +class Compute { constructor(public num1: number, public num2: number) { } public hypot() { return Math.sqrt(this.num1 * this.num1 + this.num2 * this.num2); } - static initial = new P1(0, 0); + static initial = new Compute(0, 0); } -let p: P1 = new P1(10, 20); -Assert.equal(10, p.num1); -Assert.equal(20, p.num2); -// the implements1 +let p: Compute = new Compute(4, 3); +Assert.equal(4, p.num1); +Assert.equal(3, p.num2); +Assert.equal(5,p.hypot()) + interface InterP1 { x: number; y: number; @@ -44,10 +45,11 @@ class P2 implements InterP1 { return x * y; } } -let ipoint = new P2(); -Assert.equal(1, ipoint.x); -Assert.equal(1, ipoint.y); -// the implements2 +let Ip = new P2(); +Assert.equal(1, Ip.x); +Assert.equal(1, Ip.y); +Assert.equal(2,Ip.setarea(1,2)) + interface InterP2 { Area(x: number, y: number): number; } diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts index 9e6bff1da3..57caf3cfdb 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts @@ -30,7 +30,6 @@ class Addx { return this; } } -// the extends class ChildAddx extends Addx { constructor(public x: number) { super(x); @@ -44,7 +43,7 @@ let childadd: ChildAddx = new ChildAddx(10); Assert.equal(11, childadd.move().x); let a: Addx = childadd.move(); Assert.equal(13, a.add().x); -// the implements + interface InterAddx { x: number; } @@ -59,6 +58,7 @@ let b1 = new Addx2(); Assert.equal(2, b1.setadd().x); let interb1: InterAddx = b1.setadd(); Assert.equal(3, interb1.x); + interface InterP { Area(x: number, y: number): number; } diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts index c10cde2600..4075363ecc 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts @@ -24,11 +24,13 @@ import { Assert } from '../../../../../suite/assert.js' -class P { +class Compute { constructor(public num1: number, public num2: number) { } - public hypot() { } - static initial = new P(0, 0); + public hypot() {return "what are you doing?" } + static initial = new Compute(0, 0); } -let p = new P(1, 2); +let p = new Compute(1, 2); let obj = new Object(); -Assert.equal(p.toString(), obj.toString()); \ No newline at end of file +Assert.equal(p.toString(), obj.toString()); +Assert.isString(p.hypot()); +Assert.equal(0,Compute.initial.num1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_2.ts index 44f4e7b5db..1faf83d9b3 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_2.ts @@ -56,4 +56,4 @@ class ColorPoint2 extends Point1 { let co2 = new ColorPoint2("a", "b"); Assert.equal(co2.x, "a"); Assert.equal(co2.y, "b"); -Assert.equal(co2.toString(), "a b"); +Assert.equal(co2.toString(), "a b"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_3.ts index 4c6e6d93f1..a7a294bd11 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_3.ts @@ -42,4 +42,4 @@ class Foo2 { } let foo2 = new Foo2(2, "go"); Assert.equal(foo2.x, 2); -Assert.equal(foo2.y, "go"); +Assert.equal(foo2.y, "go"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts index 8ce8ea743b..79d6a94147 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts @@ -44,7 +44,9 @@ class Animal1 { } } } -let tt1 = new Animal1(); +let tt1 = new Animal1("caihua1",NaN); +Assert.equal(tt1.name,"caihua1"); +Assert.equal(tt1.age, undefined); let tt2 = new Animal1("caihua2", 12); Assert.equal(tt2.name, "caihua2"); Assert.equal(tt2.age, 12); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/super_calls/super_calls.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/super_calls/super_calls.ts index c1488a9aa0..c938838f71 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/super_calls/super_calls.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/super_calls/super_calls.ts @@ -38,4 +38,4 @@ class HueP extends P { let p1 = new HueP(1, 2, "red"); Assert.equal(p1.num1, 1); Assert.equal(p1.num2, 2); -Assert.equal(p1.hue, "red"); +Assert.equal(p1.hue, "red"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_1.ts index 90da40dc5c..25ab9d6c7f 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_1.ts @@ -22,7 +22,7 @@ import { Assert } from '../../../../../suite/assert.js' -class A { +class Ra { public x: number; public y: number; constructor(x: number, y: number) { @@ -41,7 +41,7 @@ class A { return this.x + this.y; } } -class B extends A { +class Rb extends Ra { public z: number; constructor(x: number, y: number, z: number) { super(x, y); @@ -52,8 +52,8 @@ class B extends A { return this; } } -let a: A = new A(1, 1); -let b: B = new B(1, 1, 1); +let a: Ra = new Ra(1, 1); +let b: Rb = new Rb(1, 1, 1); Assert.equal(a.addx().x, 2); Assert.equal(a.addx().y, 1); Assert.equal(a.addx().add(), 5); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_2.ts index ae51565b7d..7686b8c6f2 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_2.ts @@ -22,7 +22,7 @@ import { Assert } from '../../../../../suite/assert.js' -class A { +class Ra { public h_x: number; constructor(h_x: number) { this.h_x = h_x; @@ -35,11 +35,11 @@ class A { } static h_s: string = "aa"; } -let aa: A = new A(1); +let aa: Ra = new Ra(1); Assert.equal(aa.h_x, 1); aa.h_f(); Assert.equal(aa.h_x, 2); -class B extends A { +class Rb extends Ra { public h_y: number; constructor(h_x: number, h_y: number) { super(h_x); @@ -47,24 +47,24 @@ class B extends A { } public h_g(): boolean { return false; } } -let bb: B = new B(1, 2); +let bb: Rb = new Rb(1, 2); Assert.equal(bb.h_x, 1); Assert.equal(bb.h_y, 2); bb.h_f(); Assert.equal(bb.h_x, 2); Assert.equal(bb.h_g(), false); -interface C { +interface Rc { h_x: number; h_f: () => void; h_g: () => any; } -let c: C = aa; +let c: Rc = aa; Assert.equal(c.h_g(), 2); -interface D { +interface Rd { h_x: number; h_y: number; h_f: () => void; h_g: () => boolean; } -let d: D = bb; +let d: Rd = bb; Assert.equal(d.h_g(), false); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_3.ts index 2122f76c3e..570be6c8ad 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_3.ts @@ -22,7 +22,7 @@ import { Assert } from '../../../../../suite/assert.js' -class A { +class Ra { public x: number = 10; private y: number = 10; protected z: number = 10; @@ -44,17 +44,17 @@ class A { return this.g(); } } -class B extends A { +class Rb extends Ra { protected z: number = 20; protected g(): boolean { return true; } } -let a: A = new A(); +let a: Ra = new Ra(); Assert.equal(a.x, 10); Assert.equal(a.gety(), 10); Assert.equal(a.getz(), 10); Assert.equal(a.getg(), false); Assert.equal(a.f().x, 11); -let b: B = new B(); +let b: Rb = new Rb(); Assert.equal(b.x, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_4.ts index 3b586b165e..3ccc9e317d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_4.ts @@ -50,4 +50,4 @@ class summation { const sun = new summation(4, 5); Assert.equal(sun.sunArea(), 20); const obj: TypeSummation = { width: 10, height: 20 }; -Assert.equal(new summation(obj).sunArea(), 200); +Assert.equal(new summation(obj).sunArea(), 200); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts index 8755124016..388c1f2f77 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts @@ -26,11 +26,19 @@ import { Assert } from '../../../../../suite/assert.js' class P { constructor(public pro1: T1, public pro2: T2) { } } -class TwoArrays extends P { } +class TwoArrays extends P { + +} let x: number = 1; let y: number = 2; let p = new P(x, y); +let one = [3,4,5]; +let two = [6,7,8] +let twoArrays = new TwoArrays(one,two); +Assert.equal(twoArrays.pro1,one); +Assert.equal(twoArrays.pro2,two) Assert.equal(p.pro1, 1); + let x2: string = "one"; let y2: string = "two"; let p2 = new P(x2, y2); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_4.ts index c1abb4f2e9..1b55b81f59 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_4.ts @@ -46,7 +46,6 @@ class myClass extends MyClass { this.num = num; } } - let myTest = new myClass(5); Assert.equal(myTest.num, 5); Assert.equal(myTest.get(), 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts index 868d4977ef..478ebc4313 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts @@ -48,14 +48,14 @@ Assert.equal(counter.Result, 3); counter.subtract(); Assert.equal(counter.subtract(), counter); Assert.equal(counter.Result, 1); -class P { +class Compute { constructor(public num1: number, public num2: number) { } public hypot() { return Math.sqrt(this.num1 * this.num1 + this.num2 * this.num2); } - static initial = new P(0, 0); + static initial = new Compute(0, 0); } -class ChildP extends P { +class ChildP extends Compute { constructor(public x: number, public y: number, public z: number) { super(x, y); this.z = z; @@ -72,4 +72,6 @@ childp.move(); Assert.equal(childp.x, 2); Assert.equal(childp.y, 3); Assert.equal(childp.z, 4); -Assert.equal(childp.move(), childp); \ No newline at end of file +Assert.equal(childp.move(), childp); +let count: ChildP = new ChildP(4,3,1); +Assert.equal(count.hypot(),5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts index af88dcf3bd..234ee19637 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts @@ -46,4 +46,6 @@ let b: number = Person.tool1(); Assert.equal(b, 20); let c: number = Person.foo; Assert.equal(c, 20); -Assert.equal(Person, Person.tool2()); \ No newline at end of file +Assert.equal(Person, Person.tool2()); +let d: Person = new Person(); +Assert.equal(d.tool(),30); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts index 1b7743d93e..d510c3a50b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts @@ -44,4 +44,4 @@ Assert.equal(Point.z, 3); let cp = new ColoredPoint(4, 5, "red"); Assert.equal(cp.x, 4); Assert.equal(cp.y, 5); -Assert.equal(ColoredPoint.r, 10); +Assert.equal(ColoredPoint.r, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts index bd4cc35054..04668be36d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts @@ -22,7 +22,6 @@ import { Assert } from '../../../../../suite/assert.js' - class A { public x: number = 1; public y: string = "name"; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_1.ts index ffc966b8c7..0d7d617c1b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_1.ts @@ -22,9 +22,9 @@ import { Assert } from '../../../../suite/assert.js' -class Point { +class Compute { constructor(public x: number, public y: number) { } - public distance(p1: Point, p2: Point) { + public range(p1: Compute, p2: Compute) { let dx = p1.x - p2.x; let dy = p1.y - p2.y; return Math.sqrt(dx * dx + dy * dy); @@ -32,12 +32,12 @@ class Point { static getx() { return this.x; } - static origin = new Point(0, 0); + static origin = new Compute(0, 0); static x: number = 10; } -let p1: Point = new Point(2, 2); -let p2: Point = new Point(1, 1); -Assert.equal(p1.distance(p1, p2), Math.sqrt(2)); -Assert.equal(Point.getx(), 10); -Assert.equal(p1.distance(p1, Point.origin), Math.sqrt(8)); -Assert.equal(Point.x, 10); +let p1: Compute = new Compute(2, 2); +let p2: Compute = new Compute(1, 1); +Assert.equal(p1.range(p1, p2), Math.sqrt(2)); +Assert.equal(Compute.getx(), 10); +Assert.equal(p1.range(p1, Compute.origin), Math.sqrt(8)); +Assert.equal(Compute.x, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_3.ts index 66ce721daa..5c6d1e7108 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_3.ts @@ -22,16 +22,16 @@ import { Assert } from '../../../../suite/assert.js' -class Point { +class Compute { public x: number; public y: number; constructor(x: number, y: number) { this.x = x; this.y = y; } - static origin = new Point(0, 0); + static origin = new Compute(0, 0); } -class ColoredPoint extends Point { +class ColoredPoint extends Compute { constructor(x: number, y: number, public color: string) { super(x, y); } @@ -39,5 +39,5 @@ class ColoredPoint extends Point { Assert.equal(ColoredPoint.prototype.color, undefined); Assert.equal(ColoredPoint.prototype.x, undefined); Assert.equal(ColoredPoint.prototype.y, undefined); -Assert.equal(Point.prototype.x, undefined); -Assert.equal(Point.prototype.y, undefined); \ No newline at end of file +Assert.equal(Compute.prototype.x, undefined); +Assert.equal(Compute.prototype.y, undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/constant_enum_declarations/constant_enum_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/constant_enum_declarations/constant_enum_declarations.ts index 9642e89210..efa9c6661e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/constant_enum_declarations/constant_enum_declarations.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/constant_enum_declarations/constant_enum_declarations.ts @@ -38,7 +38,6 @@ Assert.equal(CED["None"], -1); Assert.equal(CED["False"], 0); Assert.equal(CED["True"], 1); Assert.equal(CED["DEF"], 1024); - enum CED_COPY { None = -1, False, @@ -48,4 +47,4 @@ enum CED_COPY { Assert.equal(CED_COPY[-1], "None"); Assert.equal(CED_COPY[0], "False"); Assert.equal(CED_COPY[1], "True"); -Assert.equal(CED_COPY[1024], "DEF"); +Assert.equal(CED_COPY[1024], "DEF"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_1.ts index 4e2ac9a503..3cad444c10 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_1.ts @@ -48,4 +48,4 @@ namespace NSP { Assert.equal(NSP.A.A1, 0); Assert.equal(NSP.A.A2, 1); Assert.equal(NSP.A.A3, 2); -Assert.equal(NSP.A.A4, 3); +Assert.equal(NSP.A.A4, 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_2.ts index dc03af4393..f7efe29be5 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_2.ts @@ -34,7 +34,6 @@ Assert.equal(T1.Tex0, 0); Assert.equal(T1.Tex1, 1); Assert.equal(T1.Tex2, 2); Assert.equal(T1.Tex3, 3); - enum T2 { Tex0, Tex1, @@ -46,4 +45,4 @@ enum T2 { Assert.equal(T2.Tex0, 0); Assert.equal(T2.Tex1, 1); Assert.equal(T2.Tex2, 2); -Assert.equal(T2.Tex3, 3); +Assert.equal(T2.Tex3, 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_1.ts index 95a0b14894..cca34206d6 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_1.ts @@ -26,15 +26,14 @@ import { Assert } from '../../../../suite/assert.js' -enum Colour { - Red = 0xff0000, - Green = 0x00ff00, - Blue = 0x0000ff, +enum Animal { + cat = 0xff0000, + dog = 0x00ff00, + pig = 0x0000ff, } -Assert.isString(Colour[0xff0000]); -Assert.equal(Colour[0x00ff00], "Green"); -Assert.isNumber(Colour.Blue); - +Assert.isString(Animal[0xff0000]); +Assert.equal(Animal[0x00ff00], "dog"); +Assert.isNumber(Animal.pig); enum TypeABC { A, B, @@ -43,4 +42,4 @@ enum TypeABC { var index = TypeABC.A; Assert.equal(TypeABC.A, 0); Assert.equal(TypeABC.B, index + 1); -Assert.equal(TypeABC.C, index + 2); +Assert.equal(TypeABC.C, index + 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_2.ts index aba1af9ae1..78e6995c4d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_2.ts @@ -23,12 +23,12 @@ import { Assert } from '../../../../suite/assert.js' -enum Colour { - Red = 0xff0000, - Green = 0x00ff00, - Blue = 0x0000ff, +enum Animal { + Cat = 0xff0000, + Dog = 0x00ff00, + Pig = 0x0000ff, } -var c = Colour.Green; -Assert.isNumber(c); -Assert.isString(Colour[c]); -Assert.equal("Green", Colour[c]); +var dog = Animal.Dog; +Assert.isNumber(dog); +Assert.isString(Animal[dog]); +Assert.equal("Dog", Animal[dog]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_3.ts index dba107b1aa..481799d7ca 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_3.ts @@ -32,7 +32,6 @@ const enum H_Date { Saturday = 'Satur', Sunday = 'Sun' } - let h_date1 = H_Date.Monday; Assert.equal(h_date1, 'Mon'); let h_date2 = H_Date.Tuesday; @@ -47,7 +46,6 @@ let h_date6 = H_Date.Saturday; Assert.equal(h_date6, 'Satur'); let h_date7 = H_Date.Sunday; Assert.equal(h_date7, 'Sun'); - const enum H_Odd { a = 1, b = a + 2, diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_members/enum_members_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_members/enum_members_1.ts index 1029a371f9..acdd698b50 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_members/enum_members_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_members/enum_members_1.ts @@ -29,7 +29,6 @@ import { Assert } from '../../../../suite/assert.js' function toLength(str: string): number { return str.length; } - enum ABCList { A, B, diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_1.ts index 4eb081a6e4..32a416d660 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_1.ts @@ -31,4 +31,4 @@ interface MyArray { } const myArray: MyArray = [42, "hello"]; Assert.isNumber(myArray[0]); -Assert.isString(myArray[1]); +Assert.isString(myArray[1]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_2.ts index 135558a50a..c940dea5fe 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_2.ts @@ -28,7 +28,6 @@ var MyArray: { [1]: string; [2]: string; } = [1, "aaa", "bbb"]; - Assert.isNumber(MyArray[0]); Assert.isString(MyArray[1]); -Assert.isString(MyArray[2]); +Assert.isString(MyArray[2]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_3.ts index bc7e8b9a23..270c64722a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_3.ts @@ -23,8 +23,4 @@ import { Assert } from '../../../../suite/assert.js' const emptyArray: any[] = []; - -const emptyStringArray: string[] = emptyArray; -const emptyNumberArray: number[] = emptyArray; - -Assert.isUndefined(emptyArray[0]); +Assert.isUndefined(emptyArray[0]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_4.ts index 66154b81b3..81a90b45b6 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_4.ts @@ -26,8 +26,7 @@ import { Assert } from '../../../../suite/assert.js' let myTuple: [string, number] = ["hello", 42]; Assert.isString(myTuple[0]); Assert.isNumber(myTuple[1]); - function foo(pair: [string, number]) { return pair } -Assert.equal(JSON.stringify(foo(["hello", 42])), '["hello",42]'); +Assert.equal(JSON.stringify(foo(["hello", 42])), '["hello",42]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_5.ts index eb4daa9801..b620932604 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_5.ts @@ -24,6 +24,5 @@ import { Assert } from '../../../../suite/assert.js' let [x, y]: [string, number] = ["hello", 42]; - Assert.isString(x); -Assert.isNumber(y); +Assert.isNumber(y); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_6.ts index 08e40223f0..4e51f2a244 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_6.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_6.ts @@ -24,7 +24,6 @@ import { Assert } from '../../../../suite/assert.js' let arr = [1, 2, ...["three", "four"], 5]; - Assert.isNumber(arr[0]); Assert.isNumber(arr[1]); Assert.isString(arr[2]); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_1.ts index 659c79a89d..d2d837d32c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_1.ts @@ -25,12 +25,10 @@ import { Assert } from '../../../../suite/assert.js' const addNumbers = (num1: number, num2: number): number => { return num1 + num2; }; - const result1 = addNumbers(5, 10); Assert.equal(result1, 15); - const greet = (name: string) => { return name; }; const result2 = greet("Alice"); -Assert.equal(result2, "Alice"); +Assert.equal(result2, "Alice"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_2.ts index ca38ddf8de..d483ad0bc0 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_2.ts @@ -29,15 +29,12 @@ const myFunctionA = (num: string): string => { }; const resultA = myFunctionA("hello,world"); Assert.equal(resultA, "hello,world"); - const myFunctionB: () => string = () => "hello,world"; const resultB = myFunctionB(); Assert.equal(resultB, "hello,world"); - let getTempItem = (id: any) => ({ id: id, name: "Temp" }); const TempAResult = getTempItem(123); Assert.equal(TempAResult.id, 123); - let getTempItemB = function (id: any) { return { id: id, @@ -45,4 +42,4 @@ let getTempItemB = function (id: any) { }; }; const TempBResult = getTempItemB(123); -Assert.equal(TempBResult.id, 123); +Assert.equal(TempBResult.id, 123); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_4.ts index c238cf8a5f..c4573dceab 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_4.ts @@ -25,17 +25,16 @@ import { Assert } from '../../../../suite/assert.js' class ToAlert { information = "Have a good time!"; - start() { + F() { let for_this = this; - setTimeout(function() { - for_this.information="sad boy"; + setTimeout(function () { + for_this.information = "sad boy"; }, 2250); - Assert.notEqual(for_this.information,"sad boy") + Assert.notEqual(for_this.information, "sad boy") } }; -let Hwa = new ToAlert(); -Hwa.start(); - -Hwa.information = "boy!"; -Assert.isString(Hwa.information) -Assert.equal(Hwa.information,"boy!") \ No newline at end of file +let a = new ToAlert(); +a.F(); +a.information = "boy!"; +Assert.isString(a.information); +Assert.equal(a.information, "boy!"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts index 3d3e893eb2..2dba576210 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts @@ -27,4 +27,5 @@ import { Assert } from '../../../../../suite/assert.js' var sum: Function = function (x: number, y: number) { return x + y } -Assert.equal(typeof sum, 'function'); \ No newline at end of file +let result = sum(5, 10); +Assert.equal(result, 15); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts index d6f2c30785..9f13b77ca8 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts @@ -28,6 +28,7 @@ import { Assert } from '../../../../../suite/assert.js' var a: number = 10 var b: number = 20 var x = a + b +Assert.equal(x, 30) enum e1 { A, B, diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts index 641ea0bb0f..46e7e069c5 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts @@ -30,7 +30,6 @@ var c: boolean = false var d: string = 'str' var e: number = 10 var f: any = 20 -// the result is of type Any var w = a + b var v = a + f Assert.isString(w) diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts index 1cf90e27ae..616c89f5c7 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts @@ -32,7 +32,6 @@ var g: string = 'a' var h: string = 'b' var i: undefined = undefined var j: undefined = undefined - var k = a && b Assert.isString(k) var l = c && d diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_congruence_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_congruence_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_congruence_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_congruence_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_equal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_equal_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_equal_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_equal_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_greater_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_greater_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_greater_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_greater_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_greater_or_equal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_greater_or_equal_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_greater_or_equal_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_greater_or_equal_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_incongruence_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_incongruence_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_incongruence_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_incongruence_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_less_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_less_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_less_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_less_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_less_or_equal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_less_or_equal_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_less_or_equal_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_less_or_equal_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_unequal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_unequal_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less_lessEqual/the_unequal_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_unequal_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts index ace7f6ebff..d188766c18 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts @@ -33,8 +33,9 @@ interface B { function isString(k: A | B) { if ('num' in k) { Assert.isBoolean('num' in k) - return false + return false; } - return true + return true; } -isString({ num: 20 }); \ No newline at end of file +let result = isString({ num: 20 }); +Assert.isFalse(result); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_and_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_and_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_and_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_and_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_division_method_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_division_method_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_division_method_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_division_method_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_left_shift_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_left_shift_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_left_shift_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_left_shift_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_multiplication_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_multiplication_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_multiplication_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_multiplication_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_or_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_or_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_or_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_or_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_remainder_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_remainder_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_remainder_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_remainder_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_right_shift_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_right_shift_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_right_shift_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_right_shift_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_subtraction_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_subtraction_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_subtraction_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_subtraction_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_unsigned_shift_to_the_right.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_unsigned_shift_to_the_right.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_unsigned_shift_to_the_right.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_unsigned_shift_to_the_right.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_xor_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_xor_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem/the_xor_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_xor_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts index 7d0360cf06..2b960edfea 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts @@ -33,7 +33,6 @@ var g: string = 'a' var h: string = 'b' var i: undefined = undefined var j: undefined = undefined - var k = a || b Assert.isNumber(k) var l = c || d diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/class_expressions/class_expressions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/class_expressions/class_expressions_1.ts index b5a715ff96..e768b3d9eb 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/class_expressions/class_expressions_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/class_expressions/class_expressions_1.ts @@ -32,7 +32,6 @@ var Square = class { }; var square = new Square(5, 10); Assert.equal(square.acreage, 50); - class Reflmpl { public readonly _v = true; constructor(private _rawValue: T, public _shaw = false) { @@ -52,7 +51,6 @@ class Reflmpl { this._shaw = newShaw; } } - let ref = new Reflmpl(10, true); Assert.equal(ref.value, 10); -Assert.equal(ref._shaw, true); +Assert.equal(ref._shaw, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts index 6b58147511..0868288f8f 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts @@ -23,19 +23,14 @@ import { Assert } from '../../../../suite/assert.js' -// In a variable let a: number a = 10 Assert.isNumber(a) - -// In a parameter function fun(x: string) { let y = x + 'ing' return y } Assert.isString(fun('str')) - -// In a member declaration interface Obj { name: string age: number diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts index beea4246b1..5c60fa1c14 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts @@ -26,7 +26,6 @@ var a: number = 10 var b: number = 5 var c = (a + b) * (a - b) Assert.isNumber(c) - interface Foo { num: number str: string diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts index 7b8ddd0423..76c8be1985 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts @@ -31,7 +31,6 @@ var average1 = function (a: number, b: number) { } var rela1 = sum || average1 Assert.equal(typeof rela1, 'function') - var average2: number = 10 var rela2 = average2 || sum Assert.equal(typeof rela2, 'number'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts index 35360dd5fe..d15947b430 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts @@ -29,8 +29,6 @@ function add(x: number, y: number): number { } let sum = add(10, 20) Assert.isNumber(sum) - - type Fun = (a: number, b: number) => number function fun(fn: Fun, x: number, y: number) { return fn(x, y) diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts index 7799d6bf1f..f910a94072 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts @@ -24,26 +24,25 @@ import { Assert } from '../../../../suite/assert.js' -class Developer { - private _language = '' - private _tasks: string[] = [] - get language() { - return this._language +class C { + private _str = '' + private _arr: string[] = [] + get func() { + return this._str } - set language(value: string) { - this._language = value + set func(value: string) { + this._str= value } - get tasks() { - return this._tasks + get f() { + return this._arr } - set tasks(value: string[]) { - this._tasks = value + set f(value: string[]) { + this._arr = value } } - -const dev = new Developer() -dev.language = 'TS' -Assert.isString(dev.language) -dev.tasks = ['develop', 'test'] -dev.tasks.push('ship') -Assert.equal(dev.tasks, 'develop,test,ship'); \ No newline at end of file +const c = new C() +c.func= 'TS' +Assert.isString(c.func) +c.f = ['develop', 'test'] +c.f.push('ship') +Assert.equal(c.f, 'develop,test,ship'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts index 0c2192e4d6..2036c81219 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts @@ -22,21 +22,23 @@ import { Assert } from '../../../../suite/assert.js' -const state: Record = { - isPending: false, - results: ['a', 'b', 'c'] +const obj: Record = { + boo: false, + arr: ['a', 'b', 'c'] } - -const useValue = (name: string): [T, Function] => { - const value: T = state[name] - const setValue: Function = (value: T): void => { - state[name] = value +const para = (str: string): [T, Function] => { + const result1: T = obj[str]; + const result2: Function = (value: T) => { + obj[str] = value; + return obj[str]; } - return [value, setValue] + return [result1, result2]; } - -const [isPending, setIsPending] = useValue('isPending') -const [results, setResults] = useValue('results') - -Assert.isBoolean(isPending) -Assert.equal(results, 'a,b,c'); \ No newline at end of file +const [boo, mem2] = para('boo'); +const [arr, mem4] = para('arr'); +Assert.isBoolean(boo); +Assert.equal(arr, 'a,b,c'); +let x = mem2(true); +let y = mem4(false); +Assert.isTrue(x); +Assert.isFalse(y); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts index a7fee45284..f93221902a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts @@ -22,18 +22,14 @@ import { Assert } from '../../../../../suite/assert.js' -// a call to 'f' with two arguments, 'g < A' and 'B > (7)' var h_g: number = 5 var h_A: number = 3 var h_B: number = 6 function f(a: any, b?: any) { return a } - Assert.isFalse(f(h_g < h_A, h_B > 7)) Assert.isFalse(f(h_g < h_A, h_B > +(7))) - -// a call to a generic function 'g' with two type arguments and one regular argument type A1 = number type B1 = number function g1(a: T) { @@ -42,5 +38,4 @@ function g1(a: T) { function f1(a: any, b?: any) { return a } - Assert.equal(f1(g1(7)), 7); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts index 2412ff911d..3a90a3f947 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts @@ -36,9 +36,7 @@ interface IFnCall { const foo: IFnCall = function () { return 'a' } - var f = foo(() => { return 'f' }, 10) - Assert.equal(f, 'a'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts index ba79874724..90e344f3e6 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts @@ -35,7 +35,7 @@ interface IFnCall { const foo: IFnCall = function (fn:any) { return fn('xiao') } -const res = foo((name) => { +const res = foo((name:string) => { return name }, 10) Assert.isString(res); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_3.ts index c08c0e56c8..a1c2449b15 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_3.ts @@ -26,13 +26,13 @@ import { Assert } from '../../../../../suite/assert.js' interface IfnCall { - (name: string, age: string): string + (name: string, age: number): string } interface IfnCall { (str: string, num: string): string } -const foo: IfnCall = function (name: string, age: string) { +const foo: IfnCall = function (name:any, age:any):string { return name + ":" + age } -var f = foo("xiao", "18") +let f = foo("xiao", 18) Assert.isString(f); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts index 2620024e11..e15e385d2d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts @@ -27,6 +27,5 @@ type t = number | string function select(h_x: T, h_y: T): T { return Math.random() < 0.5 ? h_x : h_y; } - var x = select(10, 20); Assert.isNumber(x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts index 022076cc4e..7be3d43ad5 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts @@ -26,12 +26,10 @@ import { Assert } from '../../../../../suite/assert.js' -type c = number | undefined type t = number | null | undefined function select(h_x: T, h_y: T): T { return Math.random() < 0.5 ? h_x : h_y; } - var y = select(10, undefined) if (typeof y === 'number') { Assert.isNumber(y); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts index 40e5662030..bc01b5cd3f 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts @@ -23,12 +23,11 @@ import { Assert } from '../../../../../suite/assert.js' -function h_map(h_a: T[], h_f: (h_x: T) => U): U[] { - var cons: U[] = []; - for (var i = 0; i < h_a.length; i++) cons.push(h_f(h_a[i])); +function f(x: T[], fun: (a: T) => U): U[] { + let cons: U[] = []; + for (let i = 0; i < x.length; i++) cons.push(fun(x[i])); return cons; } - -var h_names = ["xiao", "xi", "xin"]; -var h_lengths = h_map(h_names, str => str.length); -Assert.equal(typeof h_lengths, 'object'); \ No newline at end of file +let xx = ["xiao", "xi", "xin"]; +let yy = f(xx, str => str.length); +Assert.isObject(yy); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts index 0c9f7f3b93..02658f4176 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts @@ -25,14 +25,13 @@ import { Assert } from '../../../../../suite/assert.js' -function h_zip(x: S[], y: T[], group: (x: S) => (y: T) => U): U[] { - var length = Math.max(x.length, y.length); - var cons: U[] = []; - for (var i = 0; i < length; i++) cons.push(group(x[i])(y[i])); +function fun(a: S[], b: T[], group: (a: S) => (b: T) => U): U[] { + let length = Math.max(a.length, b.length); + let cons: U[] = []; + for (let i = 0; i < length; i++) cons.push(group(a[i])(b[i])); return cons; } - -var h_names = ["Peter", "Paul", "Mary"]; -var h_ages = [7, 9, 12]; -var h_pairs = h_zip(h_names, h_ages, str => num => ({ name: str, age: num })); -Assert.equal(typeof h_pairs, 'object'); \ No newline at end of file +let xx = ["sum", "con", "say"]; +let yy = [1, 2, 3]; +let zz = fun(xx, yy, str => num => ({ name: str, age: num })); +Assert.isObject(zz); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_1.ts index e96d3bb579..36ee6593be 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_1.ts @@ -33,4 +33,4 @@ const fn2 = (x: number): number => x * 2; const result1 = myFunction(fn1, 123); const result2 = myFunction(fn2, 456); Assert.equal(result1, "Hello,123"); -Assert.equal(result2, 912); +Assert.equal(result2, 912); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_2.ts index bb29d63f53..b7dd95ab05 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_2.ts @@ -27,8 +27,8 @@ type MyFunctionType = (x: number, y: number) => number; function myFunction(fn: MyFunctionType) { return fn(2, 3); } -const add: MyFunctionType = function (x:number, y:number) { +const add: MyFunctionType = function (x: number, y: number) { return x + y; }; const result = myFunction(add); -Assert.equal(result, 5); +Assert.equal(result, 5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_3.ts index 42112a3510..efdd1e8157 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_3.ts @@ -30,9 +30,8 @@ function myFunction(obj: MyType) { const result = fn(123, "hello"); Assert.isTrue(result); } - let h_x: MyType = { - fn: function func(x: number, y: string) { + fn: function func() { return true; } } diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/class.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/class.ts index 70d0bea0b4..8341313a6e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/class.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/class.ts @@ -22,14 +22,12 @@ import { Assert } from '../../../../suite/assert.js' class Car { - // field engine: string; agelimit: number; - // Constructor function constructor(engine: string, agelimit: number) { this.engine = engine; this.agelimit = agelimit; } } -let car = new Car("Benci", 2); +let car = new Car("Benchi", 2); Assert.equal(car.agelimit, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/name_space.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/name_space.ts index 7e0c424ff4..dedd915898 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/name_space.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/name_space.ts @@ -35,9 +35,8 @@ namespace MyNamespace { Assert.equal(person.age, 30); } } - const person: MyNamespace.Person = { name: "John", age: 30, }; -MyNamespace.greet(person); +MyNamespace.greet(person); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/parameter.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/parameter.ts index bc2916424a..050218eaba 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/parameter.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/parameter.ts @@ -33,3 +33,5 @@ class paramMethod { } } let newparam = new paramMethod("xiaoli", 18); +Assert.equal(newparam.age, 18); +Assert.equal(newparam.person, "xiaoli"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/variable.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/variable.ts index d6af27202a..b95d6d191a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/variable.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/variable.ts @@ -24,6 +24,5 @@ import { Assert } from '../../../../suite/assert.js' let uname: string = "Runoob"; let score1: number = 50; - Assert.isString(uname); -Assert.isNumber(score1); +Assert.isNumber(score1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/boolean.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/boolean.ts index fb4fec1795..cfd5252d24 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/boolean.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/boolean.ts @@ -22,4 +22,4 @@ import { Assert } from '../../../../suite/assert.js' Assert.equal(typeof false, "boolean"); -Assert.equal(typeof true, "boolean"); +Assert.equal(typeof true, "boolean"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/null.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/null.ts index 8878a4debc..f014d23c13 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/null.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/null.ts @@ -22,5 +22,4 @@ import { Assert } from '../../../../suite/assert.js' -// TODO judge the null type Assert.isTrue(typeof null === "object"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/regexp.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/regexp.ts index 772c21d027..bb9d378516 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/regexp.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/regexp.ts @@ -22,4 +22,4 @@ import { Assert } from '../../../../suite/assert.js' -Assert.isTrue(/hello world/ instanceof RegExp); +Assert.isTrue(/hello world/ instanceof RegExp); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_3.ts index 235f41d28d..da9cb63d05 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_3.ts @@ -38,4 +38,4 @@ let animal: { }; Assert.equal(animal.run, 23); animal.run = 66; -Assert.equal(animal.run, 66); +Assert.equal(animal.run, 66); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_4.ts index a9756ff419..6cc575365a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_4.ts @@ -38,4 +38,4 @@ const P: Iperson = { }; Assert.equal(P.gender, "male"); P.gender = "female"; -Assert.equal(P.gender, "female"); +Assert.equal(P.gender, "female"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_5.ts index 0f4a068064..1fb51bc016 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_5.ts @@ -36,4 +36,4 @@ class Example { } const example = new Example(); example.count = 1; -Assert.isNumber(example.count); +Assert.isNumber(example.count); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_6.ts index 0559529d12..93dcb3d62e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_6.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_6.ts @@ -33,4 +33,4 @@ class Person { } const person = new Person(); person.name = "john"; -Assert.isString(person.name); +Assert.isString(person.name); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/parentheses/parentheses.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/parentheses/parentheses.ts index 4900910bb9..2037db98f1 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/parentheses/parentheses.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/parentheses/parentheses.ts @@ -26,16 +26,13 @@ import { Assert } from '../../../../suite/assert.js' let addparent = function (n1: number, n2: number): number { return n1 + n2; }; -// is equivalent to let addnoparent = (n1: number, n2: number): number => n1 + n2; let isCorrect = addparent(11, 22) === addnoparent(11, 22); Assert.isTrue(isCorrect); - let foo: string = "hello"; let bar: string = foo; Assert.isString(foo); Assert.isString(bar); - const obj = { value: "world" }; function printValue(value: string) { Assert.equal(value, "world"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_access_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_access_2.ts index 6291224769..fc245d3fd9 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_access_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_access_2.ts @@ -33,7 +33,6 @@ sites.sayHello = function () { return "hello " + sites.site1; }; Assert.isString(sites.sayHello()); - class Person { name: string; age: string; @@ -48,4 +47,4 @@ const person2 = { name: "Bob", age: 35 }; person1["greet"](); Assert.equal(person1.name, "Alice"); Assert.equal(person2.name, "Bob"); -Assert.equal(person1.age, 30); +Assert.equal(person1.age, 30); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_1.ts index 89bd7d7ae3..1f2250adf5 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_1.ts @@ -23,13 +23,8 @@ import { Assert } from '../../../../suite/assert.js' let myVariable: any = { name: "John", age: 30 }; - Assert.isUndefined(myVariable.firstName); - myVariable = 42; - Assert.isUndefined(myVariable.length); - myVariable = "Hello World"; - -Assert.isUndefined(myVariable.foo); +Assert.isUndefined(myVariable.foo); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_type_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_type_6.ts index 7591a9ebf7..87e41c23ce 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_type_6.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_type_6.ts @@ -26,21 +26,17 @@ import { Assert } from '../../../../suite/assert.js' interface MyObject { [key: string]: number; } - const obj: MyObject = { prop1: 1, prop2: 2, prop3: 3, }; - -const prop = "prop2"; -const value1 = obj[prop]; const value2 = obj[0]; +Assert.equal(value2, undefined); enum MyEnum { Prop1 = "prop1", Prop2 = "prop2", Prop3 = "prop3", } - const value3 = obj[MyEnum.Prop3]; -Assert.equal(value3, 3); +Assert.equal(value3, 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_apprent_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_apprent_5.ts index 8435894554..0cfac703a8 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_apprent_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_apprent_5.ts @@ -26,12 +26,10 @@ import { Assert } from '../../../../suite/assert.js' interface ExampleObject { [key: string]: string; } - const myObject: ExampleObject = { foo: "bar", baz: "qux", }; - const myIndex: any = "foo"; const myValue = myObject[myIndex]; -Assert.isString(myValue); +Assert.isString(myValue); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_index_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_index_4.ts index bd5f6d03f8..8a09d000a1 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_index_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_index_4.ts @@ -26,14 +26,11 @@ import { Assert } from '../../../../suite/assert.js' interface MyObj { [index: number]: string; } - const obj: MyObj = { 0: "foo", 1: "bar", 2: "baz", }; - Assert.equal(obj[0], "foo"); Assert.equal(obj[1], "bar"); -Assert.equal(obj[2], "baz"); - +Assert.equal(obj[2], "baz"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_string_number_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_string_number_3.ts index f35f919394..aa506e77e6 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_string_number_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_string_number_3.ts @@ -31,19 +31,15 @@ const sites = { Assert.isString(sites["siteName"]); Assert.isNumber(sites["site2"]); Assert.isFunction(sites["sayHello"]); - interface Person { name: string; age: number; city: string; } - const person: Person = { name: "Alice", age: 30, city: "New York", }; - Assert.equal(person["name"], "Alice"); - -Assert.equal(person["city"], "New York"); +Assert.equal(person["city"], "New York"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_1.ts index 413969cb9a..5dcfd232d9 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_1.ts @@ -26,7 +26,6 @@ var myType = { h_str: 'string', h_bool: true }; - var h_s = myType['h_str']; Assert.isString(h_s); var h_b = myType['h_bool']; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_comma_operator/the_comma_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_comma_operator/the_comma_operator.ts index 5ad6c8dc4e..37a507f5bd 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_comma_operator/the_comma_operator.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_comma_operator/the_comma_operator.ts @@ -22,10 +22,15 @@ import { Assert } from '../../../../suite/assert.js' -let x: number = 20 -let y: boolean = true -let z: string = 'a' -let com1 = (x++, y) -let com2 = (x++, z = z + 'b') -Assert.isBoolean(com1) -Assert.isString(com2); \ No newline at end of file +let x: number = 20; +let y: boolean = true; +let z: string = 'a'; +function add(arg1: number, arg2: number) { + return arg1 + arg2; +} +let com1 = (x++, y); +let com2 = (x++, z = z + 'b'); +let com3 = (x++, add(3, 5)); +Assert.isBoolean(com1); +Assert.isString(com2); +Assert.isNumber(com3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts index f660174baf..01e70a8364 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts @@ -25,7 +25,6 @@ import { Assert } from '../../../../suite/assert.js' var x: number = 10 var y: string = '5' -// the typeof z is string | number var z = Math.random() < 0.5 ? x + y : y && x if (typeof z === 'number') { z++ diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_1.ts index 36d96aed31..535700c2c4 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_1.ts @@ -27,4 +27,4 @@ C = function (this: any, x: number, y: number) { this.sum = x + y; }; const myObject = new C(2, 3); -Assert.equal(myObject.sum, 5); +Assert.equal(myObject.sum, 5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_2.ts index 46a0602f6f..42c673b0a3 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_2.ts @@ -30,7 +30,6 @@ class Person { interface Animal { speak(): void; } - class Dog implements Animal { speak() { return "Woof!"; @@ -39,4 +38,4 @@ class Dog implements Animal { const p = new Person("Alice", 30); const d = new Dog(); Assert.isString(p.name); -Assert.equal(d.speak(), "Woof!"); +Assert.equal(d.speak(), "Woof!"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_3.ts index 5483e09f17..7ee5e319d5 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_3.ts @@ -28,10 +28,8 @@ class Person { return "Hello,world"; } } - let person: Person = new Person(); Assert.equal(person.sayHello(), "Hello,world"); - let person2: any = new Person(); person2.sayHello(); -Assert.equal(person2.sayHello(), "Hello,world"); +Assert.equal(person2.sayHello(), "Hello,world"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_4.ts index f90ab907a6..5b764b4ce4 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_4.ts @@ -24,15 +24,6 @@ import { Assert } from '../../../../suite/assert.js' -class MyClass { - constructor() { - return "MyClass"; - } -} - -const myInstance = new MyClass(); - - class Person { name: string; age: number; @@ -43,7 +34,6 @@ class Person { } const john = new Person("john", 30); Assert.isString(john.name, "john"); - class Box { contents: T; constructor(value: T) { @@ -51,4 +41,4 @@ class Box { } } const myBox = new Box("hello"); -Assert.equal(myBox.contents, "hello"); +Assert.equal(myBox.contents, "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/arguments.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/arguments.ts index 7d49a0cbfc..9658263480 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/arguments.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/arguments.ts @@ -34,4 +34,4 @@ class SubClass extends SuperClass { } } const sub = new SubClass("hello"); -Assert.equal(sub.value, "hello"); +Assert.equal(sub.value, "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts index 8446aea645..3243840b97 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts @@ -37,4 +37,4 @@ class StringSubClass extends SubClass { } } const sub = new StringSubClass(); -Assert.equal(sub.value, "hello"); +Assert.equal(sub.value, "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/super_calls.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/super_calls.ts index cf8fb43cbc..800f6cfd45 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/super_calls.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/super_calls.ts @@ -38,7 +38,6 @@ class Animal { return `${this.name} makes a noise`; } } - class Dog extends Animal { private breed: string; constructor(name: any, breed: any) { @@ -53,4 +52,4 @@ class Dog extends Animal { } const d = new Dog("Fido", "Golden Retriever"); d.extendsSpeak(); -Assert.isString(d.extendsSpeak(), "Golden Retriever"); +Assert.isString(d.extendsSpeak(), "Golden Retriever"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/derived_class_access.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/derived_class_access.ts index 559f084c59..6bdba30fa5 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/derived_class_access.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/derived_class_access.ts @@ -23,19 +23,18 @@ import { Assert } from '../../../../../suite/assert.js' -class AnimalA { +class Animal { public makeSound(): string { return "the animal makes"; } } - -class DogA extends AnimalA { +class Dog extends Animal { public makeSound(): string { super.makeSound(); Assert.equal(super.makeSound(), "the animal makes"); return "the dog barks"; } } -const myDog = new DogA(); +const myDog = new Dog(); myDog.makeSound(); Assert.equal(myDog.makeSound(), "the dog barks"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_1.ts index 10829b5ecb..663ce484fb 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_1.ts @@ -23,7 +23,6 @@ import { Assert } from '../../../../suite/assert.js' -// CHECK this in constructor class Dog { name: string; age: number; @@ -40,14 +39,9 @@ class Dog { return this.getName() + " is bark"; } } - var dog = new Dog("doggy", 7); Assert.equal(dog.age, 7); - -// CHECK this in instance member function and instance member accessor Assert.equal("doggy is bark", dog.bark()) - -// CHECK this in instance member variable initializer class Duck { age: number = this.b; constructor(private readonly b: number) { diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_1.ts index 82c489c038..b689915f3d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_1.ts @@ -24,15 +24,12 @@ import { Assert } from '../../../../suite/assert.js' class Form { } - class Square extends Form { } - function createForm(mold: string): Form { if (mold === "square") { return new Square() } return Square } - -var square = createForm("square") +let square = createForm("square") Assert.equal(JSON.stringify(square), '{}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_2.ts index 6befd8d74f..2ec039e832 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_2.ts @@ -37,7 +37,6 @@ function doStuff(arg: Foo | Bar) { } else { Assert.equal(arg.bar, 123) } - } doStuff(new Foo()) doStuff(new Bar()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_1.ts index 775be14936..eb50e94c8d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_1.ts @@ -25,11 +25,15 @@ import { Assert } from '../../../../suite/assert.js' function h_func(h_x: number | string) { if (typeof h_x === 'string') { - Assert.isString(h_x) + Assert.isString(h_x); + return h_x.length; } else { - Assert.isNumber(h_x) + Assert.isNumber(h_x); + return h_x - 5; } } -h_func('string') -h_func(10); \ No newline at end of file +let a = h_func('string'); +Assert.equal(a, 6); +let b = h_func(10); +Assert.equal(b, 5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_10.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_10.ts index 087eba5420..53c3fab073 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_10.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_10.ts @@ -38,7 +38,6 @@ var b = f1('s') Assert.isString(b) var c = f1(undefined) Assert.isUndefined(c) - function f2(x: string | number | boolean) { if (typeof x === "undefined") { return undefined diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_11.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_11.ts index 17dd287fe2..c026b9e2f7 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_11.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_11.ts @@ -24,13 +24,17 @@ import { Assert } from '../../../../suite/assert.js' -function h_func(h_x: string | number) { - if (typeof h_x !== "string") { - Assert.isNumber(h_x) +function func(x: string | number) { + if (typeof x !== "string") { + Assert.isNumber(x); + return x + 1; } else { - Assert.isString(h_x) + Assert.isString(x); + return x.length; } } -h_func(10) -h_func('s'); \ No newline at end of file +let a = func(10); +Assert.equal(a, 11); +let b = func('s'); +Assert.equal(b, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_12.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_12.ts index e74b28969b..c96d649482 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_12.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_12.ts @@ -24,13 +24,17 @@ import { Assert } from '../../../../suite/assert.js' -function h_func(h_x: string | number) { - if (!(typeof h_x === "string")) { - Assert.isNumber(h_x) +function func(x: string | number) { + if (!(typeof x === "string")) { + Assert.isNumber(x); + return x + 1; } else { - Assert.isString(h_x) + Assert.isString(x); + return x.length; } } -h_func(10) -h_func('s'); \ No newline at end of file +let a = func(10); +Assert.equal(a, 11); +let b = func('s'); +Assert.equal(b, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_13.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_13.ts index 2c176aad23..9fcd82bbf2 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_13.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_13.ts @@ -25,17 +25,17 @@ import { Assert } from '../../../../suite/assert.js' -function h_func(h_x: string | number | undefined) { - if (typeof h_x === "string" && typeof h_x === "number") { - return undefined +function func(x: string | number | undefined) { + if (typeof x === "string" && typeof x === "number") { + return undefined; } else { - return h_x + return x; } } -var h_a = h_func(10) -Assert.isNumber(h_a) -var h_b = h_func('s') -Assert.isString(h_b) -var h_c = h_func(undefined) -Assert.isUndefined(h_c); \ No newline at end of file +let a = func(10); +Assert.isNumber(a); +let b = func('s'); +Assert.isString(b); +let c = func(undefined); +Assert.isUndefined(c); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_14.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_14.ts index 57be49076b..23569fbadb 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_14.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_14.ts @@ -25,17 +25,17 @@ import { Assert } from '../../../../suite/assert.js' -function h_func(h_x: string | number | undefined) { - if (typeof h_x === "string" || typeof h_x === "number") { - return h_x +function func(x: string | number | undefined) { + if (typeof x === "string" || typeof x === "number") { + return x; } else { - return undefined + return undefined; } } -var h_a = h_func(10) -Assert.isNumber(h_a) -var h_b = h_func('s') -Assert.isString(h_b) -var h_c = h_func(undefined) -Assert.isUndefined(h_c); \ No newline at end of file +let a = func(10); +Assert.isNumber(a); +let b = func('s'); +Assert.isString(b); +let c = func(undefined); +Assert.isUndefined(c); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_15.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_15.ts index 76c5846f6d..17c6536000 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_15.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_15.ts @@ -46,8 +46,7 @@ function func(arg: Person | Animal) { Assert.isNumber(arg.height) } } - -var p = new Person('x', 18) -func(p) -var a = new Animal(200, 180) +let p = new Person('x', 18); +func(p); +let a = new Animal(200, 180); func(a); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_2.ts index 8379ef2e6e..a8cc2ce8c1 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_2.ts @@ -26,10 +26,12 @@ import { Assert } from '../../../../suite/assert.js' function h_func(h_x: number | string) { if (typeof h_x === 'string') { - Assert.isString(h_x) + Assert.isString(h_x); + return h_x.length; } else { return h_x + 1 } } -h_func('string'); \ No newline at end of file +let a = h_func('string'); +Assert.equal(a, 6); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_3.ts index 6631b4da40..8b8027f7cd 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_3.ts @@ -26,10 +26,12 @@ import { Assert } from '../../../../suite/assert.js' function h_func(h_x: number | string) { if (!(typeof h_x === 'string')) { - Assert.isNumber(h_x) + Assert.isNumber(h_x); + return h_x; } else { return h_x.length } } -h_func(10); \ No newline at end of file +let a = h_func(10); +Assert.equal(a, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_4.ts index c37c99bf9a..e541f40f7c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_4.ts @@ -24,8 +24,9 @@ import { Assert } from '../../../../suite/assert.js' -function h_process(h_value: number | (() => number)) { - var h_x = typeof h_value == "number" ? h_value : h_value() - Assert.isNumber(h_x) +function func(arg: number | (() => number)) { + let x = typeof arg == "number" ? arg : arg(); + return x; } -h_process(5); \ No newline at end of file +let result = func(5); +Assert.isNumber(result); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_5.ts index 672afeb88e..0cf674657b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_5.ts @@ -24,8 +24,9 @@ import { Assert } from '../../../../suite/assert.js' -function h_process(h_value: number | (() => number)) { - var h_x = typeof h_value !== "number" ? h_value() : h_value - Assert.isNumber(h_x) +function func(arg: number | (() => number)) { + var x = typeof arg !== "number" ? arg() : arg; + return x; } -h_process(5); \ No newline at end of file +let result = func(5); +Assert.isNumber(result); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_6.ts index 3a96973e1a..e0f879aa33 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_6.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_6.ts @@ -15,7 +15,8 @@ /**--- description: > In the right operand of a && operation, - the type of a variable or parameter is narrowed by a type guard in the left o + the type of a variable or parameter is narrowed by a type guard in the left operand when true, + provided neither operand contains assignments to the variable or parameter. module: ESNext isCurrent: true ---*/ diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_8.ts index 3e41132722..0040c18beb 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_8.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_8.ts @@ -50,7 +50,6 @@ function func(arg: Person | Animal) { return arg.weight = 300 } } - var p = new Person(150, 18) Assert.equal(func(p), 18) var a = new Animal(200, 180) diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_9.ts index d6b6357491..7d3ef1a40d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_9.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_9.ts @@ -25,13 +25,17 @@ import { Assert } from '../../../../suite/assert.js' -function h_func(h_x: string | number) { - if (typeof h_x === "string") { - Assert.isString(h_x) +function func(x: string | number) { + if (typeof x === "string") { + Assert.isString(x); + return x.length; } else { - Assert.isNumber(h_x) + Assert.isNumber(x); + return x + 1; } } -h_func(10) -h_func('s'); \ No newline at end of file +let a = func(10); +Assert.equal(a, 11); +let b = func('s'); +Assert.equal(b, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_!_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_!_operator.ts index 87357beb51..56c624381b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_!_operator.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_!_operator.ts @@ -27,8 +27,7 @@ var num1: number = 20 var num2: number = 90 var res = !((num1 > 50) && (num2 > 80)) Assert.isBoolean(res) - -function getValue(): any { +function func(): any { } -var b = !!getValue() +var b = !!func() Assert.isBoolean(b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_++_and_--_operators.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_++_and_--_operators.ts index 9b26a46dc6..ece420a7dd 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_++_and_--_operators.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_++_and_--_operators.ts @@ -23,13 +23,12 @@ import { Assert } from '../../../../suite/assert.js' -var a: any = '10' -a++ -a-- ---a -++a -Assert.isNumber(a) - +var a: any = '10'; +a++; +a--; +--a; +++a; +Assert.isNumber(a); enum e { A, B, @@ -37,8 +36,14 @@ enum e { D } let b = e.A -b++ -b-- -++b ---b -Assert.isNumber(b); \ No newline at end of file +b++; +b--; +++b; +--b; +Assert.isNumber(b); +var c: number = 10; +c++; +++c; +--c; +c--; +Assert.isNumber(c); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_+_and_~_operators.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_+_and_~_operators.ts index 299b7be551..1d08f3e221 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_+_and_~_operators.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_+_and_~_operators.ts @@ -28,7 +28,6 @@ a = a + 1 a = a - 1 a = ~a Assert.isNumber(a) - -function getValue() { } -var n = +getValue() +function func() { } +var n = +func(); Assert.isNumber(n); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_typeof_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_typeof_operator.ts index d56999cb13..06eb874eda 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_typeof_operator.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_typeof_operator.ts @@ -22,8 +22,8 @@ import { Assert } from '../../../../suite/assert.js' -var h_x = 5 -var h_y = typeof h_x -Assert.equal(h_y, 'number') -var h_z: typeof h_x = 10 -Assert.isNumber(h_z); \ No newline at end of file +let aa = 1 +let bb = typeof aa +Assert.equal(bb, 'number') +let cc: typeof aa = 2 +Assert.equal(cc, 2) \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_1.ts index c331d744fe..e5fa6f675c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_1.ts @@ -26,37 +26,31 @@ import { Assert } from '../../../../suite/assert.js' - let pp: Promise = Promise.resolve(1); - async function fetchTest1(): Promise { return await pp; } fetchTest1().then((params) => { Assert.equal(params, 1); }); - async function fetchTest1NoReturnType() { return await pp; } fetchTest1NoReturnType().then((params) => { Assert.equal(params, 1); }); - const fetchTest2 = async (): Promise => { return await pp; }; fetchTest2().then((params) => { Assert.equal(params, 1); }); - const fetchTest2NoReturnType = async () => { return await pp; }; fetchTest2NoReturnType().then((params) => { Assert.equal(params, 1); }); - class Person { async fetchTest3(): Promise { return await pp; @@ -70,4 +64,4 @@ new Person().fetchTest3().then((params) => { }); new Person().fetchTest3NoReturnType().then((params) => { Assert.equal(params, 1); -}); +}); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_3.ts index 3054c731b9..2d547a96f0 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_3.ts @@ -39,7 +39,6 @@ function createAsyncInterator(arr: any[]): AsyncIterator { }, }; } - export function newArray(len: number, step: number = 1) { if (len <= 0) { return [] }; let arr: any[] = []; @@ -67,5 +66,4 @@ async function exp(arr: any[]) { }); } } -exp(arr); - +exp(arr); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_1.ts index 10d99c7ca5..d3a47bc49d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_1.ts @@ -39,11 +39,9 @@ function showInfo({ m_name, m_age }: Person) { Assert.equal(m_age, tt.m_age); } showInfo(tt); - let tt1: Person = new Person("caihua1", 121); let tt2: Person = new Person("caihua2", 122); let person_array: Person[] = [tt1, tt2]; - function showArrayInfo(v_array: Array) { let [tt1, tt2] = v_array; Assert.equal(tt1.m_name, v_array[0].m_name); @@ -51,4 +49,4 @@ function showArrayInfo(v_array: Array) { Assert.equal(tt2.m_name, v_array[1].m_name); Assert.equal(tt2.m_age, v_array[1].m_age); } -showArrayInfo(person_array); +showArrayInfo(person_array); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_2.ts index f304b84cc9..ab5bf3ddd4 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_2.ts @@ -39,5 +39,4 @@ function showInfo(v: Person) { Assert.isNumber(m_age); Assert.equal(m_age, 12); } -showInfo(tt); - +showInfo(tt); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_3.ts index fe87d70581..3c3293c70b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_3.ts @@ -40,4 +40,4 @@ const showInfo: (v: Person) => void = function (v) { Assert.isNumber(m_age); Assert.equal(m_age, 12); }; -showInfo(tt); +showInfo(tt); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts index 8f90e8d1b7..2f9cefa6e8 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts @@ -24,7 +24,6 @@ import { Assert } from '../../../../suite/assert.js' type testStr = "caihua"; - type testStrNum = 12; class Person { m_name: testStr | undefined; @@ -36,7 +35,6 @@ class Person { } else { this.m_name = undefined; } - if (age && typeof age === "number") { this.m_age = age; } else { @@ -45,7 +43,6 @@ class Person { } } let tt: Person = new Person(); - function showInfo(v: Person) { let { m_name = "caihua", @@ -54,4 +51,4 @@ function showInfo(v: Person) { Assert.equal(typeof m_name === "string", true); Assert.equal(typeof m_age === "number", true); } -showInfo(tt); +showInfo(tt); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_5.ts index f432223f8f..cc30604e7e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_5.ts @@ -28,7 +28,6 @@ type cc = { age: number; isJob: boolean; }; -// T is the implied type of that binding pattern function showInfo({ age, name, isJob }: cc) { Assert.isNumber(age); Assert.isBoolean(isJob); @@ -38,4 +37,4 @@ showInfo({ name: "caihua", age: 90, isJob: true, -}); +}); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_6.ts index cf1c560bfb..9e5149f23e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_6.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_6.ts @@ -29,7 +29,6 @@ interface information { place?: [number, number]; brave?: boolean; } - function infor({ title, place, brave }: information) { if (title) { Assert.equal(typeof title == "string", true); @@ -41,7 +40,6 @@ function infor({ title, place, brave }: information) { Assert.equal(typeof brave === "boolean", true); } } - infor({ title: "title" }); infor({ brave: false }); -infor({ place: [0, 1] }); +infor({ place: [0, 1] }); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts index 602be0ad4a..779bec1a95 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts @@ -29,4 +29,4 @@ function test(...v: any[]) { Assert.isNumber(v[1]); Assert.isBoolean(v[2]); } -test("caihua", 90, true); +test("caihua", 90, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_1.ts index 1efd942935..4ea5a16f19 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_1.ts @@ -37,7 +37,6 @@ function add(arg1: string | number, arg2: string | number) { return `${arg1}${arg2}`; } } - Assert.equal(add(0, 1), 1); Assert.equal(add("0", 1), "01"); -Assert.equal(add("0", "1"), "01"); +Assert.equal(add("0", "1"), "01"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_2.ts index ecc449b0f7..686fa6ef76 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_2.ts @@ -29,17 +29,10 @@ export function add1(arg1: string | number, arg2: string | number) { if (typeof arg1 === "number" && typeof arg2 === "number") { return arg1 + arg2; } - if (typeof arg1 === "string" || typeof arg2 === "string") { return `${arg1}${arg2}`; } } - Assert.equal(add1(0, 1), 1); Assert.equal(add1("0", 1), "01"); -Assert.equal(add1("0", "1"), "01"); - -declare function add2(a: string, b: string): string; -declare function add2(a: number, b: number): number; -declare function add2(a: string, b: number): string; -declare function add2(arg1: string | number, arg2: string | number): unknown; +Assert.equal(add1("0", "1"), "01"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_1.ts index b5c753e431..cc139d21f1 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_1.ts @@ -25,9 +25,8 @@ import { Assert } from '../../../../suite/assert.js' function func(h_x: number) { Assert.isNumber(h_x); } -// get function's return type type voidTest = ReturnType; let tt1: void = undefined; let tt2: voidTest = undefined; Assert.equal(tt1, tt2); -Assert.equal(tt1 === tt2, true); +Assert.equal(tt1 === tt2, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_2.ts index ee6f7d0b8d..3180469b8e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_2.ts @@ -35,7 +35,6 @@ function f(x: number) { } } type testType = ReturnType; - type ttStr = testType & string; let tt1: ttStr = "hello"; Assert.isString(tt1); @@ -44,4 +43,4 @@ let tt2: ttBoo = true; Assert.isBoolean(tt2); type ttNum = testType & number; let tt3: ttNum = 1; -Assert.isNumber(tt3); +Assert.isNumber(tt3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_3.ts index df3bfa521a..bbe98cd076 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_3.ts @@ -39,4 +39,4 @@ type cc = ReturnType; let dd: cc = "string"; Assert.isString(dd); dd = true; -Assert.isBoolean(dd); +Assert.isBoolean(dd); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_4.ts index 0d11b60153..15c7e92fda 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_4.ts @@ -38,6 +38,5 @@ function f(x: number, y: Test = { a: 1 }, z = "hello") { z: z, }; } - Assert.equal(f(0).yy.a, 1); -Assert.equal(f(0).z, "hello"); +Assert.equal(f(0).z, "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_5.ts index f98730b2bd..1427e462ac 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_5.ts @@ -25,19 +25,19 @@ import { Assert } from '../../../../suite/assert.js' let a = 3; -function f(x: number = a, y = x * 2, z = x + y) { +function f(n1: number = a, n2 = n1 * 2, n3 = n1 + 2) { let b = 12; function g(xx = b) { return xx; } let c = g(); - return { x, y, z, g: c }; + return { n1, n2, n3, g: c }; } -Assert.equal(f().x, 3); -Assert.equal(f().y, 6); -Assert.equal(f().z, 9); +Assert.equal(f().n1, 3); +Assert.equal(f().n2, 6); +Assert.equal(f().n3, 5); Assert.equal(f().g, 12); -Assert.equal(f(1).x, 1); -Assert.equal(f(1).y, 2); -Assert.equal(f(1).z, 3); -Assert.equal(f(1).g, 12); +Assert.equal(f(1).n1, 1); +Assert.equal(f(1).n2, 2); +Assert.equal(f(1).n3, 3); +Assert.equal(f(1).g, 12); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_overloads/function_overloads_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_overloads/function_overloads_1.ts index 07bee7d2aa..734b89651c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_overloads/function_overloads_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_overloads/function_overloads_1.ts @@ -25,7 +25,6 @@ import { Assert } from '../../../../suite/assert.js' function add(): number; function add(x: number): number; -function add(y: number): number; function add(x: number, y: number): number; function add(x?: number, y?: number): number { let sum: number = 0; @@ -39,4 +38,4 @@ function add(x?: number, y?: number): number { } Assert.equal(add(), 0); Assert.equal(add(1), 1); -Assert.equal(add(1, 1), 2); +Assert.equal(add(1, 1), 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_1.ts index 0acef06292..2f8f1e1c03 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_1.ts @@ -23,7 +23,6 @@ import { Assert } from '../../../../suite/assert.js' let someArray = [1, "string", false]; - for (let item of someArray) { if (typeof item === "number") { Assert.equal(item, 1); @@ -32,4 +31,4 @@ for (let item of someArray) { } else if (typeof item === "boolean") { Assert.equal(item, false); } -}; +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_2.ts index 010ab7c8a6..4601785d81 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_2.ts @@ -41,4 +41,4 @@ Assert.equal(cc.value, 2); Assert.equal(cc.done, false); cc = iterator.next(); Assert.equal(cc.value, undefined); -Assert.equal(cc.done, true); +Assert.equal(cc.done, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_1.ts index 054e367e88..5a4a3a7ae1 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_1.ts @@ -24,15 +24,13 @@ import { Assert } from '../../../../suite/assert.js' type XY = { x: number; y: number }; - function f1(arg: T): T { return arg; } Assert.equal(f1(0), 0); Assert.equal(f1("hello"), "hello"); Assert.equal(f1(true), true); - function f2(arg: T): T { return arg; } -Assert.equal(JSON.stringify(f2<{ x: number, y: number, z: number }>({ x: 0, y: 0, z: 0 })), '{"x":0,"y":0,"z":0}'); +Assert.equal(JSON.stringify(f2<{ x: number, y: number, z: number }>({ x: 0, y: 0, z: 0 })), '{"x":0,"y":0,"z":0}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_2.ts index 36c9e8de0d..4fb699c4f7 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_2.ts @@ -31,4 +31,4 @@ Assert.equal(identity(0), 0); Assert.equal(identity("hello"), "hello"); Assert.equal(identity("hello"), "hello"); Assert.equal(identity(true), true); -Assert.equal(identity(true), true); +Assert.equal(identity(true), true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/type_guard_functions/type_guard_functions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/type_guard_functions/type_guard_functions_1.ts index 8b8a5cd881..538450c5fb 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/type_guard_functions/type_guard_functions_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/type_guard_functions/type_guard_functions_1.ts @@ -29,7 +29,6 @@ class Student { this.age = age; } } - class Teacher { name: string; age: number; @@ -40,7 +39,6 @@ class Teacher { this.job = job; } } - function isTeacher(obj: Student | Teacher): obj is Teacher { return "job" in obj; } @@ -60,10 +58,9 @@ function printInfo(obj: Student | Teacher) { return "student"; } } - let tt: Teacher = new Teacher("caihuaTeacher", 20, "teacher"); let ss: Student = new Student("caihuaStudent", 20); Assert.equal(printInfo(tt), "teacher"); Assert.notEqual(printInfo(tt), "student"); Assert.equal(printInfo(ss), "student"); -Assert.notEqual(printInfo(ss), "teacher"); +Assert.notEqual(printInfo(ss), "teacher"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/return_statements/return_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/return_statements/return_statements.ts index 00e7da8e49..015db368af 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/return_statements/return_statements.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/return_statements/return_statements.ts @@ -27,8 +27,6 @@ function h_f(): (h_x: string) => number { Assert.equal(11, h_f()("openharmony")); - - function testReruen() { for (let i = 0; i < 10; i++) { diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/switch_statements/switch_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/switch_statements/switch_statements.ts index 85a7900c2c..5cd194a4b5 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/switch_statements/switch_statements.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/switch_statements/switch_statements.ts @@ -49,8 +49,6 @@ Assert.equal("c", testSwitch(3)); Assert.equal("d", testSwitch(4)); Assert.equal("e", testSwitch(5)); - - function testSwitchExpression(x: number, y: number) { let outputVar: string; switch (x + y) { diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/3_implied_type/implied_type.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/3_implied_type/implied_type.ts index 83b1c9e814..13157d9199 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/3_implied_type/implied_type.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/3_implied_type/implied_type.ts @@ -25,7 +25,6 @@ var object_name = { key1: "value1" } -// If the declaration specifies an object binding pattern, the implied type is an object type with a set of properties corresponding to the specified binding property declarations. The type of each property is the type implied by its binding property declaration, and a property is optional when its binding property declaration specifies an initializer expression. function f({ aa = {}, b = "hello", c = 3, d = object_name }) { Assert.equal("object", typeof (aa)); Assert.equal("string", typeof (b)); @@ -41,8 +40,6 @@ var objectFun = { }; f(objectFun); - -// If the declaration specifies an array binding pattern without a rest element, the implied type is a tuple type with elements corresponding to the specified binding element declarations. The type of each element is the type implied by its binding element declaration. var [a1, b1, c1, d1] = [1, "hello", true, object_name]; Assert.equal("number", typeof (a1)); @@ -50,7 +47,6 @@ Assert.equal("string", typeof (b1)); Assert.equal("boolean", typeof (c1)); Assert.equal("object", typeof (d1)); -// If the declaration specifies an array binding pattern with a rest element, the implied type is an array type with an element type of Any function testRest(...restElements: any[]): any { Assert.isTrue(restElements.length > 0); return restElements[0]; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/Intersection_Types/Intersection_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/Intersection_Types/Intersection_types_1.ts index f984b6777a..c242e8d390 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/Intersection_Types/Intersection_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/Intersection_Types/Intersection_types_1.ts @@ -30,9 +30,9 @@ interface A1 { interface B1 { str1: string; } -let ns1: A1 & B1 = { num1: 1, str1: "b" }; -Assert.equal(ns1.num1, 1); -Assert.equal(ns1.str1, "b"); +let x: A1 & B1 = { num1: 1, str1: "b" }; +Assert.equal(x.num1, 1); +Assert.equal(x.str1, "b"); enum Color { Red1 = 1, Green1, @@ -44,17 +44,17 @@ interface A2 { interface B2 { str2: Color; } -let ns2: A2 & B2 = { num2: ["a2", 1], str2: Color.Red1 }; -Assert.equal(ns2.num2[0], "a2"); -Assert.equal(ns2.str2, 1); +let x2: A2 & B2 = { num2: ["a2", 1], str2: Color.Red1 }; +Assert.equal(x2.num2[0], "a2"); +Assert.equal(x2.str2, 1); interface A3 { num3: number[]; } interface B3 { str3: boolean; } -let ns3: A3 & B3 = { num3: [1, 2, 3], str3: true }; -Assert.equal(ns3.str3, true); +let x3: A3 & B3 = { num3: [1, 2, 3], str3: true }; +Assert.equal(x3.str3, true); interface A4 { num4: number; } @@ -64,15 +64,15 @@ interface B4 { interface C4 { cm: any; } -let ns4: A4 & B4 & C4 = { num4: 1, str4: "b4", cm: 3 }; -Assert.equal(ns4.num4, 1); -Assert.equal(ns4.str4, "b4"); -Assert.equal(ns4.cm, 3); +let x4: A4 & B4 & C4 = { num4: 1, str4: "b4", cm: 3 }; +Assert.equal(x4.num4, 1); +Assert.equal(x4.str4, "b4"); +Assert.equal(x4.cm, 3); interface XX { obj: A1; } interface YY { obj: B1; } -let xxyy: XX & YY = { obj: ns1 }; -Assert.equal(xxyy.obj.num1, 1); \ No newline at end of file +let x5: XX & YY = { obj: x }; +Assert.equal(x5.obj.num1, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_3.ts index 1a804e2ed7..b50a04cf1e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_3.ts @@ -24,18 +24,18 @@ import { Assert } from '../../../../suite/assert.js' interface Person { - m_name: string; - m_age: number; + name: string; + age: number; getName(name: string): string; } type Optional = { [P in keyof T]: T[P] }; let cc: Optional = { - m_age: 18, - m_name: "caihua", + age: 18, + name: "caihua", getName(name: string) { return name; }, }; -Assert.equal(cc.m_age, 18); -Assert.equal(cc.m_name, "caihua"); +Assert.equal(cc.age, 18); +Assert.equal(cc.name, "caihua"); Assert.equal(cc.getName("caihua"), "caihua"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_4.ts index 25e67c6016..7fe8901575 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_4.ts @@ -23,7 +23,7 @@ import { Assert } from '../../../../suite/assert.js' -class cE { +class C { x: number; y: number; constructor(x: number, y: number) { @@ -31,17 +31,17 @@ class cE { this.y = y; } } -interface Pi { +interface I { front: T; later: U; } -function test(v: Pi) { +function test(v: I) { Assert.equal(v.front, "abc"); Assert.equal(v.later.x, 1); Assert.equal(v.later.y, 1); } test({ front: "abc", later: { x: 1, y: 1 } }); -let cc: Pi; +let cc: I; cc = { front: "abc", later: { diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_3.ts index c059cef765..43a1046c08 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_3.ts @@ -33,4 +33,5 @@ Assert.equal(arr8.toString(), "a,b,c,d,e,f"); arr8.pop(); Assert.equal(arr8.toString(), "a,b,c,d,e"); arr8.push("0x02"); -Assert.equal(arr8.toString(), "a,b,c,d,e,0x02"); \ No newline at end of file +Assert.equal(arr8.toString(), "a,b,c,d,e,0x02"); +Assert.isObject(arr9); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_2.ts index 15f65e8616..59218da010 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_2.ts @@ -44,7 +44,7 @@ class Teacher extends Person { return "teacher"; } } -// literal type + let testClass1: new (name: string, age: number) => Person = Student; let testObj1: Person = new testClass1("caihua1", 12); Assert.equal(testObj1.age, 12); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_3.ts index 88d7ec7b20..61a588e895 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_3.ts @@ -29,7 +29,7 @@ interface Point { interface PointConstructor { new(x: number, y: number): Point; } -class Point2D implements Point { +class Point2 implements Point { readonly x: number; readonly y: number; constructor(x: number, y: number) { @@ -44,9 +44,9 @@ function newPoint( ): Point { return new pointConstructor(x, y); } -let point1: Point = new Point2D(1, 2); +let point1: Point = new Point2(1, 2); Assert.equal(point1.x, 1); Assert.equal(point1.y, 2); -let point: Point = newPoint(Point2D, 2, 2); +let point: Point = newPoint(Point2, 2, 2); Assert.equal(point.x, 2); Assert.equal(point.y, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_4.ts index 56dd96b99c..68ac126824 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_4.ts @@ -22,7 +22,7 @@ import { Assert } from '../../../../../suite/assert.js' -class Animal1 { +class Animal { name: string | undefined; age: number | undefined; constructor(); @@ -41,11 +41,11 @@ class Animal1 { } } } -let tt1 = new Animal1(); -let tt2 = new Animal1("caihua2", 12); +let tt1 = new Animal(); +let tt2 = new Animal("caihua2", 12); Assert.equal(tt2.name, "caihua2"); Assert.equal(tt2.age, 12); -let tt3 = new Animal1("caihua3"); +let tt3 = new Animal("caihua3"); Assert.equal(tt3.name, "caihua3"); -let tt4 = new Animal1(1230); +let tt4 = new Animal(1230); Assert.equal(tt4.age, 1230); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_1.ts index cf442fede8..3ef706cd20 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_1.ts @@ -25,7 +25,7 @@ import { Assert } from '../../../../../suite/assert.js' -class h_C { +class C { public h_pub: string; private h_pri: string; protected h_pro: string; @@ -44,10 +44,10 @@ class h_C { return this.h_pro; } } -let h_c = new h_C('Public', 'Private', 'Protected'); -Assert.equal(h_c.h_pub, 'Public'); -Assert.equal(h_c.get(), 'Private'); -Assert.equal(h_c.output(), 'Protected'); -class h_child extends h_C { } -let h_ch = new h_child('public', 'private', 'protected'); -Assert.equal(h_ch.output(), 'protected'); \ No newline at end of file +let x = new C('Public', 'Private', 'Protected'); +Assert.equal(x.h_pub, 'Public'); +Assert.equal(x.get(), 'Private'); +Assert.equal(x.output(), 'Protected'); +class Child extends C { } +let y = new Child('public', 'private', 'protected'); +Assert.equal(y.output(), 'protected'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_2.ts index 7b07cf0bd6..d29630a0b1 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_2.ts @@ -24,13 +24,13 @@ import { Assert } from '../../../../../suite/assert.js' -interface h_stu { +interface I { h_name: string; h_age: number; h_height?: number; h_weight?: number; } -let h_s: h_stu = { +let h_s: I = { h_name: 'xiao', h_age: 19, h_height: 180 diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/named_type_reference/named_type_reference.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/named_type_reference/named_type_reference.ts index 5b1fd36a50..ebfad4a129 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/named_type_reference/named_type_reference.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/named_type_reference/named_type_reference.ts @@ -14,9 +14,9 @@ */ /**--- description: > - Type references to class and interface types are classified as object types. + Type references to class and interface types are classified as C1ect types. Type references to generic class and interface types include type arguments that are substituted for the type parameters of the class - or interface to produce an actual object type. + or interface to produce an actual C1ect type. module: ESNext isCurrent: true ---*/ @@ -24,31 +24,31 @@ import { Assert } from '../../../../../suite/assert.js' -class obj { +class C1 { num1: number; num2: number; constructor(num1: number, num2: number) { this.num1 = num1; this.num2 = num2; } - add(h_x: number, h_y: number): void { - var sum: number = h_x + h_y; + add(x: number, y: number): void { + let sum: number = x + y; Assert.equal(sum, 10); } } -let o: obj = new obj(4, 6); +let o: C1 = new C1(4, 6); o.add(3, 7); -interface h_inf { - h_name: string; - h_age: number; +interface I { + name: string; + age: number; greet: () => string } -let h_i: h_inf = { - h_name: 'xiao', - h_age: 18, +let i: I = { + name: 'xiao', + age: 18, greet() { return "hello"; } } -Assert.equal(h_i.h_name, "xiao"); -Assert.equal(h_i.h_age, 18); -Assert.equal(h_i.greet(), "hello"); \ No newline at end of file +Assert.equal(i.name, "xiao"); +Assert.equal(i.age, 18); +Assert.equal(i.greet(), "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_1.ts index 777c76804a..7250fab342 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_1.ts @@ -39,23 +39,19 @@ let a: boolean = true; Assert.equal(a, true); let b: boolean = false; Assert.equal(b, false); -// conditional expression let c: number = a ? 0 : 1; Assert.equal(c, 0); c = b ? 0 : 1; Assert.equal(c, 1); -// if if (a) { Assert.equal(test1(), 0); } else { Assert.equal(test2(), 1); } -// while , do ...while while (a) { Assert.equal(test3(), 1); break; } -// for for (let i = 0; a && i < 5; i++) { Assert.equal(test4(i), i); }; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_2.ts index c34fd9e338..bac6e838d6 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_2.ts @@ -29,21 +29,21 @@ Assert.equal(a, true); a = false; Assert.isBoolean(a); Assert.equal(a, false); -// > < ! + let b: boolean = 2 > 1; Assert.isBoolean(b); Assert.equal(b, true); b = !b; Assert.isBoolean(b); Assert.equal(b, false); -// && + let c: boolean = 2 > 1 && 7 < 8; Assert.isBoolean(c); Assert.equal(c, true); c = 2 < 1 && 7 < 8; Assert.isBoolean(c); Assert.equal(c, false); -// || + c = 2 > 1 || 7 < 8; Assert.isBoolean(c); Assert.equal(c, true); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_enum_type/the_enum_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_enum_type/the_enum_type_1.ts index 76cdb333de..bdac5a3c60 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_enum_type/the_enum_type_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_enum_type/the_enum_type_1.ts @@ -28,7 +28,6 @@ enum Color { Black, } let cc: Color = Color.Blue; -// true Assert.equal(cc, 2); let ee: Color = Color.Blue; let dd: number = cc; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_null_type/the_null_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_null_type/the_null_type_1.ts index 6fc02dcb11..11de69e57b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_null_type/the_null_type_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_null_type/the_null_type_1.ts @@ -26,4 +26,6 @@ let flag = false; if (n == null) { flag = true; } -Assert.equal(flag, true); \ No newline at end of file +Assert.equal(flag, true); +let x1: any = null; +Assert.equal(x1, null); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_1.ts index 9242f3f8d8..b502ee44e1 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_1.ts @@ -23,21 +23,16 @@ import { Assert } from '../../../../../suite/assert.js' -// add Assert.notEqual(0.1 + 0.2, 0.3); Assert.notEqual(0.7 + 0.1, 0.8); Assert.notEqual(0.2 + 0.4, 0.6); -// sub Assert.notEqual(1.5 - 1.2, 0.3); Assert.notEqual(0.3 - 0.2, 0.1); -// multiplication Assert.notEqual(19.9 * 100, 1990); Assert.notEqual(0.8 * 3, 2.4); Assert.notEqual(35.41 * 100, 3541); -// division Assert.notEqual(0.3 / 0.1, 3); Assert.notEqual(0.69 / 10, 0.069); -// Number.toFiexed() Assert.equal((1.335).toFixed(2), 1.33); Assert.equal((1.3335).toFixed(3), 1.333); Assert.equal((1.33335).toFixed(4), 1.3334); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_2.ts index a88d6beed3..4d35a834a8 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_2.ts @@ -21,35 +21,31 @@ import { Assert } from '../../../../../suite/assert.js' -// Integral type + let n1: number = 1; Assert.isNumber(n1); Assert.equal(n1, 1); n1 = 2; Assert.isNumber(n1); Assert.equal(n1, 2); -// Floating point number let n2: number = 1.51; Assert.isNumber(n2); Assert.equal(n2, 1.51); n2 = 3.53; Assert.isNumber(n2); Assert.equal(n2, 3.53); -// binary let n3: number = 0b1011; Assert.isNumber(n3); Assert.equal(n3, 0b1011); n3 = 0b1111; Assert.isNumber(n3); Assert.equal(n3, 0b1111); -// octal let n4: number = 0o17; Assert.isNumber(n4); Assert.equal(n4, 0o17); n4 = 0o24; Assert.isNumber(n4); Assert.equal(n4, 0o24); -// hexadecimal let n5: number = 0xf00d; Assert.isNumber(n5); Assert.equal(n5, 0xf00d); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_3.ts index 876e4b56ab..a4bfd74f7a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_3.ts @@ -21,9 +21,7 @@ import { Assert } from '../../../../../suite/assert.js' -// Equivalent to h_z: number = 123.456 let h_z = 123.456; -// The property of Number let s = h_z.toFixed(2); Assert.equal(s, 123.46); let a = h_z.toString(); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_2.ts index 152aa09ada..2f37788501 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_2.ts @@ -25,7 +25,6 @@ import { Assert } from '../../../../../suite/assert.js' interface Test { v: "hello"; } - function test(dd: Test) { Assert.equal(dd.v.length, 5); return dd; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_3.ts index 7e2a89a138..0b823f8aeb 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_3.ts @@ -23,14 +23,14 @@ import { Assert } from '../../../../../suite/assert.js' -// If you define a variable type without explicit type annotations, the variable defaults to string instead of the string literal type it should be let HELLO: "HELLO" = "HELLO"; let WORLD: "WORLD" = "WORLD"; -// type: string + let hello = HELLO.toLowerCase(); Assert.equal(hello, "hello"); -// type: string + let HELLOWORLD = HELLO + WORLD; Assert.equal(HELLOWORLD, "HELLOWORLD"); -// valid -let a: "foo" | number = "foo"; \ No newline at end of file + +let a: "foo" | number = "foo"; +Assert.equal(a, 'foo'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_symbol_type/the_symbol_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_symbol_type/the_symbol_type_3.ts index 3abcb36b7e..24b14a5b4b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_symbol_type/the_symbol_type_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_symbol_type/the_symbol_type_3.ts @@ -24,9 +24,9 @@ import { Assert } from '../../../../../suite/assert.js' -let h_x: symbol = Symbol(); -let h_obj: any = {}; -h_obj[h_x] = "primitive type"; -Assert.equal(h_obj[h_x], "primitive type"); -h_obj[Symbol.toStringTag] = "project"; -Assert.equal(h_obj[Symbol.toStringTag], "project"); \ No newline at end of file +let x: symbol = Symbol(); +let y: any = {}; +y[x] = "primitive type"; +Assert.equal(y[x], "primitive type"); +y[Symbol.toStringTag] = "project"; +Assert.equal(y[Symbol.toStringTag], "project"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_undefined_type/the_undefined_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_undefined_type/the_undefined_type_1.ts index b29b6fd279..b3b814bdc1 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_undefined_type/the_undefined_type_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_undefined_type/the_undefined_type_1.ts @@ -22,4 +22,23 @@ import { Assert } from '../../../../../suite/assert.js' let u: undefined = undefined; -Assert.equal(u, undefined); \ No newline at end of file +Assert.equal(u, undefined); +interface I2 { + s: number; +} +interface I { + a: number; + b?: string; + c?: number; + d?: object; + e?: string | number; + f?: I2; + g?: string & number; +} +let x: I = { a: 1 }; +Assert.isUndefined(x.b); +Assert.isUndefined(x.c); +Assert.isUndefined(x.d); +Assert.isUndefined(x.e); +Assert.isUndefined(x.f); +Assert.isUndefined(x.g); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_2.ts index 19086e188f..d7f422dfab 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_2.ts @@ -27,7 +27,6 @@ let v: void; Assert.equal(v, undefined); let v2: void = undefined; Assert.equal(v2, undefined); -let nu = null; let u: undefined = undefined; v = u; Assert.equal(v, undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_3.ts index c5ef13370a..4e90b5298b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_3.ts @@ -23,7 +23,6 @@ import { Assert } from '../../../../../suite/assert.js' let v: void; -let nu = null; let u: undefined = undefined; let a: any; a = v; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_5.ts index 5a338ef874..e3f047c52a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_5.ts @@ -30,6 +30,5 @@ let restname1 = restFun("aa", "bb", "cc"); Assert.equal(restname1, "aa bb cc"); let restname2 = restFun(1, 2, 3, 4); Assert.equal(restname2, "1 2 3 4"); -// boolean let restname3 = restFun(true, false, true); Assert.equal(restname3, "true false true"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_6.ts index ab97af1724..f83717453c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_6.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_6.ts @@ -24,7 +24,7 @@ import { Assert } from '../../../../../../suite/assert.js' -class Person2 { +class Person { public name: string; private age: number; protected sex: string; @@ -42,7 +42,7 @@ class Person2 { } } } -class Child extends Person2 { +class Child extends Person { f() { if (this.sex === "man") { this.sex = "male"; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_1.ts index 80957119ba..acb546ff93 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_1.ts @@ -22,20 +22,20 @@ import { Assert } from '../../../../../../suite/assert.js' -function identity(h_x: T): T { - return h_x; +function identity(x: T): T { + return x; } -let h_x: number = 1; -Assert.equal(h_x, identity(h_x)); -function identity2(h_x: T, h_y: U): T { - return h_x; +let x: number = 1; +Assert.equal(x, identity(x)); +function identity2(x: T, y: U): T { + return x; } -Assert.equal(h_x, identity2(h_x, 1)); +Assert.equal(x, identity2(x, 1)); function identity3(obj: T, key: K) { return obj[key]; } -let h_y = { h_a: 1, h_b: 2, h_c: 3, h_d: 4 }; -identity3(h_y, "h_a"); +let y = { h_a: 1, h_b: 2, h_c: 3, h_d: 4 }; +identity3(y, "h_a"); function identity4(arg: T[]): T[] { return arg; } diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_2.ts index 4592b7c737..c1e98499b3 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_2.ts @@ -23,12 +23,10 @@ import { Assert } from '../../../../../../suite/assert.js' -function identity(h_x: T): T { - return h_x; +function identity(x: T): T { + return x; } -let h_x: number = 3; -// CHECK explicitly specified type in call -Assert.equal(identity(h_x), 3); -let h_y = "string"; -// CHECK inferred from argument in the call -Assert.equal(identity(h_y), "string"); \ No newline at end of file +let x: number = 3; +Assert.equal(identity(x), 3); +let y = "string"; +Assert.equal(identity(y), "string"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/index_signatures/index_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/index_signatures/index_signatures.ts index 0dd50020f7..20bdba48b2 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/index_signatures/index_signatures.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/index_signatures/index_signatures.ts @@ -23,25 +23,23 @@ import { Assert } from '../../../../../suite/assert.js' -let si: { [key: string]: number } = { a: 97, A: 65 }; -si["b"] = 98; -Assert.equal(si["a"], 97); -Assert.equal(si["A"], 65); -let ni: { [key: number]: boolean } = { 0: false, 1: true }; -ni[-1] = true; -Assert.isBoolean(ni[0]); -Assert.equal(ni[-1], true); - +let x: { [key: string]: number } = { a: 97, A: 65 }; +x["b"] = 98; +Assert.equal(x["a"], 97); +Assert.equal(x["A"], 65); +let y: { [key: number]: boolean } = { 0: false, 1: true }; +y[-1] = true; +Assert.isBoolean(y[0]); +Assert.equal(y[-1], true); interface StringKey { [key: string]: string; } -let sk: StringKey = { "1": "0x01", "2": "0x02", 3: "0x03", "4": "0x04" }; -Assert.equal(sk["1"], "0x01"); -Assert.equal(sk["2"], "0x02"); -Assert.equal(sk[3], 0x03); +let z: StringKey = { "1": "0x01", "2": "0x02", 3: "0x03", "4": "0x04" }; +Assert.equal(z["1"], "0x01"); +Assert.equal(z["2"], "0x02"); interface NumberKey { [key: number]: string; } -let nk: NumberKey = { 1: "0x01", 2: "0x02", "3": "0x03", 4: "0x04" }; -Assert.equal(nk[1], "0x01"); -Assert.equal(nk[2], "0x02"); +let u: NumberKey = { 1: "0x01", 2: "0x02", "3": "0x03", 4: "0x04" }; +Assert.equal(u[1], "0x01"); +Assert.equal(u[2], "0x02"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_1.ts index 1eacb9e701..6e62eb349b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_1.ts @@ -23,7 +23,6 @@ import { Assert } from '../../../../../suite/assert.js' -// interfaces interface point { point(x: number, y: number, z?: number): number; } @@ -41,7 +40,7 @@ let sum = p1.point(x, y, z); Assert.equal(sum, 6); sum = p1.point(x, y); Assert.equal(sum, 3); -// object type literals + let point2: { x: number; y: number; z?: number }; point2 = { x: 1, y: 2, z: 3 }; let pp1 = point2; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_3.ts index fdfccc3279..e02654d7c8 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_3.ts @@ -22,13 +22,13 @@ import { Assert } from '../../../../../suite/assert.js' -let h_test1: string | number[]; -h_test1 = 'string'; -Assert.equal(h_test1, 'string'); -h_test1 = [3, 5]; -Assert.equal(h_test1[0], 3); -Assert.equal(h_test1[1], 5); -let h_test2: (string | number)[]; -h_test2 = [2, 'a']; -Assert.equal(h_test2[0], 2); -Assert.equal(h_test2[1], 'a'); \ No newline at end of file +let test: string | number[]; +test = 'string'; +Assert.equal(test, 'string'); +test = [3, 5]; +Assert.equal(test[0], 3); +Assert.equal(test[1], 5); +let test2: (string | number)[]; +test2 = [2, 'a']; +Assert.equal(test2[0], 2); +Assert.equal(test2[1], 'a'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_4.ts index 6f96a48423..eaf2c69edf 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_4.ts @@ -25,12 +25,12 @@ import { Assert } from '../../../../../suite/assert.js' let arr: Array = [2, 'a']; Assert.equal(arr[0], 2); Assert.equal(arr[1], 'a'); -let h_x = function () { - return 'h_x'; +let x = function () { + return 'x'; } -let h_y = function () { - return 'h_y'; +let y = function () { + return 'y'; } -let fun: Array<() => string> = [h_x, h_y]; +let fun: Array<() => string> = [x, y]; Assert.isFunction(fun[0]); Assert.isFunction(fun[1]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/function_type_literals/function_type_literals_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/function_type_literals/function_type_literals_3.ts index 75a002d76f..711f57f6cf 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/function_type_literals/function_type_literals_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/function_type_literals/function_type_literals_3.ts @@ -23,16 +23,16 @@ import { Assert } from '../../../../../suite/assert.js' -interface h_inter { - (h_x: string): number; - (h_x: number): string +interface I { + (x: string): number; + (x: number): string } -let h_i: h_inter = Object.assign(function (h_x: any) { - if (typeof h_x === 'string') { - return h_x.toString(); +let i: I = Object.assign(function (x: any) { + if (typeof x === 'string') { + return x.toString(); } else { - return h_x.toString(); + return x.toString(); } }) -Assert.equal(h_i('a'), 'a') -Assert.equal(h_i(2), 2); \ No newline at end of file +Assert.equal(i('a'), 'a'); +Assert.equal(i(2), 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/intersection_type_literals/intersection_type_literals.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/intersection_type_literals/intersection_type_literals.ts index d0483b0e6f..daec49b722 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/intersection_type_literals/intersection_type_literals.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/intersection_type_literals/intersection_type_literals.ts @@ -23,8 +23,8 @@ import { Assert } from '../../../../../suite/assert.js' -let t_inter: object & { name: string }; -t_inter = { +let x: object & { name: string }; +x = { name: 'intersection' } -Assert.isObject(t_inter); \ No newline at end of file +Assert.isObject(x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/object_type_literals/object_type_literals.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/object_type_literals/object_type_literals.ts index 535c85a317..897b990a08 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/object_type_literals/object_type_literals.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/object_type_literals/object_type_literals.ts @@ -23,7 +23,7 @@ import { Assert } from '../../../../../suite/assert.js' -let h_obj: { +let obj: { num: number; str: string; boo: boolean; @@ -32,16 +32,16 @@ let h_obj: { str: 'str', boo: true } -Assert.equal(h_obj.num, 5); -Assert.equal(h_obj.str, 'str'); -Assert.equal(h_obj.boo, true); -interface h_i { +Assert.equal(obj.num, 5); +Assert.equal(obj.str, 'str'); +Assert.equal(obj.boo, true); +interface I { name: string, age: number } -let h_o: h_i = { +let i: I = { name: 'xiao', age: 18 } -Assert.equal(h_o.name, 'xiao'); -Assert.equal(h_o.age, 18); \ No newline at end of file +Assert.equal(i.name, 'xiao'); +Assert.equal(i.age, 18); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/predefined_types/predefined_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/predefined_types/predefined_types.ts index 2637703d61..29f12aae67 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/predefined_types/predefined_types.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/predefined_types/predefined_types.ts @@ -23,14 +23,14 @@ import { Assert } from '../../../../../suite/assert.js' -let m_n: number = 5; -Assert.equal(m_n.toString(), "5"); +let x1: number = 5; +Assert.equal(x1.toString(), "5"); -let m_b: boolean = true; -Assert.equal(m_b.toString(), "true"); +let x2: boolean = true; +Assert.equal(x2.toString(), "true"); -let m_s: string = 's'; -Assert.equal(m_s.toString(), "s"); +let x3: string = 's'; +Assert.equal(x3.toString(), "s"); -let m_sy: symbol = Symbol(); -Assert.equal(m_sy.toString(), "Symbol()"); \ No newline at end of file +let x4: symbol = Symbol(); +Assert.equal(x4.toString(), "Symbol()"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/specifying_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/specifying_types_1.ts index fbc74449db..32e6a20d1f 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/specifying_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/specifying_types_1.ts @@ -23,22 +23,22 @@ import { Assert } from '../../../../suite/assert.js' -let h_num: number = 5; -Assert.isNumber(h_num); +let num: number = 5; +Assert.isNumber(num); -let h_obj = { +let obj = { name: 'xiao', age: 18 } -Assert.equal(typeof h_obj, 'object'); +Assert.equal(typeof obj, 'object'); -let h_arr = [10, 5, 7, 20]; -Assert.equal(typeof h_arr, 'object'); +let arr = [10, 5, 7, 20]; +Assert.equal(typeof arr, 'object'); -let h_tup = ['str', 5, true]; -Assert.equal(typeof h_tup, 'object'); +let arr2 = ['str', 5, true]; +Assert.equal(typeof arr2, 'object'); -let h_func = (h_x: number, h_y: number) => { +let fun = (h_x: number, h_y: number) => { return h_x + h_y } -Assert.equal(typeof h_func, 'function'); \ No newline at end of file +Assert.equal(typeof fun, 'function'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/specifying_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/specifying_types_2.ts index a68f47cbd5..861a9cc8cf 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/specifying_types_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/specifying_types_2.ts @@ -22,10 +22,10 @@ import { Assert } from '../../../../suite/assert.js' -let h_arr: (string | number)[] = ['10', 5]; -Assert.equal(typeof h_arr, 'object'); +let arr: (string | number)[] = ['10', 5]; +Assert.equal(typeof arr, 'object'); let m_fun = function func(x: number) { return x; } -let h_func: ((h_x: string) => string) | ((h_x: number) => number) = m_fun; -Assert.equal(typeof h_func, 'function'); \ No newline at end of file +let fun: ((h_x: string) => string) | ((h_x: number) => number) = m_fun; +Assert.equal(typeof fun, 'function'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/this_type_references/this_type_references_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/this_type_references/this_type_references_2.ts index 2d935990b2..098a4a3ca6 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/this_type_references/this_type_references_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/this_type_references/this_type_references_2.ts @@ -24,14 +24,14 @@ import { Assert } from '../../../../../suite/assert.js' -interface h_inter { +interface I { name: string; - getN(this: h_inter): string; + getN(this: I): string; } -let h_i: h_inter = { +let i: I = { name: 'xiao', getN() { return this.name; } } -Assert.equal(h_i.getN(), 'xiao'); \ No newline at end of file +Assert.equal(i.getN(), 'xiao'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/tuple_type_literals/tuple_type_literals.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/tuple_type_literals/tuple_type_literals.ts index 30f35ee178..5eba9508bd 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/tuple_type_literals/tuple_type_literals.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/tuple_type_literals/tuple_type_literals.ts @@ -23,7 +23,7 @@ import { Assert } from '../../../../../suite/assert.js' -let t_arr: [number, string, boolean] = [3, 'a', true] -Assert.isNumber(t_arr[0]); -Assert.isString(t_arr[1]); -Assert.isBoolean(t_arr[2]); \ No newline at end of file +let arr: [number, string, boolean] = [3, 'a', true] +Assert.isNumber(arr[0]); +Assert.isString(arr[1]); +Assert.isBoolean(arr[2]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_queries/type_queries_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_queries/type_queries_2.ts index 7ce1b35da2..a20eba8f6c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_queries/type_queries_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_queries/type_queries_2.ts @@ -23,11 +23,11 @@ import { Assert } from '../../../../../suite/assert.js' -let h_a: { h_x: number, h_y: string }; +let a: { x: number, y: string }; -let h_b: typeof h_a; -h_b = { - h_x: 10, - h_y: 'h_y' +let b: typeof a; +b = { + x: 10, + y: 'y' } -Assert.equal(typeof h_b, 'object'); \ No newline at end of file +Assert.equal(typeof b, 'object'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_1.ts index 95aa3f28fb..1fde37489d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_1.ts @@ -23,15 +23,15 @@ import { Assert } from '../../../../../suite/assert.js' -let h_obj: { +let obj: { month: number; day: number; } = { month: 5, day: 15 } -Assert.equal(h_obj.month, 5); -Assert.equal(h_obj.day, 15); +Assert.equal(obj.month, 5); +Assert.equal(obj.day, 15); function identity1(value: T, message: U): [T, U] { return [value, message]; } diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_2.ts index 290bc01e41..441d6416dd 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_2.ts @@ -23,29 +23,29 @@ import { Assert } from '../../../../../suite/assert.js' -interface h_A { - h_a: string; +interface I1 { + a: string; } -interface h_B extends h_A { - h_b: string; +interface I2 extends I1 { + b: string; } -interface h_C extends h_B { - h_c: string; +interface I3 extends I2 { + c: string; } -interface h_G { - h_x: T; - h_y: U; +interface I4 { + x: T; + y: U; } -let h_v: h_G = { - h_x: { h_a: 'h_a' }, - h_y: { - h_a: 'h_a', - h_b: 'h_b', - h_c: 'h_c' +let z: I4 = { + x: { a: 'a' }, + y: { + a: 'a', + b: 'b', + c: 'c' } } -Assert.equal(h_v.h_x.h_a, 'h_a'); -Assert.equal(h_v.h_y.h_a, 'h_a'); -Assert.equal(h_v.h_y.h_b, 'h_b'); -Assert.equal(h_v.h_y.h_c, 'h_c'); \ No newline at end of file +Assert.equal(z.x.a, 'a'); +Assert.equal(z.y.a, 'a'); +Assert.equal(z.y.b, 'b'); +Assert.equal(z.y.c, 'c'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_3.ts index 4771022fad..7d8838deab 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_3.ts @@ -24,35 +24,35 @@ import { Assert } from '../../../../../suite/assert.js' -interface h_A { - h_a: string; +interface I1 { + a: string; } -interface h_B extends h_A { - h_b: string; +interface I2 extends I1 { + b: string; } -interface h_C extends h_B { - h_c: string; +interface I3 extends I2 { + c: string; } -interface h_G { - h_x: T; - h_y: U; +interface I4 { + x: T; + y: U; } -let h_v: h_G, h_C> = { - h_x: { - h_x: { h_a: 'h_a' }, - h_y: { - h_a: 'h_a', - h_b: 'h_b' +let z: I4, I3> = { + x: { + x: { a: 'a' }, + y: { + a: 'a', + b: 'b' } }, - h_y: { - h_a: 'h_a', - h_b: 'h_b', - h_c: 'h_c' + y: { + a: 'a', + b: 'b', + c: 'c' } } -Assert.equal(h_v.h_x.h_x.h_a, 'h_a'); -Assert.equal(h_v.h_x.h_y.h_b, 'h_b'); -Assert.equal(h_v.h_y.h_a, 'h_a'); -Assert.equal(h_v.h_y.h_b, 'h_b'); -Assert.equal(h_v.h_y.h_c, 'h_c'); \ No newline at end of file +Assert.equal(z.x.x.a, 'a'); +Assert.equal(z.x.y.b, 'b'); +Assert.equal(z.y.a, 'a'); +Assert.equal(z.y.b, 'b'); +Assert.equal(z.y.c, 'c'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/union_type_literals/union_type_literals.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/union_type_literals/union_type_literals.ts index 76018c6cfd..b226b6655d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/union_type_literals/union_type_literals.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/union_type_literals/union_type_literals.ts @@ -23,8 +23,8 @@ import { Assert } from '../../../../../suite/assert.js' -let t_union: string | number; -t_union = 's'; -Assert.isString(t_union); -t_union = 5; -Assert.isNumber(t_union); \ No newline at end of file +let x: string | number; +x = 's'; +Assert.isString(x); +x = 5; +Assert.isNumber(x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_1.ts index f245dc5f8c..c5c1a672f8 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_1.ts @@ -31,4 +31,14 @@ Assert.equal(x, 12); x = "abc"; Assert.equal(x, "abc"); x = true; -Assert.equal(x, true); \ No newline at end of file +Assert.equal(x, true); +x = [1, 2, 3]; +Assert.equal(x[0], 1); +x = ["aa", "bb"]; +Assert.equal(x[0], "aa"); +x = (a: number, b: number) => { return a + b }; +Assert.isFunction(x); +x = Symbol("aa"); +Assert.isSymbol(x); +x = { a: 1, b: 1 }; +Assert.isObject(x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_3.ts index 9521493864..3bc23487d6 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_3.ts @@ -24,12 +24,31 @@ import { Assert } from '../../../../suite/assert.js' let x: any +let fun: any; +fun = (x: any) => x; +Assert.equal(fun(5), 5); x = 1024; x.toString(); Assert.isString(x.toString()); x = "AAA"; x.length; Assert.equal(x.length, 3); -let fun: any; -fun = (a: number) => a; -Assert.equal(fun(5), 5); \ No newline at end of file +Assert.equal(fun(x), "AAA"); +x = true; +Assert.equal(x, true); +Assert.equal(fun(x), true); +x = [1, 2, 3]; +Assert.equal(x[0], 1); +Assert.equal(fun(x), "1,2,3"); +x = ["aa", "bb"]; +Assert.equal(x[0], "aa"); +Assert.equal(fun(x), "aa,bb"); +x = (a: number, b: number) => { return a + b }; +Assert.isFunction(x); +Assert.isFunction(fun(x)); +x = Symbol("aa"); +Assert.isSymbol(x); +Assert.isSymbol(fun(x)); +x = { a: 1, b: 1 }; +Assert.isObject(x); +Assert.isObject(fun(x)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_1.ts index 4cbfd57a2d..6d52692591 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_1.ts @@ -24,17 +24,17 @@ import { Assert } from '../../../../suite/assert.js' type MyString = string; -var h_x: MyString = 'x'; -Assert.isString(h_x); +let x: MyString = 'x'; +Assert.isString(x); type MyUnionType = number | string | boolean; -var h_y: MyUnionType = 10; -Assert.isNumber(h_y); -h_y = '10'; -Assert.isString(h_y); -h_y = true; -Assert.isBoolean(h_y); +let y: MyUnionType = 10; +Assert.isNumber(y); +y = '10'; +Assert.isString(y); +y = true; +Assert.isBoolean(y); type MyInterType = object & { name: string }; -var h_z: MyInterType = { name: 'xiao' }; -Assert.equal(typeof h_z, 'object'); \ No newline at end of file +let z: MyInterType = { name: 'xiao' }; +Assert.equal(typeof z, 'object'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_2.ts index a62ac1ad94..351ed8fb63 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_2.ts @@ -23,13 +23,13 @@ import { Assert } from '../../../../suite/assert.js' -type h_MyType = { +type MyType = { h_name: string; h_age: number; h_height?: number; h_weight?: number } -var h_ty: h_MyType = { +var h_ty: MyType = { h_name: 'xiao', h_age: 18, h_height: 180 diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_3.ts index b6d3499c02..35cbfafab4 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_3.ts @@ -23,15 +23,15 @@ import { Assert } from '../../../../suite/assert.js' -interface h_inter { +interface I { h_x: T; h_y: U; } -interface h_face { +interface I2 { h_y: T; h_b: U; } -type MyType = h_inter | h_face +type MyType = I | I2 var mytest: MyType = { h_x: 10, h_y: 'y', diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types.ts index f39b82d770..4e414adda1 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types.ts @@ -43,12 +43,10 @@ class CB extends CA { return "CB:" + this.name; } } - let bB: CB = new CB(); let xB = bB.f().b(); Assert.equal(bB, xB); - -var thisStrB: string = bB.cbName("CB"); +let thisStrB: string = bB.cbName("CB"); Assert.equal(thisStrB, "CB:CB"); -var thisStrA: string = bB.caName("CA"); -Assert.equal(thisStrA, "CA:CA"); +let thisStrA: string = bB.caName("CA"); +Assert.equal(thisStrA, "CA:CA"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types_1.ts index c173d3d5b9..a011585986 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types_1.ts @@ -23,22 +23,21 @@ import { Assert } from '../../../../../suite/assert.js' -interface h_inter { - h_say: () => string; +interface INTERFACE { + say: () => string; } -let h_i: h_inter = { - h_say() { +let i: INTERFACE = { + say() { return typeof this; } } -Assert.equal(h_i.h_say(), 'object'); - -class h_C { +Assert.equal(i.say(), 'object'); +class C { num: number; constructor(num: number) { this.num = num; Assert.equal(typeof this, 'object'); } } -let h_c = new h_C(10); +let h_c = new C(10); Assert.equal(h_c.num, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types_2.ts index f0e04d9e1e..ff20e6e436 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types_2.ts @@ -47,8 +47,7 @@ class CB extends CA { let bB: CB = new CB(); let xB = bB.f().b(); Assert.equal(bB, xB); - -var thisStrB: string = bB.cbName("CB"); +let thisStrB: string = bB.cbName("CB"); Assert.equal(thisStrB, "CB:CB"); -var thisStrA: string = bB.caName("CA"); -Assert.equal(thisStrA, "CA:CA"); +let thisStrA: string = bB.caName("CA"); +Assert.equal(thisStrA, "CA:CA"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_2.ts index b2b2c138c2..1e2ef9e1ba 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_2.ts @@ -20,7 +20,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' interface GenericIdentityFn { (arg: T): T; @@ -28,8 +28,8 @@ interface GenericIdentityFn { function identity(arg: T): T { return arg; } -let myidenti: number = 1; -let myIdentity: GenericIdentityFn = identity; -let myidenti2 = myIdentity(myidenti); -Assert.equal(myidenti2, 1); +let x: number = 1; +let y: GenericIdentityFn = identity; +let z = y(x); +Assert.equal(z, 1); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_4.ts index 4506e526ea..36aed13d2c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_4.ts @@ -23,9 +23,9 @@ import { Assert } from '../../../../../suite/assert.js' -function h_iden(h_x: T): T { +function fun(h_x: T): T { return h_x; } -var x = h_iden(10); +let x = fun(10); Assert.isNumber(x); Assert.equal(x, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_1.ts index 2cf95d862b..542289e72a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_1.ts @@ -21,9 +21,8 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -// class class MinClass { public list: T[] = []; add(v: T) { @@ -40,14 +39,14 @@ class MinClass { return minNum; } } -// string type + let minStringValue = new MinClass(); minStringValue.add("a"); minStringValue.add("b"); minStringValue.add("c"); minStringValue.add("d"); Assert.equal(minStringValue.findminNumberValue(), "a"); -// number type + let minNumberValue = new MinClass(); minNumberValue.add(1); minNumberValue.add(2); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_2.ts index d8050e3c19..2f82c9044b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_2.ts @@ -21,14 +21,13 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -// interface interface OutputValue { (arg: T): T; } -let tt1: OutputValue = function (arg: T): T { +let x: OutputValue = function (arg: T): T { return arg; }; -Assert.equal(tt1("abc"), "abc"); +Assert.equal(x("abc"), "abc"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_3.ts index da55632ee2..1ac5683c06 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_3.ts @@ -21,9 +21,8 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -// alias class Person { name: string; age: number; @@ -34,14 +33,14 @@ class Person { this.job = job; } } -// Mapping: This parameter is optional + type optionallyTest = { [P in keyof T]?: T[P]; }; -let pp: optionallyTest = {}; -pp = { name: "dog" }; -Assert.isUndefined(pp.job); -Assert.isUndefined(pp.age); -pp = { name: "dog", age: 18 }; -Assert.isUndefined(pp.job); -pp = { name: "dog", age: 18, job: "teacher" }; +let x: optionallyTest = {}; +x = { name: "dog" }; +Assert.isUndefined(x.job); +Assert.isUndefined(x.age); +x = { name: "dog", age: 18 }; +Assert.isUndefined(x.job); +x = { name: "dog", age: 18, job: "teacher" }; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_5.ts index f6ade18805..b72720d112 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_5.ts @@ -21,11 +21,9 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -// function declaration function sum(a: T, b: K): string { return "a"; } Assert.equal(sum(1, 1), "a"); - diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity.ts index f56301825f..9656503fa3 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity.ts @@ -21,11 +21,11 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' class Teacher { private x: T; - constructor(t:T) { + constructor(t: T) { this.x = t; } @@ -35,15 +35,14 @@ interface student1 { f(): string; } interface student2 { f(): string; } -class Person implements student1,student2 { +class Person implements student1, student2 { f() { return "X+Y" } } -let Hwa: Teacher = new Teacher(new Person); -let Hwb: Teacher = new Teacher(new Person); - -Assert.isObject(Hwa); -Assert.isObject(Hwb); -Assert.equal(typeof Hwa,typeof Hwb) +let a: Teacher = new Teacher(new Person); +let b: Teacher = new Teacher(new Person); +Assert.isObject(a); +Assert.isObject(b); +Assert.equal(typeof a, typeof b) \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_3.ts index 1f02ff3b0b..26ac209857 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_3.ts @@ -23,7 +23,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' let obj: Object; obj = { @@ -40,7 +40,4 @@ class Person { return "hello" } } -function test() { - let myTest1: new (str: string, num: number) => Person -} Assert.notEqual(Person.toString(), "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_4.ts index 81f95f0a57..27fe913488 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_4.ts @@ -21,7 +21,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' interface Array1 { [index1: string]: string @@ -39,5 +39,5 @@ const stu1 = { const stu2 = { name: "xiao" } -Assert.equal(test(stu1), "right") +Assert.equal(test(stu1), "right"); Assert.equal(test(stu2), "right"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_5.ts index d9ac3a6326..aa43b61234 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_5.ts @@ -21,7 +21,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' interface Array1 { [index1: string]: number @@ -39,5 +39,5 @@ const stu1 = { const stu2 = { number: 10001 } -Assert.equal(test(stu1), "right") +Assert.equal(test(stu1), "right"); Assert.equal(test(stu2), "right"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_6.ts index 6d2aa963d7..40ddf28c78 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_6.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_6.ts @@ -21,7 +21,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' interface Array1 { [index1: string]: string @@ -39,5 +39,5 @@ const stu1 = { const stu2 = { name: "xiao" } -Assert.equal(test(stu1), "right") +Assert.equal(test(stu1), "right"); Assert.equal(test(stu2), "right"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_7.ts index 663a997a86..45bed47d2b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_7.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_7.ts @@ -21,7 +21,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' interface Array1 { [index1: string]: number @@ -39,5 +39,5 @@ const stu1 = { const stu2 = { number: 10001 } -Assert.equal(test(stu1), "right") +Assert.equal(test(stu1), "right"); Assert.equal(test(stu2), "right"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_8.ts index 2aee866f82..49cbe222a5 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_8.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_8.ts @@ -22,8 +22,8 @@ import { Assert } from '../../../../../suite/assert.js' -var obj: Object = { num1: 10, num2: 20 }; +let obj: Object = { num1: 10, num2: 20 }; Assert.equal(JSON.stringify(obj), '{"num1":10,"num2":20}') -var fun: Function = (num: number) => num * num; +let fun: Function = (num: number) => num * num; Assert.isUndefined(JSON.stringify(fun)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_13.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_13.ts index b4b2e32315..a058d9e4af 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_13.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_13.ts @@ -28,7 +28,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' interface T { (x: any, y: any): void @@ -36,10 +36,10 @@ interface T { interface S { (x: number): void } -var t: T = (x, y): void => { +let t: T = (x, y): void => { return; } -var s: S = (x): void => { +let s: S = (x): void => { return; } t = s diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_18.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_18.ts index d4a8cf61f2..119ae5e291 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_18.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_18.ts @@ -26,8 +26,8 @@ import { Assert } from '../../../../../suite/assert.js' function func(stu: { num: number; name?: string }) { return stu } -var f1 = func({ num: 1234 }); +let f1 = func({ num: 1234 }); Assert.equal(JSON.stringify(f1), '{"num":1234}') -var f2 = func({ num: 1234, name: "xiao" }) +let f2 = func({ num: 1234, name: "xiao" }) Assert.equal(JSON.stringify(f2), '{"num":1234,"name":"xiao"}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_6.ts index b63b572c2c..3ccdf7dc27 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_6.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_6.ts @@ -21,9 +21,9 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -var T: string = "T"; +let T: string = "T"; type S = "s" | "str" | "string"; let s: S = "str" T = s diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/contextual_signature_instantiation/contextual_signature_instantiation.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/contextual_signature_instantiation/contextual_signature_instantiation.ts index 0282fa627d..88f45984e2 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/contextual_signature_instantiation/contextual_signature_instantiation.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/contextual_signature_instantiation/contextual_signature_instantiation.ts @@ -21,17 +21,16 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -function zip(x: S[], y: T[], combine: (x: S) => (y: T) => U): U[] { - var len = Math.max(x.length, y.length); - var result: U[] = []; - for (var i = 0; i < len; i++) result.push(combine(x[i])(y[i])); +function fun(x: S[], y: T[], combine: (x: S) => (y: T) => U): U[] { + let len = Math.max(x.length, y.length); + let result: U[] = []; + for (let i = 0; i < len; i++) result.push(combine(x[i])(y[i])); return result; } -var names = ["Peter", "Paul", "Mary"]; -var ages = [7, 9, 12]; -// the type of 'pairs' is '{ name: string; age: number }[]' -var pairs = zip(names, ages, s => n => ({ name: s, age: n })); +let names = ["Peter", "Paul", "Mary"]; +let ages = [7, 9, 12]; +let pairs = fun(names, ages, s => n => ({ name: s, age: n })); Assert.equal(JSON.stringify(pairs), '[{"name":"Peter","age":7},{"name":"Paul","age":9},{"name":"Mary","age":12}]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_1.ts index c8e74197d2..0185de083e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_1.ts @@ -23,14 +23,14 @@ import { Assert } from '../../../../../suite/assert.js' -interface Options { - strict?: boolean - source?: string - target?: string +interface I { + a?: boolean + b?: string + c?: string } -var options: Options = { - strict: true, - source: "./src", - target: "./bin" +let x: I = { + a: true, + b: "./src", + c: "./bin" } -Assert.equal(JSON.stringify(options), '{"strict":true,"source":"./src","target":"./bin"}'); \ No newline at end of file +Assert.equal(JSON.stringify(x), '{"a":true,"b":"./src","c":"./bin"}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_2.ts index 3751b7e930..1d2b4cdcc4 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_2.ts @@ -1,7 +1,7 @@ /* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * you may not c this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 @@ -22,19 +22,16 @@ import { Assert } from '../../../../../suite/assert.js' -interface Input { - place: string; - phanic?: boolean; - // the any type is allowed to be the additional properties +interface I { + a: string; + b?: boolean; [str: string]: any; } -var site: Input = { - place: "Address", - phanic: true, - // Can do this because of index signature - use: "Enter address here", - // Can do this because of index signature - shortcut: "Alt-A" +let x: I = { + a: "aaa", + b: true, + c: "ccc", + d: "ddd" }; -Assert.equal(JSON.stringify(site), '{"place":"Address","phanic":true,"use":"Enter address here","shortcut":"Alt-A"}'); \ No newline at end of file +Assert.equal(JSON.stringify(x), '{"a":"aaa","b":true,"c":"ccc","d":"ddd"}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_3.ts index 8cdf425225..7a6dc44683 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_3.ts @@ -21,13 +21,10 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -// { x: 0, y: 0 } is the fresh object literal type const p: { x: number, y: number } = { x: 0, y: 0 } Assert.equal(JSON.stringify(p), '{"x":0,"y":0}') -// The freshness disappears when the type of the express in a type assertion -// There is Excess Property y but no error const p1: { x: number } = { x: 0, y: 0 } as { x: 0, y: 0 } Assert.equal(JSON.stringify(p1), '{"x":0,"y":0}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/recursive_types/recursive_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/recursive_types/recursive_types.ts index 9622da97a0..ab23d074cf 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/recursive_types/recursive_types.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/recursive_types/recursive_types.ts @@ -40,5 +40,5 @@ type IsEqual = (() => T2 extends U ? 1 : 2) ? true : false -var t1: IsEqual = true +var t1: IsEqual = true; Assert.isTrue(t1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_10.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_10.ts index 05364e35c2..9ee1b09a00 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_10.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_10.ts @@ -22,7 +22,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' interface S { name: string @@ -46,5 +46,5 @@ let t: T = { age: 20 } -t = s +t = s; Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_12.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_12.ts index 231d656fb7..cb4b90c5a2 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_12.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_12.ts @@ -29,7 +29,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' type T = { name: any @@ -50,5 +50,5 @@ let s: S = { height: 180 } -t = s +t = s; Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_13.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_13.ts index c580cb34a6..665f1fb45e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_13.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_13.ts @@ -28,7 +28,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' interface T { (x: any, y: any): void @@ -36,12 +36,12 @@ interface T { interface S { (x: number): void } -var t: T = (x, y): void => { +let t: T = (x, y): void => { return; } -var s: S = (x): void => { +let s: S = (x): void => { return; } -t = s +t = s; Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_14.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_14.ts index 16b8499c48..c54c0ff060 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_14.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_14.ts @@ -24,7 +24,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' interface T { name: string @@ -36,5 +36,10 @@ interface S { interface U { [name: string]: any } +let x: T = { name: "aa" }; +Assert.equal(x.name, "aa"); +let y: S = { name: "aa", age: 11 }; +Assert.equal(y.name, "aa"); +Assert.equal(y.age, 11); let obj: U = { name: "xiao", age: 18 } Assert.equal(JSON.stringify(obj), '{"name":"xiao","age":18}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_15.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_15.ts index 0c0c320900..8410f41593 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_15.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_15.ts @@ -24,7 +24,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' interface T { age: number @@ -36,6 +36,11 @@ interface S { interface U { [age: number]: any } +let x: T = { age: 11 }; +Assert.equal(x.age, 11); +let y: S = { age: 11, height: 11 }; +Assert.equal(y.age, 11); +Assert.equal(y.height, 11); let obj: U = {} obj[5] = { age: 18, height: 180 } Assert.equal(JSON.stringify(obj[5]), '{"age":18,"height":180}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_2.ts index 8519d9fb99..098eaa1675 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_2.ts @@ -21,7 +21,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' interface T { name: any @@ -42,5 +42,5 @@ let s: S = { hobbies: ["draw", "game"] }; -t = s +t = s; Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_3.ts index 69126a26c6..3faad4a7ce 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_3.ts @@ -21,7 +21,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' interface T { name: string | undefined @@ -43,5 +43,5 @@ let s: S = { hobbies: undefined }; -t = s +t = s; Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_4.ts index aeb89ec4f8..45fb780724 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_4.ts @@ -21,7 +21,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' interface T { name: any @@ -43,5 +43,5 @@ let s: S = { hobbies: null }; -t = s +t = s; Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_5.ts index 9b51a5e29f..7452d54fd8 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_5.ts @@ -21,7 +21,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' var T: number = 4; enum S { diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_6.ts index 7f0232654d..03ee7dd0d9 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_6.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_6.ts @@ -22,11 +22,11 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' var T: string = "T"; type S = "s" | "str" | "string"; let s: S = "str" -T = s +T = s; Assert.equal(T, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_7.ts index 55ec5d8fd9..8562babf4a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_7.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_7.ts @@ -22,10 +22,10 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -var T: any = true; -var S: number | string = 18; +let T: any = true; +let S: number | string = 18; -T = S +T = S; Assert.equal(T, 18); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_8.ts index 43c69739d2..b713d707f5 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_8.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_8.ts @@ -22,7 +22,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' interface T { name: string @@ -46,5 +46,5 @@ let s: S = { hobby: "drawing" } -t = s +t = s; Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_9.ts index f26efd106a..f775365370 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_9.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_9.ts @@ -22,10 +22,10 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -var T: number | string = "18"; -var S: number = 20; +let T: number | string = "18"; +let S: number = 20; -T = S +T = S; Assert.equal(T, S); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_1.ts index 9dfc40d45e..39e9d6a0b4 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_1.ts @@ -22,17 +22,19 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -interface Cb { +interface I1 { (a: number): void } -interface Fn { - (cb: Cb): void +interface I2 { + (cb: I1): void } -const fn: Fn = function (cb) { } -// The argument a to the anonymous function is of type number +const fn: I2 = function (cb) { + Assert.isFunction(cb); +} + fn(function (a) { Assert.isNumber(a); a = a + 1; -}); \ No newline at end of file +}); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_2.ts index d6a76f6d34..a07b9b18a6 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_2.ts @@ -21,7 +21,7 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' function map(a: T[], f: (x: T) => U): U[] { var result: U[] = []; @@ -30,6 +30,6 @@ function map(a: T[], f: (x: T) => U): U[] { } var names = ["Peter", "Paul", "Mary"]; -// the type of lengths is number[] + var lengths = map(names, s => s.length); Assert.equal(typeof lengths, 'object'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_3.ts index 0663487aad..819c983fbf 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_3.ts @@ -21,11 +21,11 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' + -// the type of T is string | number | boolean let T = [1, 'a', true] Assert.equal(typeof T, 'object') -// the type of S is string | number | number[] + let S = [[1, 2, 3], 2, 'b'] Assert.equal(typeof S, 'object'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_4.ts index 60c35327d9..0e0a4d5b7b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_4.ts @@ -25,7 +25,7 @@ isCurrent: true ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' type Maybe = T | void @@ -39,7 +39,6 @@ function getOrElse(x: Maybe, defaultValue: T): T { return isDefined(x) ? x : defaultValue; } function test1(x: Maybe) { - // x1,x2,x3 are of type string let x1 = getOrElse(x, "Undefined"); Assert.isString(x1) let x2 = isDefined(x) ? x : "undefined"; @@ -49,7 +48,6 @@ function test1(x: Maybe) { } test1('t1') function test2(x: Maybe) { - // x1,x2,x3 are of type number let x1 = getOrElse(x, - 1); Assert.isNumber(x1) let x2 = isDefined(x) ? x : -1; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_6.ts index e1dc8877d4..0f02f24664 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_6.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_6.ts @@ -22,11 +22,8 @@ ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -interface T { - [key: string]: string -} interface S { [value: string]: string } diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_1.ts index 19d8ff749e..47db9b2c1a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_1.ts @@ -21,18 +21,15 @@ ---*/ -import {Assert} from '../../../../suite/assert.js' - -var n_s: number | string; -var b_s: boolean | string; -var o_na: object | number[]; -n_s = 2048; -Assert.isNumber(n_s); -b_s = false; -Assert.isFalse(b_s); -n_s = "NARC"; -Assert.isString(n_s); -b_s = "1"; -Assert.equal(b_s, "1"); - +import { Assert } from '../../../../suite/assert.js' +var x: number | string; +var y: boolean | string; +x = 2048; +Assert.isNumber(x); +y = false; +Assert.isFalse(y); +x = "NARC"; +Assert.isString(x); +y = "1"; +Assert.equal(y, "1"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_2.ts index b2a1c3391c..f2c050785d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_2.ts @@ -21,15 +21,15 @@ ---*/ -import {Assert} from '../../../../suite/assert.js' +import { Assert } from '../../../../suite/assert.js' -var ab: number | string; -var ba: string | number; -ab = 1408; -ba = 1408; -Assert.equal(ab, ba); -Assert.equal(typeof ab, typeof ba); -ab = "Shift"; -ba = "Shift"; -Assert.equal(ab, ba); -Assert.equal(typeof ab, typeof ba); +let x: number | string; +let y: string | number; +x = 1408; +y = 1408; +Assert.equal(x, y); +Assert.equal(typeof x, typeof y); +x = "Shift"; +y = "Shift"; +Assert.equal(x, y); +Assert.equal(typeof x, typeof y); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_3.ts index 69dd98e314..1a66085107 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_3.ts @@ -21,36 +21,30 @@ ---*/ -import {Assert} from '../../../../suite/assert.js' +import { Assert } from '../../../../suite/assert.js' class ClassT { size: number = 0; description: string = ''; } - class ClassU1 extends ClassT { alive: boolean = false; } - class ClassU2 extends ClassT { weight: number = 0; } - interface InterfaceU1 { speak(): string; } - interface InterfaceU2 { eat(): string; } - class ClassT2 implements InterfaceU1, InterfaceU2 { food: string = ''; language: string = ''; speak() { return this.language; } - eat() { return this.food; } @@ -59,14 +53,11 @@ class ClassT2 implements InterfaceU1, InterfaceU2 { this.language = language; } } - -var u1: ClassU1 | ClassU2 = { size: 7, description: "A", alive: false }; -var t1: ClassT; +let u1: ClassU1 | ClassU2 = { size: 7, description: "A", alive: false }; +let t1: ClassT; t1 = u1; Assert.equal(JSON.stringify(t1), '{"size":7,"description":"A","alive":false}'); - -var u2: InterfaceU1 | InterfaceU2; -var t2: ClassT2 = new ClassT2("rice", "Chinese"); +let u2: InterfaceU1 | InterfaceU2; +let t2: ClassT2 = new ClassT2("rice", "Chinese"); u2 = t2; -Assert.equal(JSON.stringify(u2), '{"food":"rice","language":"Chinese"}'); - +Assert.equal(JSON.stringify(u2), '{"food":"rice","language":"Chinese"}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_4.ts index aa16e34c9c..d87814f638 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_4.ts @@ -21,44 +21,34 @@ ---*/ -import {Assert} from '../../../../suite/assert.js' +import { Assert } from '../../../../suite/assert.js' type numType = { num: number }; type strType = { str: string }; type boolType = { bool: boolean }; type objType = { obj: Object }; -var u4a: any; -var u4: numType | strType | boolType | objType | undefined; -var u4_1: numType = { num: 0xCA }; -u4a = u4_1; -Assert.equal(JSON.stringify(u4a), '{"num":202}'); - -var u4_2: strType = { str: "QWER" }; -u4a = u4_2; -Assert.equal(JSON.stringify(u4a), '{"str":"QWER"}'); - -var u4_3: boolType = { bool: false }; -u4a = u4_3; -Assert.equal(JSON.stringify(u4a), '{"bool":false}'); - -var u4_4: objType = { obj: { 0: "ZERO" } }; -u4a = u4_4; -Assert.equal(JSON.stringify(u4a), '{"obj":{"0":"ZERO"}}'); - - -u4 = { num: 0xCA, str: "ABC", bool: false, obj: u4_4 }; -u4a = u4; -Assert.equal(JSON.stringify(u4a), '{"num":202,"str":"ABC","bool":false,"obj":{"obj":{"0":"ZERO"}}}'); - - -u4 = u4_1; -Assert.equal(JSON.stringify(u4), '{"num":202}'); - -u4 = u4_2; -Assert.equal(JSON.stringify(u4), '{"str":"QWER"}'); - -u4 = u4_3; -Assert.equal(JSON.stringify(u4), '{"bool":false}'); - -u4 = u4_4; -Assert.equal(JSON.stringify(u4), '{"obj":{"0":"ZERO"}}'); +let x: any; +let y: numType | strType | boolType | objType | undefined; +let z: numType = { num: 0xCA }; +x = z; +Assert.equal(JSON.stringify(x), '{"num":202}'); +let a: strType = { str: "QWER" }; +x = a; +Assert.equal(JSON.stringify(x), '{"str":"QWER"}'); +let b: boolType = { bool: false }; +x = b; +Assert.equal(JSON.stringify(x), '{"bool":false}'); +let c: objType = { obj: { 0: "ZERO" } }; +x = c; +Assert.equal(JSON.stringify(x), '{"obj":{"0":"ZERO"}}'); +y = { num: 0xCA, str: "ABC", bool: false, obj: c }; +x = y; +Assert.equal(JSON.stringify(x), '{"num":202,"str":"ABC","bool":false,"obj":{"obj":{"0":"ZERO"}}}'); +y = z; +Assert.equal(JSON.stringify(y), '{"num":202}'); +y = a; +Assert.equal(JSON.stringify(y), '{"str":"QWER"}'); +y = b; +Assert.equal(JSON.stringify(y), '{"bool":false}'); +y = c; +Assert.equal(JSON.stringify(y), '{"obj":{"0":"ZERO"}}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_5.ts index c48510570d..7b128e80e9 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_5.ts @@ -20,40 +20,35 @@ ---*/ -import {Assert} from '../../../../suite/assert.js' - -var ns5: A1 = 1408 || "NARC"; -var ns5_1: number | string; -var ns5_2: string | number; -ns5 = 1500; -ns5_2 = ns5 <= 1408 ? "NARC" : 1024; -Assert.equal(ns5_2, 1024); -ns5 = 100; -ns5_2 = ns5 <= 1408 ? "NARC" : 1024; -Assert.equal(ns5_2, "NARC"); +import { Assert } from '../../../../suite/assert.js' +let x: A1 = 1408 || "NARC"; +let y: string | number; +x = 1500; +y = x <= 1408 ? "NARC" : 1024; +Assert.equal(y, 1024); +x = 100; +y = x <= 1408 ? "NARC" : 1024; +Assert.equal(y, "NARC"); type A1 = string | number | object; type B1 = number | boolean | string; -var ns5_3: A1 & B1; -ns5_3 = 125; -Assert.isNumber(ns5_3); -ns5_3 = "Fn"; -Assert.isString(ns5_3); - -var arruni1: Array | Array; -arruni1 = [0, true, -1, false]; -Assert.equal(JSON.stringify(arruni1), '[0,true,-1,false]'); -arruni1 = [true, "True", false, "False"]; -Assert.equal(JSON.stringify(arruni1), '[true,"True",false,"False"]'); - -var arruni2: number[] | boolean[]; -arruni2 = [2, 4, 6]; -Assert.equal(JSON.stringify(arruni2), '[2,4,6]'); -arruni2 = [true, false]; -Assert.equal(JSON.stringify(arruni2), '[true,false]'); - -var arruni3: (number | string)[] | (boolean | Object)[]; -arruni3 = [1, 3, 5, "AND", "OR"]; -Assert.equal(JSON.stringify(arruni3), '[1,3,5,"AND","OR"]'); -arruni3 = [true, false, { 0x00: "0x00" }, { 0xFA: "0xFA" }]; -Assert.equal(JSON.stringify(arruni3), '[true,false,{"0":"0x00"},{"250":"0xFA"}]'); \ No newline at end of file +let z: A1 & B1; +z = 125; +Assert.isNumber(z); +z = "Fn"; +Assert.isString(z); +let a: Array | Array; +a = [0, true, -1, false]; +Assert.equal(JSON.stringify(a), '[0,true,-1,false]'); +a = [true, "True", false, "False"]; +Assert.equal(JSON.stringify(a), '[true,"True",false,"False"]'); +let b: number[] | boolean[]; +b = [2, 4, 6]; +Assert.equal(JSON.stringify(b), '[2,4,6]'); +b = [true, false]; +Assert.equal(JSON.stringify(b), '[true,false]'); +let c: (number | string)[] | (boolean | Object)[]; +c = [1, 3, 5, "AND", "OR"]; +Assert.equal(JSON.stringify(c), '[1,3,5,"AND","OR"]'); +c = [true, false, { 0x00: "0x00" }, { 0xFA: "0xFA" }]; +Assert.equal(JSON.stringify(c), '[true,false,{"0":"0x00"},{"250":"0xFA"}]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_6.ts index 3f0746b6bc..171bc00ed4 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_6.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_6.ts @@ -23,8 +23,8 @@ import { Assert } from '../../../../suite/assert.js' -var h_x: string | number; -h_x = 37; -h_x = "hello"; -var h_n = typeof h_x === "string" ? h_x.length : h_x; -Assert.isNumber(h_n); +let x: string | number; +x = 37; +x = "hello"; +let h_n = typeof x === "string" ? x.length : x; +Assert.isNumber(h_n); \ No newline at end of file -- Gitee From 15acfaf8d9e7d3066ff8ba2a48b6345954e0b0bf Mon Sep 17 00:00:00 2001 From: tanglizhen Date: Wed, 7 Jun 2023 15:13:58 +0800 Subject: [PATCH 09/18] =?UTF-8?q?Ts=20test=20cases=20fix=20Issues=EF=BC=9A?= =?UTF-8?q?https://gitee.com/openharmony/arkcompiler=5Fets=5Ffrontend/issu?= =?UTF-8?q?es/I78HJU=3Ffrom=3Dproject-issue=20Signed-off-by:=20tanglizhen?= =?UTF-8?q?=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es2panda/test/ts_extra_tests/run_ts_case.py | 42 ++++++++++----------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/es2panda/test/ts_extra_tests/run_ts_case.py b/es2panda/test/ts_extra_tests/run_ts_case.py index 330590a1d8..28dc55b3e2 100644 --- a/es2panda/test/ts_extra_tests/run_ts_case.py +++ b/es2panda/test/ts_extra_tests/run_ts_case.py @@ -147,7 +147,6 @@ for file_path in args.release: failed_case += 1 continue for file_path in get_path_file(file_path, None, True, args.limit_version): - # continue if False == file_path.endswith(".ts"): continue if is_disable_case(file_path, disable_list): @@ -158,26 +157,27 @@ for file_path in args.release: if failed : failed_case += 1 - # delete abc files - if args.arkruntime: - for file_paths in get_path_file("suite", None, True): - if file_paths.endswith(".abc"): - if os.path.exists(file_paths): - os.remove(file_paths) - - for file_paths in get_path_file("test_ts_cases", None, True): - if file_paths.endswith(".abc"): - if os.path.exists(file_paths): - os.remove(file_paths) - if file_paths.endswith(".ts"): - if os.path.exists(file_paths): - file = open(file_paths, 'r') - lines = file.readlines() - if lines[-1] == 'print("TESTCASE SUCCESS");': - lines.pop() - file = open(file_paths, 'w') - file.writelines(lines) - file.close() +# delete abc files +if args.arkruntime: + for file_paths in get_path_file("suite", None, True): + if file_paths.endswith(".abc"): + if os.path.exists(file_paths): + os.remove(file_paths) + + for file_paths in get_path_file("test_ts_cases", None, True): + if file_paths.endswith(".abc"): + if os.path.exists(file_paths): + os.remove(file_paths) + if file_paths.endswith(".ts"): + if os.path.exists(file_paths): + file = open(file_paths, 'r') + lines = file.readlines() + if lines[-1] == 'print("TESTCASE SUCCESS");': + lines.pop() + lines[-1] = lines[-1].replace('\n', '') + file = open(file_paths, 'w') + file.writelines(lines) + file.close() print("TOTAL CASE COUNT:%d" % total_case) print("FAILED CASE COUNT:%d" % failed_case) -- Gitee From 8162b7907d9ece301ee8ab6045f7d2e63351e6be Mon Sep 17 00:00:00 2001 From: tanglizhen Date: Wed, 7 Jun 2023 17:13:16 +0800 Subject: [PATCH 10/18] =?UTF-8?q?Ts=20test=20cases=20fix=20Issues=EF=BC=9A?= =?UTF-8?q?https://gitee.com/openharmony/arkcompiler=5Fets=5Ffrontend/issu?= =?UTF-8?q?es/I78HJU=3Ffrom=3Dproject-issue=20Signed-off-by:=20tanglizhen?= =?UTF-8?q?=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../abstract_properties_and_accessors.ts | 9 ++++ .../module_resolution_enhancements_2.ts | 29 ----------- .../tagged_union_types_1.ts | 50 +++++++------------ .../object_type/object_type_3.ts} | 32 ++++++++---- ..._contravariance_for_callback_parameters.ts | 32 +++++------- .../2.8/predefined_conditional_types.ts | 8 +++ .../disabling_import_elision_1.ts | 4 +- .../disabling_import_elision/human.ts} | 22 ++++---- .../private_field_presence_checks_1.ts | 14 +++--- ...rsion_elimination_on_conditional_types1.ts | 8 +-- ...rsion_elimination_on_conditional_types2.ts | 16 +++--- ...emplate_string_types_as_discriminants_1.ts | 16 +++--- .../some-module.ts | 4 +- .../type_modifiers_on_import_names_1.ts | 14 +++--- .../4.6/1_allowing_code_in_constructors.ts | 6 ++- .../4.6/3_improved_recursion_depth_checks.ts | 1 - ...4_indexed_access_inference_improvements.ts | 42 ++++++++++++---- ..._flow_analysis_for_dependent_parameters.ts | 21 +++++--- 18 files changed, 166 insertions(+), 162 deletions(-) delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_resolution_enhancements/module_resolution_enhancements_2.ts rename es2panda/test/ts_extra_tests/test_ts_cases/{2.0/module_resolution_enhancements/module_resolution_enhancements_3.ts => 2.2/object_type/object_type_3.ts} (48%) rename es2panda/test/ts_extra_tests/test_ts_cases/{2.0/module_resolution_enhancements/module_resolution_enhancements_1.ts => 4.5/disabling_import_elision/human.ts} (61%) diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts index 866652e0af..ae4b7844c8 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts @@ -26,11 +26,20 @@ import { Assert } from "../../../suite/assert.js" abstract class Skill { abstract name: string; abstract damage:number; + abstract get accessor(); + abstract set accessor(ok:string); } class Divied extends Skill { name = "derived"; damage = 128; + get accessor() { + return 'ok' + } + set accessor(ok:string) { + this.name = ok; + } } let d = new Divied(); Assert.equal(d.name, "derived"); Assert.equal(d.damage, 128); +Assert.equal(d.accessor, "ok"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_resolution_enhancements/module_resolution_enhancements_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_resolution_enhancements/module_resolution_enhancements_2.ts deleted file mode 100644 index 567be71b56..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_resolution_enhancements/module_resolution_enhancements_2.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: > - The TypeScript compiler supports the declaration of such mappings using paths property in tsconfig.json files, - Path mapping. - The tsc command needs to be executed in the 2.0 file directory. - tsconfig.json file url: testing-framework\test\2.0\tsconfig.json. -module: ESNext -isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" -import { Directions } from "../test_virtual_directories_with_rootDirs/view2.js" - -Assert.equal(Directions.Up, 0); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/tagged_union_types/tagged_union_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/tagged_union_types/tagged_union_types_1.ts index 607723bc9a..f736a3b469 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/tagged_union_types/tagged_union_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/tagged_union_types/tagged_union_types_1.ts @@ -21,32 +21,33 @@ isCurrent: true import { Assert } from "../../../suite/assert.js" -interface Color { +type Color = { name: "Color"; rgb: [number, number, number]; } -interface Point { +type Point = { name: "Point"; point: [number, number]; } -interface Level { - name: "Level"; - level: number; -} -type ColorPoint = Color | Point | Level; -function test(s: ColorPoint) { - switch (s.name) { - case "Color": - return s.rgb; - case "Point": - return s.point; - case "Level": - return s.level; +type ColorPoint = Color | Point +let un:ColorPoint[] = [{name:"Color", rgb:[0,0,0]},{name:"Point", point:[1,1]}]; +let count:number = 0; +function test(s: ColorPoint[]) { + for (const unElement of s) { + switch (unElement.name) { + case "Color": + count++ + break + case "Point": + count++ + break + } } + return count; } function test1(s: ColorPoint) { @@ -56,28 +57,11 @@ function test1(s: ColorPoint) { return s; } -function test2(s: ColorPoint) { - if (s.name === "Color" || s.name === "Point") { - return; - } - return s; -} - -let color: Color = { - name: "Color", - rgb: [255, 0, 0] -}; - let point: Point = { name: "Point", point: [0, 0] }; -let level: Level = { - name: "Level", - level: 10 -}; -Assert.equal(JSON.stringify(test(color)), '[255,0,0]'); +Assert.equal(JSON.stringify(test(un)), 2); Assert.equal(test1(point).name, 'Point'); -Assert.equal(test2(level)?.level, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_resolution_enhancements/module_resolution_enhancements_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type_3.ts similarity index 48% rename from es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_resolution_enhancements/module_resolution_enhancements_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type_3.ts index f4b2dd70e5..6007f1806f 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_resolution_enhancements/module_resolution_enhancements_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type_3.ts @@ -13,18 +13,28 @@ * limitations under the License. */ /**--- -description: > - Using ‘rootDirs’, you can inform the compiler of the roots making up this “virtual” directory; - and thus the compiler can resolve relative modules imports within these “virtual” directories - as if they were merged together in one directory. - The tsc command needs to be executed in the 2.0 file directory. - tsconfig.json file url: testing-framework\test\2.0\tsconfig.json. -module: ESNext -isCurrent: true ----*/ + description: > + Create an object type variable + module: ESNext + isCurrent: true + ---*/ import { Assert } from '../../../suite/assert.js' -import { Directions } from '../test_virtual_directories_with_rootDirs/view2.js' -Assert.equal(Directions.Left, 2); \ No newline at end of file +let obj5 = new Object({ Damage: 1024, DamageType: 'XO' }); +Assert.equal(JSON.stringify(obj5), '{"Damage":1024,"DamageType":"XO"}'); + +type ColorOBJ = { Color: [number, number, number], ColorName: string }; +let obj6: ColorOBJ = { Color: [255, 0, 0], ColorName: 'Red' }; +Assert.equal(JSON.stringify(obj6), '{"Color":[255,0,0],"ColorName":"Red"}'); + +interface Weapon { + Damage: number; + DamageType: string; +} +let obj7: Weapon = { Damage: 333, DamageType: 'EXP' }; +Assert.equal(JSON.stringify(obj7), '{"Damage":333,"DamageType":"EXP"}'); + +let obj8: object = { A: 1 }; +Assert.equal(JSON.stringify(obj8), '{"A":1}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/4_strict_contravariance_for_callback_parameters/4_strict_contravariance_for_callback_parameters.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/4_strict_contravariance_for_callback_parameters/4_strict_contravariance_for_callback_parameters.ts index 2fd1f237b2..e9db170dbe 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/4_strict_contravariance_for_callback_parameters/4_strict_contravariance_for_callback_parameters.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/4_strict_contravariance_for_callback_parameters/4_strict_contravariance_for_callback_parameters.ts @@ -21,27 +21,19 @@ import { Assert } from '../../../suite/assert.js' -interface I { - add(t: T): T; -} -class C implements I { - add(n: number) { - return n += 10; +function f(arg: U): U{ + if (typeof arg === 'number') { + return arg; } -} - -let a: I; -let b: I; -a = new C(); - -b = a; -Assert.equal(20, b.add(10)); - -function func(arg: T): T{ return arg; } -let f1 = func(5); -let f2 = func('a'); +function func(a: T, callback: (arg: U) => U){ + return callback(a); +} -f2 = f1; -Assert.equal(f1, f2); \ No newline at end of file +let a = func(5, f); +let b = func('a', f); +Assert.isNumber(a); +Assert.isString(b); +b = a; +Assert.equal(a, b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/predefined_conditional_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/predefined_conditional_types.ts index 0d99bebb58..bbf58c8b5f 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/predefined_conditional_types.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/predefined_conditional_types.ts @@ -64,4 +64,12 @@ import { Assert } from '../../suite/assert.js' Assert.equal(typeof f, "function"); Assert.equal(x.a, 1); Assert.equal(y.x, 1); + + type G = number[] | number | null | undefined + type TypeG = NonNullable; + let g: TypeG; + g = [0, 1, 2]; + Assert.equal(g.length, 3); + g = -1; + Assert.equal(g, -1); }; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/disabling_import_elision/disabling_import_elision_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/disabling_import_elision/disabling_import_elision_1.ts index 22a16b12f0..de587ac3da 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/disabling_import_elision/disabling_import_elision_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/disabling_import_elision/disabling_import_elision_1.ts @@ -22,6 +22,6 @@ import { Assert } from "../../../suite/assert.js"; -import { animal } from "./animal.js"; +import { human } from "./human.js"; -Assert.isFunction(animal); \ No newline at end of file +Assert.isFunction(human); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_resolution_enhancements/module_resolution_enhancements_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/disabling_import_elision/human.ts similarity index 61% rename from es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_resolution_enhancements/module_resolution_enhancements_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.5/disabling_import_elision/human.ts index 0f57862551..53918940d0 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_resolution_enhancements/module_resolution_enhancements_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/disabling_import_elision/human.ts @@ -12,17 +12,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/**--- -description: > - test base url import,the tsc command needs to be executed in the 2.0 file directory. - tsconfig.json file url: testing-framework\test\2.0\tsconfig.json. -module: ESNext -isCurrent: true ----*/ -import { Assert } from "../../../suite/assert.js" -import { ADD, flag } from "../test_base_url.js" +export class Human { + name: string; + age: number; + gender: string; + constructor(name: string, age: number, gender: string) { + this.name = name; + this.age = age; + this.gender = gender; + } +} -Assert.equal(ADD(50, 75), 125); -Assert.equal(flag, "baseurl"); +export { Human as human }; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/private_field_presence_checks/private_field_presence_checks_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/private_field_presence_checks/private_field_presence_checks_1.ts index b25dc25615..9bffc1aac6 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/private_field_presence_checks/private_field_presence_checks_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/private_field_presence_checks/private_field_presence_checks_1.ts @@ -23,15 +23,15 @@ import { Assert } from '../../../suite/assert.js' class RunP { - #name: string; - constructor(name: string) { - this.#name = name; + #type: string; + constructor(type: string) { + this.#type = type; } - combine(other: any) { - return other && - typeof other === "object" && - this.#name === other.#name; + combine(additional: any) { + return additional && + typeof additional === "object" && + this.#type === additional.#type; } } diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types1.ts index 220fd6d951..e893954d60 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types1.ts @@ -22,8 +22,8 @@ import { Assert } from "../../../suite/assert.js" -type project = T extends ` ${infer Rest}` ? project : T; +type project = T extends ` ${infer push}` ? project : T; -type test = project<" oops">; -var t: test = "oops"; -Assert.equal(t, "oops"); +type example = project<" tool">; +var t: example = "tool"; +Assert.equal(t, "tool"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts index dd053e796b..82774d24c3 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts @@ -23,18 +23,18 @@ import { Assert } from "../../../suite/assert.js" -type RunGetChars = S extends `${infer Char}${infer Rest}` - ? Char | RunGetChars - : never; -type gc = RunGetChars<" getChar">; -var g1: gc = "e"; +type RunChars = S extends `${infer Char}${infer Rest}` + ? Char | RunChars + : never; +type gc = RunChars<" RunChar">; +var g1: gc = "n"; Assert.isString(g1); type RunGetChars1 = RunGetCharsHelper; type RunGetCharsHelper = S extends `${infer Char}${infer Rest}` - ? RunGetCharsHelper - : Acc; + ? RunGetCharsHelper + : Acc; type gch = RunGetCharsHelper; var g2: gch = 10; -Assert.isNumber(g2); +Assert.isNumber(g2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/template_string_types_as_discriminants/template_string_types_as_discriminants_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/template_string_types_as_discriminants/template_string_types_as_discriminants_1.ts index 55f6304307..26938121c1 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/template_string_types_as_discriminants/template_string_types_as_discriminants_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/template_string_types_as_discriminants/template_string_types_as_discriminants_1.ts @@ -28,31 +28,31 @@ interface Message { } interface SMessage { - pattern: `${string}Success`; + pattern: `${string}SMessage`; location: string; } interface EMessage { - pattern: `${string}Error`; + pattern: `${string}EMessage`; message: string; } function RunTest(r: SMessage | EMessage |Message) { - if (r.pattern === "HttpSuccess") { + if (r.pattern === "WinSMessage") { let token = r.pattern; - Assert.equal(token, "HttpSuccess"); + Assert.equal(token, "WinSMessage"); } else { - Assert.equal(r.pattern, "HttpError"); + Assert.equal(r.pattern, "LostEMessage"); } } const successMessage: SMessage = { - pattern: "HttpSuccess", - location: "request success" + pattern: "WinSMessage", + location: "request SMessage" } const errorMessage: EMessage = { - pattern: "HttpError", + pattern: "LostEMessage", message: "100-continue" } diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/some-module.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/some-module.ts index 1a7b34d361..3c939175fc 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/some-module.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/some-module.ts @@ -15,8 +15,8 @@ let num = 5; -export let someFunc = function () { +export let privateF = function () { return 10 + num; }; -export class BaseType { }; +export class PrivateType { }; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts index 6f2206ac50..cec36c68b1 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts @@ -22,15 +22,15 @@ isCurrent: true import { Assert } from "../../../suite/assert.js" -import { someFunc, BaseType } from "./some-module.js" +import { privateF, PrivateType } from "./some-module.js" -export class Thing implements BaseType { - someMethod() { - return someFunc(); +export class Type implements PrivateType { + func() { + return privateF(); } } -const thing = new Thing(); -Assert.isFunction(Thing); -Assert.equal(thing.someMethod(), 15); \ No newline at end of file +const type = new Type(); +Assert.isFunction(Type); +Assert.equal(type.func(), 15); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/1_allowing_code_in_constructors.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/1_allowing_code_in_constructors.ts index 618c4e4cc0..1ce1356b83 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/1_allowing_code_in_constructors.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/1_allowing_code_in_constructors.ts @@ -21,10 +21,14 @@ import { Assert } from '../../suite/assert.js' -class C { } +class C { + a: number = 1; +} class C2 extends C { bool = true; constructor() { + let x = 1; + Assert.equal(x, 1); super(); this.bool = false; } diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/3_improved_recursion_depth_checks.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/3_improved_recursion_depth_checks.ts index 75da0c1a7f..cd07f12434 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/3_improved_recursion_depth_checks.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/3_improved_recursion_depth_checks.ts @@ -28,5 +28,4 @@ let x: I3>>>>>; let y: I3>>>>; y = { prop: { prop: { prop: { prop: { prop: "prop" } } } } } x = { prop: y }; -Assert.isString("x = y; this is error"); Assert.notEqual(JSON.stringify(x), JSON.stringify(y)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/4_indexed_access_inference_improvements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/4_indexed_access_inference_improvements.ts index df32d679b4..80cc93cdaa 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/4_indexed_access_inference_improvements.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/4_indexed_access_inference_improvements.ts @@ -22,24 +22,46 @@ import { Assert } from '../../suite/assert.js' interface I { - xx: number; - yy: string; - zz: boolean; + a: number; + b: string; + c: boolean; + d: object; } type T

= { [K in P]: { - name: K; + nameI: K; v: I[K]; f: (p: I[K]) => void; }; }[P]; -function fun(record: T) { - record.f(record.v); +function fun(x: T) { + x.f(x.v); } fun({ - name: "yy", - v: "hello!", - f: (val) => { - Assert.equal(val.toUpperCase(), "HELLO!"); + nameI: "a", + v: 11, + f: (x) => { + Assert.isNumber(x); + }, +}); +fun({ + nameI: "b", + v: "b", + f: (x) => { + Assert.isString(x); + }, +}); +fun({ + nameI: "c", + v: true, + f: (x) => { + Assert.isBoolean(x); + }, +}); +fun({ + nameI: "d", + v: {}, + f: (x) => { + Assert.isObject(x); }, }); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/5_control_flow_analysis_for_dependent_parameters.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/5_control_flow_analysis_for_dependent_parameters.ts index 2718d06002..8e83d91347 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/5_control_flow_analysis_for_dependent_parameters.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/5_control_flow_analysis_for_dependent_parameters.ts @@ -21,14 +21,19 @@ import { Assert } from '../../suite/assert.js' -type T = (...args: ["a", number] | ["b", string]) => void; -const fun: T = (kind, payload) => { - if (kind === "a") { - Assert.equal(42, payload.toFixed()); +type T = (...args: [1, number] | [true, string] | ["a", boolean]) => void; +const fun: T = (x: true | 1 | "a", y: string | number | boolean) => { + if (x === 1) { + Assert.equal(10, y); } - if (kind === "b") { - Assert.equal("HELLO", payload.toUpperCase()); + if (x === true) { + Assert.equal("hello", y); } + if (x === "a") { + Assert.isBoolean(y); + } + }; -fun("a", 42); -fun("b", "hello"); \ No newline at end of file +fun(1, 10); +fun(true, "hello"); +fun("a", true); \ No newline at end of file -- Gitee From 2917861170c0ce36e36333c8e8418589aa52c6d4 Mon Sep 17 00:00:00 2001 From: tanglizhen Date: Wed, 14 Jun 2023 13:48:26 +0800 Subject: [PATCH 11/18] =?UTF-8?q?Ts=20test=20cases=20fix=20Issues=EF=BC=9A?= =?UTF-8?q?https://gitee.com/openharmony/arkcompiler=5Fets=5Ffrontend/issu?= =?UTF-8?q?es/I78HJU=3Ffrom=3Dproject-issue=20Signed-off-by:=20tanglizhen?= =?UTF-8?q?=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ..._property_Inference_from_constructors_1.ts | 44 ++---------- .../labeled_tuple_elements_1.ts | 35 +++++---- .../labeled_tuple_elements_2.ts | 17 +++-- .../labeled_tuple_elements_3.ts | 17 +++-- ...short_circuiting_assignment_operators_1.ts | 12 +++- .../unknow_on_catch_clause_bindings_1.ts | 4 +- .../unknow_on_catch_clause_bindings_2.ts | 36 ++++++---- .../variadic_tuple_types_1.ts | 26 +++---- .../variadic_tuple_types_2.ts | 40 +++-------- .../variadic_tuple_types_3.ts | 40 ++++++----- .../variadic_tuple_types_6.ts | 54 -------------- .../private_field_presence_checks_1.ts | 1 + ...rsion_elimination_on_conditional_types2.ts | 28 +++++--- .../type_modifiers_on_import_names_1.ts | 3 +- .../constant_enum_declarations.ts | 10 ++- .../spec/enums/enum_members/enum_members_1.ts | 21 +++++- .../array_literals/array_literal_2.ts | 10 ++- .../the_congruence_operator.ts | 0 .../the_equal_operator.ts | 0 .../the_greater_operator.ts | 0 .../the_greater_or_equal_operator.ts | 0 .../the_incongruence_operator.ts | 0 .../the_less_operator.ts | 0 .../the_less_or_equal_operator.ts | 0 .../the_unequal_operator.ts | 0 .../the_and_operator.ts | 0 .../the_division_method_operator.ts | 0 .../the_left_shift_operator.ts | 0 .../the_multiplication_operator.ts | 0 .../the_or_operator.ts | 0 .../the_remainder_operator.ts | 0 .../the_right_shift_operator.ts | 0 .../the_subtraction_operator.ts | 0 .../the_unsigned_shift_to_the_right.ts | 0 .../the_xor_operator.ts | 0 .../object_literal/object_literal_1.ts} | 43 ++++++----- .../object_literal/object_literal_2.ts | 50 +++++++++++++ .../object_literal/object_literal_3.ts | 37 ++++++---- .../object_literal/object_literal_5.ts | 1 - .../object_literal/object_literal_6.ts | 21 ++++-- .../object_literal/object_literal_7.ts | 25 +++---- .../object_literal/object_literal_8.ts | 41 +++++++++++ .../object_literal/object_literal_9.ts | 57 +++++++++++++++ .../property_access/object_any_1.ts | 12 ++-- .../property_access/object_string_number_3.ts | 4 +- .../the_new_operator/new_operator_1.ts | 10 ++- .../super_calls/super_calls.ts | 4 +- .../this_key_word/this_key_word_1.ts | 38 +++++----- .../this_key_word/this_key_word_2.ts} | 31 +++++--- .../interface_declarations_1.ts | 71 +++++++++++++++---- .../interface_declarations_2.ts | 18 ++--- .../interface_declarations_3.ts | 4 +- .../declaration_merging_1.ts | 25 +++++-- .../interfaces_extending_classes_1.ts | 4 +- .../interfaces_extending_classes_2.ts | 4 +- .../dynamic_type_checks_1.ts | 18 ++--- .../types/object_types/members/members_3.ts} | 17 ++--- .../named_type_reference.ts | 13 +++- .../parameter_list/parameter_list_1.ts | 3 - .../constructor_type_literals.ts} | 48 +++++++------ .../union_type_literals.ts | 6 +- .../spec/types/the_any_type/any_type_3.ts | 20 +++++- .../excess_properties/excess_properties_1.ts | 20 ++++-- .../spec/types/widend_types/widend_types_1.ts | 2 +- 64 files changed, 645 insertions(+), 400 deletions(-) delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_6.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_greater_less => the_greater}/the_congruence_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_greater_less => the_greater}/the_equal_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_greater_less => the_greater}/the_greater_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_greater_less => the_greater}/the_greater_or_equal_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_greater_less => the_greater}/the_incongruence_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_greater_less => the_greater}/the_less_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_greater_less => the_greater}/the_less_or_equal_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_greater_less => the_greater}/the_unequal_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_mul_div_rem_sub => the_mul}/the_and_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_mul_div_rem_sub => the_mul}/the_division_method_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_mul_div_rem_sub => the_mul}/the_left_shift_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_mul_div_rem_sub => the_mul}/the_multiplication_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_mul_div_rem_sub => the_mul}/the_or_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_mul_div_rem_sub => the_mul}/the_remainder_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_mul_div_rem_sub => the_mul}/the_right_shift_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_mul_div_rem_sub => the_mul}/the_subtraction_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_mul_div_rem_sub => the_mul}/the_unsigned_shift_to_the_right.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/{the_mul_div_rem_sub => the_mul}/the_xor_operator.ts (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/{4.0/variadic_tuple_types/variadic_tuple_types_5.ts => spec/expressions/object_literal/object_literal_1.ts} (43%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_8.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_9.ts rename es2panda/test/ts_extra_tests/test_ts_cases/{4.5/disabling_import_elision/animal.ts => spec/expressions/this_key_word/this_key_word_2.ts} (54%) rename es2panda/test/ts_extra_tests/test_ts_cases/{4.0/labeled_tuple_elements/labeled_tuple_elements_4.ts => spec/types/object_types/members/members_3.ts} (60%) rename es2panda/test/ts_extra_tests/test_ts_cases/{4.0/variadic_tuple_types/variadic_tuple_types_4.ts => spec/types/specifying_types/constructor_type_literals/constructor_type_literals.ts} (48%) diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/class_property_Inference_from_constructors/class_property_Inference_from_constructors_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/class_property_Inference_from_constructors/class_property_Inference_from_constructors_1.ts index 2bfe3fc36d..d245de2941 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/class_property_Inference_from_constructors/class_property_Inference_from_constructors_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/class_property_Inference_from_constructors/class_property_Inference_from_constructors_1.ts @@ -22,46 +22,12 @@ import { Assert } from '../../../suite/assert.js' -class HWP { - name: string; - age: number | undefined; +class NA { + name; + constructor(name: string) { this.name = name; } - setAge(age: number) { - if (age >= 0) { - this.age = age; - } - } -} -const W = new HWP("tom"); -Assert.equal(W.name, "tom"); - -class HWSD { - area: number | undefined; - - sideLength: number | undefined; - constructor(sideLength: number) { - this.sideLength = sideLength; - this.area = sideLength * 2; - } -} -const D = new HWSD(6); -Assert.equal(D.area, 12); - -class HWS { - sideLength!: number; - constructor(sideLength: number) { - this.initialize(sideLength); - } - - initialize(sideLength: number) { - this.sideLength = sideLength; - } - - get area() { - return this.sideLength ** 2; - } } -const b = new HWS(8); -Assert.equal(b.area, 64); +const W = new NA("tom"); +Assert.equal(W.name, 'tom'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_1.ts index ce576222cb..6f9c5e6aec 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_1.ts @@ -14,8 +14,8 @@ */ /**--- description: > - function foo(...args: [string, number]): void { - // ...} + To deepen the connection between parameter lists and tuple types, + the syntax for rest elements and optional elements mirrors the syntax for parameter lists. module: ESNext isCurrent: true ---*/ @@ -23,15 +23,24 @@ import { Assert } from '../../../suite/assert.js' -function funLTE01(...args: [string, number]): void { - const newArr = [args[0].toUpperCase(), args[1] * 2]; - Assert.equal(newArr[0], "HELLO"); - Assert.equal(newArr[1], 10); +type Weapon = [Damage: number, DamageType?: string, ...rest: any[]]; +function getWeaponJSON(weapon: Weapon): string { + let len: number = weapon.length; + let obj: { [key: string | number]: any } = { 'Damage': 0 }; + for (let i = 0; i < len; i++) { + if (i == 0) { + obj['Damage'] = weapon[i]; + } else if (i == 1) { + obj['DamageType'] = weapon[i]; + } else { + obj[i] = weapon[i]; + } + } + return JSON.stringify(obj); } -funLTE01("hello", 5); -function funLTE02(arg0: string, arg1: number): void { - const Arrb = [arg0.toUpperCase(), arg1 * 2]; - Assert.equal(Arrb[0], "HELLO"); - Assert.equal(Arrb[1], 10); -} -funLTE02("hello", 5); +let weapon1: Weapon = [1024, 'XO', 0, 'NARC', true]; +let weapon2: Weapon = [100]; +let weapon3: Weapon = [333, 'EXP', ['A', 1024, false], { A: 1, B: 2 }]; +Assert.equal(getWeaponJSON(weapon1), '{"2":0,"3":"NARC","4":true,"Damage":1024,"DamageType":"XO"}'); +Assert.equal(getWeaponJSON(weapon2), '{"Damage":100}'); +Assert.equal(getWeaponJSON(weapon3), '{"2":["A",1024,false],"3":{"A":1,"B":2},"Damage":333,"DamageType":"EXP"}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_2.ts index 4538478934..59b2dc0951 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_2.ts @@ -14,8 +14,8 @@ */ /**--- description: > - To deepen the connection between parameter lists and tuple types, - the syntax for rest elements and optional elements mirrors the syntax for parameter lists. + There are a few rules when using labeled tuples. + For one, when labeling a tuple element, all other elements in the tuple must also be labeled. module: ESNext isCurrent: true ---*/ @@ -23,9 +23,12 @@ import { Assert } from '../../../suite/assert.js' -type HWT = [first: number, second?: string, ...rest: any[]]; -let arr: HWT = [42, "Hello", true, { foo: "bar" }]; +type A01 = [name: string, age: number]; +type A02 = [name?: string, age?: number]; -Assert.equal(arr[0], 42); -Assert.equal(arr[1], "Hello"); -Assert.equal(arr[2], true); +let a1: A01 = ['NARC', 0]; +let a2_1: A02 = []; +let a2_2: A02 = ['ACDC']; +Assert.equal(JSON.stringify(a1), '["NARC",0]'); +Assert.equal(JSON.stringify(a2_1), '[]'); +Assert.equal(JSON.stringify(a2_2), '["ACDC"]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_3.ts index fc23def7cf..44a74e138c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_3.ts @@ -14,8 +14,8 @@ */ /**--- description: > - There are a few rules when using labeled tuples. - For one, when labeling a tuple element, all other elements in the tuple must also be labeled. + It’s worth noting - labels don’t require us to name our variables differently when destructuring. + They’re purely there for documentation and tooling. module: ESNext isCurrent: true ---*/ @@ -23,10 +23,9 @@ import { Assert } from '../../../suite/assert.js' -type A01 = [name: string, age: number]; -type A02 = [name?: string, age?: number]; - -const t: [string, number, boolean] = ["hello", 123, true]; -Assert.equal(t[0], "hello"); -Assert.equal(t[1], 123); -Assert.equal(t[2], true); +function funLTE01(x: [first: string, second: number]) { + const [a, b] = x; + Assert.equal(a, "hello"); + Assert.equal(b, 42); +} +funLTE01(["hello", 42]); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_1.ts index f63de617e9..42d5761db6 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_1.ts @@ -56,15 +56,21 @@ Assert.equal(m, 0); let o: number = 4; let p: number = 5; -o = o && p; +let o1 = o && p; +o &&= p; Assert.equal(o, 5); +Assert.equal(o1, 5); let s: number = 7; let t: number = 8; -s = s || t; +let s1 = s || t; +s ||= t; Assert.equal(s, 7); +Assert.equal(s1, 7); let u: number = 10; let v: number = 20; -u = u ?? v; +let u1 = u ?? v; +u ??= v; +Assert.equal(u1, 10); Assert.equal(u, 10); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_1.ts index d99ffb1e81..a698a64af2 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_1.ts @@ -23,11 +23,11 @@ import { Assert } from '../../../suite/assert.js' -function h_throwError(): never { +function getErrorMessage(): never { throw new Error("An error occurred"); } try { - h_throwError(); + getErrorMessage(); } catch (error: any) { Assert.equal(error.message, "An error occurred"); }; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_2.ts index 7e94e895f2..ef8a9f770c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_2.ts @@ -27,18 +27,30 @@ import { Assert } from '../../../suite/assert.js' let flag: boolean = false; -function h_throwError(): never { +function getErrorMessage(): never { throw new Error("An error occurred"); } -try { - h_throwError(); -} catch (error: unknown) { - if (error instanceof Error) { - flag = true; - Assert.equal(error.message, "An error occurred"); - } else { - flag = false; - let errString = "An unknow error occurred"; +function getUnknown(): never { + let err: unknown; + throw err; +} +function getFlag(fun: Function) { + try { + fun(); + } catch (error: unknown) { + if (error instanceof Error) { + flag = true; + Assert.equal(error.message, "An error occurred"); + return error.message; + } else { + flag = false; + let errString = "An unknow error occurred"; + return errString; + } } -}; -Assert.isTrue(flag); \ No newline at end of file +} +getFlag(getErrorMessage); +Assert.isTrue(flag); +let errString = getFlag(getUnknown); +Assert.equal(errString, "An unknow error occurred"); +Assert.isFalse(flag); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_1.ts index a45266399f..b6ca4a49be 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_1.ts @@ -14,7 +14,9 @@ */ /**--- description: > - Consider a function in JavaScript called concat that takes two array or tuple types and concatenates them together to make a new array. + The first change is that spreads in tuple type syntax can now be generic. + This means that we can represent higher-order operations on tuples and arrays even when we don’t know the actual types we’re operating over. + When generic spreads are instantiated (or, replaced with a real type) in these tuple types, they can produce other sets of array and tuple types. module: ESNext isCurrent: true ---*/ @@ -22,19 +24,11 @@ import { Assert } from '../../../suite/assert.js' -function funVTT01(arr1: any, arr2: any) { - return [...arr1, ...arr2]; +function dropFrist(arr1: T[], arr2: U[]): Array { + const [first, ...others] = [...arr1, ...arr2]; + return others; } -const arrA: any = [1, 2, 3]; -const arrB: any = [4, 5, 6]; -let len01 = funVTT01(arrA, arrB).length; -Assert.equal(len01, 6); - -function funVTT02(arg: any) { - const [_, ...result] = arg; - return result; -} - -const arrC: any = [1, 2, 3, 4, 5]; -let len02 = funVTT02(arrC).length; -Assert.equal(len02, 4); +let num123: number[] = [1, 2, 3]; +let abc: string[] = ['a', 'b', 'c']; +let arr = dropFrist(num123, abc); +Assert.equal(JSON.stringify(arr), '[2,3,"a","b","c"]'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_2.ts index 6ec22e852b..8ff840a023 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_2.ts @@ -14,39 +14,21 @@ */ /**--- description: > - How would we type either of these in TypeScript? - For concat, the only valid thing we could do in older versions of the language was to try and write some overloads. - function concat(arr1: [A, B, C, D, E, F], arr2: []): [A, B, C, D, E, F]; + The second change is that rest elements can occur anywhere in a tuple - not just at the end! + Note that in cases when we spread in a type without a known length, the resulting type becomes unbounded as well, and all the following elements factor into the resulting rest element type. module: ESNext isCurrent: true ---*/ -import { Assert } from '../../../suite/assert.js' +import { Assert } from "../../../suite/assert.js" -function funVTT01(arr1: [T1, T2], arr2: []): [T1, T2]; -function funVTT01(arr1: T[], arr2: T[]): T[] { - return arr1.concat(arr2); +type N = [number, number, number]; +type S = [string, string, string]; +type NBSB = [...N, boolean, ...S, boolean] +function mergedArray1(nbsb: NBSB): string { + return JSON.stringify(nbsb); } -const t0: [] = []; -const tns: [number, string] = funVTT01([1, "a"], t0); -Assert.equal(tns[0], 1); -Assert.equal(tns[1], "a"); - -const arr1: [number, string, boolean, number[], object, string] = [ - 1, - "NARC", - true, - [2, 3], - { name: "Rose" }, - "AAAA", -]; -const arr2: [] = []; -function funVTT02( - arr1: [A, B, C, D, E, F], - arr2: [] -): [A, B, C, D, E, F] { - return [...arr1, ...arr2]; -} -const result = funVTT02(arr1, arr2); -Assert.equal(result.length, 6); +let a: NBSB = [1, 2, 3, true, 'A', 'B', 'C', false]; +let s = mergedArray1(a); +Assert.equal(s, '[1,2,3,true,"A","B","C",false]'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_3.ts index 43d07f66b2..9f38c52975 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_3.ts @@ -14,9 +14,7 @@ */ /**--- description: > - This is another case of what we like to call “death by a thousand overloads”, and it doesn’t even solve the problem generally. - It only gives correct types for as many overloads as we care to write. - If we wanted to make a catch-all case, we’d need an overload like the following: + TypeScript 4.0 improves the inference process for rest parameters and rest tuple elements so that we can type this and have it “just work”. module: ESNext isCurrent: true ---*/ @@ -24,19 +22,27 @@ import { Assert } from '../../../suite/assert.js' -function funVTT01(arr1: T[], arr2: U[]): Array { - return [...arr1, ...arr2] +type UnknownArray = readonly unknown[]; + +function lockType(f: (...list: [...T, ...U]) => R, ...listA: T) { + return (...listB: U) => f(...listA, ...listB); } -const arr1: string[] = ["hello", "world"]; -const arr2: number[] = [1, 2, 3]; -const arrsn: Array = funVTT01(arr1, arr2); -function funVTT02(arg: any) { - const [_, ...result] = arg; - return result; +function exp(num: number, str: string, bool: boolean): string { + let obj = { num: num, str: str, bool: bool }; + return JSON.stringify(obj); } -const myTuple: any = [1, 2, 3, 4] as const; -const newArr: any = ["hello", "world"]; -const r1 = funVTT02(myTuple); -const r2 = funVTT02([...myTuple, ...newArr] as const); -const Arrlength = r2.length; -Assert.equal(Arrlength, 5); +const f1 = lockType(exp); +let f1str = f1(1, "A", true); +Assert.equal(f1str, '{"num":1,"str":"A","bool":true}'); + +const f2 = lockType(exp, 100); +let f2str = f2("B", false); +Assert.equal(f2str, '{"num":100,"str":"B","bool":false}'); + +const f3 = lockType(exp, 1024, "XO"); +let f3str = f3(true); +Assert.equal(f3str, '{"num":1024,"str":"XO","bool":true}'); + +const f4 = lockType(exp, 1408, "EXP", false); +let f4str = f4(); +Assert.equal(f4str, '{"num":1408,"str":"EXP","bool":false}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_6.ts deleted file mode 100644 index 8672a43c71..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_6.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The second change is that rest elements can occur anywhere in a tuple - not just at the end! - TypeScript 4.0 improves the inference process for rest parameters and rest tuple elements so that we can type this and have it “just work”. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -type ArrStr = [string, string]; -type ArrNum = number[]; -type ASN = [...ArrStr, ...ArrNum, boolean]; -const asn: ASN = ["hello", "world", 1, 2, true]; -Assert.equal(asn.length, 5); -type Arr = readonly any[]; -function funVTT01(arr1: T, arr2: U): [...T, ...U] { - return [...arr1, ...arr2]; -} -const arr1 = [1, 2, 3]; -const arr2 = ["a", "b", "c"]; -const arr3 = funVTT01(arr1, arr2); -Assert.equal(arr3.length, 6); - - -type Arry = readonly unknown[]; - -function funVTT02( - f: (...args: [...T, ...U]) => R, - ...headArgs: T -) { - return (...tailArgs: U) => f(...headArgs, ...tailArgs); -} -function funVTT03(a: number, b: number, c: number): number { - return a + b + c; -} -const add2And3 = funVTT02(funVTT03, 2, 3); -const result = add2And3(4); -Assert.equal(result, 9); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/private_field_presence_checks/private_field_presence_checks_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/private_field_presence_checks/private_field_presence_checks_1.ts index 9bffc1aac6..3d042696a5 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/private_field_presence_checks/private_field_presence_checks_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/private_field_presence_checks/private_field_presence_checks_1.ts @@ -31,6 +31,7 @@ class RunP { combine(additional: any) { return additional && typeof additional === "object" && + #type in additional&& this.#type === additional.#type; } } diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts index 82774d24c3..c8756ae053 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts @@ -23,18 +23,28 @@ import { Assert } from "../../../suite/assert.js" -type RunChars = S extends `${infer Char}${infer Rest}` - ? Char | RunChars +type RunObtain = S extends `${infer Char}${infer Rest}` + ? Char | RunObtain : never; -type gc = RunChars<" RunChar">; -var g1: gc = "n"; +type gc = RunObtain<" getChar">; +var g1: gc = "e"; Assert.isString(g1); -type RunGetChars1 = RunGetCharsHelper; -type RunGetCharsHelper = S extends `${infer Char}${infer Rest}` - ? RunGetCharsHelper +type RunObtain1 = RunObtainHelper; +type RunObtainHelper = S extends `${infer Char}${infer Rest}` + ? RunObtainHelper : Acc; -type gch = RunGetCharsHelper; +type gch = RunObtainHelper; var g2: gch = 10; -Assert.isNumber(g2); \ No newline at end of file +Assert.isNumber(g2); + +let g3: RunObtain1<' NEW'> = ' '; +Assert.equal(g3, ' '); +g3 = 'E'; +Assert.equal(g3, 'E'); + +let g4: RunObtainHelper<' NARC ', 'ACC'> = 'ACC'; +Assert.equal(g4, 'ACC'); +g4 = 'N'; +Assert.equal(g4, 'N'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts index cec36c68b1..6f5d5337cd 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts @@ -22,7 +22,8 @@ isCurrent: true import { Assert } from "../../../suite/assert.js" -import { privateF, PrivateType } from "./some-module.js" +import type { PrivateType } from "./some-module.js" +import { privateF } from "./some-module.js" export class Type implements PrivateType { diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/constant_enum_declarations/constant_enum_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/constant_enum_declarations/constant_enum_declarations.ts index efa9c6661e..0ead90f56e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/constant_enum_declarations/constant_enum_declarations.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/constant_enum_declarations/constant_enum_declarations.ts @@ -23,28 +23,34 @@ import { Assert } from '../../../../suite/assert.js' - +let v = 8 * 8; const enum CED { None = -1, False, True = 1, DEF = 1024, + Val = DEF / 8, } Assert.equal(CED.None, -1); Assert.equal(CED.False, 0); Assert.equal(CED.True, 1); Assert.equal(CED.DEF, 1024); +Assert.equal(CED.Val, 128); Assert.equal(CED["None"], -1); Assert.equal(CED["False"], 0); Assert.equal(CED["True"], 1); Assert.equal(CED["DEF"], 1024); +Assert.equal(CED["Val"], 128); + enum CED_COPY { None = -1, False, True = 1, DEF = 1024, + Val = DEF / 8, } Assert.equal(CED_COPY[-1], "None"); Assert.equal(CED_COPY[0], "False"); Assert.equal(CED_COPY[1], "True"); -Assert.equal(CED_COPY[1024], "DEF"); \ No newline at end of file +Assert.equal(CED_COPY[1024], "DEF"); +Assert.equal(CED_COPY[128], "Val"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_members/enum_members_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_members/enum_members_1.ts index acdd698b50..3a272a6a11 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_members/enum_members_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_members/enum_members_1.ts @@ -29,6 +29,7 @@ import { Assert } from '../../../../suite/assert.js' function toLength(str: string): number { return str.length; } +let k = 999; enum ABCList { A, B, @@ -40,6 +41,15 @@ enum ABCList { H = 0xff & 0xaa, I = E | F, J = toLength(ABCList[11]), + K = k++, + L = k--, + M = 1 + 2, + N = 1 - 2, + O = 1 / 2, + P = 1 % 2, + Q = 1 >> 2, + R = 1 >>> 2, + S = 1 ^ 2, } Assert.equal(ABCList.A, 0); Assert.equal(ABCList.B, 1); @@ -50,4 +60,13 @@ Assert.equal(ABCList.F, -18); Assert.equal(ABCList.G, 60); Assert.equal(ABCList.H, 170); Assert.equal(ABCList.I, -17); -Assert.equal(ABCList.J, 1); \ No newline at end of file +Assert.equal(ABCList.J, 1); +Assert.equal(ABCList.K, 999); +Assert.equal(ABCList.L, 1000); +Assert.equal(ABCList.M, 3); +Assert.equal(ABCList.N, -1); +Assert.equal(ABCList.O, 0.5); +Assert.equal(ABCList.P, 1); +Assert.equal(ABCList.Q, 0); +Assert.equal(ABCList.R, 0); +Assert.equal(ABCList.S, 3); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_2.ts index c940dea5fe..78b09fffd4 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_2.ts @@ -23,11 +23,9 @@ import { Assert } from '../../../../suite/assert.js' -var MyArray: { - [0]: number; - [1]: string; - [2]: string; -} = [1, "aaa", "bbb"]; -Assert.isNumber(MyArray[0]); +let MyArray: { + [key: number]: string; +} = ["aaa", "bbb", "ccc"]; +Assert.isString(MyArray[0]); Assert.isString(MyArray[1]); Assert.isString(MyArray[2]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_congruence_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_congruence_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_congruence_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_congruence_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_equal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_equal_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_equal_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_equal_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_greater_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_greater_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_greater_or_equal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_or_equal_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_greater_or_equal_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_or_equal_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_incongruence_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_incongruence_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_incongruence_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_incongruence_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_less_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_less_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_less_or_equal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_or_equal_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_less_or_equal_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_or_equal_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_unequal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_unequal_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater_less/the_unequal_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_unequal_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_and_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_and_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_and_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_and_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_division_method_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_division_method_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_division_method_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_division_method_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_left_shift_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_left_shift_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_left_shift_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_left_shift_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_multiplication_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_multiplication_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_multiplication_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_multiplication_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_or_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_or_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_or_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_or_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_remainder_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_remainder_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_remainder_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_remainder_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_right_shift_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_right_shift_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_right_shift_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_right_shift_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_subtraction_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_subtraction_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_subtraction_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_subtraction_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_unsigned_shift_to_the_right.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_unsigned_shift_to_the_right.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_unsigned_shift_to_the_right.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_unsigned_shift_to_the_right.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_xor_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_xor_operator.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul_div_rem_sub/the_xor_operator.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_xor_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_1.ts similarity index 43% rename from es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_1.ts index 7a4c1e42a1..e23968a8c9 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_1.ts @@ -13,28 +13,35 @@ * limitations under the License. */ /**--- - description: > - The first change is that spreads in tuple type syntax can now be generic. - This means that we can represent higher-order operations on tuples and arrays even when we don’t know the actual types we’re operating over. - When generic spreads are instantiated (or, replaced with a real type) in these tuple types, they can produce other sets of array and tuple types + description: > + If the object literal is contextually typed and the contextual type contains a property with a matching name, + the property assignment is contextually typed by the type of that property. module: ESNext isCurrent: true ---*/ -import { Assert } from '../../../suite/assert.js' +import { Assert } from '../../../../suite/assert.js' -function funVTT01(arr: readonly [any, ...T]) { - const [_ignored, ...rest] = arr; - return rest; +let obj1: { + str: string; + num: number; + bool: boolean; +} = { + str: 'string', + num: 5, + bool: true } -const anum = [1, 2, 3, 4] as const; -const astr = ["hello", "world"]; -const r1 = funVTT01(anum); -const r2 = funVTT01([...anum, ...astr] as const); -Assert.equal(r2.length, 5); -Assert.equal(r2[0], 2); -Assert.equal(r2[1], 3); -Assert.equal(r2[2], 4); -Assert.equal(r2[3], "hello"); -Assert.equal(r2[4], "world"); +Assert.isString(obj1.str); +Assert.isNumber(obj1.num); +Assert.isBoolean(obj1.bool); + +interface I{ + num: number; + str: string; +} +let obj2 = {} as I; +obj2.num = 10; +obj2.str = 'string'; +Assert.isNumber(obj2.num); +Assert.isString(obj2.str); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_2.ts new file mode 100644 index 0000000000..94500c72a7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_2.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + if the object literal is contextually typed, + if the contextual type contains a numeric index signature, + and if the property assignment specifies a numeric property name, + the property assignment is contextually typed by the type of the numeric index signature. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let obj1: { + 1: string; + [key: number]: string; +} = { + 1: 'string', + 2: 'number', + 3: 'boolean' +} +Assert.isString(obj1[2]); +Assert.isString(obj1[3]); + +interface I{ + 1: string; + [key: number]: string; +} +let obj2 = {} as I; +obj2 = { + 1: 'string', + 2: 'number', + 3: 'boolean' +} +Assert.isString(obj2[2]); +Assert.isString(obj2[3]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_3.ts index da9cb63d05..0d7ec34ce5 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_3.ts @@ -23,19 +23,26 @@ import { Assert } from '../../../../suite/assert.js' -let animal: { - name: String; - age: Number; - run: Number; - bark(run: Number): Number; +let obj1: { + 'str': string; + [key: string]: string; } = { - name: "Tom", - age: 12, - run: 23, - bark(run) { - return run; - }, -}; -Assert.equal(animal.run, 23); -animal.run = 66; -Assert.equal(animal.run, 66); \ No newline at end of file + 'str': 'string', + 'num': 'number', + 'bool': 'boolean' +} +Assert.isString(obj1['num']); +Assert.isString(obj1['bool']); + +interface I{ + 'str': string; + [key: string]: string; +} +let obj2 = {} as I; +obj2 = { + 'str': 'string', + 'num': 'number', + 'bool': 'boolean' +} +Assert.isString(obj2['num']); +Assert.isString(obj2['bool']); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_5.ts index 1fb51bc016..456393ae28 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_5.ts @@ -35,5 +35,4 @@ class Example { } } const example = new Example(); -example.count = 1; Assert.isNumber(example.count); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_6.ts index 93dcb3d62e..09c5532834 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_6.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_6.ts @@ -22,15 +22,26 @@ import { Assert } from '../../../../suite/assert.js' -class Person { +class Person1 { private _name: string = ""; - get name(): string { + get name(){ return this._name; } set name(value: string) { this._name = value; } } -const person = new Person(); -person.name = "john"; -Assert.isString(person.name); \ No newline at end of file +const person1 = new Person1(); +Assert.isString(person1.name); + +class Person2 { + private _name: string = ""; + get name(): string{ + return this._name; + } + set name(value) { + this._name = value; + } +} +const person2 = new Person2(); +Assert.isString(person2.name); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_7.ts index 68b54aaa78..1c5358d3eb 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_7.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_7.ts @@ -23,18 +23,15 @@ import { Assert } from '../../../../suite/assert.js' -class h_C { - private num: number; - constructor(num: number) { - this.num = num; - } - get() { - return this.num; - } - set() { - return this.num - } +class Example { + private _count: number = 0; + get count() { + return this._count; + }; + set count(value) { + Assert.isNumber(value); + this._count = value; + } } -let h_c = new h_C(10); -Assert.isNumber(h_c.get()) -Assert.isNumber(h_c.set()); \ No newline at end of file +const example = new Example(); +Assert.isNumber(example.count); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_8.ts new file mode 100644 index 0000000000..3fb79b27f7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_8.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If a get accessor is declared for a property, + the return type of the get accessor becomes the type of the property. + If only a set accessor is declared for a property, + the parameter type of the set accessor becomes the type of the property. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class C{ + private mem; + constructor(mem: string) { + this.mem = mem; + } + get Mem(): string { + return this.mem; + } + set Mem(mem: string) { + this.mem = mem; + } +} +let c = new C('a'); +Assert.isString(c.Mem); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_9.ts new file mode 100644 index 0000000000..f364ccedab --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_9.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When an object literal is contextually typed by a type that includes a string/numeric index signature, + the resulting type of the object literal includes a string/numeric index signature with the union type + of the types of the properties declared in the object literal, or the Undefined type if the object literal is empty. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface I1{ + 1: string; + [key: string]: string; +} +let obj1: I1 = { + 1: 'number', + 'str': 'string' +} +Assert.isString(obj1[1]); +Assert.isString(obj1['str']); +let obj2: I1 = { + 1: 'number' +} +Assert.isString(obj2[1]); +Assert.isUndefined(obj2['str']); + +interface I2{ + 'string': string; + [key: number]: string; +} +let obj3: I2 = { + 'string': 'number', + 1: 'string' +} +Assert.isString(obj3['string']); +Assert.isString(obj3[1]); +let obj4: I2 = { + 'string': 'number' +} +Assert.isString(obj4['string']); +Assert.isUndefined(obj4[1]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_1.ts index 1f2250adf5..167baf148f 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_1.ts @@ -23,8 +23,10 @@ import { Assert } from '../../../../suite/assert.js' let myVariable: any = { name: "John", age: 30 }; -Assert.isUndefined(myVariable.firstName); -myVariable = 42; -Assert.isUndefined(myVariable.length); -myVariable = "Hello World"; -Assert.isUndefined(myVariable.foo); \ No newline at end of file +Assert.isString(myVariable.name); +myVariable.name = 42; +Assert.isNumber(myVariable.name); + +Assert.isNumber(myVariable.age); +myVariable.age = "Hello World"; +Assert.isString(myVariable.age); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_string_number_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_string_number_3.ts index aa506e77e6..9e4293dba4 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_string_number_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_string_number_3.ts @@ -14,8 +14,8 @@ */ /**--- description: > - If index is a string literal or a numeric literal and object has an apparent property (section 3.11.1) with the name given by that literal - (converted to its string representation in the case of a numeric literal), the property access is of the type of that property. + If index is a string literal or a numeric literal and object has an apparent property with the name given by that literal, + the property access is of the type of that property. module: ESNext isCurrent: true ---*/ diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_1.ts index 535700c2c4..6579559ced 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_1.ts @@ -26,5 +26,11 @@ let C: any; C = function (this: any, x: number, y: number) { this.sum = x + y; }; -const myObject = new C(2, 3); -Assert.equal(myObject.sum, 5); \ No newline at end of file +let myObject = new C(2, 3); +Assert.equal(myObject.sum, 5); +myObject = 5; +Assert.isNumber(myObject); +myObject = 'a'; +Assert.isString(myObject); +myObject = true; +Assert.isBoolean(myObject); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/super_calls.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/super_calls.ts index 800f6cfd45..b64f05916a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/super_calls.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/super_calls.ts @@ -15,13 +15,11 @@ /**--- description: > The super keyword can be used in expressions to reference base class properties and the base class constructor. - Super calls consist of the keyword super followed by an argument list enclosed in parentheses. - Super calls are only permitted in constructors of derived classes, as described in section 8.3.2. + Super calls consist of the keyword super followed by an argument list enclosed in parentheses. Super calls are only permitted in constructors of derived classes. A super call invokes the constructor of the base class on the instance referenced by this. A super call is processed as a function call (section 4.15) using the construct signatures of the base class constructor function type as the initial set of candidate signatures for overload resolution. The type of a super call expression is Void. - The JavaScript code generated for a super call is specified in section 8.7.2. module: ESNext isCurrent: true ---*/ diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_1.ts index 663ce484fb..61a7a65a42 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_1.ts @@ -23,29 +23,25 @@ import { Assert } from '../../../../suite/assert.js' -class Dog { - name: string; - age: number; - constructor(name: string, age: number) { - this.name = name; - this.age = age; +class C{ + public mem: string; + private num: number; + constructor(mem: string, num: number) { + this.mem = mem; + this.num = num; + Assert.isObject(this); } - - getName(): string { - return this.name; + func() { + return this; } - - bark(): string { - return this.getName() + " is bark"; + get getNum() { + Assert.isObject(this); + return this.num; } -} -var dog = new Dog("doggy", 7); -Assert.equal(dog.age, 7); -Assert.equal("doggy is bark", dog.bark()) -class Duck { - age: number = this.b; - constructor(private readonly b: number) { + set setNum(num: number) { + this.num = num; } } -var duck = new Duck(6); -Assert.equal(6, duck.age); \ No newline at end of file +let c = new C('a', 10); +c.getNum; +Assert.isObject(c.func()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/disabling_import_elision/animal.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_2.ts similarity index 54% rename from es2panda/test/ts_extra_tests/test_ts_cases/4.5/disabling_import_elision/animal.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_2.ts index 6e8b68ee43..af043bd290 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/disabling_import_elision/animal.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_2.ts @@ -12,17 +12,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/**--- + description: > + In a static member function or static member accessor, the type of this is the constructor function type of the containing class. + module: ESNext + isCurrent: true + ---*/ -export class Animal { - color: string; - age: number; - gender: string; - constructor(color: string, age: number, gender: string) { - this.color = color; - this.age = age; - this.gender = gender; +import { Assert } from '../../../../suite/assert.js' + +class C{ + static mem: string = 'a'; + static get getMem() { + Assert.isFunction(this); + return this.mem; + } + static set setMem(mem: string) { + this.mem = mem; + } + static func() { + return this; } } - -export { Animal as animal }; \ No newline at end of file +C.getMem; +Assert.isFunction(C.func()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_1.ts index a4589bf231..fa6621e1ed 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_1.ts @@ -28,47 +28,88 @@ import { Assert } from '../../../../suite/assert.js' interface Worker { x: number; - work(): void; + work(): string; - getS(): { velocity: number; }; + getS(): { rate: number,velocity: number; }; } interface Tool { y: number; - tool(): void; + tool(): string; - getS(): { rate: number; }; + getS(): { rate: number, velocity: number;}; } - let result1: { rate: number; } = { - rate: 1 + interface Runer extends Tool,Worker{ + z:string, + + getS(): { rate: number, velocity: number,play:string}; + + run():string; + + tool(): string; + } + + let result1: { rate: number,velocity: number; } = { + rate: 1, + velocity:123, }; - let result2: { velocity: number; } = { + let result2: { velocity: number,rate: number,} = { velocity: 1, + rate:999, }; + let ToRun: {velocity: number, rate: number, play: string} = { + velocity: 1314, + rate:999, + play:"一万年", + } let point: Worker = { x: 1, - getS(): { velocity: number; } { + getS(): {rate: number, velocity: number} { return result2 }, - work(): void { + work(): string { + return "work"; } }; let pointer: Tool = { y: 1, - getS(): { rate: number; } { + getS(): {rate: number, velocity: number} { return result1 }, - tool(): void { + tool(): string { + return "tool"; }, }; + let run:Runer = { + x: ++point.x, + y: --pointer.y, + z:"with z", + getS(): { rate: number; velocity: number; play: string } { + return ToRun; + }, + work(): string { + return "let it work"; + }, + run():string { + return "let it run"; + }, + tool(): string { + return "He is the tool of work"; + } + } - Assert.equal(point.x, 1); - Assert.equal(pointer.y, 1); + Assert.equal(run.x,2); + Assert.equal(run.y,0); + Assert.equal(run.z,"with z"); + Assert.equal(run.getS(),ToRun); + Assert.equal(run.run()+","+run.work()+","+run.tool(),"let it run,let it work,He is the tool of work"); + Assert.equal(point.x, 2); + Assert.equal(pointer.y, 0); Assert.equal(point.getS(), result2); Assert.equal(pointer.getS(), result1); - Assert.equal(pointer.tool(), undefined); - Assert.equal(point.work(), undefined); + Assert.equal(pointer.tool(), "tool"); + Assert.equal(point.work(), "work"); }; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_2.ts index 1ee6986784..4040342f7f 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_2.ts @@ -41,7 +41,7 @@ import { Assert } from '../../../../suite/assert.js' } interface WorkerTool extends Worker, Tool { - z: number; + z: string; getS(): { velocity: number; rate: number; }; } @@ -52,22 +52,24 @@ import { Assert } from '../../../../suite/assert.js' }; let point: WorkerTool = { - x: 1, - z: 1, + x: 1 , y: 1, + z: "zzz", getS(): { velocity: number; rate: number; } { return result }, - tool(): void { + tool(): string { + return "tool"; }, - work(): void { + work(): string { + return "work"; } }; Assert.equal(point.x, 1); Assert.equal(point.y, 1); - Assert.equal(point.z, 1); + Assert.equal(point.z, "zzz"); Assert.equal(point.getS(), result); - Assert.equal(point.tool(), undefined); - Assert.equal(point.work(), undefined); + Assert.equal(point.tool(), "tool"); + Assert.equal(point.work(), "work"); }; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_3.ts index 11351ac9fa..def71989e3 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_3.ts @@ -24,10 +24,10 @@ import { Assert } from '../../../../suite/assert.js' { - interface StringC { + interface Example1 { (h_a: string, h_b: string): number; } - let sc: StringC = (h_a: string, h_b: string): number => { return h_a.charCodeAt(0) + h_b.charCodeAt(0); }; + let sc: Example1 = (h_a: string, h_b: string): number => { return h_a.charCodeAt(0) + h_b.charCodeAt(0); }; Assert.equal(sc('a', 'b'), 195); }; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_1.ts index 7aba6ce7a3..d1a8386819 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_1.ts @@ -45,14 +45,31 @@ import { Assert } from '../../../../suite/assert.js' return 0 } }; + let src :Ds = { + createE1(a: number): number { + return 1 + }, + createE2(a: number | string): number { + return 2; + }, + createE3(a: number | string): number { + return 3; + }, + } - class Class { + class Get { static getName(name: Ds): Ds { return name; + }; + static getSrc(src :Ds){ + return src; } } - Assert.equal(Class.getName(name).createE1(''), 0); - Assert.equal(Class.getName(name).createE3(0), 0); - Assert.equal(Class.getName(name).createE2(true), 0); + Assert.equal(Get.getSrc(src).createE1(1),1); + Assert.equal(Get.getSrc(src).createE2(""),2); + Assert.equal(Get.getName(src).createE3("233"), 3); + Assert.equal(Get.getName(name).createE1(''), 0); + Assert.equal(Get.getName(name).createE3(0), 0); + Assert.equal(Get.getName(name).createE2(true), 0); }; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_1.ts index 590267ccf5..12887890b3 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_1.ts @@ -26,7 +26,7 @@ import { Assert } from '../../../../suite/assert.js' { class h_C { private state: any = 0; - point: any = 0; + point: number | unknown = 0; } interface h_SC extends h_C { @@ -39,6 +39,8 @@ import { Assert } from '../../../../suite/assert.js' } } + Assert.equal(new h_B().point,0); + Assert.equal(typeof new h_B().point,"number"); Assert.isTrue(new h_B().hasOwnProperty('point')); Assert.isTrue(new h_B().hasOwnProperty('state')); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_2.ts index 115e1a2458..584bb73ebe 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_2.ts @@ -44,7 +44,7 @@ class h_c extends h_C implements h_I { return 'choose'; } } -var h_CC = new h_C('private'); +let h_CC = new h_C('private'); Assert.equal(h_CC.get(), 'private'); -var h_cc = new h_c('PRIVATE'); +let h_cc = new h_c('PRIVATE'); Assert.equal(h_cc.get(), 'PRIVATE'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/4_dynamic_type_checks/dynamic_type_checks_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/4_dynamic_type_checks/dynamic_type_checks_1.ts index 7eb0e29d9a..58eccbd620 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/4_dynamic_type_checks/dynamic_type_checks_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/4_dynamic_type_checks/dynamic_type_checks_1.ts @@ -24,27 +24,27 @@ import { Assert } from '../../../../suite/assert.js' -{ - interface WorkerTool { + +interface WorkerTool { shift(): void; rock(): void; getS(): void; - } +} - function asWorkerTool(o: any): WorkerTool { +function asWorkerTool(o: any): WorkerTool { return o && o.shift && o.rock && o.getS ? o : null; - } +} - let point: WorkerTool = { +let point: WorkerTool = { getS(): void { }, rock(): void { }, shift(): void { } - }; +}; - Assert.equal(asWorkerTool(point), point); -}; \ No newline at end of file +Assert.equal(asWorkerTool(point), point); +Assert.equal(typeof asWorkerTool(point),"object") \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_3.ts similarity index 60% rename from es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_3.ts index 44a74e138c..521985e8d3 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_3.ts @@ -14,18 +14,19 @@ */ /**--- description: > - It’s worth noting - labels don’t require us to name our variables differently when destructuring. - They’re purely there for documentation and tooling. + Index signatures, which define type constraints for properties in the given type. + An object type can have at most one string index signature and one numeric index signature. module: ESNext isCurrent: true ---*/ -import { Assert } from '../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -function funLTE01(x: [first: string, second: number]) { - const [a, b] = x; - Assert.equal(a, "hello"); - Assert.equal(b, 42); +interface numberIndex { + [index: number]: string } -funLTE01(["hello", 42]); +let numberTest: numberIndex = ['1', '2', '3'] +Assert.equal(numberTest[0], '1'); +Assert.equal(numberTest[1], '2'); +Assert.equal(numberTest[2], '3'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/named_type_reference/named_type_reference.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/named_type_reference/named_type_reference.ts index ebfad4a129..62bd85f61f 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/named_type_reference/named_type_reference.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/named_type_reference/named_type_reference.ts @@ -51,4 +51,15 @@ let i: I = { } Assert.equal(i.name, "xiao"); Assert.equal(i.age, 18); -Assert.equal(i.greet(), "hello"); \ No newline at end of file +Assert.equal(i.greet(), "hello"); +class C2 { + x: T; + constructor(x: T) { + this.x = x; + } + getx() { + return this.x; + }; +} +let c2 = new C2(1); +Assert.equal(c2.getx(), 1) \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_1.ts index 6d0fc9322f..ee4efbffa2 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_1.ts @@ -23,9 +23,6 @@ import { Assert } from '../../../../../../suite/assert.js' -function fun0() { - return "zero parameter"; -} function fun1(firstParameter: string, lastParameter?: string) { if (lastParameter) return firstParameter + " " + lastParameter; else return firstParameter; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/constructor_type_literals/constructor_type_literals.ts similarity index 48% rename from es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/constructor_type_literals/constructor_type_literals.ts index aaca1f3ed2..267b0dedb7 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/constructor_type_literals/constructor_type_literals.ts @@ -14,30 +14,38 @@ */ /**--- description: > - Uh…okay, that’s…seven overloads for when the second array is always empty. Let’s add some for when arr2 has one argument. - function concat(arr1: [A1, B1, C1, D1, E1, F1], arr2: [A2]): [A1, B1, C1, D1, E1, F1, A2]; + A constructor type literal specifies the type parameters, regular parameters, and return type of a construct signature. module: ESNext isCurrent: true ---*/ -import { Assert } from "../../../suite/assert.js" +import { Assert } from '../../../../../suite/assert.js' -function funVTT01( - arr1: [A1, B1, C1, D1, E1, F1, A2], - arr2: [A3] -): [A1, B1, C1, D1, E1, F1, A2, A3] { - return [...arr1, ...arr2]; +interface I1 { + x: number; + y: number; } -const arr1: [string, number, boolean, number, null, undefined, string] = [ - "hello", - 12, - true, - 45, - null, - undefined, - "tom", -]; -const arr2: [string] = ["world"]; -const result = funVTT01(arr1, arr2); -Assert.equal(result.length, 8); + +interface Constructor { + new(x: number, y: number): I1; +} +class I2 implements I1 { + readonly x: number; + readonly y: number; + + constructor(x: number, y: number) { + this.x = x; + this.y = y; + } +} +function fun( + cons: Constructor, + x: number, + y: number +): I1 { + return new cons(x, y); +} +let x1: I1 = fun(I2, 2, 2) +Assert.equal(x1.x, 2); +Assert.equal(x1.y, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/union_type_literals/union_type_literals.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/union_type_literals/union_type_literals.ts index b226b6655d..dd967d6d15 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/union_type_literals/union_type_literals.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/union_type_literals/union_type_literals.ts @@ -23,8 +23,10 @@ import { Assert } from '../../../../../suite/assert.js' -let x: string | number; +let x: string | number | boolean; x = 's'; Assert.isString(x); x = 5; -Assert.isNumber(x); \ No newline at end of file +Assert.isNumber(x); +x = true; +Assert.isBoolean(x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_3.ts index 3bc23487d6..77f7b25a76 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_3.ts @@ -15,7 +15,7 @@ /**--- description: > properties of any name can be accessed through an Any value - and Any values can be called as functions with any argument list. + and Any values can be called as functions or constructors with any argument list. module: ESNext isCurrent: true ---*/ @@ -51,4 +51,20 @@ Assert.isSymbol(x); Assert.isSymbol(fun(x)); x = { a: 1, b: 1 }; Assert.isObject(x); -Assert.isObject(fun(x)); \ No newline at end of file +Assert.isObject(fun(x)); +class C { + public a: any; + public b: any; + constructor(a: any, b: any) { + this.a = a; + this.b = b; + } +} +let c1 = new C(1, "1"); +Assert.isNumber(c1.a); +let c2 = new C("aa", "bb"); +Assert.isString(c2.a); +let c3 = new C(true, true); +Assert.isBoolean(c3.a); +let c4 = new C({}, {}); +Assert.isObject(c4.a); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_1.ts index 0185de083e..6a809181c5 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_1.ts @@ -24,13 +24,21 @@ import { Assert } from '../../../../../suite/assert.js' interface I { - a?: boolean - b?: string + a?: number + b?: boolean c?: string } let x: I = { - a: true, - b: "./src", - c: "./bin" + a: 12, + b: true, + c: "ccc" } -Assert.equal(JSON.stringify(x), '{"a":true,"b":"./src","c":"./bin"}'); \ No newline at end of file +Assert.equal(x.a, 12); +Assert.equal(x.b, true); +Assert.equal(x.c, "ccc"); +let y: I = { + a: 11, + b: false +} +Assert.equal(y.a, 11); +Assert.equal(y.b, false); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/widend_types/widend_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/widend_types/widend_types_1.ts index 24b4a2df49..b93a60ebd7 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/widend_types/widend_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/widend_types/widend_types_1.ts @@ -21,7 +21,7 @@ ---*/ -import {Assert} from '../../../../suite/assert.js' +import { Assert } from '../../../../suite/assert.js' var str = "xiao" Assert.isString(str); \ No newline at end of file -- Gitee From fa5306df2ab682e5c07ae2d4da7308815d82ef4e Mon Sep 17 00:00:00 2001 From: tanglizhen Date: Fri, 16 Jun 2023 16:54:25 +0800 Subject: [PATCH 12/18] =?UTF-8?q?Ts=20test=20cases=20fix=20Issues=EF=BC=9A?= =?UTF-8?q?https://gitee.com/openharmony/arkcompiler=5Fets=5Ffrontend/issu?= =?UTF-8?q?es/I78HJU=3Ffrom=3Dproject-issue=20Signed-off-by:=20tanglizhen?= =?UTF-8?q?=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test_ts_cases/2.1/record/record_pick.ts | 49 +++++++++++++ .../async_generators/async_generators.ts | 4 +- .../3_improved_inference_for_generics.ts | 18 ++--- .../2.5/1_optional_catch_clause_variables.ts | 9 ++- .../2.8/Defaulted_declarations.ts | 27 +++++++ .../IIFEs_as_namespace_declarations.ts} | 28 +++----- .../1_support_number_and_symbol_nam_1.ts | 31 ++++---- .../1_support_number_and_symbol_nam_2.ts | 34 +++++---- .../optional_elements_in_tuple_types.ts | 37 ++++++++++ .../rest_parameters_with_tuple_types.ts} | 56 +++------------ .../rest_parameters_with_tuple_types.ts | 8 +-- ...spread_expressions_in_object_literals_2.ts | 10 ++- .../better_support_for_never.ts | 28 ++++++++ .../recursive_type_aliases_1.ts | 4 +- ...sing_differences_in_optional_assertions.ts | 29 ++++++++ ...short_circuiting_assignment_operators_3.ts | 4 +- .../key_remapping_in_mapped_types_1.ts | 18 ++--- .../template_literal_types_1.ts | 14 ++-- .../template_literal_types_2.ts | 46 ++++++------ .../Reverting_Template_Literal_Inference.ts | 22 +++--- .../abstract_construct_signatures.ts | 43 +---------- .../abstract_construct_signatures_3.ts | 45 ++++++++---- .../relaxed_rules.ts} | 0 .../smarter_type_alias_preservation1.ts | 9 ++- .../smarter_type_alias_preservation2.ts | 7 +- ...uctorParameters_works_on_abstract_class.ts | 4 +- .../ecmascript_private_calss_elements.ts | 6 +- ...verride_and_the_noImplicitOverride_Flag.ts | 26 +++---- .../separate_write_types_on_properties_1.ts | 4 +- .../separate_write_types_on_properties_2.ts | 4 +- .../static_index_signatures.ts | 18 ++--- ...cannot_be_compared_to_arbitrary_numbers.ts | 16 ++--- ..._tuples_have_a_readonly_length_property.ts | 11 +-- ...or_infer_types_in_template_string_types.ts | 12 +--- .../auto_accessors_in_classes.ts | 20 +++--- .../the_satisfies_operator.ts | 28 ++++---- ...property_narrowing_with_the_in_operator.ts | 71 ++++++++----------- .../Ambient_Class_Declarations.ts} | 29 ++++---- .../ambient_function_declarations.ts | 2 - .../ambient_variable_declarations.ts | 35 +++++++++ .../ambient_module_declarations_3.ts | 12 ++-- .../declarations/declarations_1.ts | 16 ++--- .../declarations/declarations_2.ts | 2 + .../class_declarations_2.ts | 16 ++--- .../constructor_parameters_2.ts | 8 +-- .../members/accessibility/accessibility_2.ts | 22 +++--- .../members/accessibility/accessibility_3.ts | 14 ++-- .../members/class_types/class_types_3.ts | 10 +-- .../constructor_function_types_5.ts | 43 ++++++----- .../constructor_function_types_6.ts | 23 +++--- .../constructor_function_types_7.ts | 36 +++------- .../dynamic_property_declarations.ts | 41 +++++++++++ .../member_function_declarations_1.ts | 12 ++-- .../member_function_declarations_3.ts | 6 +- .../member_function_declarations_4.ts | 8 +-- .../member_function_declarations_5.ts | 6 +- .../member_variable_declarations_1.ts | 16 ++--- .../member_variable_declarations_3.ts | 12 ++-- .../property_member_declarations_1.ts | 4 +- .../property_member_declarations_3.ts | 2 +- .../constant_enum_declarations.ts | 2 +- .../arrow_function/arrow_function_4.ts | 6 +- .../the_add_operator/the_add_operator_3.ts | 4 +- .../type_argument_inference_1.ts | 2 +- .../type_argument_inference_2.ts | 2 +- .../type_argument_inference_3.ts | 13 ++-- .../type_argument_inference_4.ts | 16 ++--- .../type_assertion/type_assertion_1.ts | 16 ++--- .../expressions/type_guards/type_guards_1.ts | 23 +++--- .../expressions/type_guards/type_guards_10.ts | 40 ++++------- .../expressions/type_guards/type_guards_11.ts | 29 ++++---- .../expressions/type_guards/type_guards_12.ts | 23 +++--- .../expressions/type_guards/type_guards_13.ts | 41 +++++++---- .../expressions/type_guards/type_guards_2.ts | 22 +++--- .../expressions/type_guards/type_guards_3.ts | 21 +++--- .../expressions/type_guards/type_guards_4.ts | 12 ++-- .../expressions/type_guards/type_guards_5.ts | 15 ++-- .../expressions/type_guards/type_guards_6.ts | 39 ++++++++-- .../expressions/type_guards/type_guards_7.ts | 24 +++++-- .../expressions/type_guards/type_guards_8.ts | 58 ++++++++------- .../expressions/type_guards/type_guards_9.ts | 17 +++-- .../Type_and_Member_Identity_1.ts | 33 +++++++++ .../Type_and_Member_Identity_2.ts | 30 ++++++++ .../Type_and_Member_Identity_3.ts | 33 +++++++++ .../Type_and_Member_Identity_4.ts | 36 ++++++++++ .../Type_and_Member_Identity_5.ts} | 47 ++++++------ .../Type_and_Member_Identity_6.ts | 38 ++++++++++ 87 files changed, 1077 insertions(+), 740 deletions(-) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.1/record/record_pick.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.8/Defaulted_declarations.ts rename es2panda/test/ts_extra_tests/test_ts_cases/{spec/expressions/type_guards/type_guards_14.ts => 2.8/IIFEs_as_namespace_declarations.ts} (50%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.0/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts rename es2panda/test/ts_extra_tests/test_ts_cases/{2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_3.ts => 3.0/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts} (39%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.7/better_support_for_never/better_support_for_never.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.9/Parsing_differences_in_optional_assertions/Parsing_differences_in_optional_assertions.ts rename es2panda/test/ts_extra_tests/test_ts_cases/4.2/{relaxed_rules/relaxed_rules_between_optional_properties_and_string_index_signatures_1.ts => relaxed_rules_between_optional_properties_and_string_index_signatures/relaxed_rules.ts} (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{classes/members/constructorc_function_types/constructor_function_types_8.ts => ambients/ambient_declarations/Ambient_Class_Declarations/Ambient_Class_Declarations.ts} (56%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_variable_declarations/ambient_variable_declarations.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/dynamic_property_declarations/dynamic_property_declarations.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_4.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{expressions/type_guards/type_guards_15.ts => types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_5.ts} (51%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_6.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/record/record_pick.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/record/record_pick.ts new file mode 100644 index 0000000000..bfe31d37c0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/record/record_pick.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Record pick + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../suite/assert.js" + +function test(o: Record, testObj: (s: B) => C): Record { + + for (let oElement in o) { + // @ts-ignore + o[oElement] = testObj(o[oElement]); + } + // @ts-ignore + return o; +} + +let testO = { ok: "1", demo: "2" }; +let ret = test(testO, str => str.length); +Assert.isNumber(ret.ok) + +let person:{name?:string, age?:string} = {}; +function test1(o: T, ...ks: K[]): Pick{ + for (let oElement of ks) { + // @ts-ignore + o[oElement] = oElement; + } + return o; +} +test1(person, "name", "age"); +Assert.equal(person.name, 'name'); +Assert.equal(person.age, 'age'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.3/async_iteration/async_generators/async_generators.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.3/async_iteration/async_generators/async_generators.ts index d9cd289bce..95369ceef3 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.3/async_iteration/async_generators/async_generators.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.3/async_iteration/async_generators/async_generators.ts @@ -25,7 +25,7 @@ import { Assert } from '../../../../suite/assert.js' -async function* ag() { +async function* fun() { let i = 0; let c = 0; yield* [0, 0, 0, 0]; @@ -60,7 +60,7 @@ function newArray() { } return arr; } -let arr = ag(); +let arr = fun(); async function showAsyncGenerator(arr: AsyncGenerator) { let i = 0; for await (let x of arr) { diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts index a21ebea758..e9b28a447b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts @@ -21,19 +21,13 @@ import { Assert } from '../../../suite/assert.js' -function func(f: (x: T) => U): (a: T[]) => U[] { - return a => a.map(f); +function func(a: number, b: string) { + return a + b; } - -const len: (a: string[]) => number[] = func(s => s.length); -Assert.equal(1, len(["s", "ss", "sss"])[0]); -Assert.equal(2, len(["s", "ss", "sss"])[1]); -Assert.equal(3, len(["s", "ss", "sss"])[2]); - +Assert.isString(func(10, 'a')); type T1 = (x: T, y: U) => [T, U]; -type T2 = (x: S, y: S) => [S, S]; - +type T2 = (x: T, y: T) => [T, T]; function f(a: T1, b: T2) { b = a; Assert.isTrue(b == a); @@ -42,7 +36,7 @@ function f(a: T1, b: T2) { let a: T1 = function funA(x: T, y: U): [T, U] { return [x, y]; } -let b: T2 = function funB(x: S, y: S): [S, S] { - return [x, x]; +let b: T2 = function funB(x: T, y: T): [T, T] { + return [x, y]; } f(a, b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.5/1_optional_catch_clause_variables.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.5/1_optional_catch_clause_variables.ts index 587a946674..9584bf048c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.5/1_optional_catch_clause_variables.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.5/1_optional_catch_clause_variables.ts @@ -28,5 +28,12 @@ function func(str: string) { return str + " is Error JSON"; } } + +let arrjson: string = '[1,3,5]'; +let arr = func(arrjson); +Assert.equal(arr[0], 1); +Assert.equal(arr[1], 3); +Assert.equal(arr[2], 5); + let str: string = 'string'; -Assert.equal(func(str), 'string is Error JSON'); \ No newline at end of file +Assert.equal(func(str), 'string is Error JSON'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/Defaulted_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/Defaulted_declarations.ts new file mode 100644 index 0000000000..a52a3eb2cd --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/Defaulted_declarations.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Defaulted declarations + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../suite/assert.js' + +let x; +x = x || 1; +Assert.equal(x, 1); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_14.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/IIFEs_as_namespace_declarations.ts similarity index 50% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_14.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/2.8/IIFEs_as_namespace_declarations.ts index 23569fbadb..cddb233030 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_14.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/IIFEs_as_namespace_declarations.ts @@ -14,28 +14,20 @@ */ /**--- description: > - A type guard of the form expr1 || expr2, - when true, narrows the type of x to T1 | T2, where T1 is the type of x narrowed by expr1 when true, - and T2 is the type of x narrowed by expr1 when false and then by expr2 when true, or - when false, narrows the type of x by expr1 when false and then by expr2 when false. + IIFEs as namespace declarations module: ESNext isCurrent: true ---*/ -import { Assert } from '../../../../suite/assert.js' +import { Assert } from '../../suite/assert.js' -function func(x: string | number | undefined) { - if (typeof x === "string" || typeof x === "number") { - return x; +let C:any = (function() { + function C(this:any, net:any):void { + this.x = net; } - else { - return undefined; - } -} -let a = func(10); -Assert.isNumber(a); -let b = func('s'); -Assert.isString(b); -let c = func(undefined); -Assert.isUndefined(c); \ No newline at end of file + return C; +})(); +let c = new C(1); + +Assert.equal(c.x, 1) \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts index 3f38cafb22..52f705f74c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts @@ -13,7 +13,8 @@ * limitations under the License. */ /**--- - description: TypeScript 2.9 adds support for number and symbol named properties in index types and mapped types. + description: > + TypeScript 2.9 adds support for number and symbol named properties in index types and mapped types. module: ESNext isCurrent: true ---*/ @@ -24,23 +25,23 @@ import { Assert } from '../../../suite/assert.js' const str = "x"; const num = 1; const sym = Symbol(); -const enum NUM { ONE, TWO, THREE } -const enum XYZStr { X = "X", Y = "Y", Z = "Z" } -type TypeObj = { - y: string; + +type Obj = { 2: string; [str]: string; [num]: string; [sym]: string; - [NUM.ONE]: string; - [XYZStr.X]: string; } -type X1 = keyof TypeObj; -type X2 = Extract; -type X3 = Extract; -let x1: X1 = "x"; -let x2: X2 = XYZStr.X; -let x3: X3 = 1; +type T1 = keyof Obj; +let x1: T1 = "x"; +let x2: T1 = sym; +let x3: T1 = 1; +let x4: T1 = 2; Assert.equal("x", x1); -Assert.equal(XYZStr.X, x2); -Assert.equal(1, x3); \ No newline at end of file +Assert.isString(x1); +Assert.equal(sym, x2); +Assert.isSymbol(x2); +Assert.equal(1, x3); +Assert.isNumber(x3); +Assert.equal(2, x4); +Assert.isNumber(x4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts index ad50c7756e..3f67dfe55b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts @@ -13,7 +13,8 @@ * limitations under the License. */ /**--- - description: Since keyof now reflects the presence of a numeric index signature by including type number in the key type, mapped types such as Partial and Readonly work correctly when applied to object types with numeric index signatures. + description: > + TypeScript 2.9 adds support for number and symbol named properties in index types and mapped types. module: ESNext isCurrent: true ---*/ @@ -21,17 +22,22 @@ import { Assert } from '../../../suite/assert.js' -type TYPE1 = { - a: number; - [b: number]: T; +const str = 'x' +const num = 1 +const sym = Symbol() +type Objs1 = { + [str]: string, + [num]: number, + [sym]: symbol } -type TYPE2 = Readonly>; -let arr: TYPE2 = { - [1]: "b", - [2]: "a", - a: 2, -}; -let len = arr.a; -let x = arr[1]; -Assert.equal(2, len); -Assert.equal("b", x); \ No newline at end of file +type Types = { + [P in keyof T]: T[P] +} +let objs2: Types = { + x: 'xx', + 1: 11, + [sym]: Symbol() +} +Assert.isString(objs2[str]); +Assert.isNumber(objs2[num]); +Assert.isSymbol(objs2[sym]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts new file mode 100644 index 0000000000..224eb8e721 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Optional elements in tuple types , Rest elements in tuple types + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../suite/assert.js' + +let o1:[number, ...string[]] = [1, '1', '2'] +let o2:[number, ...string[]] = [1, '1', '2', '3'] +Assert.equal(o1.length, 3) +Assert.equal(o2.length, 4) + +let o3: [string, string?, number?] +o3 = ['test', "hello", 1]; +Assert.equal(o3.length, 3) +o3 = ['test', "hello"]; +Assert.equal(o3.length, 2) +o3 = ['test']; +Assert.equal(o3.length, 1) + diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts similarity index 39% rename from es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/3.0/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts index 3f5efb00e2..3ca47e82df 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts @@ -8,60 +8,26 @@ * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implie d. + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /**--- - description: with the keyof operator's support for number and symbol named keys, it is now possible to abstract over access to properties of objects that are indexed by numeric literals (such as numeric enum types) and unique symbols. + description: > + Rest parameters with tuple types module: ESNext isCurrent: true ----*/ + ---*/ import { Assert } from '../../../suite/assert.js' -const enum E1 { - ONE, - TWO, - THREE, +function test1(...ar:[string,number,boolean]):number { + return 0 } -const ets = { - [E1.ONE]: "ONE", - [E1.TWO]: "TWO", - [E1.THREE]: "THREE", -}; -const x = Symbol(); -const y = Symbol(); -const z = Symbol(); -const etn = { - [x]: 1, - [y]: 2, - [z]: 3, -}; -function getValue(obj: T, key: K): T[K] { - return obj[key]; +function test2(ar:string,ar1: number,ar2:boolean):number { + return 1 } -let x1 = getValue(ets, E1.THREE); -let x2 = getValue(etn, z); -Assert.equal("THREE", x1); -Assert.equal(3, x2); -function fun1>(o: T, k: K) { - let m: string = k; - return m; -} -const stringMap = { - a: "mystring" -}; -let x3 = fun1(stringMap, "a"); -Assert.equal("a", x3); -function fun2(o: T, k: K) { - let m: string | number | symbol = k; - return m; -} -const uniteMap = { - a: "mystring", - b: 1 -}; -let x4 = fun2(uniteMap, "b"); -Assert.equal("b", x4); \ No newline at end of file + +Assert.equal(test1("11",2,true), 0); +Assert.equal(test2("11",2,true), 1); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts index d27c87f499..23c9f57e85 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts @@ -22,14 +22,14 @@ import { Assert } from '../../../../suite/assert.js' -function rfun1(...v: [number, string, boolean]) { +function rfun1(a: string, b: number, c: boolean, ...v: [number, string, boolean]) { return { number: v[0], string: v[1], boolean: v[2] }; } -function rfun2(v1: number, v2: string, v3: boolean) { +function rfun2(a: string, b: number, c: boolean, v1: number, v2: string, v3: boolean) { return { number: v1, string: v2, boolean: v3 }; } -var r1 = rfun1(1, "rfun", true); -var r2 = rfun2(1, "rfun", true); +var r1 = rfun1("a", 1, true, 1, "rfun", true); +var r2 = rfun2("a", 1, true, 1, "rfun", true); var jr1 = JSON.stringify(r1); var jr2 = JSON.stringify(r2); Assert.equal(jr1, jr2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts index ede86b4ea5..0ea5538293 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts @@ -22,15 +22,13 @@ import { Assert } from "../../../suite/assert.js" -function func(arg1: T, arg2: { str: string }, arg3:{num: number}) { - let obj = { n: 5, ...arg2, ...arg1, s: 's', ...arg3 }; +function func(arg1: T, arg2: { str: string }) { + let obj = { n: 5, ...arg1, s: 's', ...arg2 }; return obj; } let o1 = { str: 'a' }; -let o2 = { - num: 10 -}; -var f = func({ s: "string" }, o1, o2); +let f = func({ s: "string" }, o1); Assert.isObject(f); +Assert.equal(JSON.stringify(f), '{"n":5,"s":"s","str":"a"}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/better_support_for_never/better_support_for_never.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/better_support_for_never/better_support_for_never.ts new file mode 100644 index 0000000000..cad8262fc7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/better_support_for_never/better_support_for_never.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/**--- + description: > + Better Support for never -Returning Functions + module: ESNext + isCurrent: true + ---*/ + +import {Assert} from "../../../suite/assert.js"; +function test() { + process.exit(1); +} +Assert.equal(test(), 'never') \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/recursive_type_aliases/recursive_type_aliases_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/recursive_type_aliases/recursive_type_aliases_1.ts index 101a620ca9..67b78880da 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/recursive_type_aliases/recursive_type_aliases_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/recursive_type_aliases/recursive_type_aliases_1.ts @@ -27,10 +27,10 @@ type JSONType = | number | boolean | null - | HWJsonObject + | JsonObjectX | JsonArray; -interface HWJsonObject { +interface JsonObjectX { [property: string]: JSONType; } diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.9/Parsing_differences_in_optional_assertions/Parsing_differences_in_optional_assertions.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.9/Parsing_differences_in_optional_assertions/Parsing_differences_in_optional_assertions.ts new file mode 100644 index 0000000000..6488e62012 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/3.9/Parsing_differences_in_optional_assertions/Parsing_differences_in_optional_assertions.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/**--- + description: > + Parsing Differences in Optional Chaining and Non-Null Assertions + module: ESNext + isCurrent: true + ---*/ + +import {Assert} from "../../../suite/assert.js"; + +let s; +s = { a:1, b:{c:2}}; +Assert.equal(s?.a, 1); +Assert.equal((s.b!).c, 2); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_3.ts index a4d820977b..431a93f8c1 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_3.ts @@ -29,8 +29,8 @@ const obj = { }, set prop(_val: boolean) { }, }; -function hwtest01() { +function test01() { return true; } -obj.prop = obj.prop || hwtest01(); +obj.prop = obj.prop || test01(); Assert.equal(obj.prop, true); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_1.ts index 0da690c619..41c7efa8a4 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_1.ts @@ -26,22 +26,22 @@ type G = { [K in keyof T as `get${Capitalize}`]: () => T[K]; }; interface I1 { - name: string; - id: number; - lo: string; + a: string; + b: number; + c: string; } type I1Type = G; let k1: I1Type = { - getName() { + getA() { return "honny"; }, - getId() { + getB() { return 2; }, - getLo() { + getC() { return "qingdao"; }, }; -Assert.equal(k1.getName(), "honny"); -Assert.equal(k1.getId(), 2); -Assert.equal(k1.getLo(), "qingdao"); \ No newline at end of file +Assert.equal(k1.getA(), "honny"); +Assert.equal(k1.getB(), 2); +Assert.equal(k1.getC(), "qingdao"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_1.ts index 9e8d9661f2..091f4882eb 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_1.ts @@ -22,14 +22,14 @@ import { Assert } from '../../../suite/assert.js' -function getnum(location: "top" | "middle" | "bottom") { - if (location == "top") return 1; - else if (location == "middle") return 2; - else if (location == "bottom") return 3; +function getnum(x: "a" | "b" | "c") { + if (x == "a") return 1; + else if (x == "b") return 2; + else if (x == "c") return 3; } -let num1 = getnum("top"); -let num2 = getnum("middle"); -let num3 = getnum("bottom"); +let num1 = getnum("a"); +let num2 = getnum("b"); +let num3 = getnum("c"); Assert.equal(num1, 1); Assert.equal(num2, 2); Assert.equal(num3, 3); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_2.ts index 4c40cd23f1..44529217d3 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_2.ts @@ -23,30 +23,30 @@ import { Assert } from '../../../suite/assert.js' -type World = "world"; -type Greeting = `hello ${World}`; -function helloworld(w: World | Greeting) { - if (w == "world") return 1; - else if (w == "hello world") return 2; +type Go = "go"; +type Dong = `just ${Go}`; +function fun(w: Go | Dong) { + if (w == "go") return 1; + else if (w == "just go") return 2; } -let saying1 = helloworld("world"); +let saying1 = fun("go"); Assert.equal(saying1, 1); -let saying2 = helloworld("hello world"); +let saying2 = fun("just go"); Assert.equal(saying2, 2); -type Color = "red" | "blue"; -type Quantity = "one" | "two"; -type SeussFish = `${Quantity | Color} fish`; -function getfish(fish: SeussFish) { - if (fish == "one fish") return 1; - else if (fish == "two fish") return 2; - else if (fish == "red fish") return "red"; - else if (fish == "blue fish") return "blue"; +type Size = "small" | "big"; +type Num = "one" | "two"; +type Food = `${Num | Size} food`; +function getfish(food: Food) { + if (food == "one food") return 1; + else if (food == "two food") return 2; + else if (food == "small food") return "small"; + else if (food == "big food") return "big"; } -let fish1 = getfish("one fish"); -Assert.equal(fish1, 1); -let fish2 = getfish("two fish"); -Assert.equal(fish2, 2); -let fish3 = getfish("red fish"); -Assert.equal(fish3, "red"); -let fish4 = getfish("blue fish"); -Assert.equal(fish4, "blue"); +let x1 = getfish("one food"); +Assert.equal(x1, 1); +let x2 = getfish("two food"); +Assert.equal(x2, 2); +let x3 = getfish("small food"); +Assert.equal(x3, "small"); +let x4 = getfish("big food"); +Assert.equal(x4, "big"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/Reverting_Template_Literal_Inference/Reverting_Template_Literal_Inference.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/Reverting_Template_Literal_Inference/Reverting_Template_Literal_Inference.ts index 9a1b4317d4..c50fadb28c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/Reverting_Template_Literal_Inference/Reverting_Template_Literal_Inference.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/Reverting_Template_Literal_Inference/Reverting_Template_Literal_Inference.ts @@ -23,19 +23,15 @@ import { Assert } from '../../../suite/assert.js' -const logo:string ="just do it" - -const hw: string = `go ${logo}`; - -let hwa: string = `hello ${logo}`; - -let hws:string = `luckily dog ${logo}` as const; - -function check(op?:string){ +const logo: "just do it" = "just do it"; +const str1: string = `go ${logo}`; +let str2: string = `hello ${logo}`; +let str3: "luckily dog just do it" = `luckily dog ${logo}` as const; +function check(op?: string){ if (op){ - Assert.isString(op) + Assert.isString(op); } } -check(hw+hwa+hws); -Assert.equal(hw,"go just do it"); -Assert.equal(hwa,"hello just do it"); \ No newline at end of file +check(str1 + str2 + str3); +Assert.equal(str1, "go just do it"); +Assert.equal(str2, "hello just do it"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures.ts index dae3a27a2c..866275dfa2 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures.ts @@ -50,45 +50,4 @@ class ColorCopy extends Color { } let color: ColorCopy = new ColorCopy(255, 0, 0); -Assert.equal(JSON.stringify(color.getRGB()), '[255,0,0]'); - -abstract class Point { - abstract a: number; - abstract b: number; - abstract getPoint(): [number, number]; -} - -type MIX = abstract new (...args: any[]) => T - -function mixClass>(Ctor: T) { - abstract class CPColor extends Ctor { - abstract red: number; - abstract green: number; - abstract blue: number; - abstract getColor(): [number, number, number]; - } - return CPColor; -} - -class ColorPoint extends mixClass(Point) { - red: number = 0; - green: number = 0; - blue: number = 0; - a: number = 0; - b: number = 0; - getColor(): [number, number, number] { - return [this.red, this.green, this.blue]; - } - getPoint(): [number, number] { - return [this.a, this.b]; - } - constructor(red: number = 0, green: number = 0, blue: number = 0, a: number = 0, b: number = 0) { - super(); - this.a = a; this.b = b; - this.red = red; this.green = green; this.blue = blue; - } -} - -let cp = new ColorPoint(0, 255, 0, 25, 25); -Assert.equal(JSON.stringify(cp.getColor()), '[0,255,0]'); -Assert.equal(JSON.stringify(cp.getPoint()), '[25,25]'); \ No newline at end of file +Assert.equal(JSON.stringify(color.getRGB()), '[255,0,0]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures_3.ts index 5f796a4af2..1ee46162c2 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures_3.ts @@ -22,26 +22,43 @@ import { Assert } from '../../../suite/assert.js' -abstract class myClass { - abstract h_method(): number; - func() { }; +abstract class Point { + abstract a: number; + abstract b: number; + abstract getPoint(): [number, number]; } -type myType = abstract new (...args: any[]) => T; +type MIX = abstract new (...args: any[]) => T -function myFunc>(value: T) { - abstract class myC extends value { - getS() { - }; +function mixClass>(Ctor: T) { + abstract class CPColor extends Ctor { + abstract red: number; + abstract green: number; + abstract blue: number; + abstract getColor(): [number, number, number]; } - return myC; + return CPColor; } -class h_C extends myFunc(myClass) { - h_method(): number { - return 10; +class ColorPoint extends mixClass(Point) { + red: number = 0; + green: number = 0; + blue: number = 0; + a: number = 0; + b: number = 0; + getColor(): [number, number, number] { + return [this.red, this.green, this.blue]; + } + getPoint(): [number, number] { + return [this.a, this.b]; + } + constructor(red: number = 0, green: number = 0, blue: number = 0, a: number = 0, b: number = 0) { + super(); + this.a = a; this.b = b; + this.red = red; this.green = green; this.blue = blue; } } -let test = new h_C(); -Assert.equal(test.h_method(), 10); \ No newline at end of file +let cp = new ColorPoint(0, 255, 0, 25, 25); +Assert.equal(JSON.stringify(cp.getColor()), '[0,255,0]'); +Assert.equal(JSON.stringify(cp.getPoint()), '[25,25]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/relaxed_rules/relaxed_rules_between_optional_properties_and_string_index_signatures_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/relaxed_rules_between_optional_properties_and_string_index_signatures/relaxed_rules.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/4.2/relaxed_rules/relaxed_rules_between_optional_properties_and_string_index_signatures_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/4.2/relaxed_rules_between_optional_properties_and_string_index_signatures/relaxed_rules.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation1.ts index 244f511368..9ccb67a316 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation1.ts @@ -22,17 +22,16 @@ import { Assert } from '../../../suite/assert.js' -type NumStrBool = number | string | boolean; - -function func(value: NumStrBool): NumStrBool { +type T = number | string | boolean; +function func(value: T): T { return value; } let arr = [1, "hello", false]; Assert.equal(typeof func(arr[0]), "number"); class C{ - mem: NumStrBool; - constructor(mem: NumStrBool) { + mem: T; + constructor(mem: T) { this.mem = mem; } } diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation2.ts index 9d99a29f24..e6cd3461ba 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation2.ts @@ -22,10 +22,9 @@ import { Assert } from '../../../suite/assert.js' -type NumStrBool = number | string | boolean; - -function func(value: NumStrBool) { - return value; +type T = number | string | boolean; +function func(arg: T) { + return arg; } let arr = [10, "hello", false]; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/constructorParameters_works_on_abstract_class/constructorParameters_works_on_abstract_class.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/constructorParameters_works_on_abstract_class/constructorParameters_works_on_abstract_class.ts index 8bd39f4b19..a3618c6e84 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/constructorParameters_works_on_abstract_class/constructorParameters_works_on_abstract_class.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/constructorParameters_works_on_abstract_class/constructorParameters_works_on_abstract_class.ts @@ -22,7 +22,7 @@ import { Assert } from "../../../suite/assert.js" -abstract class HWC { +abstract class CPC { a: string; b: number; constructor(a: string, b: number) { @@ -31,6 +31,6 @@ abstract class HWC { } } -type TypeC = ConstructorParameters; +type TypeC = ConstructorParameters; var c: TypeC = ["s", 10]; Assert.equal(JSON.stringify(c), '["s",10]'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/ecmascript_private_class_elements/ecmascript_private_calss_elements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/ecmascript_private_class_elements/ecmascript_private_calss_elements.ts index 8437bc5d29..16ee873e22 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/ecmascript_private_class_elements/ecmascript_private_calss_elements.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/ecmascript_private_class_elements/ecmascript_private_calss_elements.ts @@ -26,7 +26,7 @@ import { Assert } from "../../../suite/assert.js" -class HWC { +class ClassP { #FUN() { return 1; } @@ -37,7 +37,7 @@ class HWC { return num; } F2() { - return HWC.#something(10); + return ClassP.#something(10); } get #V() { return 100; @@ -48,7 +48,7 @@ class HWC { } } -let c = new HWC(); +let c = new ClassP(); Assert.equal(c.F1(), 1); Assert.equal(c.F2(), 10); Assert.equal(c.mFUN(), 100); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/override_and_the_noImplicitOverride_Flag/override_and_the_noImplicitOverride_Flag.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/override_and_the_noImplicitOverride_Flag/override_and_the_noImplicitOverride_Flag.ts index 89788b6316..99a9b6f11f 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/override_and_the_noImplicitOverride_Flag/override_and_the_noImplicitOverride_Flag.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/override_and_the_noImplicitOverride_Flag/override_and_the_noImplicitOverride_Flag.ts @@ -24,27 +24,27 @@ import { Assert } from "../../../suite/assert.js" -class Boss{ - run(person?:string): string{ - return person+" go" +class Boss { + run(person?: string): string { + return person + " go" } } -class manage extends Boss{ +class Manage extends Boss { run(person?: string): string { return super.run(person); } } -class staff extends Boss{ - override run(person?:string): string { +class Staff extends Boss { + override run(person?: string): string { super.run(); - return person+" run"; + return person + " run"; } } -let Hwa = new Boss(); -Assert.equal(Hwa.run("boss"),"boss go"); +let boss = new Boss(); +Assert.equal(boss.run("boss"), "boss go"); -let hwc = new manage(); -Assert.equal(hwc.run("manage"),"manage go"); +let manage = new Manage(); +Assert.equal(manage.run("manage"), "manage go"); -let Hwb = new staff(); -Assert.equal(Hwb.run("staff"),"staff run"); +let staff = new Staff(); +Assert.equal(staff.run("staff"), "staff run"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_1.ts index e56668065b..a925554105 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_1.ts @@ -27,7 +27,7 @@ import { Assert } from "../../../suite/assert.js" -class HWC { +class SWTC1 { #data = 0; get data(): number { return this.#data; @@ -49,7 +49,7 @@ class HWC { } } -let c = new HWC(); +let c = new SWTC1(); let n: number = 0; c.data = "hello"; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_2.ts index a078e41f35..c765ea1462 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_2.ts @@ -24,12 +24,12 @@ import { Assert } from "../../../suite/assert.js" -interface HWC { +interface SWTC2 { get data(): number; set data(val: number | string | boolean); } -function funSW(): HWC { +function funSW(): SWTC2 { let data = 0; return { get data(): number { diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/static_index_signatures/static_index_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/static_index_signatures/static_index_signatures.ts index e1bb7faebb..99f3ab9544 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/static_index_signatures/static_index_signatures.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/static_index_signatures/static_index_signatures.ts @@ -23,17 +23,17 @@ import { Assert } from "../../../suite/assert.js" -class HWC { +class SIS { hello = "hello"; world = "1213"; [propName: string]: string | number | undefined; } -let hwc = new HWC(); -hwc["Yes!Yes!Yes!"] = 42; -Assert.equal(hwc["Yes!Yes!Yes!"], 42); +let sis = new SIS(); +sis["Yes!Yes!Yes!"] = 42; +Assert.equal(sis["Yes!Yes!Yes!"], 42); -let x = hwc["No!No!No!"]; +let x = sis["No!No!No!"]; x = undefined; Assert.isUndefined(x); x = 20; @@ -41,16 +41,16 @@ Assert.equal(x, 20); x = "x"; Assert.equal(x, "x"); -class HWB { +class B { static hello = "hello"; static world = 1342; static [propName: string]: string | number | undefined; } -HWB["Yes!Yes!Yes!"] = 42; -Assert.equal(HWB["Yes!Yes!Yes!"], 42); +B["Yes!Yes!Yes!"] = 42; +Assert.equal(B["Yes!Yes!Yes!"], 42); -let y = HWB["No!No!No!"]; +let y = B["No!No!No!"]; y = "y"; Assert.equal(y, "y"); y = 10; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/union_enums_cannot_be_compared_to_arbitrary_numbers/union_enums_cannot_be_compared_to_arbitrary_numbers.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/union_enums_cannot_be_compared_to_arbitrary_numbers/union_enums_cannot_be_compared_to_arbitrary_numbers.ts index 31df78ced9..1ff166bc82 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/union_enums_cannot_be_compared_to_arbitrary_numbers/union_enums_cannot_be_compared_to_arbitrary_numbers.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/union_enums_cannot_be_compared_to_arbitrary_numbers/union_enums_cannot_be_compared_to_arbitrary_numbers.ts @@ -31,33 +31,33 @@ enum AB { B = 1, } -function hwtest01(x: AB | -1) { +function eFun01(x: AB | -1) { if (x === -1) { return -1; } return 1; } -Assert.equal(hwtest01(-1), -1); -Assert.equal(hwtest01(AB.A), 1); +Assert.equal(eFun01(-1), -1); +Assert.equal(eFun01(AB.A), 1); -function hwtest02(x: AB) { +function eFun02(x: AB) { if ((x as number) === -1) { return x; } return x + 1; } -Assert.equal(hwtest02(AB.A), 1); +Assert.equal(eFun02(AB.A), 1); enum ab { A = +0, B = 1, } -function hwtest03(x: ab) { +function eFun03(x: ab) { if (x === 1) { return x; } return x + 2; } -Assert.equal(hwtest03(ab.A), 2); -Assert.equal(hwtest03(ab.B), 1); +Assert.equal(eFun03(ab.A), 2); +Assert.equal(eFun03(ab.B), 1); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/readonly_tuples_have_a_readonly_length_property/readonly_tuples_have_a_readonly_length_property.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/readonly_tuples_have_a_readonly_length_property/readonly_tuples_have_a_readonly_length_property.ts index 78273286af..a3c17f788b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/readonly_tuples_have_a_readonly_length_property/readonly_tuples_have_a_readonly_length_property.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/readonly_tuples_have_a_readonly_length_property/readonly_tuples_have_a_readonly_length_property.ts @@ -22,8 +22,11 @@ import { Assert } from '../../../suite/assert.js' -function func(tuple: readonly [string, string, string]) { - return tuple.length; +class C{ + readonly arr: [number, string, boolean]; + constructor(arr: [number, string, boolean]) { + this.arr = arr; + } } -var a = func(['a', 'b', 'c']); -Assert.equal(a, 3); \ No newline at end of file +let c = new C([10, 'a', true]); +Assert.equal(c.arr.length, 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.8/improved_inference_for_infer_types_in_template_string_types/improved_inference_for_infer_types_in_template_string_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.8/improved_inference_for_infer_types_in_template_string_types/improved_inference_for_infer_types_in_template_string_types.ts index 0b4e79cafc..f47743cc54 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.8/improved_inference_for_infer_types_in_template_string_types/improved_inference_for_infer_types_in_template_string_types.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.8/improved_inference_for_infer_types_in_template_string_types/improved_inference_for_infer_types_in_template_string_types.ts @@ -33,12 +33,6 @@ let arr = ["A", "B", "C"]; let first = func(arr, 65); Assert.equal(JSON.stringify(first), "[65,\"B\",\"C\"]"); -type N = "10" extends `${infer U extends number}` ? U : false; -type Bi = "string" extends `${infer U extends string}` ? U : false; -type Bool = "true" extends `${infer U extends boolean}` ? U : false; -let sn: N = 10; -let sbi: Bi = "string"; -let sbool: Bool = true; -Assert.equal(sn, 10); -Assert.equal(sbi, "string"); -Assert.equal(sbool, true); \ No newline at end of file +type S = "string" extends `${infer T extends string}` ? T : false; +let s: S = "string"; +Assert.equal(s, "string"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.9/auto_accessors_in_classes/auto_accessors_in_classes.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.9/auto_accessors_in_classes/auto_accessors_in_classes.ts index e34cbf1ec2..48ab4e76df 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.9/auto_accessors_in_classes/auto_accessors_in_classes.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.9/auto_accessors_in_classes/auto_accessors_in_classes.ts @@ -14,7 +14,7 @@ */ /**--- description: > - typescript 4.9 makes the in operator a little bit more powerful when narrowing types that don’t list the property at all. + TypeScript 4.9 supports an upcoming feature in ECMAScript called auto-accessors. options: target: es2015 module: ESNext @@ -25,15 +25,15 @@ import { Assert } from "../../../suite/assert.js" class NormalClass { - #_str: string; - get str(): string { - return this.#_str; + #str: string; + constructor(str: string) { + this.#str = str; } - set str(value: string) { - this.#_str = value; + get Str(): string { + return this.#str; } - constructor(str: string) { - this.#_str = str; + set Str(str: string) { + this.#str = str; } } class AutoClass { @@ -45,7 +45,7 @@ class AutoClass { let c1 = new NormalClass("0"); let c2 = new AutoClass("0"); -c1.str = "NormalClass"; -Assert.equal(c1.str, "NormalClass"); +c1.Str = "NormalClass"; +Assert.equal(c1.Str, "NormalClass"); c2.str = "AutoClass"; Assert.equal(c2.str, "AutoClass"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.9/the_satisfies_operator/the_satisfies_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.9/the_satisfies_operator/the_satisfies_operator.ts index 243116bc2d..84846a9a5a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.9/the_satisfies_operator/the_satisfies_operator.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.9/the_satisfies_operator/the_satisfies_operator.ts @@ -22,24 +22,22 @@ import { Assert } from '../../../suite/assert.js' -type Colors = "Red" | "Green" | "Blue"; -type RGB = [Red: number, Green: number, Blue: number]; -const rgbData = { - Red: [255, 0, 0], - Green: "0x00ff00", - Blue: [0, 0, 255], +const day = { + Mon: 'monday', + Wedn: "wednesday", + Fri: 'friday' }; -const favoriteColors = { - "Red": "yes", - "Green": false, - "Blue": "kinda", +const hobby = { + "Mon": false, + "Wedn": false, + "Fri": true }; -const redComponent = rgbData.Red.length; -const greenUpperCase = rgbData.Green.toUpperCase(); -const g: boolean = favoriteColors.Green; +const long = day.Mon.length; +const w = day.Wedn.toUpperCase(); +const g = hobby.Wedn; -Assert.equal(redComponent, 3); -Assert.equal(greenUpperCase, "0X00FF00"); +Assert.equal(long, 6); +Assert.equal(w, "WEDNESDAY"); Assert.isFalse(g); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.9/unlisted_property_narrowing_with_the_in_operator/unlisted_property_narrowing_with_the_in_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.9/unlisted_property_narrowing_with_the_in_operator/unlisted_property_narrowing_with_the_in_operator.ts index 9fb4f82aee..6aaac94c01 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.9/unlisted_property_narrowing_with_the_in_operator/unlisted_property_narrowing_with_the_in_operator.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/4.9/unlisted_property_narrowing_with_the_in_operator/unlisted_property_narrowing_with_the_in_operator.ts @@ -22,52 +22,37 @@ import { Assert } from '../../../suite/assert.js' -interface RGBIN { - red: number; - green: number; - blue: number; -} - -interface HSV { - hue: number; - saturation: number; - value: number; -} - -function setColor(color: RGBIN | HSV) { - if ("hue" in color && "red" in color) { - return "RGBIN | HSV"; - } else if ("hue" in color) { - return "HSV"; - } else if ("red" in color) { - return "RGBIN"; +type T1 = { num: number }; +type T2 = { str: string }; +function func(arg: T1 | T2) { + if ("num" in arg && "str" in arg) { + return "T1 | T2"; + } else if ("num" in arg) { + return "T1"; + } else if ("str" in arg) { + return "T2"; } } -var c1: RGBIN = { red: 0, green: 0, blue: 0 }; -var c2: HSV = { hue: 0, saturation: 0, value: 0 }; -var c3: RGBIN | HSV = { hue: 0, saturation: 0, value: 0, red: 0, green: 0, blue: 0 }; - -Assert.equal(setColor(c1), "RGBIN"); -Assert.equal(setColor(c2), "HSV"); -Assert.equal(setColor(c3), "RGBIN | HSV"); - -interface Package { - JSON: unknown; +let x: T1 = { num: 10 }; +let y: T2 = { str: 'a' }; +let z: T1 | T2 = { num: 10, str: 'a' }; +Assert.equal(func(x), "T1"); +Assert.equal(func(y), "T2"); +Assert.equal(func(z), "T1 | T2"); + +interface I{ + mem: any; } - -function getPackageName(pak: Package): string { - const p:any = pak.JSON; - if (p && typeof p === "object") { - if ("name" in p && typeof p.name === "string") { - return p.name; +function check(arg: I) { + let mem = arg.mem; + if (mem && typeof mem === "object") { + if ("num" in mem && typeof mem.num === 'number') { + return mem.num; } } - return "no JSON"; + return null; } -let pak: Package = { JSON: { name: "JSON" } }; -let none: Package = { JSON: "null" }; -let out1 = getPackageName(pak); -let out2 = getPackageName(none); - -Assert.equal(out1, "JSON"); -Assert.equal(out2, "no JSON"); +let a: I = { mem: 10 }; +let b: I = { mem: { num: 10 } }; +Assert.isTrue(check(a) === null); +Assert.isNumber(check(b)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/Ambient_Class_Declarations/Ambient_Class_Declarations.ts similarity index 56% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_8.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/Ambient_Class_Declarations/Ambient_Class_Declarations.ts index 8435c66f74..40efacf774 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_8.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/Ambient_Class_Declarations/Ambient_Class_Declarations.ts @@ -14,8 +14,7 @@ */ /**--- description: > - A property named 'prototype', the type of which is an instantiation of the class type with type Any supplied - as a type argument for each type parameter. + An ambient class declaration declares a class type and a constructor function in the containing declaration space. module: ESNext isCurrent: true ---*/ @@ -23,14 +22,20 @@ import { Assert } from '../../../../../suite/assert.js' -class Animal { - public name: string; - constructor(name: string) { - this.name = name; - } +declare class Student { + constructor(sname?: string, sage?: number); + public sname: string; + public sage: number; + cl():number; } -Assert.equal(typeof (Animal.prototype), "object"); -let cat = new Animal("Cat") -Assert.equal(Object.getPrototypeOf(cat) === Animal.prototype, true); -Assert.equal(Object.getPrototypeOf(Animal.prototype) === Object.prototype, true); -Assert.equal(Object.getPrototypeOf(Object.prototype) === null, true); \ No newline at end of file +let s1 :Student ={ + sname:"static", + sage:12, + cl(){ + return 1; + } +} +Assert.equal(s1.sname,"static"); +Assert.equal(s1.sage,"12"); +Assert.equal(s1.cl(),1); +Assert.isFunction(s1.cl); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts index 9d6d409248..60d3b91412 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts @@ -27,8 +27,6 @@ import { Assert } from '../../../../../suite/assert.js' declare type DF1 = () => void; declare type DF2 = (a: string, b: string) => string; declare type DF3 = (a: number, b?: number) => string; -declare function fun1(): void; -declare function fun2(a: number): string; const dFun1: DF1 = () => { Assert.isString("dFun1"); } const dFun2: DF2 = (a: string, b: string) => { Assert.isString("dFun2"); return a + b; } const dFun3: DF3 = (a: number, b?: number) => { diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_variable_declarations/ambient_variable_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_variable_declarations/ambient_variable_declarations.ts new file mode 100644 index 0000000000..d76695a41e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_variable_declarations/ambient_variable_declarations.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + An ambient variable declaration introduces a variable in the containing declaration space. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +declare type variable1 = number; +declare type variable2 = string; +declare type variable3 = (vab1:number,vab2:string) => string;; + +var vab1:variable1 = 3; +let vab2:variable2 = "www"; +const vab3:variable3 = (vab1,vab2) =>{return vab1+vab2;} + +Assert.equal(typeof vab1,"number"); +Assert.equal(typeof vab2,"string"); +Assert.equal(vab3(vab1,vab2),"3www"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts index d5bc6b046c..22d8b49755 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts @@ -23,21 +23,21 @@ import { Assert } from '../../../../suite/assert.js' -export declare module AMD3_1 { - interface AMD3_1IF { +export declare module m1 { + interface I1 { a3_1: boolean; a3_2: number; } var AMD2Var1: string; } -declare module AMD3_2 { - export interface AMD3_2IF { +declare module m2 { + export interface I2 { a3_1: boolean; a3_2: string; } export var AMD2Var1: string; } -var am3_1: AMD3_1.AMD3_1IF = { a3_1: false, a3_2: 0 }; -var am3_2: AMD3_2.AMD3_2IF = { a3_1: true, a3_2: "T" }; +var am3_1: m1.I1 = { a3_1: false, a3_2: 0 }; +var am3_2: m2.I2 = { a3_1: true, a3_2: "T" }; Assert.equal(JSON.stringify(am3_1), '{"a3_1":false,"a3_2":0}'); Assert.equal(JSON.stringify(am3_2), '{"a3_1":true,"a3_2":"T"}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_1.ts index 1064bbb2b1..bc0c2bd827 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_1.ts @@ -24,13 +24,13 @@ import { Assert } from '../../../../suite/assert.js' -let a: string = "a is string"; -Assert.equal("a is string1", a + "1"); -type a = String; -let x: a = "xx"; -Assert.equal("xx", x); -namespace a { +let Rog: string = "a is string"; +Assert.equal("a is string1", Rog + "1"); +type Rog = String; +let newOne: Rog = "xx"; +Assert.equal("xx", newOne); +namespace Rog { export type b = string; } -let y: a.b = "ystr"; -Assert.equal("ystr", y); \ No newline at end of file +let yoo: Rog.b = "ystr"; +Assert.equal("ystr", yoo); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_2.ts index 8452726f3c..b67f8f3601 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_2.ts @@ -33,9 +33,11 @@ class Myclass { constructor(a: string) { this.a = a; } + static a :number = 33; } var c: Myclass = new Myclass("x"); Assert.equal(c.a, "x"); +Assert.equal(Myclass.a,33); enum WeekDay { MON = 1, TUE, diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_2.ts index 606b9083bc..eaa0ec471b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_2.ts @@ -20,24 +20,24 @@ ---*/ import { Assert } from '../../../../suite/assert.js' -class Point { +class MyClass { constructor(public x: number, public y: number) { this.x = x; this.y = y; } - static initial = new Point(0, 0); - static distance(a: Point, b: Point) { + static initial = new MyClass(0, 0); + static distance(a: MyClass, b: MyClass) { let dx = a.x - b.x; let dy = a.y - b.y; return Math.hypot(dx, dy); } } -Assert.equal(0, Point.initial.x); -Assert.equal(0, Point.initial.y); -let p1 = new Point(0, 4); -let p2 = new Point(3, 0); +Assert.equal(0, MyClass.initial.x); +Assert.equal(0, MyClass.initial.y); +let p1 = new MyClass(0, 4); +let p2 = new MyClass(3, 0); Assert.equal(0, p1.x); Assert.equal(4, p1.y); Assert.equal(3, p2.x); Assert.equal(0, p2.y); -Assert.equal(5, Point.distance(p1, p2)); \ No newline at end of file +Assert.equal(5, MyClass.distance(p1, p2)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts index 82f12111d9..2af41b9e05 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts @@ -24,13 +24,13 @@ import { Assert } from '../../../../../suite/assert.js' -class P1 { +class MyClass1 { constructor(public num1: number, private num2: number = 1) { } get foo(): number { return this.num2; } } -class Point2 { +class MyClass2 { public num1: number; protected num2: number; constructor(num1: number, num2: number) { @@ -41,8 +41,8 @@ class Point2 { return this.num2; } } -let p1 = new P1(1, 2); +let p1 = new MyClass1(1, 2); Assert.equal(p1.num1, 1); Assert.equal(p1.foo, 2); -let p2 = new Point2(3, 4); +let p2 = new MyClass2(3, 4); Assert.equal(p2.foo, 4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_2.ts index c8bb08dfaf..0a8a658283 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_2.ts @@ -2,7 +2,7 @@ * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * You may obtain m copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -15,7 +15,7 @@ /**--- description: > Private property members can be accessed only within their declaring class. Specifically, - a private member M declared in a class C can be accessed only within the class body of C. + m private member M declared in m class C can be accessed only within the class body of C. module: ESNext isCurrent: true ---*/ @@ -35,15 +35,15 @@ class Base { public addxy(): number { return this.x + this.y; } - static f(a: Base, b: Derived) { - a.x = 1; - b.x = 1; - a.y = 1; - b.y = 1; + static fun(m: Base, n: Derived) { + m.x = 1; + n.x = 1; + m.y = 1; + n.y = 1; } } class Derived extends Base { } -let a: Base = new Base(); -a.addx(); -Assert.equal(a.foo, 2); -Assert.equal(a.addxy(), 4); \ No newline at end of file +let m: Base = new Base(); +m.addx(); +Assert.equal(m.foo, 2); +Assert.equal(m.addxy(), 4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_3.ts index 93465706ca..b91989153a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_3.ts @@ -35,10 +35,10 @@ class Base { public get foo() { return this.x; } - static f(a: Base, b: Derived) { - a.x = 1; + static fun(m: Base, b: Derived) { + m.x = 1; b.x = 1; - a.y = 1; + m.y = 1; b.y = 1; } } @@ -49,14 +49,14 @@ class Derived extends Base { public get foo() { return this.x; } - static f(b: Derived) { + static fun(b: Derived) { b.x = 1; b.y = 1; } } -let a: Base = new Base(); -a.addx(); -Assert.equal(a.foo, 2); +let m: Base = new Base(); +m.addx(); +Assert.equal(m.foo, 2); let b: Derived = new Derived(); b.addx(); Assert.equal(b.foo, 2); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_3.ts index 570be6c8ad..870c54edb0 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_3.ts @@ -37,16 +37,16 @@ class Ra { public getz(): number { return this.z; } - protected g(): boolean { + protected fun(): boolean { return false; } - public getg() { - return this.g(); + public getfun() { + return this.fun(); } } class Rb extends Ra { protected z: number = 20; - protected g(): boolean { + protected fun(): boolean { return true; } } @@ -54,7 +54,7 @@ let a: Ra = new Ra(); Assert.equal(a.x, 10); Assert.equal(a.gety(), 10); Assert.equal(a.getz(), 10); -Assert.equal(a.getg(), false); +Assert.equal(a.getfun(), false); Assert.equal(a.f().x, 11); let b: Rb = new Rb(); Assert.equal(b.x, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts index 388c1f2f77..98ad0473e6 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts @@ -14,8 +14,7 @@ */ /**--- description: > - Every class automatically contains a static property member named 'prototype', - the type of which is the containing class with type Any substituted for each type parameter. + A property for each static member variable declaration in the class body. module: ESNext isCurrent: true ---*/ @@ -23,26 +22,24 @@ import { Assert } from '../../../../../suite/assert.js' -class P { - constructor(public pro1: T1, public pro2: T2) { } +class A1 { + public numa: number; + constructor(a: number) { + this.numa = a; + } + static c: number = 20; } -class TwoArrays extends P { - +class B1 extends A1 { + public numb: number; + constructor(a: number, b: number) { + super(a); + this.numb = b; + } } -let x: number = 1; -let y: number = 2; -let p = new P(x, y); -let one = [3,4,5]; -let two = [6,7,8] -let twoArrays = new TwoArrays(one,two); -Assert.equal(twoArrays.pro1,one); -Assert.equal(twoArrays.pro2,two) -Assert.equal(p.pro1, 1); - -let x2: string = "one"; -let y2: string = "two"; -let p2 = new P(x2, y2); -Assert.equal(p2.pro1, "one"); -let x3: boolean = true; -let p3 = new P(x3, y); -Assert.equal(p3.pro1, true); \ No newline at end of file +let a: A1 = new A1(10); +Assert.equal(a.numa, 10); +Assert.equal(A1.c, 20); +let b: B1 = new B1(10, 20); +Assert.equal(b.numa, 10); +Assert.equal(b.numb, 20); +Assert.equal(B1.c, 20); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_6.ts index 98ad0473e6..d97b249c6e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_6.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_6.ts @@ -14,7 +14,7 @@ */ /**--- description: > - A property for each static member variable declaration in the class body. + A property of a function type for each static member function declaration in the class body. module: ESNext isCurrent: true ---*/ @@ -27,7 +27,10 @@ class A1 { constructor(a: number) { this.numa = a; } - static c: number = 20; + static c = 10; + static f(): void { + this.c++; + } } class B1 extends A1 { public numb: number; @@ -35,11 +38,13 @@ class B1 extends A1 { super(a); this.numb = b; } + static f() { + this.c++; + return this.c + } } -let a: A1 = new A1(10); -Assert.equal(a.numa, 10); -Assert.equal(A1.c, 20); -let b: B1 = new B1(10, 20); -Assert.equal(b.numa, 10); -Assert.equal(b.numb, 20); -Assert.equal(B1.c, 20); \ No newline at end of file +Assert.equal(A1.c, 10); +A1.f(); +Assert.equal(A1.c, 11); +Assert.equal(B1.c, 11); +Assert.equal(B1.f(), 12); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_7.ts index d97b249c6e..8435c66f74 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_7.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_7.ts @@ -14,7 +14,8 @@ */ /**--- description: > - A property of a function type for each static member function declaration in the class body. + A property named 'prototype', the type of which is an instantiation of the class type with type Any supplied + as a type argument for each type parameter. module: ESNext isCurrent: true ---*/ @@ -22,29 +23,14 @@ import { Assert } from '../../../../../suite/assert.js' -class A1 { - public numa: number; - constructor(a: number) { - this.numa = a; - } - static c = 10; - static f(): void { - this.c++; - } -} -class B1 extends A1 { - public numb: number; - constructor(a: number, b: number) { - super(a); - this.numb = b; - } - static f() { - this.c++; - return this.c +class Animal { + public name: string; + constructor(name: string) { + this.name = name; } } -Assert.equal(A1.c, 10); -A1.f(); -Assert.equal(A1.c, 11); -Assert.equal(B1.c, 11); -Assert.equal(B1.f(), 12); \ No newline at end of file +Assert.equal(typeof (Animal.prototype), "object"); +let cat = new Animal("Cat") +Assert.equal(Object.getPrototypeOf(cat) === Animal.prototype, true); +Assert.equal(Object.getPrototypeOf(Animal.prototype) === Object.prototype, true); +Assert.equal(Object.getPrototypeOf(Object.prototype) === null, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/dynamic_property_declarations/dynamic_property_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/dynamic_property_declarations/dynamic_property_declarations.ts new file mode 100644 index 0000000000..c11af2fa48 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/dynamic_property_declarations/dynamic_property_declarations.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A dynamic property declaration does not introduce a property in the class type or constructor function type. + The property name expression of a dynamic property assignment must be of type Any or the String, Number, or Symbol primitive type. + The name associated with a dynamic property declarations is considered to be a numeric property name if the property name expression is of type Any or the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class computer { + [compute:string]:any + constructor( + public name:string, + public age:number + ){} + sayOne(){return "one"} +} +let uce = new computer("aa",22); +uce.pid = "223"; +uce.id=1; +Assert.equal(uce.name,"aa"); +Assert.equal(typeof uce,"object"); +Assert.equal(uce.id+uce.pid,"1223"); +Assert.equal(uce.sayOne(),"one"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts index 8df54b7a99..81ff4b1d7b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts @@ -22,19 +22,19 @@ import { Assert } from '../../../../../suite/assert.js' -class P { +class MyClass { constructor(public x: number, public y: number) { } - public distance(p: P) { + public distance(p: MyClass) { let dx = this.x - p.x; let dy = this.y - p.y; return Math.sqrt(dx * dx + dy * dy); } - static add(p1: P) { + static add(p1: MyClass) { p1.x++; return p1.x } } -let p1: P = new P(2, 2); -let p2: P = new P(1, 1); +let p1: MyClass = new MyClass(2, 2); +let p2: MyClass = new MyClass(1, 1); Assert.equal(p1.distance(p2), Math.sqrt(2)); -Assert.equal(P.add(p1), 3); \ No newline at end of file +Assert.equal(MyClass.add(p1), 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts index 1b220996f1..b5b27f92c4 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts @@ -22,7 +22,7 @@ import { Assert } from '../../../../../suite/assert.js' -class Point { +class MyClass { constructor(public x: number = 3, public y: number = 3) { } static z: number; static pro() { @@ -32,5 +32,5 @@ class Point { this.z; } } -Assert.equal(Point.pro(), "[object Object]"); -Assert.equal(Point.returnz(), undefined); \ No newline at end of file +Assert.equal(MyClass.pro(), "[object Object]"); +Assert.equal(MyClass.returnz(), undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts index bcbc62b837..00b736c2f0 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts @@ -22,13 +22,13 @@ import { Assert } from '../../../../../suite/assert.js' -class P { +class MyClass { constructor(public x: number, public y: number) { } public add() { return this.x + this.y; } } -class childP extends P { +class MyClass2 extends MyClass { constructor(x: number, y: number, public z: number) { super(x, y); } @@ -36,10 +36,10 @@ class childP extends P { return super.add() + this.z; } } -let p = new P(1, 2); +let p = new MyClass(1, 2); Assert.equal(p.x, 1); Assert.equal(p.y, 2); Assert.equal(p.add(), 3); -let cp = new childP(1, 2, 3); +let cp = new MyClass2(1, 2, 3); Assert.equal(cp.z, 3); Assert.equal(cp.add(), 6); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts index d428053613..9d52a76633 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts @@ -22,18 +22,18 @@ import { Assert } from '../../../../../suite/assert.js' -class P { +class TP { constructor(public a: number = 1, public b: number = 1) { } static createthis() { return new this(); } } -class CP extends P { +class CP extends TP { constructor(public a: number = 2, public b = 2) { super(); } } -let x = P.createthis(); +let x = TP.createthis(); let y = CP.createthis(); Assert.equal(x.a, 1); Assert.equal(y.a, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts index 97ed1b4270..0858958081 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts @@ -22,18 +22,18 @@ import { Assert } from '../../../../../suite/assert.js' -class Point { +class MyClass { constructor(public x: number, public y: number) { } public addc() { - Point.c++; + MyClass.c++; } - static origin = new Point(0, 0); + static po = new MyClass(0, 0); static c: number = 10; } -let a: Point = new Point(1, 1); -Assert.equal(Point.c, 10); +let a: MyClass = new MyClass(1, 1); +Assert.equal(MyClass.c, 10); a.addc(); -Assert.equal(Point.c, 11); -let b: Point = new Point(1, 1); +Assert.equal(MyClass.c, 11); +let b: MyClass = new MyClass(1, 1); b.addc(); -Assert.equal(Point.c, 12); \ No newline at end of file +Assert.equal(MyClass.c, 12); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts index d510c3a50b..562151a0f7 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts @@ -22,7 +22,7 @@ import { Assert } from '../../../../../suite/assert.js' -class Point { +class MyClass { public x: number; public y: number; constructor(x: number, y: number) { @@ -31,17 +31,17 @@ class Point { } static z: number = 3; } -class ColoredPoint extends Point { +class MyClass2 extends MyClass { constructor(x: number, y: number, public color: string) { super(x, y); } static r: number = 10; } -let p = new Point(1, 2); +let p = new MyClass(1, 2); Assert.equal(p.x, 1); Assert.equal(p.y, 2); -Assert.equal(Point.z, 3); -let cp = new ColoredPoint(4, 5, "red"); +Assert.equal(MyClass.z, 3); +let cp = new MyClass2(4, 5, "red"); Assert.equal(cp.x, 4); Assert.equal(cp.y, 5); -Assert.equal(ColoredPoint.r, 10); \ No newline at end of file +Assert.equal(MyClass2.r, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_1.ts index 0d7d617c1b..f6eacfb220 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_1.ts @@ -32,12 +32,12 @@ class Compute { static getx() { return this.x; } - static origin = new Compute(0, 0); + static po = new Compute(0, 0); static x: number = 10; } let p1: Compute = new Compute(2, 2); let p2: Compute = new Compute(1, 1); Assert.equal(p1.range(p1, p2), Math.sqrt(2)); Assert.equal(Compute.getx(), 10); -Assert.equal(p1.range(p1, Compute.origin), Math.sqrt(8)); +Assert.equal(p1.range(p1, Compute.po), Math.sqrt(8)); Assert.equal(Compute.x, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_3.ts index 5c6d1e7108..e8432500f8 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_3.ts @@ -29,7 +29,7 @@ class Compute { this.x = x; this.y = y; } - static origin = new Compute(0, 0); + static p = new Compute(0, 0); } class ColoredPoint extends Compute { constructor(x: number, y: number, public color: string) { diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/constant_enum_declarations/constant_enum_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/constant_enum_declarations/constant_enum_declarations.ts index 0ead90f56e..4c56963def 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/constant_enum_declarations/constant_enum_declarations.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/constant_enum_declarations/constant_enum_declarations.ts @@ -23,7 +23,7 @@ import { Assert } from '../../../../suite/assert.js' -let v = 8 * 8; + const enum CED { None = -1, False, diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_4.ts index c4573dceab..f7e54b5fac 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_4.ts @@ -27,10 +27,8 @@ class ToAlert { information = "Have a good time!"; F() { let for_this = this; - setTimeout(function () { - for_this.information = "sad boy"; - }, 2250); - Assert.notEqual(for_this.information, "sad boy") + for_this.information = "sad boy"; + Assert.equal(for_this.information, "sad boy") } }; let a = new ToAlert(); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts index 8541ba99e3..278986a94b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts @@ -23,6 +23,6 @@ import { Assert } from '../../../../../suite/assert.js' -function getValue() { } -var s = getValue() + "" +function func() { } +let s = func() + "" Assert.isString(s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts index e15e385d2d..7030557db6 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts @@ -25,7 +25,7 @@ import { Assert } from '../../../../../suite/assert.js' type t = number | string function select(h_x: T, h_y: T): T { - return Math.random() < 0.5 ? h_x : h_y; + return h_x < h_y ? h_x : h_y; } var x = select(10, 20); Assert.isNumber(x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts index 7be3d43ad5..fb9d601be9 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts @@ -28,7 +28,7 @@ import { Assert } from '../../../../../suite/assert.js' type t = number | null | undefined function select(h_x: T, h_y: T): T { - return Math.random() < 0.5 ? h_x : h_y; + return h_x ? h_x : h_y; } var y = select(10, undefined) if (typeof y === 'number') { diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts index bc01b5cd3f..a133fc3c7c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts @@ -23,11 +23,10 @@ import { Assert } from '../../../../../suite/assert.js' -function f(x: T[], fun: (a: T) => U): U[] { - let cons: U[] = []; - for (let i = 0; i < x.length; i++) cons.push(fun(x[i])); - return cons; +function func(arg1: T, arg2:T) { + return [arg1, arg2]; } -let xx = ["xiao", "xi", "xin"]; -let yy = f(xx, str => str.length); -Assert.isObject(yy); \ No newline at end of file +let a = func(3, 5); +let b = func('a', 'b'); +Assert.equal(a, '3,5'); +Assert.equal(b, 'a,b'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts index 02658f4176..173b602bbb 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts @@ -25,13 +25,11 @@ import { Assert } from '../../../../../suite/assert.js' -function fun(a: S[], b: T[], group: (a: S) => (b: T) => U): U[] { - let length = Math.max(a.length, b.length); - let cons: U[] = []; - for (let i = 0; i < length; i++) cons.push(group(a[i])(b[i])); - return cons; +type T = (arg: number) => number; +let f = (arg: T): T => { return arg }; +let para: T = function func(arg: number) { + return arg; } -let xx = ["sum", "con", "say"]; -let yy = [1, 2, 3]; -let zz = fun(xx, yy, str => num => ({ name: str, age: num })); -Assert.isObject(zz); \ No newline at end of file +let result = f(para(20)); +Assert.equal(result, 20); +Assert.isFunction(f); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_1.ts index b689915f3d..17020e1b08 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_1.ts @@ -23,13 +23,13 @@ import { Assert } from '../../../../suite/assert.js' -class Form { } -class Square extends Form { } -function createForm(mold: string): Form { - if (mold === "square") { - return new Square() +class P{ } +class C extends P { } +function func(str: string): P { + if (str === "string") { + return new C(); } - return Square + return C; } -let square = createForm("square") -Assert.equal(JSON.stringify(square), '{}'); \ No newline at end of file +let c = func("string"); +Assert.equal(JSON.stringify(c), '{}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_1.ts index eb50e94c8d..08b585694d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_1.ts @@ -23,17 +23,18 @@ import { Assert } from '../../../../suite/assert.js' -function h_func(h_x: number | string) { - if (typeof h_x === 'string') { - Assert.isString(h_x); - return h_x.length; +function fun(x: boolean | number | string) { + if (typeof x === 'string') { + Assert.isString(x); } - else { - Assert.isNumber(h_x); - return h_x - 5; + if (typeof x === 'boolean') { + x = true; + Assert.isTrue(x); + } + if (typeof x === 'number') { + Assert.isNumber(x); } } -let a = h_func('string'); -Assert.equal(a, 6); -let b = h_func(10); -Assert.equal(b, 5); \ No newline at end of file +fun('string'); +fun(10); +fun(false); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_10.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_10.ts index 53c3fab073..c96d649482 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_10.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_10.ts @@ -14,9 +14,9 @@ */ /**--- description: > - A type guard of the form typeof x === s, where s is a string literal with any value but 'string', 'number', or 'boolean', - when true, if x is a union type, removes from the type of x all constituent types that are subtypes of the string, number, or boolean primitive type, - or when false, has no effect on the type of x. + A type guard of the form !expr, + when true, narrows the type of x by expr when false, + or when false, narrows the type of x by expr when true. module: ESNext isCurrent: true ---*/ @@ -24,31 +24,17 @@ import { Assert } from '../../../../suite/assert.js' -function f1(x: string | number | undefined) { - if (typeof x === "undefined") { - return undefined +function func(x: string | number) { + if (!(typeof x === "string")) { + Assert.isNumber(x); + return x + 1; } else { - return x + Assert.isString(x); + return x.length; } } -var a = f1(10) -Assert.isNumber(a) -var b = f1('s') -Assert.isString(b) -var c = f1(undefined) -Assert.isUndefined(c) -function f2(x: string | number | boolean) { - if (typeof x === "undefined") { - return undefined - } - else { - return x - } -} -var a1 = f2(10) -Assert.isNumber(a1) -var b1 = f2('s') -Assert.isString(b1) -var c1 = f2(true) -Assert.isBoolean(c1); \ No newline at end of file +let a = func(10); +Assert.equal(a, 11); +let b = func('s'); +Assert.equal(b, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_11.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_11.ts index c026b9e2f7..9fcd82bbf2 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_11.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_11.ts @@ -14,9 +14,10 @@ */ /**--- description: > - A type guard of the form typeof x !== s, where s is a string literal, - when true, narrows the type of x by typeof x === s when false, - or when false, narrows the type of x by typeof x === s when true. + A type guard of the form expr1 && expr2, + when true, narrows the type of x by expr1 when true and then by expr2 when true, or + when false, narrows the type of x to T1 | T2, where T1 is the type of x narrowed by expr1 when false, + and T2 is the type of x narrowed by expr1 when true and then by expr2 when false. module: ESNext isCurrent: true ---*/ @@ -24,17 +25,17 @@ import { Assert } from '../../../../suite/assert.js' -function func(x: string | number) { - if (typeof x !== "string") { - Assert.isNumber(x); - return x + 1; - } - else { - Assert.isString(x); - return x.length; - } +function func(x: string | number | undefined) { + if (typeof x === "string" && typeof x === "number") { + return undefined; + } + else { + return x; + } } let a = func(10); -Assert.equal(a, 11); +Assert.isNumber(a); let b = func('s'); -Assert.equal(b, 1); \ No newline at end of file +Assert.isString(b); +let c = func(undefined); +Assert.isUndefined(c); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_12.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_12.ts index c96d649482..23569fbadb 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_12.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_12.ts @@ -14,9 +14,10 @@ */ /**--- description: > - A type guard of the form !expr, - when true, narrows the type of x by expr when false, - or when false, narrows the type of x by expr when true. + A type guard of the form expr1 || expr2, + when true, narrows the type of x to T1 | T2, where T1 is the type of x narrowed by expr1 when true, + and T2 is the type of x narrowed by expr1 when false and then by expr2 when true, or + when false, narrows the type of x by expr1 when false and then by expr2 when false. module: ESNext isCurrent: true ---*/ @@ -24,17 +25,17 @@ import { Assert } from '../../../../suite/assert.js' -function func(x: string | number) { - if (!(typeof x === "string")) { - Assert.isNumber(x); - return x + 1; +function func(x: string | number | undefined) { + if (typeof x === "string" || typeof x === "number") { + return x; } else { - Assert.isString(x); - return x.length; + return undefined; } } let a = func(10); -Assert.equal(a, 11); +Assert.isNumber(a); let b = func('s'); -Assert.equal(b, 1); \ No newline at end of file +Assert.isString(b); +let c = func(undefined); +Assert.isUndefined(c); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_13.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_13.ts index 9fcd82bbf2..17c6536000 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_13.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_13.ts @@ -14,10 +14,7 @@ */ /**--- description: > - A type guard of the form expr1 && expr2, - when true, narrows the type of x by expr1 when true and then by expr2 when true, or - when false, narrows the type of x to T1 | T2, where T1 is the type of x narrowed by expr1 when false, - and T2 is the type of x narrowed by expr1 when true and then by expr2 when false. + A type guard of any other form has no effect on the type of x. module: ESNext isCurrent: true ---*/ @@ -25,17 +22,31 @@ import { Assert } from '../../../../suite/assert.js' -function func(x: string | number | undefined) { - if (typeof x === "string" && typeof x === "number") { - return undefined; +class Person { + name: string + age: number + public constructor(name: string, age: number) { + this.name = name + this.age = age } - else { - return x; +} +class Animal { + height: number + weight: number + public constructor(height: number, weight: number) { + this.height = height + this.weight = weight + } +} +function func(arg: Person | Animal) { + if ('age' in arg) { + Assert.isString(arg.name) + } + if ('height' in arg) { + Assert.isNumber(arg.height) } } -let a = func(10); -Assert.isNumber(a); -let b = func('s'); -Assert.isString(b); -let c = func(undefined); -Assert.isUndefined(c); \ No newline at end of file +let p = new Person('x', 18); +func(p); +let a = new Animal(200, 180); +func(a); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_2.ts index a8cc2ce8c1..8b8027f7cd 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_2.ts @@ -14,8 +14,8 @@ */ /**--- description: > - In the true branch statement of an 'if' statement, - the type of a variable or parameter is narrowed by a type guard in the 'if' condition when true, + In the false branch statement of an 'if' statement, + the type of a variable or parameter is narrowed by a type guard in the 'if' condition when false, provided no part of the 'if' statement contains assignments to the variable or parameter. module: ESNext isCurrent: true @@ -25,13 +25,13 @@ import { Assert } from '../../../../suite/assert.js' function h_func(h_x: number | string) { - if (typeof h_x === 'string') { - Assert.isString(h_x); - return h_x.length; - } - else { - return h_x + 1 - } + if (!(typeof h_x === 'string')) { + Assert.isNumber(h_x); + return h_x; + } + else { + return h_x.length + } } -let a = h_func('string'); -Assert.equal(a, 6); \ No newline at end of file +let a = h_func(10); +Assert.equal(a, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_3.ts index 8b8027f7cd..d092aec559 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_3.ts @@ -14,9 +14,9 @@ */ /**--- description: > - In the false branch statement of an 'if' statement, - the type of a variable or parameter is narrowed by a type guard in the 'if' condition when false, - provided no part of the 'if' statement contains assignments to the variable or parameter. + In the true expression of a conditional expression, + the type of a variable or parameter is narrowed by a type guard in the condition when true, + provided no part of the conditional expression contains assignments to the variable or parameter. module: ESNext isCurrent: true ---*/ @@ -24,14 +24,9 @@ import { Assert } from '../../../../suite/assert.js' -function h_func(h_x: number | string) { - if (!(typeof h_x === 'string')) { - Assert.isNumber(h_x); - return h_x; - } - else { - return h_x.length - } +function func(arg: string | (() => string)) { + let x = typeof arg == "string" ? arg : arg(); + return x; } -let a = h_func(10); -Assert.equal(a, 10); \ No newline at end of file +let result = func("abc"); +Assert.isString(result); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_4.ts index e541f40f7c..1497787e83 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_4.ts @@ -14,8 +14,8 @@ */ /**--- description: > - In the true expression of a conditional expression, - the type of a variable or parameter is narrowed by a type guard in the condition when true, + In the false expression of a conditional expression, + the type of a variable or parameter is narrowed by a type guard in the condition when false, provided no part of the conditional expression contains assignments to the variable or parameter. module: ESNext isCurrent: true @@ -24,9 +24,9 @@ import { Assert } from '../../../../suite/assert.js' -function func(arg: number | (() => number)) { - let x = typeof arg == "number" ? arg : arg(); +function func(arg: string | (() => string)) { + var x = typeof arg !== "string" ? arg() : arg; return x; } -let result = func(5); -Assert.isNumber(result); \ No newline at end of file +let result = func("abc"); +Assert.isString(result); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_5.ts index 0cf674657b..8eaf5a06cf 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_5.ts @@ -14,9 +14,9 @@ */ /**--- description: > - In the false expression of a conditional expression, - the type of a variable or parameter is narrowed by a type guard in the condition when false, - provided no part of the conditional expression contains assignments to the variable or parameter. + In the right operand of a && operation, + the type of a variable or parameter is narrowed by a type guard in the left operand when true, + provided neither operand contains assignments to the variable or parameter. module: ESNext isCurrent: true ---*/ @@ -24,9 +24,8 @@ import { Assert } from '../../../../suite/assert.js' -function func(arg: number | (() => number)) { - var x = typeof arg !== "number" ? arg() : arg; - return x; +function fun(obj: any) { + typeof obj === "number" && obj + Assert.isNumber(obj) } -let result = func(5); -Assert.isNumber(result); \ No newline at end of file +fun(12); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_6.ts index e0f879aa33..0040c18beb 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_6.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_6.ts @@ -14,9 +14,11 @@ */ /**--- description: > - In the right operand of a && operation, - the type of a variable or parameter is narrowed by a type guard in the left operand when true, - provided neither operand contains assignments to the variable or parameter. + A type guard of the form 'x instanceof C', where x is not of type Any, + C is of a subtype of the global type 'Function', and C has a property named 'prototype', + when true, narrows the type of x to the type of the 'prototype' property in C provided it is a subtype of the type of x, + or, if the type of x is a union type, removes from the type of x all constituent types that aren't subtypes of the type of the 'prototype' property in C, + or when false, has no effect on the type of x. module: ESNext isCurrent: true ---*/ @@ -24,8 +26,31 @@ import { Assert } from '../../../../suite/assert.js' -function isString(obj: any) { - typeof obj === "string" && obj.length < 10 - Assert.isString(obj) +class Person { + height: number + age: number + public constructor(height: number, age: number) { + this.height = height + this.age = age + } } -isString('s'); \ No newline at end of file +class Animal { + height: number + weight: number + public constructor(height: number, weight: number) { + this.height = height + this.weight = weight + } +} +function func(arg: Person | Animal) { + if (arg instanceof Person) { + return arg.age = 18 + } + if (arg instanceof Animal) { + return arg.weight = 300 + } +} +var p = new Person(150, 18) +Assert.equal(func(p), 18) +var a = new Animal(200, 180) +Assert.equal(func(a), 300); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_7.ts index 6294a16ce0..7d3ef1a40d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_7.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_7.ts @@ -14,9 +14,10 @@ */ /**--- description: > - In the right operand of a || operation, - the type of a variable or parameter is narrowed by a type guard in the left operand when false, - provided neither operand contains assignments to the variable or parameter. + A type guard of the form typeof x === s, where s is a string literal with the value 'string', 'number', or 'boolean', + when true, narrows the type of x to the given primitive type provided it is a subtype of the type of x, + or, if the type of x is a union type, removes from the type of x all constituent types that aren't subtypes of the given primitive type, + or when false, removes the primitive type from the type of x. module: ESNext isCurrent: true ---*/ @@ -24,8 +25,17 @@ import { Assert } from '../../../../suite/assert.js' -function isString(obj: any) { - typeof obj === "string" || obj.length > 10 - Assert.isString(obj) +function func(x: string | number) { + if (typeof x === "string") { + Assert.isString(x); + return x.length; + } + else { + Assert.isNumber(x); + return x + 1; + } } -isString('s'); \ No newline at end of file +let a = func(10); +Assert.equal(a, 11); +let b = func('s'); +Assert.equal(b, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_8.ts index 0040c18beb..53c3fab073 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_8.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_8.ts @@ -14,10 +14,8 @@ */ /**--- description: > - A type guard of the form 'x instanceof C', where x is not of type Any, - C is of a subtype of the global type 'Function', and C has a property named 'prototype', - when true, narrows the type of x to the type of the 'prototype' property in C provided it is a subtype of the type of x, - or, if the type of x is a union type, removes from the type of x all constituent types that aren't subtypes of the type of the 'prototype' property in C, + A type guard of the form typeof x === s, where s is a string literal with any value but 'string', 'number', or 'boolean', + when true, if x is a union type, removes from the type of x all constituent types that are subtypes of the string, number, or boolean primitive type, or when false, has no effect on the type of x. module: ESNext isCurrent: true @@ -26,31 +24,31 @@ import { Assert } from '../../../../suite/assert.js' -class Person { - height: number - age: number - public constructor(height: number, age: number) { - this.height = height - this.age = age - } +function f1(x: string | number | undefined) { + if (typeof x === "undefined") { + return undefined + } + else { + return x + } } -class Animal { - height: number - weight: number - public constructor(height: number, weight: number) { - this.height = height - this.weight = weight - } +var a = f1(10) +Assert.isNumber(a) +var b = f1('s') +Assert.isString(b) +var c = f1(undefined) +Assert.isUndefined(c) +function f2(x: string | number | boolean) { + if (typeof x === "undefined") { + return undefined + } + else { + return x + } } -function func(arg: Person | Animal) { - if (arg instanceof Person) { - return arg.age = 18 - } - if (arg instanceof Animal) { - return arg.weight = 300 - } -} -var p = new Person(150, 18) -Assert.equal(func(p), 18) -var a = new Animal(200, 180) -Assert.equal(func(a), 300); \ No newline at end of file +var a1 = f2(10) +Assert.isNumber(a1) +var b1 = f2('s') +Assert.isString(b1) +var c1 = f2(true) +Assert.isBoolean(c1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_9.ts index 7d3ef1a40d..c026b9e2f7 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_9.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_9.ts @@ -14,10 +14,9 @@ */ /**--- description: > - A type guard of the form typeof x === s, where s is a string literal with the value 'string', 'number', or 'boolean', - when true, narrows the type of x to the given primitive type provided it is a subtype of the type of x, - or, if the type of x is a union type, removes from the type of x all constituent types that aren't subtypes of the given primitive type, - or when false, removes the primitive type from the type of x. + A type guard of the form typeof x !== s, where s is a string literal, + when true, narrows the type of x by typeof x === s when false, + or when false, narrows the type of x by typeof x === s when true. module: ESNext isCurrent: true ---*/ @@ -26,14 +25,14 @@ import { Assert } from '../../../../suite/assert.js' function func(x: string | number) { - if (typeof x === "string") { - Assert.isString(x); - return x.length; - } - else { + if (typeof x !== "string") { Assert.isNumber(x); return x + 1; } + else { + Assert.isString(x); + return x.length; + } } let a = func(10); Assert.equal(a, 11); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_1.ts new file mode 100644 index 0000000000..594bfae855 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_1.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Two types are considered identical when they are both the Any type. + module: ESNext + isCurrent: true + ---*/ + + + import { Assert } from '../../../../../suite/assert.js' + +type T = any; +type U = any; + +let a1: T = 10; +let b1: U = 10; +Assert.equal(typeof a1, typeof b1); +let a2: T = 10; +let b2: U = 10; +Assert.equal(typeof a2, typeof b2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_2.ts new file mode 100644 index 0000000000..a46fc6fc97 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_2.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Two types are considered identical when they are the same primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +type T = number; +type U = number; + +let a: T = 5; +let b: U = 10; +Assert.equal(typeof a, typeof b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_3.ts new file mode 100644 index 0000000000..9cb462699e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_3.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Two types are considered identical when they are the same type parameter. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +type T = string; +type U = string; +function func(arg: T) { + return arg; +} + +let a = func('a'); +let b = func('b'); +Assert.equal(typeof a, typeof b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_4.ts new file mode 100644 index 0000000000..ae758273e6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_4.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Two types are considered identical when they are union types with identical sets of constituent types. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +type T = number | string | boolean; +type U = number | string | boolean; + +let a1: T = 10; +let a2: U = 5; +Assert.equal(typeof a1, typeof a2); +let b1: T = '10'; +let b2: U = '5'; +Assert.equal(typeof b1, typeof b2); +let c1: T = true; +let c2: U = false; +Assert.equal(typeof c1, typeof c2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_15.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_5.ts similarity index 51% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_15.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_5.ts index 17c6536000..aa1e6dce8b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_15.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_5.ts @@ -14,39 +14,32 @@ */ /**--- description: > - A type guard of any other form has no effect on the type of x. + Two members are considered identical when they are public properties with identical names, optionality, and types. module: ESNext isCurrent: true ---*/ -import { Assert } from '../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -class Person { - name: string - age: number - public constructor(name: string, age: number) { - this.name = name - this.age = age - } +interface M{ + str: string; + mem?: number; } -class Animal { - height: number - weight: number - public constructor(height: number, weight: number) { - this.height = height - this.weight = weight - } +interface M{ + str: string; + mem?: number; + boo: boolean; } -function func(arg: Person | Animal) { - if ('age' in arg) { - Assert.isString(arg.name) - } - if ('height' in arg) { - Assert.isNumber(arg.height) - } +let a: M = { + str: 'a', + mem: 5, + boo: true } -let p = new Person('x', 18); -func(p); -let a = new Animal(200, 180); -func(a); \ No newline at end of file +let b: M = { + str: 'a', + mem: 5, + boo: false +} +Assert.equal(typeof a.str, typeof b.str); +Assert.equal(typeof a.mem, typeof b.mem); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_6.ts new file mode 100644 index 0000000000..e545055f5e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_6.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Two call or construct signatures are considered identical + when they have the same number of type parameters with identical type parameter constraints and, + after substituting type Any for the type parameters introduced by the signatures, + identical number of parameters with identical kind and types, and identical return types. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface M{ + (arg: T): T; +} +interface M{ + (arg: T): T; +} +function func(arg: T): T{ + return arg; +} +let a: M = func('a'); +Assert.isString(a); \ No newline at end of file -- Gitee From b099e0a7321819ba0c899ff4df5ea860492c6819 Mon Sep 17 00:00:00 2001 From: tanglizhen Date: Mon, 17 Jul 2023 17:21:31 +0800 Subject: [PATCH 13/18] Ts test cases Signed-off-by: tanglizhen --- .../abstract_properties_and_accessors.ts | 45 ----- ...icate_identifiers_across_declarations_1.ts | 45 ----- .../control_flow_based_type_analysis1.ts | 44 ----- .../control_flow_based_type_analysis2.ts | 33 ---- .../control_flow_based_type_analysis3.ts | 35 ---- .../dotted_names_in_type_guards_1.ts | 64 ------- .../expression_operators_1.ts | 32 ---- .../expression_operators_2.ts | 52 ------ .../implicit_index_signatures.ts | 38 ---- ...le_identifiers_allow_for_js_extension_1.ts | 26 --- .../test_js_extension.ts | 22 --- .../2.0/never_type/never_type.ts | 39 ----- .../non_null_and_non_undefined.ts | 42 ----- .../non_null_assertion_operator.ts | 30 ---- .../null_and_undefined_aware_types.ts | 40 ----- .../optional_class_properties.ts | 52 ------ .../optional_parameters_and_properties.ts | 63 ------- .../private_and_protected_constructor.ts | 51 ------ ...ad-only_properties_and_index_signatures.ts | 52 ------ ...shorthand_ambient_module_declarations_1.ts | 27 --- .../test_ts.ts | 21 --- ...ifying_the_type_of_this_for_functions_1.ts | 28 --- ...ifying_the_type_of_this_for_functions_2.ts | 45 ----- .../tagged_union_types_1.ts | 67 -------- .../test_ts_cases/2.0/test_base_url.ts | 21 --- .../view2.ts | 22 --- ...ailing_commas_in_parameter_and_argument.ts | 29 ---- .../better_inference_for_literal_types_1.ts | 47 ----- .../better_inference_for_literal_types_2.ts | 47 ----- .../better_inference_for_literal_types_3.ts | 48 ------ .../downlevel_async_functions_1.ts | 42 ----- .../improved_any_inference_1.ts | 34 ---- .../improved_any_inference_2.ts | 39 ----- .../keyof_and_lookup_types_1.ts | 64 ------- .../keyof_and_lookup_types_2.ts | 43 ----- .../2.1/mapped_types/mapped_types_1.ts | 64 ------- .../2.1/mapped_types/mapped_types_2.ts | 49 ------ .../2.1/mapped_types/mapped_types_3.ts | 44 ----- .../2.1/mapped_types/mapped_types_4.ts | 58 ------- .../object_spread_and_rest_1.ts | 51 ------ .../object_spread_and_rest_2.ts | 38 ---- .../object_spread_and_rest_3.ts | 37 ---- .../test_ts_cases/2.1/record/record_pick.ts | 49 ------ ...turned_values_from_super_call_as_this_1.ts | 42 ----- ..._for_types_with_string_index_signatures.ts | 51 ------ .../2.2/object_type/object_type_1.ts | 31 ---- .../2.2/object_type/object_type_2.ts | 32 ---- .../2.2/object_type/object_type_3.ts | 40 ----- .../support_for_mix_in_classes_1.ts | 75 -------- .../support_for_mix_in_classes_2.ts | 51 ------ .../support_for_new.target_1.ts | 53 ------ .../support_for_new.target_2.ts | 42 ----- .../async_generators/async_generators.ts | 71 -------- .../async_iterators/async_iterators_1.ts | 63 ------- .../async_iterators/async_iterators_2.ts | 35 ---- .../generators/generators_1.ts | 44 ----- .../generators/generators_2.ts | 44 ----- .../iterators/iterators_1.ts | 47 ----- .../iterators/iterators_2.ts | 40 ----- .../generic_parameter_defaults_1.ts | 38 ---- .../generic_parameter_defaults_2.ts | 57 ------ .../generic_parameter_defaults_3.ts | 34 ---- .../1_dynamic_import_expressions.ts | 31 ---- .../2.4/1_dynamic_import_expressions/lib.ts | 19 -- .../2.4/2_string_enums/string_enums_1.ts | 32 ---- .../3_improved_inference_for_generics.ts | 42 ----- ..._contravariance_for_callback_parameters.ts | 39 ----- .../5_weak_type_detection.ts | 53 ------ .../2.5/1_optional_catch_clause_variables.ts | 39 ----- ...rs_in_ts_files_using_ts_ignore_comments.ts | 35 ---- .../10_numeric_separators.ts | 30 ---- .../1_constant_named_properties.ts | 48 ------ .../2.7/2_unique_symbol/2_unique_symbol.ts | 36 ---- .../3_strict_class_initialization.ts | 43 ----- .../4_definite_assignment_assertions.ts | 49 ------ .../5_fixed_length_tuples.ts | 42 ----- ...oved_type_inference_for_object_literals.ts | 54 ------ .../7_improved_handling.ts | 101 ----------- ...8_Type_guards_inferred_from_in_operator.ts | 57 ------ .../2.8/Defaulted_declarations.ts | 27 --- .../2.8/IIFEs_as_namespace_declarations.ts | 33 ---- ...mproved_keyof_with_intersection_types_1.ts | 64 ------- ...mproved_keyof_with_intersection_types_2.ts | 78 --------- .../test_ts_cases/2.8/conditional_types.ts | 43 ----- .../2.8/distributive_conditional_types.ts | 67 -------- .../test_ts_cases/2.8/filter_union_types.ts | 39 ----- ...ed_control_over_mapped_type_modifiers_1.ts | 33 ---- ...ed_control_over_mapped_type_modifiers_2.ts | 32 ---- .../2.8/predefined_conditional_types.ts | 75 -------- .../test_ts_cases/2.8/prototype_assignment.ts | 33 ---- .../test_ts_cases/2.8/type_inference.ts | 61 ------- .../generic_type_arguments_in_tt.ts | 39 ----- .../2.9/import_types/import_types.ts | 41 ----- .../test_ts_cases/2.9/module.ts | 23 --- .../1_support_number_and_symbol_nam_1.ts | 47 ----- .../1_support_number_and_symbol_nam_2.ts | 43 ----- .../new_unknown_top_type.ts | 117 ------------- .../optional_elements_in_tuple_types.ts | 37 ---- .../3.0/reference_lib/reference_lib.ts | 26 --- .../rest_parameters_with_tuple_types.ts | 33 ---- .../generic_rest_parameters.ts | 44 ----- .../optional_elements_in_tuple_types.ts | 39 ----- .../rest_elements_in_tuple_types.ts | 43 ----- .../rest_parameters_with_tuple_types.ts | 35 ---- .../spread_expressions_with_tuple_types.ts | 39 ----- .../mapped_types_on_tuples_and_arrays_1.ts | 46 ----- .../properties_declarations_on_functions_1.ts | 61 ------- .../test_ts_cases/3.2/bigint/bigint_1.ts | 49 ------ .../test_ts_cases/3.2/bigint/bigint_2.ts | 32 ---- .../test_ts_cases/3.2/bigint/bigint_3.ts | 39 ----- ...ic_object_rest_variables_and_parameters.ts | 44 ----- ...spread_expressions_in_object_literals_1.ts | 33 ---- ...spread_expressions_in_object_literals_2.ts | 34 ---- ...spread_expressions_in_object_literals_3.ts | 44 ----- .../non-unit_types_as_union_discriminants.ts | 73 -------- ...proved_behavior_for_calling_union_types.ts | 62 ------- .../test_ts_cases/3.4/Caveats.ts | 44 ----- .../3.4/Type_checking_for_globalThis.ts | 36 ---- .../3.4/a_new_syntax_for_readonly_array.ts | 29 ---- .../test_ts_cases/3.4/const_assertions.ts | 57 ------ .../3.4/higher_order_type_inference.ts | 46 ----- .../test_ts_cases/3.4/readonly_tuples.ts | 34 ---- .../3.5/higher_order_type_inference.ts | 53 ------ ...d_excess_property_checks_in_union_types.ts | 41 ----- .../test_ts_cases/3.5/omit_helper_type.ts | 43 ----- .../3.5/smarter_union_type_checking.ts | 64 ------- ...etter_unicode_support_for_identifiers_1.ts | 27 --- ...ssors_are_allowed_in_ambient_contexts_1.ts | 42 ----- .../test.ts | 21 --- .../improved_UX_Around_Promises.ts | 62 ------- .../more_accurate_array_spread_1.ts | 33 ---- .../stricter_generators_1.ts | 39 ----- .../stricter_generators_2.ts | 65 ------- .../stricter_generators_3.ts | 41 ----- .../stricter_generators_4.ts | 34 ---- .../stricter_generators_5.ts | 44 ----- .../assertion_functions_1.ts | 32 ---- .../better_support_for_never.ts | 28 --- .../nullish_coalescing_1.ts | 33 ---- .../nullish_coalescing_2.ts | 31 ---- .../optional_chaining/optional_chaining_1.ts | 33 ---- .../optional_chaining/optional_chaining_2.ts | 36 ---- .../optional_chaining/optional_chaining_3.ts | 33 ---- .../optional_chaining/optional_chaining_4.ts | 52 ------ .../optional_chaining/optional_chaining_5.ts | 34 ---- .../recursive_type_aliases_1.ts | 43 ----- .../ts_nocheck_in_typescript_files.ts | 37 ---- .../3.8/1_type_only_imports_and_export.ts | 28 --- .../2_ecmsscript_private_fields_1.ts | 36 ---- .../2_ecmsscript_private_fields_2.ts | 41 ----- .../2_ecmsscript_private_fields_3.ts | 38 ---- .../test_ts_cases/3.8/3_which_should_i_use.ts | 41 ----- .../3.8/4_export_star_as_ns_syntax.ts | 27 --- .../test_ts_cases/3.8/export_star.ts | 17 -- .../test_ts_cases/3.8/my_module.ts | 18 -- .../test_ts_cases/3.8/some_module.ts | 19 -- ...sing_differences_in_optional_assertions.ts | 29 ---- ...provements_in_inference_and_Promise.all.ts | 48 ------ .../ts-expect-error_comments.ts | 37 ---- ..._property_Inference_from_constructors_1.ts | 33 ---- .../labeled_tuple_elements_1.ts | 46 ----- .../labeled_tuple_elements_2.ts | 34 ---- .../labeled_tuple_elements_3.ts | 31 ---- ...short_circuiting_assignment_operators_1.ts | 76 -------- ...short_circuiting_assignment_operators_2.ts | 31 ---- ...short_circuiting_assignment_operators_3.ts | 36 ---- .../unknow_on_catch_clause_bindings_1.ts | 33 ---- .../unknow_on_catch_clause_bindings_2.ts | 56 ------ .../variadic_tuple_types_1.ts | 34 ---- .../variadic_tuple_types_2.ts | 34 ---- .../variadic_tuple_types_3.ts | 48 ------ .../Checked_Indexed_Accesses.ts | 43 ----- .../for_each_index.ts | 35 ---- .../Checked_Indexed_Accesses/for_of_index.ts | 35 ---- .../for_traversal_index.ts | 35 ---- ...bstract_members_can_not_be_marked_async.ts | 43 ----- ...known_are_propagated_in_falsy_positions.ts | 33 ---- ...al_spreads_create_optional_properties_1.ts | 52 ------ .../key_remapping_in_mapped_types_1.ts | 47 ----- .../key_remapping_in_mapped_types_2.ts | 34 ---- .../recursive_conditional_types.ts | 41 ----- ...ters_are_no_longer_optional_in_promises.ts | 39 ----- .../template_literal_types_1.ts | 35 ---- .../template_literal_types_2.ts | 52 ------ .../template_literal_types_3.ts | 46 ----- .../Reverting_Template_Literal_Inference.ts | 37 ---- .../abstract_construct_signatures.ts | 53 ------ .../abstract_construct_signatures_1.ts | 43 ----- .../abstract_construct_signatures_2.ts | 33 ---- .../abstract_construct_signatures_3.ts | 64 ------- ...ng_middle_rest_elements_in_tuple_types1.ts | 35 ---- ...ng_middle_rest_elements_in_tuple_types2.ts | 41 ----- ...ng_middle_rest_elements_in_tuple_types3.ts | 51 ------ ...ng_middle_rest_elements_in_tuple_types4.ts | 40 ----- .../relaxed_rules.ts | 41 ----- .../smarter_type_alias_preservation1.ts | 43 ----- .../smarter_type_alias_preservation2.ts | 31 ---- .../always-truthy_promise_checks.ts | 39 ----- ...uctorParameters_works_on_abstract_class.ts | 36 ---- .../contextual_narrowing_for_generics.ts | 42 ----- .../ecmascript_private_calss_elements.ts | 54 ------ ...verride_and_the_noImplicitOverride_Flag.ts | 50 ------ .../separate_write_types_on_properties_1.ts | 65 ------- .../separate_write_types_on_properties_2.ts | 64 ------- .../static_index_signatures.ts | 59 ------- .../template_string_type_improvements_1.ts | 43 ----- .../template_string_type_improvements_2.ts | 37 ---- .../template_string_type_improvements_3.ts | 41 ----- .../template_string_type_improvements_4.ts | 51 ------ ...cannot_be_compared_to_arbitrary_numbers.ts | 63 ------- ..._aliased_conditions_and_discriminants_1.ts | 85 --------- ..._aliased_conditions_and_discriminants_2.ts | 48 ------ ..._aliased_conditions_and_discriminants_3.ts | 38 ---- ..._aliased_conditions_and_discriminants_4.ts | 69 -------- ...o_the_unknown_type_in_catch_variables_1.ts | 40 ----- ...o_the_unknown_type_in_catch_variables_2.ts | 40 ----- ...o_the_unknown_type_in_catch_variables_3.ts | 38 ---- .../exact_optional_property_types_1.ts | 40 ----- .../static_blocks_in_classes1.ts | 41 ----- .../static_blocks_in_classes2.ts | 44 ----- ...lates_string_pattern_index_signatures_1.ts | 35 ---- ...lates_string_pattern_index_signatures_2.ts | 30 ---- ...lates_string_pattern_index_signatures_3.ts | 36 ---- ...lates_string_pattern_index_signatures_4.ts | 36 ---- ...lates_string_pattern_index_signatures_5.ts | 44 ----- .../disabling_import_elision_1.ts | 27 --- .../4.5/disabling_import_elision/human.ts | 28 --- .../private_field_presence_checks_1.ts | 41 ----- ...rsion_elimination_on_conditional_types1.ts | 29 ---- ...rsion_elimination_on_conditional_types2.ts | 50 ------ ...emplate_string_types_as_discriminants_1.ts | 60 ------- ...awaited_type_and_promise_improvements_1.ts | 47 ----- .../some-module.ts | 22 --- .../type_modifiers_on_import_names_1.ts | 37 ---- .../4.6/1_allowing_code_in_constructors.ts | 40 ----- .../4.6/2_control_flow_analysis.ts | 68 -------- .../4.6/3_improved_recursion_depth_checks.ts | 31 ---- ...4_indexed_access_inference_improvements.ts | 67 -------- ..._flow_analysis_for_dependent_parameters.ts | 39 ----- ...w_analysis_for_bracketed_element_access.ts | 53 ------ ...analysis_for_bracketed_element_access_1.ts | 43 ----- ...nds_constraints_on_infer_type_variables.ts | 48 ------ ...nction_inference_in_objects_and_methods.ts | 95 ---------- .../instantiation_expressions.ts | 73 -------- ...ariance_annotations_for_type_parameters.ts | 52 ------ ..._tuples_have_a_readonly_length_property.ts | 32 ---- ...tion_Union_Compatibility,_and_Narrowing.ts | 67 -------- ...or_infer_types_in_template_string_types.ts | 38 ---- .../auto_accessors_in_classes.ts | 51 ------ .../checks_for_equality_on_NaN.ts | 31 ---- .../the_satisfies_operator.ts | 43 ----- ...property_narrowing_with_the_in_operator.ts | 58 ------- .../Ambient_Class_Declarations.ts | 41 ----- .../ambient_function_declarations.ts | 45 ----- .../ambient_namespace_declarations.ts | 36 ---- .../ambient_variable_declarations.ts | 35 ---- .../ambient_module_declarations_1.ts | 33 ---- .../ambient_module_declarations_3.ts | 43 ----- .../declarations/declarations_1.ts | 36 ---- .../declarations/declarations_2.ts | 56 ------ .../computed_property_names_1.ts | 44 ----- .../names/property_names/property_names_1.ts | 50 ------ .../any_cannot_be_type_name_1.ts | 28 --- .../any_cannot_be_type_name_2.ts | 25 --- .../boolean_cannot_be_type_name_1.ts | 28 --- .../boolean_cannot_be_type_name_2.ts | 25 --- .../number_cannot_be_type_name_1.ts | 28 --- .../number_cannot_be_type_name_2.ts | 25 --- .../string_cannot_be_type_name_1.ts | 27 --- .../string_cannot_be_type_name_2.ts | 25 --- .../symbol_cannot_be_type_name_1.ts | 27 --- .../symbol_cannot_be_type_name_2.ts | 25 --- .../abstract_is_valid_identifier_1.ts | 25 --- .../abstract_is_valid_identifier_2.ts | 27 --- .../abstract_is_valid_identifier_3.ts | 34 ---- .../abstract_is_valid_identifier_4.ts | 34 ---- .../as_is_valid_identifier_1.ts | 25 --- .../as_is_valid_identifier_2.ts | 27 --- .../as_is_valid_identifier_3.ts | 34 ---- .../as_is_valid_identifier_4.ts | 34 ---- .../async_is_valid_identifier_1.ts | 25 --- .../async_is_valid_identifier_2.ts | 27 --- .../async_is_valid_identifier_3.ts | 34 ---- .../async_is_valid_identifier_4.ts | 34 ---- .../constructor_is_valid_identifier_1.ts | 25 --- .../constructor_is_valid_identifier_2.ts | 27 --- .../constructor_is_valid_identifier_3.ts | 34 ---- .../constructor_is_valid_identifier_4.ts | 34 ---- .../declare_is_valid_identifier_1.ts | 25 --- .../declare_is_valid_identifier_2.ts | 27 --- .../declare_is_valid_identifier_3.ts | 34 ---- .../declare_is_valid_identifier_4.ts | 34 ---- .../from_is_valid_identifier_1.ts | 25 --- .../from_is_valid_identifier_2.ts | 27 --- .../from_is_valid_identifier_3.ts | 34 ---- .../from_is_valid_identifier_4.ts | 34 ---- .../get_is_valid_identifier_1.ts | 25 --- .../get_is_valid_identifier_2.ts | 27 --- .../get_is_valid_identifier_3.ts | 34 ---- .../get_is_valid_identifier_4.ts | 34 ---- .../is_is_valid_identifier_1.ts | 25 --- .../is_is_valid_identifier_2.ts | 27 --- .../is_is_valid_identifier_3.ts | 34 ---- .../is_is_valid_identifier_4.ts | 34 ---- .../module_is_valid_identifier_1.ts | 25 --- .../module_is_valid_identifier_2.ts | 27 --- .../module_is_valid_identifier_3.ts | 39 ----- .../module_is_valid_identifier_4.ts | 34 ---- .../namespace_is_valid_identifier_1.ts | 25 --- .../namespace_is_valid_identifier_2.ts | 27 --- .../namespace_is_valid_identifier_3.ts | 34 ---- .../namespace_is_valid_identifier_4.ts | 34 ---- .../of_is_valid_identifier_1.ts | 25 --- .../of_is_valid_identifier_2.ts | 27 --- .../of_is_valid_identifier_3.ts | 34 ---- .../of_is_valid_identifier_4.ts | 34 ---- .../require_is_valid_identifier_1.ts | 34 ---- .../set_is_valid_identifier_1.ts | 25 --- .../set_is_valid_identifier_2.ts | 27 --- .../set_is_valid_identifier_3.ts | 34 ---- .../set_is_valid_identifier_4.ts | 34 ---- .../type_is_valid_identifier_1.ts | 25 --- .../type_is_valid_identifier_2.ts | 27 --- .../type_is_valid_identifier_3.ts | 34 ---- .../type_is_valid_identifier_4.ts | 34 ---- .../spec/basic_concepts/scopes/let_scope.ts | 36 ---- .../spec/basic_concepts/scopes/scopes_1.ts | 40 ----- .../spec/basic_concepts/scopes/scopes_10.ts | 43 ----- .../spec/basic_concepts/scopes/scopes_11.ts | 50 ------ .../spec/basic_concepts/scopes/scopes_12.ts | 40 ----- .../spec/basic_concepts/scopes/scopes_13_1.ts | 32 ---- .../spec/basic_concepts/scopes/scopes_13_2.ts | 30 ---- .../spec/basic_concepts/scopes/scopes_13_3.ts | 43 ----- .../spec/basic_concepts/scopes/scopes_14.ts | 37 ---- .../spec/basic_concepts/scopes/scopes_2.ts | 27 --- .../spec/basic_concepts/scopes/scopes_2_m.ts | 32 ---- .../spec/basic_concepts/scopes/scopes_3.ts | 37 ---- .../spec/basic_concepts/scopes/scopes_4.ts | 33 ---- .../spec/basic_concepts/scopes/scopes_5.ts | 44 ----- .../spec/basic_concepts/scopes/scopes_6.ts | 27 --- .../spec/basic_concepts/scopes/scopes_7.ts | 36 ---- .../spec/basic_concepts/scopes/scopes_8.ts | 40 ----- .../spec/basic_concepts/scopes/scopes_9.ts | 33 ---- .../spec/basic_concepts/scopes/var_scope.ts | 34 ---- .../class_body/class_body.ts | 78 --------- .../class_declarations_1.ts | 33 ---- .../class_declarations_2.ts | 43 ----- .../class_declarations_3.ts | 61 ------- .../class_heritage_specification_1.ts | 52 ------ .../class_heritage_specification_2.ts | 62 ------- .../class_heritage_specification_3.ts | 76 -------- .../class_heritage_specification_4.ts | 36 ---- .../class_heritage_specification_5.ts | 51 ------ .../class_heritage_specification_6.ts | 42 ----- .../automatic_constructors_1.ts | 44 ----- .../automatic_constructors_2.ts | 59 ------- .../automatic_constructors_3.ts | 45 ----- .../constructor_parameters_1.ts | 56 ------ .../constructor_parameters_2.ts | 48 ------ .../constructor_parameters_3.ts | 44 ----- .../constructor_parameters_4.ts | 32 ---- .../constructor_parameters_5.ts | 36 ---- .../constructor_parameters_6.ts | 36 ---- .../super_calls/super_calls.ts | 41 ----- .../index_member_declarations.ts | 38 ---- .../members/accessibility/accessibility_1.ts | 79 --------- .../members/accessibility/accessibility_2.ts | 49 ------ .../members/accessibility/accessibility_3.ts | 63 ------- .../members/class_types/class_types_1.ts | 67 -------- .../members/class_types/class_types_2.ts | 70 -------- .../members/class_types/class_types_3.ts | 60 ------- .../constructor_function_types_1.ts | 35 ---- .../constructor_function_types_2.ts | 45 ----- .../constructor_function_types_3.ts | 38 ---- .../constructor_function_types_4.ts | 53 ------ .../constructor_function_types_5.ts | 45 ----- .../constructor_function_types_6.ts | 50 ------ .../constructor_function_types_7.ts | 36 ---- .../inheritance_and_overriding_1.ts | 45 ----- .../inheritance_and_overriding_2.ts | 51 ------ .../inheritance_and_overriding_3.ts | 42 ----- .../inheritance_and_overriding_4.ts | 51 ------ .../inheritance_and_overriding_5.ts | 59 ------- .../instance_and_static_members_1.ts | 47 ----- .../instance_and_static_members_2.ts | 77 --------- .../instance_and_static_members_3.ts | 51 ------ .../dynamic_property_declarations.ts | 41 ----- .../member_accessor_declarations.ts | 47 ----- .../member_function_declarations_1.ts | 40 ----- .../member_function_declarations_2.ts | 35 ---- .../member_function_declarations_3.ts | 36 ---- .../member_function_declarations_4.ts | 45 ----- .../member_function_declarations_5.ts | 39 ----- .../member_variable_declarations_1.ts | 39 ----- .../member_variable_declarations_2.ts | 58 ------- .../member_variable_declarations_3.ts | 47 ----- .../member_variable_declarations_4.ts | 42 ----- .../property_member_declarations_1.ts | 43 ----- .../property_member_declarations_2.ts | 46 ----- .../property_member_declarations_3.ts | 43 ----- .../constant_enum_declarations.ts | 56 ------ .../declaration_merging_1.ts | 51 ------ .../declaration_merging_2.ts | 48 ------ .../enum_declarations/enum_declarations_1.ts | 45 ----- .../enum_declarations/enum_declarations_2.ts | 34 ---- .../enum_declarations/enum_declarations_3.ts | 60 ------- .../spec/enums/enum_members/enum_members_1.ts | 72 -------- .../array_literals/array_literal_1.ts | 34 ---- .../array_literals/array_literal_2.ts | 31 ---- .../array_literals/array_literal_3.ts | 26 --- .../array_literals/array_literal_4.ts | 32 ---- .../array_literals/array_literal_5.ts | 28 --- .../array_literals/array_literal_6.ts | 31 ---- .../arrow_function/arrow_function_1.ts | 34 ---- .../arrow_function/arrow_function_2.ts | 45 ----- .../arrow_function/arrow_function_3.ts | 31 ---- .../arrow_function/arrow_function_4.ts | 38 ---- .../assignment_operator_1.ts | 31 ---- .../assignment_operator_2.ts | 49 ------ .../assignment_operator_3.ts | 31 ---- .../destructing_assignment_1.ts | 29 ---- .../destructing_assignment_2.ts | 35 ---- .../destructing_assignment_3.ts | 34 ---- .../destructing_assignment_4.ts | 42 ----- .../destructing_assignment_5.ts | 42 ----- .../destructing_assignment_6.ts | 30 ---- .../destructing_assignment_7.ts | 32 ---- .../destructing_assignment_8.ts | 35 ---- .../the_add_operator/the_add_operator_1.ts | 55 ------ .../the_add_operator/the_add_operator_2.ts | 42 ----- .../the_add_operator/the_add_operator_3.ts | 28 --- .../the_and_operator/the_and_operator.ts | 64 ------- .../the_greater/the_congruence_operator.ts | 32 ---- .../the_greater/the_equal_operator.ts | 32 ---- .../the_greater/the_greater_operator.ts | 32 ---- .../the_greater_or_equal_operator.ts | 32 ---- .../the_greater/the_incongruence_operator.ts | 32 ---- .../the_greater/the_less_operator.ts | 32 ---- .../the_greater/the_less_or_equal_operator.ts | 32 ---- .../the_greater/the_unequal_operator.ts | 32 ---- .../the_in_operator/the_in_operator.ts | 41 ----- .../the_instanceof_operator.ts | 57 ------ .../the_mul/the_and_operator.ts | 42 ----- .../the_mul/the_division_method_operator.ts | 42 ----- .../the_mul/the_left_shift_operator.ts | 42 ----- .../the_mul/the_multiplication_operator.ts | 42 ----- .../the_mul/the_or_operator.ts | 42 ----- .../the_mul/the_remainder_operator.ts | 42 ----- .../the_mul/the_right_shift_operator.ts | 42 ----- .../the_mul/the_subtraction_operator.ts | 42 ----- .../the_unsigned_shift_to_the_right.ts | 42 ----- .../the_mul/the_xor_operator.ts | 42 ----- .../the_or_operator/the_or_operator_1.ts | 65 ------- .../the_or_operator/the_or_operator_2.ts | 33 ---- .../class_expressions/class_expressions_1.ts | 56 ------ .../contextually_typed_expressions_1.ts | 43 ----- .../contextually_typed_expressions_10.ts | 38 ---- .../contextually_typed_expressions_11.ts | 30 ---- .../contextually_typed_expressions_12.ts | 37 ---- .../contextually_typed_expressions_14.ts | 36 ---- .../contextually_typed_expressions_15.ts | 29 ---- .../contextually_typed_expressions_16.ts | 31 ---- .../contextually_typed_expressions_2.ts | 30 ---- .../contextually_typed_expressions_3.ts | 31 ---- .../contextually_typed_expressions_4.ts | 45 ----- .../contextually_typed_expressions_5.ts | 39 ----- .../contextually_typed_expressions_6.ts | 35 ---- .../contextually_typed_expressions_7.ts | 48 ------ .../contextually_typed_expressions_8.ts | 44 ----- .../contextually_typed_expressions_9.ts | 39 ----- .../grammar_ambiguities.ts | 41 ----- .../overload_resolution_1.ts | 42 ----- .../overload_resolution_2.ts | 41 ----- .../overload_resolution_3.ts | 38 ---- .../overload_resolution_4.ts | 41 ----- .../type_argument_inference_2.ts | 39 ----- .../type_argument_inference_3.ts | 32 ---- .../type_argument_inference_4.ts | 35 ---- .../function_expressions_1.ts | 36 ---- .../function_expressions_2.ts | 34 ---- .../function_expressions_3.ts | 38 ---- .../spec/expressions/identifiers/class.ts | 33 ---- .../spec/expressions/identifiers/enum.ts | 31 ---- .../spec/expressions/identifiers/function.ts | 27 --- .../expressions/identifiers/name_space.ts | 42 ----- .../spec/expressions/identifiers/parameter.ts | 37 ---- .../spec/expressions/identifiers/variable.ts | 28 --- .../spec/expressions/literals/boolean.ts | 25 --- .../spec/expressions/literals/null.ts | 25 --- .../spec/expressions/literals/number.ts | 25 --- .../spec/expressions/literals/regexp.ts | 25 --- .../spec/expressions/literals/string.ts | 26 --- .../object_literal/object_literal_1.ts | 47 ----- .../object_literal/object_literal_2.ts | 50 ------ .../object_literal/object_literal_3.ts | 48 ------ .../object_literal/object_literal_4.ts | 41 ----- .../object_literal/object_literal_5.ts | 38 ---- .../object_literal/object_literal_6.ts | 47 ----- .../object_literal/object_literal_7.ts | 37 ---- .../object_literal/object_literal_8.ts | 41 ----- .../object_literal/object_literal_9.ts | 57 ------ .../expressions/parentheses/parentheses.ts | 41 ----- .../property_access/object_access_2.ts | 50 ------ .../property_access/object_any_1.ts | 32 ---- .../property_access/object_any_type_6.ts | 42 ----- .../property_access/object_apprent_5.ts | 35 ---- .../property_access/object_index_4.ts | 36 ---- .../property_access/object_string_number_3.ts | 45 ----- .../property_access/property_access_1.ts | 32 ---- .../property_access/property_access_2.ts | 32 ---- .../the_comma_operator/the_comma_operator.ts | 36 ---- .../the_conditional_operator_1.ts | 35 ---- .../the_conditional_operator_2.ts | 33 ---- .../the_new_operator/new_operator_1.ts | 36 ---- .../the_new_operator/new_operator_2.ts | 41 ----- .../the_new_operator/new_operator_3.ts | 35 ---- .../the_new_operator/new_operator_4.ts | 44 ----- .../super_calls/arguments.ts | 37 ---- .../super_calls/gengric_extends.ts | 40 ----- .../super_calls/super_calls.ts | 53 ------ .../derived_class_access.ts | 40 ----- .../static_member_access.ts | 39 ----- .../this_key_word/this_key_word_1.ts | 47 ----- .../this_key_word/this_key_word_2.ts | 39 ----- .../type_assertion/type_assertion_1.ts | 35 ---- .../type_assertion/type_assertion_2.ts | 42 ----- .../type_assertion/type_assertion_3.ts | 33 ---- .../expressions/type_guards/type_guards_1.ts | 40 ----- .../expressions/type_guards/type_guards_10.ts | 40 ----- .../expressions/type_guards/type_guards_11.ts | 41 ----- .../expressions/type_guards/type_guards_12.ts | 41 ----- .../expressions/type_guards/type_guards_13.ts | 52 ------ .../expressions/type_guards/type_guards_2.ts | 37 ---- .../expressions/type_guards/type_guards_3.ts | 32 ---- .../expressions/type_guards/type_guards_4.ts | 32 ---- .../expressions/type_guards/type_guards_5.ts | 31 ---- .../expressions/type_guards/type_guards_6.ts | 56 ------ .../expressions/type_guards/type_guards_7.ts | 41 ----- .../expressions/type_guards/type_guards_8.ts | 54 ------ .../expressions/type_guards/type_guards_9.ts | 40 ----- .../unary_operators/the_!_operator.ts | 33 ---- .../the_++_and_--_operators.ts | 49 ------ .../unary_operators/the_+_and_~_operators.ts | 33 ---- .../unary_operators/the_delete_operator.ts | 35 ---- .../unary_operators/the_typeof_operator.ts | 29 ---- .../unary_operators/the_void_operator.ts | 28 --- .../asynchronous_functions_1.ts | 67 -------- .../asynchronous_functions_2.ts | 61 ------- .../asynchronous_functions_3.ts | 69 -------- .../asynchronous_functions_4.ts | 36 ---- .../destructuring_parameter_declarations_1.ts | 52 ------ .../destructuring_parameter_declarations_2.ts | 42 ----- .../destructuring_parameter_declarations_3.ts | 43 ----- .../destructuring_parameter_declarations_4.ts | 54 ------ .../destructuring_parameter_declarations_5.ts | 40 ----- .../destructuring_parameter_declarations_6.ts | 45 ----- .../destructuring_parameter_declarations_7.ts | 32 ---- .../function_declarations_1.ts | 42 ----- .../function_declarations_2.ts | 38 ---- .../function_implementations_1.ts | 32 ---- .../function_implementations_2.ts | 46 ----- .../function_implementations_3.ts | 42 ----- .../function_implementations_4.ts | 42 ----- .../function_implementations_5.ts | 43 ----- .../function_overloads_1.ts | 41 ----- .../generator_functions_1.ts | 34 ---- .../generator_functions_2.ts | 44 ----- .../generator_functions_3.ts | 54 ------ .../generic_functions/generic_functions_1.ts | 36 ---- .../generic_functions/generic_functions_2.ts | 34 ---- .../type_guard_functions_1.ts | 66 ------- .../spec/grammar/classes/classes.ts | 64 ------- .../test_ts_cases/spec/grammar/enums/enums.ts | 68 -------- .../spec/grammar/expressions/expressions.ts | 58 ------- .../spec/grammar/functions/functions.ts | 35 ---- .../spec/grammar/interfaces/interfaces.ts | 47 ----- .../spec/grammar/namespaces/namespaces.ts | 76 -------- .../scripts_and_modules.ts | 63 ------- .../scripts_and_modules/source_file_1.ts | 61 ------- .../scripts_and_modules/source_file_2.ts | 27 --- .../scripts_and_modules/source_file_3.ts | 30 ---- .../scripts_and_modules/source_file_4.ts | 29 ---- .../spec/grammar/statements/statements.ts | 65 ------- .../test_ts_cases/spec/grammar/types/types.ts | 162 ------------------ .../interface_declarations_1.ts | 115 ------------- .../interface_declarations_2.ts | 75 -------- .../interface_declarations_3.ts | 33 ---- .../declaration_merging_1.ts | 75 -------- .../declaration_merging_2.ts | 77 --------- .../interfaces_extending_classes_1.ts | 47 ----- .../interfaces_extending_classes_2.ts | 50 ------ .../dynamic_type_checks_1.ts | 50 ------ .../declaration_merging_1_1.ts | 26 --- .../declaration_merging_1_2.ts | 26 --- .../declaration_merging_1_3.ts | 30 ---- .../declaration_merging_2.ts | 91 ---------- .../export_declarations_1.ts | 33 ---- .../export_declarations_2.ts | 39 ----- .../export_declarations_3.ts | 37 ---- .../import_alias_declarations_1.ts | 43 ----- .../import_alias_declarations_3.ts | 61 ------- .../namespace_body/namespace_body.ts | 75 -------- .../namespace_declarations_1.ts | 44 ----- .../namespace_declarations_2.ts | 52 ------ .../namespace_declarations_3.ts | 53 ------ .../namespace_declarations_4.ts | 36 ---- .../1_source_files_dependencies/source_00.ts | 17 -- .../source_files_dependencies.ts | 28 --- .../1_programs_and_source_files/source_1.ts | 19 -- .../1_programs_and_source_files/source_10.ts | 21 --- .../1_programs_and_source_files/source_2.ts | 19 -- .../1_programs_and_source_files/source_3.ts | 18 -- .../1_programs_and_source_files/source_4.ts | 19 -- .../1_programs_and_source_files/source_5.ts | 21 --- .../1_programs_and_source_files/source_6.ts | 21 --- .../1_programs_and_source_files/source_7.ts | 27 --- .../1_programs_and_source_files/source_8.ts | 17 -- .../1_programs_and_source_files/source_9.ts | 25 --- .../2_modules/modules_1.ts | 28 --- .../import_declarations_1.ts | 28 --- .../import_declarations_2.ts | 30 ---- .../import_declarations_3.ts | 31 ---- .../import_declarations_4.ts | 31 ---- .../import_require_declarations_1.ts | 29 ---- .../export_declarations_1.ts | 27 --- .../export_declarations_2.ts | 27 --- .../export_declarations_3.ts | 26 --- .../export_declarations_4.ts | 27 --- .../export_declarations_5.ts | 27 --- .../export_assignments_1.ts | 30 ---- .../7_commonJS_modules/commonJS_modules_1.ts | 30 ---- .../7_commonJS_modules/commonJS_modules_2.ts | 30 ---- .../if_do_and_while_Statements_1.ts | 65 ------- .../if_do_and_while_Statements_2.ts | 51 ------ .../spec/statements/blocks/blocks_1.ts | 41 ----- .../spec/statements/blocks/blocks_2.ts | 36 ---- .../spec/statements/blocks/blocks_3.ts | 41 ----- .../spec/statements/blocks/blocks_4.ts | 35 ---- .../break_statements/break_statements.ts | 50 ------ .../continue_statements.ts | 54 ------ .../for_in_statements/for_in_statements.ts | 64 ------- .../for_of_statements/for_of_statements.ts | 42 ----- .../for_statements/for_statements.ts | 29 ---- .../let_and_const_declarations.ts | 37 ---- .../return_statements/return_statements.ts | 38 ---- .../switch_statements/switch_statements.ts | 74 -------- .../throw_statements/throw_statements.ts | 71 -------- .../try_statements/try_statements.ts | 44 ----- .../simple_variable_declarations_1.ts | 64 ------- .../simple_variable_declarations_2.ts | 49 ------ .../simple_variable_declarations_3.ts | 28 --- .../destructuring_variable_declarations_1.ts | 41 ----- .../destructuring_variable_declarations_2.ts | 57 ------ .../destructuring_variable_declarations_3.ts | 52 ------ .../3_implied_type/implied_type.ts | 56 ------ .../Intersection_types_1.ts | 10 +- .../object_types/array_types/array_types_1.ts | 29 +++- .../function_types/function_types_2.ts | 4 +- .../the_number_type/the_number_type_1.ts | 43 +++-- .../the_number_type/the_number_type_2.ts | 9 +- .../the_void_type/the_void_type_2.ts | 1 - .../method_signatures/method_signatures_1.ts | 36 +++- .../method_signatures/method_signatures_2.ts | 8 +- .../array_type_literals_2.ts | 2 +- .../constructor_type_literals.ts | 33 +++- ...erals_3.ts => function_type_literals_1.ts} | 0 .../function_type_literals_2.ts} | 23 ++- .../object_type_literals.ts | 38 +++- .../predefined_types/predefined_types.ts | 11 +- .../this_type_references_1.ts | 52 ++++-- .../this_type_references_2.ts | 37 ---- .../type_queries/type_queries_1.ts | 37 ++-- .../type_queries/type_queries_2.ts | 33 ---- .../the_any_type/any_type_4.ts} | 49 ++++-- .../spec/types/type_aliases/type_aliases_3.ts | 8 +- .../Type_and_Member_Identity_1.ts | 22 ++- .../Type_and_Member_Identity_2.ts | 24 ++- .../Type_and_Member_Identity_4.ts | 20 ++- .../excess_properties/excess_properties_3.ts | 30 ---- .../subtypes_and_supertypes_14.ts | 45 ----- .../subtypes_and_supertypes_15.ts | 46 ----- .../subtypes_and_supertypes_16.ts | 29 ---- .../spec/types/union_types/union_types_7.ts | 22 ++- es2panda/test/ts_extra_tests/tool/testcfg.py | 16 ++ 684 files changed, 422 insertions(+), 27461 deletions(-) delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/allow_duplicate_identifiers_across_declarations/allow_duplicate_identifiers_across_declarations_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/dotted_names_in_type_guards/dotted_names_in_type_guards_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/expression_operators/expression_operators_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/expression_operators/expression_operators_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/implicit_index_signatures/implicit_index_signatures.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_identifiers_allow_for_js_extension/module_identifiers_allow_for_js_extension_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_identifiers_allow_for_js_extension/test_js_extension.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/never_type/never_type.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/non_null_and_non_undefined/non_null_and_non_undefined.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/non_null_assertion_operator/non_null_assertion_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/null_and_undefined_aware_types/null_and_undefined_aware_types.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/optional_class_properties/optional_class_properties.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/optional_parameters_and_properties/optional_parameters_and_properties.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/private_and_protected_constructor/private_and_protected_constructor.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/read-only_properties_and_index_signatures/read-only_properties_and_index_signatures.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/shorthand_ambient_module_declarations/shorthand_ambient_module_declarations_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/shorthand_ambient_module_declarations/test_ts.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/tagged_union_types/tagged_union_types_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/test_base_url.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/test_virtual_directories_with_rootDirs/view2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.0/trailing_commas_in_parameter_and_argument/trailing_commas_in_parameter_and_argument.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.1/downlevel_async_functions/downlevel_async_functions_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.1/improved_any_inference/improved_any_inference_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.1/improved_any_inference/improved_any_inference_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.1/keyof_and_lookup_types/keyof_and_lookup_types_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.1/keyof_and_lookup_types/keyof_and_lookup_types_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.1/record/record_pick.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.1/use_returned_values_from_super_call_as_this/use_returned_values_from_super_call_as_this_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.2/dotted_property_for_types_with_string_index_signatures/dotted_property_for_types_with_string_index_signatures.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_mix_in_classes/support_for_mix_in_classes_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_mix_in_classes/support_for_mix_in_classes_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_new.target/support_for_new.target_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_new.target/support_for_new.target_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.3/async_iteration/async_generators/async_generators.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.3/async_iteration/async_iterators/async_iterators_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.3/async_iteration/async_iterators/async_iterators_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.3/generic_parameter_defaults/generic_parameter_defaults_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.3/generic_parameter_defaults/generic_parameter_defaults_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.3/generic_parameter_defaults/generic_parameter_defaults_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.4/1_dynamic_import_expressions/1_dynamic_import_expressions.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.4/1_dynamic_import_expressions/lib.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.4/2_string_enums/string_enums_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.4/4_strict_contravariance_for_callback_parameters/4_strict_contravariance_for_callback_parameters.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.4/5_weak_type_detection/5_weak_type_detection.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.5/1_optional_catch_clause_variables.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.6/suppress_errors_in_ts_files_using_ts_ignore_comments/suppress_errors_in_ts_files_using_ts_ignore_comments.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.7/10_numeric_separators/10_numeric_separators.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.7/1_constant_named_properties/1_constant_named_properties.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.7/2_unique_symbol/2_unique_symbol.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.7/3_strict_class_initialization/3_strict_class_initialization.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.7/4_definite_assignment_assertions/4_definite_assignment_assertions.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.7/5_fixed_length_tuples/5_fixed_length_tuples.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.7/6_improved_type_inference_for_object_literals/6_improved_type_inference_for_object_literals.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.7/7_improved_handling/7_improved_handling.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.7/8_Type_guards_inferred_from_in_operator/8_Type_guards_inferred_from_in_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.8/Defaulted_declarations.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.8/IIFEs_as_namespace_declarations.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.8/Improved_keyof_with_intersection_types_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.8/Improved_keyof_with_intersection_types_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.8/conditional_types.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.8/distributive_conditional_types.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.8/filter_union_types.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.8/improved_control_over_mapped_type_modifiers_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.8/improved_control_over_mapped_type_modifiers_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.8/predefined_conditional_types.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.8/prototype_assignment.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.8/type_inference.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.9/generic_type_arguments_in_tt/generic_type_arguments_in_tt.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.9/import_types/import_types.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.9/module.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.0/new_unknown_top_type/new_unknown_top_type.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.0/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.0/reference_lib/reference_lib.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.0/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/generic_rest_parameters/generic_rest_parameters.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_elements_in_tuple_types/rest_elements_in_tuple_types.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/spread_expressions_with_tuple_types/spread_expressions_with_tuple_types.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.1/mapped_types_on_tuples_and_arrays/mapped_types_on_tuples_and_arrays_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.1/properties_declarations_on_functions/properties_declarations_on_functions_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.2/bigint/bigint_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.2/bigint/bigint_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.2/bigint/bigint_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_object_rest_variables_and_parameters/generic_object_rest_variables_and_parameters.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.2/non-unit_types_as_union_discriminants/non-unit_types_as_union_discriminants.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.3/improved_behavior_for_calling_union_types.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.4/Caveats.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.4/Type_checking_for_globalThis.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.4/a_new_syntax_for_readonly_array.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.4/const_assertions.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.4/higher_order_type_inference.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.4/readonly_tuples.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.5/higher_order_type_inference.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.5/improved_excess_property_checks_in_union_types.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.5/omit_helper_type.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.5/smarter_union_type_checking.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.6/better_unicode_support_for_identifiers/better_unicode_support_for_identifiers_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/get_and_set_accessors_are_allowed_in_ambient_contexts_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/test.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.6/improved_UX_Around_Promises/improved_UX_Around_Promises.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.6/more_accurate_array_spread/more_accurate_array_spread_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.7/assertion_functions/assertion_functions_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.7/better_support_for_never/better_support_for_never.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.7/nullish_coalescing/nullish_coalescing_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.7/nullish_coalescing/nullish_coalescing_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.7/recursive_type_aliases/recursive_type_aliases_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.7/ts_nocheck_in_typescript_files/ts_nocheck_in_typescript_files.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.8/1_type_only_imports_and_export.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.8/3_which_should_i_use.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.8/4_export_star_as_ns_syntax.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.8/export_star.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.8/my_module.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.8/some_module.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.9/Parsing_differences_in_optional_assertions/Parsing_differences_in_optional_assertions.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.9/improvements_in_inference_and_Promise.all/improvements_in_inference_and_Promise.all.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/3.9/ts-expect-error_comments/ts-expect-error_comments.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.0/class_property_Inference_from_constructors/class_property_Inference_from_constructors_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/Checked_Indexed_Accesses.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_each_index.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_of_index.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_traversal_index.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.1/abstract_members_can_not_be_marked_async/abstract_members_can_not_be_marked_async.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.1/any_or_unknown_are_propagated_in_falsy_positions/any_or_unknown_are_propagated_in_falsy_positions.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.1/conditional_spreads_create_optional_properties/conditional_spreads_create_optional_properties_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.1/recursive_conditional_types/recursive_conditional_types.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.1/resolvers_parameters_are_no_longer_optional_in_promises/resolves_parameters_are_no_longer_optional_in_promises.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.2/Reverting_Template_Literal_Inference/Reverting_Template_Literal_Inference.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.2/relaxed_rules_between_optional_properties_and_string_index_signatures/relaxed_rules.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.3/always-truthy_promise_checks/always-truthy_promise_checks.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.3/constructorParameters_works_on_abstract_class/constructorParameters_works_on_abstract_class.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.3/contextual_narrowing_for_generic/contextual_narrowing_for_generics.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.3/ecmascript_private_class_elements/ecmascript_private_calss_elements.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.3/override_and_the_noImplicitOverride_Flag/override_and_the_noImplicitOverride_Flag.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.3/static_index_signatures/static_index_signatures.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.3/union_enums_cannot_be_compared_to_arbitrary_numbers/union_enums_cannot_be_compared_to_arbitrary_numbers.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.4/exact_optional_property_types/exact_optional_property_types_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.4/static_blocks_in_classe/static_blocks_in_classes1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.4/static_blocks_in_classe/static_blocks_in_classes2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.5/disabling_import_elision/disabling_import_elision_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.5/disabling_import_elision/human.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.5/private_field_presence_checks/private_field_presence_checks_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.5/template_string_types_as_discriminants/template_string_types_as_discriminants_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.5/the_awaited_type_and_promise_improvements/the_awaited_type_and_promise_improvements_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/some-module.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.6/1_allowing_code_in_constructors.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.6/2_control_flow_analysis.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.6/3_improved_recursion_depth_checks.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.6/4_indexed_access_inference_improvements.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.6/5_control_flow_analysis_for_dependent_parameters.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.7/extends_constraints_on_infer_type_variables/extends_constraints_on_infer_type_variables.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.7/improved_function_inference_in_objects_and_methods/improved_function_inference_in_objects_and_methods.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.7/instantiation_expressions/instantiation_expressions.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.7/optional_variance_annotations_for_type_parameters/optional_variance_annotations_for_type_parameters.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.7/readonly_tuples_have_a_readonly_length_property/readonly_tuples_have_a_readonly_length_property.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.8/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.8/improved_inference_for_infer_types_in_template_string_types/improved_inference_for_infer_types_in_template_string_types.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.9/auto_accessors_in_classes/auto_accessors_in_classes.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.9/checks_for_equality_on_NaN/checks_for_equality_on_NaN.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.9/the_satisfies_operator/the_satisfies_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/4.9/unlisted_property_narrowing_with_the_in_operator/unlisted_property_narrowing_with_the_in_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/Ambient_Class_Declarations/Ambient_Class_Declarations.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_namespace_declarations/ambient_namespace_declarations.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_variable_declarations/ambient_variable_declarations.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/computed_property_names/computed_property_names_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/property_names/property_names_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/require_is_valid_identifier_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/let_scope.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_10.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_11.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_12.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_14.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_2_m.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_7.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_8.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_9.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/var_scope.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_body/class_body.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/super_calls/super_calls.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/index_member_declarations/index_member_declarations.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_7.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/dynamic_property_declarations/dynamic_property_declarations.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_accessor_declarations/member_accessor_declarations.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/constant_enum_declarations/constant_enum_declarations.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_members/enum_members_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_7.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_8.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_congruence_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_equal_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_or_equal_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_incongruence_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_or_equal_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_unequal_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_instanceof_operator/the_instanceof_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_and_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_division_method_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_left_shift_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_multiplication_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_or_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_remainder_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_right_shift_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_subtraction_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_unsigned_shift_to_the_right.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_xor_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/class_expressions/class_expressions_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_10.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_11.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_15.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_16.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_9.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/class.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/enum.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/function.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/name_space.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/parameter.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/variable.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/boolean.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/null.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/number.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/regexp.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/string.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_7.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_8.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_9.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/parentheses/parentheses.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_access_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_type_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_apprent_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_index_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_string_number_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_comma_operator/the_comma_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/arguments.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/super_calls.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/derived_class_access.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/static_member_access.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_10.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_11.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_12.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_13.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_7.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_8.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_9.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_!_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_++_and_--_operators.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_+_and_~_operators.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_delete_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_typeof_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_void_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_overloads/function_overloads_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/type_guard_functions/type_guard_functions_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/classes/classes.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/enums/enums.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/expressions/expressions.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/functions/functions.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/interfaces/interfaces.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/namespaces/namespaces.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/scripts_and_modules.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/statements/statements.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/types/types.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/4_dynamic_type_checks/dynamic_type_checks_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/import_alias_declarations/import_alias_declarations_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/import_alias_declarations/import_alias_declarations_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_body/namespace_body.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_00.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_files_dependencies.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_10.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_7.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_8.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_9.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/2_modules/modules_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/4_import_require_declarations/import_require_declarations_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/6_export_assignments/export_assignments_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/break_statements/break_statements.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/continue_statements/continue_statements.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_in_statements/for_in_statements.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_of_statements/for_of_statements.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_statements/for_statements.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/let_and_const_declarations/let_and_const_declarations.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/return_statements/return_statements.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/switch_statements/switch_statements.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/throw_statements/throw_statements.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/try_statements/try_statements.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/3_implied_type/implied_type.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/function_type_literals/{function_type_literals_3.ts => function_type_literals_1.ts} (100%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{expressions/function_calls/type_argument_inference/type_argument_inference_1.ts => types/specifying_types/function_type_literals/function_type_literals_2.ts} (59%) delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/this_type_references/this_type_references_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_queries/type_queries_2.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{expressions/contextually_typed_expressions/contextually_typed_expressions_13.ts => types/the_any_type/any_type_4.ts} (51%) delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_14.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_15.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_16.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts deleted file mode 100644 index ae4b7844c8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/abstract_properties_and_accessors/abstract_properties_and_accessors.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: > - An abstract class can declare abstract properties and/or accessors. Any sub class will need to declare the abstract - properties or be marked as abstract. Abstract properties cannot have an initializer. Abstract accessors cannot have bodies. -module: ESNext -isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -abstract class Skill { - abstract name: string; - abstract damage:number; - abstract get accessor(); - abstract set accessor(ok:string); -} -class Divied extends Skill { - name = "derived"; - damage = 128; - get accessor() { - return 'ok' - } - set accessor(ok:string) { - this.name = ok; - } -} -let d = new Divied(); -Assert.equal(d.name, "derived"); -Assert.equal(d.damage, 128); -Assert.equal(d.accessor, "ok"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/allow_duplicate_identifiers_across_declarations/allow_duplicate_identifiers_across_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/allow_duplicate_identifiers_across_declarations/allow_duplicate_identifiers_across_declarations_1.ts deleted file mode 100644 index 6b6f3bf2cc..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/allow_duplicate_identifiers_across_declarations/allow_duplicate_identifiers_across_declarations_1.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: TypeScript 2.0 relaxes this constraint and allows duplicate identifiers across blocks, as long as they have identical types. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" - -interface Skill { - damage?: number; -} - -interface Skill { - skillName?: string; - damageType?: string; - damage?: number; -} - -let sa: Skill = { - damage: 1024, -}; - -let sb: Skill = { - skillName: "XOMissile", - damageType: "XO", - damage: 128, -}; - -Assert.equal(sa.damage, 1024); -Assert.equal(sb.damage, 128); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis1.ts deleted file mode 100644 index 5e5619f1ec..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis1.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the type checker analyses all possible flows of control in statements and expressions to produce the most specific type possible (the narrowed type) at any given location for a local variable or parameter that is declared to have a union type. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" - -let arg = Math.random() < 0.5 ? 5 : 'a'; -if (typeof arg === 'string') { - Assert.isString(arg); - arg = 3; - Assert.isNumber(arg); -} - -Assert.isNumber(arg); - - -function func(x: string | number) { - if (typeof x === "number") { - return "10"; - } - - return 10 -} - -Assert.isNumber(func("10")); -Assert.isString(func(10)); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis2.ts deleted file mode 100644 index 99374a56ec..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis2.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Control flow based type analysis is particularly relevant in strictNullChecks mode because nullable types are represented using union types. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" - -function testFun(x: string | null): void { - if (x === null) { - return; - } - - Assert.isString(x); -} - -testFun(null); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis3.ts deleted file mode 100644 index 7e7d38f213..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/control_flow_based_type_analysis/control_flow_based_type_analysis3.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In strictNullChecks mode, control flow based type analysis includes definite assignment analysis for local variables of types that don’t permit the value undefined. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" - -function tFun(c: boolean): void { - let x: number; - if (c) { - x = 1; - Assert.equal(x, 1); - } - x = 2; - Assert.equal(x, 2); -} - -tFun(true); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/dotted_names_in_type_guards/dotted_names_in_type_guards_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/dotted_names_in_type_guards/dotted_names_in_type_guards_1.ts deleted file mode 100644 index 30186c31c7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/dotted_names_in_type_guards/dotted_names_in_type_guards_1.ts +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: Type guards now support checking “dotted names” consisting of a variable or parameter name followed one or more property accesses. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" - -type StrObj = - { - strobj?: { - str1?: string; - str2?: string; - }; - } - | undefined; - -function funSO(so?: StrObj): string | void { - if (so && so.strobj && so.strobj.str1) { - const x: string = so.strobj.str1; - Assert.isString(x); - return x; - } else if (so && so.strobj && so.strobj.str2) { - const x: string = so.strobj.str2; - Assert.isString(x); - return x; - } else { - if (so && so.strobj && so.strobj.str1 === undefined) { - return "so.strobj.str1 === undefined"; - } else if (so && so.strobj && so.strobj.str2 === undefined) { - return "so.strobj.str2 === undefined"; - } else if (so !== undefined && so.strobj === undefined) { - return "so.strobj === undefined"; - } else if (so === undefined) { - return "so === undefined"; - } - } -} - -let so: StrObj = undefined; -Assert.equal(funSO(so), "so === undefined"); -so = {}; -Assert.equal(funSO(so), "so.strobj === undefined"); -so = { strobj: {} }; -Assert.equal(funSO(so), "so.strobj.str1 === undefined"); -so = { strobj: { str1: "str1" } }; -Assert.equal(funSO(so), "str1"); -so = { strobj: {str2: "str2"} }; -Assert.equal(funSO(so), "str2"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/expression_operators/expression_operators_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/expression_operators/expression_operators_1.ts deleted file mode 100644 index 4881985ea6..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/expression_operators/expression_operators_1.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: Expression operators permit operand types to include null and/or undefined but always produce values of non-null and non-undefined types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -let x: number | undefined; -let y: string | null; -let method: string | number | undefined | null; - -x = undefined; -y = 'a'; -method = null -method = x + y + method; -Assert.isString(method); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/expression_operators/expression_operators_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/expression_operators/expression_operators_2.ts deleted file mode 100644 index 0a5b375bec..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/expression_operators/expression_operators_2.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The && operator adds null and/or undefined to the type of the right operand depending on which are present in the type of the left operand, and the || operator removes both null and undefined from the type of the left operand in the resulting union type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -type o = { - num: 10 -} -type T = o | undefined; -let x: T; - -let y = x && x.num; -y = 10; -Assert.isNumber(y); -y = undefined; -Assert.isUndefined(y); - -let z = x || { num: 5 }; -Assert.isObject(z); - -interface I{ - str: string; -} -type t = I | undefined; -let a: t; - -let b = a && a.str; -b = ' '; -Assert.isString(b); -b = undefined; -Assert.isUndefined(b); - -let c = a || { str: 's' }; -Assert.isObject(c); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/implicit_index_signatures/implicit_index_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/implicit_index_signatures/implicit_index_signatures.ts deleted file mode 100644 index e49b071acc..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/implicit_index_signatures/implicit_index_signatures.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - An object literal type is now assignable to a type with an index signature if all known properties in the - object literal are assignable to that index signature. This makes it possible to pass a variable that was initialized with an object literal as parameter to a function that expects a map or dictionary: - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -function func(str: string, arg: { [x: string]: string }) { - return JSON.stringify(arg); -} -const arg = { - "Color": "Red", -}; -let s1: string = func("", { - "Color": "red", -}); -Assert.equal(s1, '{"Color":"red"}'); - -let s2: string = func("", arg); -Assert.equal(s2, '{"Color":"Red"}'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_identifiers_allow_for_js_extension/module_identifiers_allow_for_js_extension_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_identifiers_allow_for_js_extension/module_identifiers_allow_for_js_extension_1.ts deleted file mode 100644 index b5716d30ff..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_identifiers_allow_for_js_extension/module_identifiers_allow_for_js_extension_1.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: With TypeScript 2.0, the compiler will look up definition of "moduleA.js" in ./moduleA.ts or ./moduleA.d.t. -module: ESNext -isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" -import { HelloWorld } from "./test_js_extension.js" - -let world = new HelloWorld("HelloWorld.txt"); -Assert.equal(world.txt, "HelloWorld.txt"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_identifiers_allow_for_js_extension/test_js_extension.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_identifiers_allow_for_js_extension/test_js_extension.ts deleted file mode 100644 index f9b155f734..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/module_identifiers_allow_for_js_extension/test_js_extension.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -export class HelloWorld { - txt: string; - constructor(name: string) { - this.txt = name; - } -}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/never_type/never_type.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/never_type/never_type.ts deleted file mode 100644 index 28d93a7c67..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/never_type/never_type.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - never type - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -function testError():never { - throw new Error("testError"); -} - -try { - testError(); -} catch (e:any) { - Assert.equal(e.message, "testError"); -} - -function test():never { - return "ok" as never -} - -Assert.equal(typeof test(), "string"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/non_null_and_non_undefined/non_null_and_non_undefined.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/non_null_and_non_undefined/non_null_and_non_undefined.ts deleted file mode 100644 index eebda7ab58..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/non_null_and_non_undefined/non_null_and_non_undefined.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Non-null and non-undefined type guards - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -function testNullAndUndefined(x: number): string { - return x.toString(); -} - -let x: number | null | undefined; -x = 1; - -Assert.equal(testNullAndUndefined(x), '1'); - -let y: number | null | undefined; - -let ad = y && testNullAndUndefined(y) ; -ad = "1" -Assert.equal(ad, "1"); -ad = undefined -Assert.equal(ad, undefined); -ad = null; -Assert.equal(ad, null); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/non_null_assertion_operator/non_null_assertion_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/non_null_assertion_operator/non_null_assertion_operator.ts deleted file mode 100644 index 45bd994f48..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/non_null_assertion_operator/non_null_assertion_operator.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: > - A new ! post-fix expression operator may be used to assert that its operand is non-null and non-undefined in contexts where the type checker is unable to conclude that fact. -module: ESNext -isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" - -function testStr(x?: string, y?: number | string): string { - let z: number | string = x! + y!; - return z; -} -Assert.equal(testStr("A"), "Aundefined"); -Assert.equal(testStr("B", 5), "B5"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/null_and_undefined_aware_types/null_and_undefined_aware_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/null_and_undefined_aware_types/null_and_undefined_aware_types.ts deleted file mode 100644 index 9291b75e83..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/null_and_undefined_aware_types/null_and_undefined_aware_types.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Null- and undefined-aware types - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -let a: number; -let b: number | undefined; -let c: number | null | undefined; - -a = 0; -Assert.equal(a,0); -b = 0; -Assert.equal(b,0); -b = undefined; -Assert.equal(b,undefined); -c = 0; -Assert.equal(c,0); -c = undefined; -Assert.equal(c,undefined); -c = null; -Assert.equal(c,null); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/optional_class_properties/optional_class_properties.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/optional_class_properties/optional_class_properties.ts deleted file mode 100644 index d8e5a35e47..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/optional_class_properties/optional_class_properties.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: Optional properties and methods can now be declared in classes, similar to what is already permitted in interfaces. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -class Demo { - a: number = 0; - b?: number; - func() { - return this.a; - } - - get?(): number; - handle?() { - return this.b; - } -} -let c = new Demo(); -c.a = 1024; -c.b = 1408; -Assert.equal(c.func(), 1024); - -if (c.handle) { - Assert.equal(c.handle(), 1408); -} - -c.get = () => { - if (c.b !== undefined) { - return c.a + c.b; - } else { - return c.a; - } -} -Assert.equal(c.get(), 2432); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/optional_parameters_and_properties/optional_parameters_and_properties.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/optional_parameters_and_properties/optional_parameters_and_properties.ts deleted file mode 100644 index 8aa15f10aa..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/optional_parameters_and_properties/optional_parameters_and_properties.ts +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: Optional parameters and properties automatically have undefined added to their types, even when their type annotations don’t specifically include undefined. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js"; - -function printPoint(a: number, b: number, c?: number): string { - let obj: { a: number, b: number, c?: number }; - if (c !== undefined) { - obj = { a, b, c }; - Assert.isNumber(c); - } else { - obj = { a, b }; - Assert.isUndefined(c); - } - return JSON.stringify(obj); -} -Assert.equal(printPoint(1, 3, 5), '{"a":1,"b":3,"c":5}'); -Assert.equal(printPoint(1, 1), '{"a":1,"b":1}'); - -interface I{ - num: number; - str?: string; -} -let i1: I = { - num: 5 -} -Assert.isUndefined(i1.str); -let i2: I = { - num: 5, - str: 'a' -} -Assert.isString(i2.str); - -class C{ - num: number; - str?: string; - constructor(num: number, str?: string) { - this.num = num; - this.str = str; - } -} -let c1 = new C(10); -Assert.isUndefined(c1.str); -let c2 = new C(10, 'a'); -Assert.isString(c2.str); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/private_and_protected_constructor/private_and_protected_constructor.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/private_and_protected_constructor/private_and_protected_constructor.ts deleted file mode 100644 index dda0fb44a3..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/private_and_protected_constructor/private_and_protected_constructor.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: A class constructor may be marked private or protected. A class with private constructor cannot be instantiated outside the class body, and cannot be extended. A class with protected constructor cannot be instantiated outside the class body, but can be extended. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -class Box { - s!:string; - private static subBox: Box; - private constructor() { } - static getSubBos(s:string) { - if (!Box.subBox) { - Box.subBox = new Box(); - Box.subBox.s = s; - } - return Box.subBox; - } -} -let v: Box = Box.getSubBos("s"); -Assert.equal(v.s, "s"); - -class myBox{ - arg: string; - protected constructor(arg: string) { - this.arg = arg; - } -} -class myLittleBox extends myBox{ - constructor(arg: string) { - super(arg); - } -} -let tool = new myLittleBox('hammer'); -Assert.equal(tool.arg, 'hammer'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/read-only_properties_and_index_signatures/read-only_properties_and_index_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/read-only_properties_and_index_signatures/read-only_properties_and_index_signatures.ts deleted file mode 100644 index 0a7e42b76a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/read-only_properties_and_index_signatures/read-only_properties_and_index_signatures.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A property or index signature can now be declared with the readonly modifier is considered read-only. - Read-only properties may have initializers and may be assigned to in constructors within the same class declaration, but otherwise assignments to read-only properties are disallowed - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -interface Demo { - readonly x: number; - readonly y: number; -} -let d2 = { x: 1, y: 1 }; - -let d3: Demo = d2; -Assert.equal(JSON.stringify(d3), '{"x":1,"y":1}'); - -d2.x = 5; - -Assert.equal(d3.x, 5) - -let x: Array = [0, 1, 2]; -let y: ReadonlyArray = x; -Assert.equal(JSON.stringify(y), '[0,1,2]'); - -class Demo2 { - readonly x = 1; - readonly y: string; - constructor() { - this.y = "demo"; - } - -} - -Assert.equal(new Demo2().y, "demo"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/shorthand_ambient_module_declarations/shorthand_ambient_module_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/shorthand_ambient_module_declarations/shorthand_ambient_module_declarations_1.ts deleted file mode 100644 index 14c73669a0..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/shorthand_ambient_module_declarations/shorthand_ambient_module_declarations_1.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: > - If you don’t want to take the time to write out declarations before using a new module, - you can now just use a shorthand declaration to get started quickly. -module: ESNext -isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" -import hwexpNumAdd15, { y } from "./test_ts.js" - -Assert.equal(hwexpNumAdd15(y), 25); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/shorthand_ambient_module_declarations/test_ts.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/shorthand_ambient_module_declarations/test_ts.ts deleted file mode 100644 index 13cc016851..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/shorthand_ambient_module_declarations/test_ts.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -export default function hwexpNumAdd15(a: number) { - return a + 15; -} - -export const y = 10; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_1.ts deleted file mode 100644 index ea3bcc2501..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_1.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: You can provide an explicit this parameter. this parameters are fake parameters that come first in the parameter list of a function. -module: ESNext -isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" - -function fun_this(this: any) { - Assert.equal(this, undefined); -} - -fun_this(); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_2.ts deleted file mode 100644 index 9348bd0d1f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/specifying_the_type_of_this_for_functions/specifying_the_type_of_this_for_functions_2.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: > - this parameters in callbacks.Libraries can also use this parameters to declare how callbacks will be invoked. - this: void means that addClickListener expects onclick to be a function that does not require a this type. -module: ESNext -isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" - -interface Web { - Click(onclick: (this: void, e: Event) => void): void; -} - -class NetLink { - info: string; - constructor(info: string) { - this.info = info; - } - onClickGood(this: void, e: Event) { - } -} - -let web: Web = { - Click(Onclick: (this: void, e: Event) => void) { - Assert.equal(typeof this, "object"); - } -}; -let onAir = new NetLink("OnAir"); -web.Click(onAir.onClickGood); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/tagged_union_types/tagged_union_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/tagged_union_types/tagged_union_types_1.ts deleted file mode 100644 index f736a3b469..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/tagged_union_types/tagged_union_types_1.ts +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: The TS compiler now support type guards that narrow union types based on tests of a discriminant property and furthermore extend that capability to switch statements. -module: ESNext -isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" - -type Color = { - name: "Color"; - rgb: [number, number, number]; -} - -type Point = { - name: "Point"; - point: [number, number]; -} - - - -type ColorPoint = Color | Point -let un:ColorPoint[] = [{name:"Color", rgb:[0,0,0]},{name:"Point", point:[1,1]}]; -let count:number = 0; -function test(s: ColorPoint[]) { - for (const unElement of s) { - switch (unElement.name) { - case "Color": - count++ - break - case "Point": - count++ - break - } - } - return count; -} - -function test1(s: ColorPoint) { - if (s.name === "Color") { - return s; - } - return s; -} - -let point: Point = { - name: "Point", - point: [0, 0] -}; - - -Assert.equal(JSON.stringify(test(un)), 2); -Assert.equal(test1(point).name, 'Point'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/test_base_url.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/test_base_url.ts deleted file mode 100644 index 8d0e09479a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/test_base_url.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -function add(a: number, b: number): number { - return a + b; -} -let flag: string = "baseurl"; -export { add as ADD, flag }; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/test_virtual_directories_with_rootDirs/view2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/test_virtual_directories_with_rootDirs/view2.ts deleted file mode 100644 index 58d9a6f69e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/test_virtual_directories_with_rootDirs/view2.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -export enum Directions { - Up, - Down, - Left, - Right -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/trailing_commas_in_parameter_and_argument/trailing_commas_in_parameter_and_argument.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.0/trailing_commas_in_parameter_and_argument/trailing_commas_in_parameter_and_argument.ts deleted file mode 100644 index 28859f9abb..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.0/trailing_commas_in_parameter_and_argument/trailing_commas_in_parameter_and_argument.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: Trailing commas in function parameter and argument lists - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -function point(x:number, y:number,) { - return x+y -} - -Assert.equal(3,point(1,2 )) -Assert.equal(3,point(1,2, )) diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_1.ts deleted file mode 100644 index d276b7f620..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_1.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The type inferred for a const variable or readonly property without a type annotation is the type of the literal initializer. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -const a = 1; -let aa: typeof a = 1; -Assert.equal(typeof aa , "number"); -const b = false; -let bb: typeof b = false; -Assert.equal(typeof bb , "boolean"); -const c = "hello"; -let cc: typeof c = "hello"; -Assert.equal(typeof cc , "string"); - - -class Test { - static readonly age = 12; - static readonly isJob = false; - static readonly nickName = "wangcai"; -} - -let age: typeof Test.age = 12; -Assert.equal(typeof age, "number"); -let isJob: typeof Test.isJob = false; -Assert.equal(typeof isJob, "boolean"); -let nickName: typeof Test.nickName = "wangcai"; -Assert.equal(typeof nickName, "string"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_2.ts deleted file mode 100644 index 497649f49c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_2.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The type inferred for a let variable, var variable, parameter, or non-readonly property with an initializer - and no type annotation is the widened literal type of the initializer. - where the widened type for a string literal type is string, number for numeric literal types, boolean for true or false - and the containing enum for enum literal types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -let a = 1; -let newA: typeof a = 12; -Assert.isNumber(newA); - -let b = 1; -let newB: typeof b = 12; -Assert.isNumber(newB); - -function test(a:boolean = true) { - return a; -} -let newT: ReturnType = false; -Assert.isBoolean(newT); - -class Test { - static job = "coder"; -} - -let newC: typeof Test.job = "driver"; -Assert.isString(newC); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_3.ts deleted file mode 100644 index efe57c6d4d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/better_inference_for_literal_types/better_inference_for_literal_types_3.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: Literal type widening can be controlled through explicit type annotations. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -const newString = "hello"; - -let newV = newString; -newV = "world"; -const newS2: "hello" = "hello"; -let newV2 = newS2; -Assert.equal(newV2, "hello"); - -const newN = 1; -let n4 = newN; -n4 = 10; -Assert.equal(n4, 10); -const n5: 1 = 1; -let n6 = n5; -n6 = 1; -Assert.equal(n6, 1); - -const newB = false; -let b8 = newB; -b8 = true; -Assert.equal(b8, true); -const b9: false = false; -let b10 = b9; -b10 = false; -Assert.equal(b10, false); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/downlevel_async_functions/downlevel_async_functions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/downlevel_async_functions/downlevel_async_functions_1.ts deleted file mode 100644 index 2987c40354..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/downlevel_async_functions/downlevel_async_functions_1.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - This feature was supported before TypeScript 2.1, - but only when targeting ES6/ES2015. - TypeScript 2.1 brings the capability to ES3 and ES5 run-times. - options: - lib:dom,es5,es2015.promise - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -function dTime(milli: number) { - return new Promise((resolve) => { - setTimeout(resolve, milli); - }); -} -async function showMsg(a: number, b: string) { - Assert.equal(a, 12); - for (let i = 0; i < 5; i++) { - await dTime(300); - Assert.equal(b, "New"); - } - Assert.equal(b, "New"); -} -showMsg(12, "New"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/improved_any_inference/improved_any_inference_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/improved_any_inference/improved_any_inference_1.ts deleted file mode 100644 index c5a618c9a7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/improved_any_inference/improved_any_inference_1.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript2.1 will infer types based on what you end up assigning later on. - This is only enabled if noImplicitAny is set. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -let win; -win = (a: number) => a + 1; - -let fail = win; -Assert.equal(fail(12), 13); - -win = "abc"; -Assert.isString(win); -Assert.equal(win.toUpperCase(), "ABC"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/improved_any_inference/improved_any_inference_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/improved_any_inference/improved_any_inference_2.ts deleted file mode 100644 index 3ee331afe7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/improved_any_inference/improved_any_inference_2.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A variable declared with no type annotation and an initial value of [] is considered an implicit any[] variable. - However, each subsequent x.push(value), x.unshift(value) or x[n] = value operation evolves the type of the variable - in accordance with what elements are added to it. - This is only enabled if noImplicitAny is set. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -function funcT() { - let arr = []; - arr[0] = 0; - arr.push("true"); - arr.unshift("abc"); - return arr; -} - -type newF = ReturnType; - -let funC: newF = ["hello", 12]; -Assert.equal(JSON.stringify(funC), '["hello",12]'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/keyof_and_lookup_types/keyof_and_lookup_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/keyof_and_lookup_types/keyof_and_lookup_types_1.ts deleted file mode 100644 index efbc1da5aa..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/keyof_and_lookup_types/keyof_and_lookup_types_1.ts +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - An indexed type query keyof T yields the type of permitted property names for T. - A keyof T type is considered a subtype of string. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -class TestHuman { - name: string; - age: number; - private job: string; - constructor(name: string, age: number, job: string) { - this.name = name; - this.age = age; - this.job = job; - } -} -type TestName = Pick; -let nn: TestName = { - name: "ayw", -}; -Assert.notEqual(nn.name, undefined); -Assert.equal(nn.name, "ayw"); - -type TestAge = Pick; -let aa: TestAge = { - age: 20, -}; -Assert.notEqual(aa.age, undefined); -Assert.equal(aa.age, 20); - -type Test = Pick; -let cc: Test = { - name: "cool", - age: 15, -}; -Assert.notEqual(cc.name, undefined); -Assert.notEqual(cc.age, undefined); - -Assert.equal(cc.name, "cool"); -Assert.equal(cc.age, 15); - -type TestString = keyof { [x: string]: number }; - -let str: TestString = "abc"; -Assert.isString(str); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/keyof_and_lookup_types/keyof_and_lookup_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/keyof_and_lookup_types/keyof_and_lookup_types_2.ts deleted file mode 100644 index 47410ddcb1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/keyof_and_lookup_types/keyof_and_lookup_types_2.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: indexed access types, also called lookup types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -class TestHuman { - name: string; - age: number; - constructor(name: string, age: number, job: string) { - this.name = name; - this.age = age; - } -} - -type TestName = TestHuman["name"]; -let test1: TestName = ""; -Assert.equal(typeof test1, "string"); -Assert.notEqual(typeof test1, "number"); -Assert.notEqual(typeof test1, "boolean"); - -type TestAge = TestHuman["age"]; -let test2: TestAge = 0; -Assert.equal(typeof test2, "number"); -Assert.notEqual(typeof test2, "string"); -Assert.notEqual(typeof test2, "boolean"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_1.ts deleted file mode 100644 index 1556bb11b5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_1.ts +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Partial - Constructs a type with all properties of Type set to optional. - This utility will return a type that represents all subsets of a given type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -interface HumanTest { - name: string; - age: number; - destination: string; -} -type PersonType = Partial; - -let pt1: HumanTest = { - name: "caihua", - age: 20, - destination: "earth", -}; - -let pt2: PersonType; -pt2 = {}; -Assert.equal(pt2.name, undefined); -Assert.equal(pt2.age, undefined); -Assert.equal(pt2.destination, undefined); -pt2 = { name: "caihua" }; -Assert.equal(pt2.name, "caihua"); -Assert.equal(pt2.age, undefined); -Assert.equal(pt2.destination, undefined); -pt2 = { age: 20 }; -Assert.equal(pt2.name, undefined); -Assert.equal(pt2.age, 20); -Assert.equal(pt2.destination, undefined); -pt2 = { destination: "earth" }; -Assert.equal(pt2.name, undefined); -Assert.equal(pt2.age, undefined); -Assert.equal(pt2.destination, "earth"); -pt2 = { name: "caihua", age: 20 }; -Assert.equal(pt2.name, "caihua"); -Assert.equal(pt2.age, 20); -Assert.equal(pt2.destination, undefined); -pt2 = { name: "lwx", age: 27, destination: "nanj" }; -Assert.equal(pt2.name, "lwx"); -Assert.equal(pt2.age, 27); -Assert.equal(pt2.destination, "nanj"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_2.ts deleted file mode 100644 index bb4e1c8314..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_2.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Readonly - Constructs a type with all properties of Type set to readonly, - meaning the properties of the constructed type cannot be reassigned. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -interface HumanTest { - name: string; - age: number; - destination: string; -} -type PersonType = Readonly; - -let pt1: HumanTest = { - name: "caihua", - age: 20, - destination: "earth", -}; -pt1.name = "caihua1"; -Assert.notEqual(pt1.name, "caihua"); -pt1.age = 15; -Assert.notEqual(pt1.age, 20); -pt1.destination = "Mars"; -Assert.notEqual(pt1.destination, "earth"); -let pt2: PersonType = { - name: "caihua", - age: 20, - destination: "earth", -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_3.ts deleted file mode 100644 index ea6ef38b4c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_3.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Record - Constructs an object type whose property keys are Keys and whose property values are Type. - This utility can be used to map the properties of a type to another type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -interface CatInfoTest { - age: number; - breed: string; -} - -type CatNameType = "miffy" | "boris" | "mordred"; - -const cats: Record = { - miffy: { age: 10, breed: "Persian" }, - boris: { age: 5, breed: "Maine Coon" }, - mordred: { age: 16, breed: "British Shorthair" }, -}; -Assert.equal(cats.miffy.age, 10); -Assert.equal(cats.boris.age, 5); -Assert.equal(cats.mordred.age, 16); -Assert.equal(cats.miffy.breed, "Persian"); -Assert.equal(cats.boris.breed, "Maine Coon"); -Assert.equal(cats.mordred.breed, "British Shorthair"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_4.ts deleted file mode 100644 index af235985d8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/mapped_types/mapped_types_4.ts +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Pick - Constructs a type by picking the set of properties Keys (string literal or union of string literals) from Type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -interface TodoInter { - title: string; - description: string; - completed: boolean; -} - -type TodoTitle = Pick; -type TodoTitleOrCompleted = Pick; -type TodoAll = Pick; - -const title: TodoTitle = { - title: "Clean room", -}; -Assert.equal("title" in title, true); -Assert.equal("description" in title, false); -Assert.equal("completed" in title, false); - -const titleAndCompleted: TodoTitleOrCompleted = { - title: "Clean room", - completed: false, -}; -Assert.equal("title" in titleAndCompleted, true); -Assert.equal("completed" in titleAndCompleted, true); -Assert.equal("description" in titleAndCompleted, false); - -const testAll: TodoAll = { - title: "Clean room", - description: "clean the whole room", - completed: false, -}; -Assert.equal("title" in testAll, true); -Assert.equal("description" in testAll, true); -Assert.equal("completed" in testAll, true); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_1.ts deleted file mode 100644 index 33bbe63b23..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_1.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: spreading an object can be handy to get a shallow copy. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -let humen = { - name: "caihua", - age: 20, -}; -let job = { job: "stu" }; -let data = { - location: "mars", - pets: { - type: "dog", - name: "ahuang", - }, -}; - -let combine = { ...humen, ...job, ...data }; - -Assert.equal(combine.name, humen.name); -Assert.equal(combine.age, humen.age); -Assert.equal(combine.job, job.job); -Assert.equal(combine.location, data.location); -Assert.equal(combine.pets.name, data.pets.name); -Assert.equal(combine.pets.type, data.pets.type); -Assert.equal(combine.name == humen.name, true); -Assert.equal(combine.age == humen.age, true); -Assert.equal(combine.job == job.job, true); -Assert.equal(combine.location == data.location, true); -Assert.equal(combine.pets == data.pets, true); -Assert.equal(combine.pets.type == data.pets.type, true); -Assert.equal(combine.pets.name == data.pets.name, true); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_2.ts deleted file mode 100644 index 5b1976e764..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_2.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - override existing properties and add new ones - The order of specifying spread operations determines what properties end up in the resulting object; - properties in later spreads "win out" over previously created properties. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -let humen = { - name: "caihua", - age: 20, -}; - -let combine = { ...humen, name: "huahua", job: "teacher" }; - -Assert.equal(combine.age, humen.age); -Assert.equal(combine.age == humen.age, true); -Assert.equal(combine.name != humen.name, true); - -Assert.equal(combine.job != undefined, true); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_3.ts deleted file mode 100644 index 83fadffad5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/object_spread_and_rest/object_spread_and_rest_3.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - override existing properties and add new ones - The order of specifying spread operations determines what properties end up in the resulting object; - properties in later spreads "win out" over previously created properties. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -let humen = { - name: "caihua", - age: 20, -}; - -let combine = { ...humen, name: "huahua", job: "teacher" }; - -let { job, ...restProperties } = combine; -Assert.equal(job, combine.job); -Assert.equal(restProperties.age, combine.age); -Assert.equal(restProperties.name, combine.name); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/record/record_pick.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/record/record_pick.ts deleted file mode 100644 index bfe31d37c0..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/record/record_pick.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Record pick - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -function test(o: Record, testObj: (s: B) => C): Record { - - for (let oElement in o) { - // @ts-ignore - o[oElement] = testObj(o[oElement]); - } - // @ts-ignore - return o; -} - -let testO = { ok: "1", demo: "2" }; -let ret = test(testO, str => str.length); -Assert.isNumber(ret.ok) - -let person:{name?:string, age?:string} = {}; -function test1(o: T, ...ks: K[]): Pick{ - for (let oElement of ks) { - // @ts-ignore - o[oElement] = oElement; - } - return o; -} -test1(person, "name", "age"); -Assert.equal(person.name, 'name'); -Assert.equal(person.age, 'age'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/use_returned_values_from_super_call_as_this/use_returned_values_from_super_call_as_this_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.1/use_returned_values_from_super_call_as_this/use_returned_values_from_super_call_as_this_1.ts deleted file mode 100644 index 1cbabba767..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.1/use_returned_values_from_super_call_as_this/use_returned_values_from_super_call_as_this_1.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In ES2015, constructors which return an object implicitly substitute the value of this for any callers of super(). - it is necessary to capture any potential return value of super() and replace it with this. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -class Test { - one: number; - constructor(one: number) { - this.one = one; - return { - one: 1, - }; - } -} -class Test_sub extends Test { - constructor(x: number) { - super(x); - } -} -let newC = new Test_sub(12); -Assert.equal(newC.one, 1); -Assert.notEqual(newC.one, 12); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.2/dotted_property_for_types_with_string_index_signatures/dotted_property_for_types_with_string_index_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/dotted_property_for_types_with_string_index_signatures/dotted_property_for_types_with_string_index_signatures.ts deleted file mode 100644 index a6dbefe1f5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.2/dotted_property_for_types_with_string_index_signatures/dotted_property_for_types_with_string_index_signatures.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - types with a string index signature can be indexed using the "[]" notation, but were not allowed to use the ".". Starting with TypeScript 2.2 using either should be allowed. - this only apply to types with an explicit string index signature. It is still an error to access unknown properties on a type using "." notation. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -type myType = { [arg: string]: string }; -let my_t: myType = { - 'color': 'blue' -} - -Assert.equal(my_t['color'], 'blue'); -Assert.equal(my_t.color, 'blue'); - -class C{ - Arg: { [arg: string]: string }; - constructor(Arg: { [arg: string]: string }) { - this.Arg = Arg; - } -} -let c = new C({ 'color': 'black' }); -Assert.equal(c.Arg['color'], 'black'); -Assert.equal(c.Arg.color, 'black'); - -interface StringArrIndex { - [x: string]: T; -} -var strArr: StringArrIndex = {}; -strArr["ATP"] = 0x00; -strArr.NARC = 0x01; -Assert.equal(strArr.ATP, 0x00); -Assert.equal(strArr["NARC"], 0x01); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type_1.ts deleted file mode 100644 index 1961d02258..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type_1.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - typeScript did not have a type that represents the non-primitive type, i.e. any thing that is not number, string, - boolean, symbol, null, or undefined. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -var obj1 = { num: 0, str: "string", bool: false, null: null, undefined: undefined }; -Assert.isNumber(obj1.num); -Assert.isString(obj1.str); -Assert.isBoolean(obj1.bool); -Assert.equal(obj1.null, null); -Assert.equal(obj1.undefined, undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type_2.ts deleted file mode 100644 index 63fe0025e2..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type_2.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - typeScript did not have a type that represents the non-primitive type, i.e. any thing that is not number, string, - boolean, symbol, null, or undefined. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -let obj2 = { num: 1 }; -let obj3 = { str: "OBJ" }; -let obj4 = { num: 1 }; -Assert.equal(typeof obj2, 'object'); -Assert.equal(typeof obj3, 'object'); -Assert.isTrue(typeof obj2 === typeof obj3); -Assert.isFalse(obj2 === obj4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type_3.ts deleted file mode 100644 index 6007f1806f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.2/object_type/object_type_3.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Create an object type variable - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -let obj5 = new Object({ Damage: 1024, DamageType: 'XO' }); -Assert.equal(JSON.stringify(obj5), '{"Damage":1024,"DamageType":"XO"}'); - -type ColorOBJ = { Color: [number, number, number], ColorName: string }; -let obj6: ColorOBJ = { Color: [255, 0, 0], ColorName: 'Red' }; -Assert.equal(JSON.stringify(obj6), '{"Color":[255,0,0],"ColorName":"Red"}'); - -interface Weapon { - Damage: number; - DamageType: string; -} -let obj7: Weapon = { Damage: 333, DamageType: 'EXP' }; -Assert.equal(JSON.stringify(obj7), '{"Damage":333,"DamageType":"EXP"}'); - -let obj8: object = { A: 1 }; -Assert.equal(JSON.stringify(obj8), '{"A":1}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_mix_in_classes/support_for_mix_in_classes_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_mix_in_classes/support_for_mix_in_classes_1.ts deleted file mode 100644 index a1a2eea523..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_mix_in_classes/support_for_mix_in_classes_1.ts +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - typeScript 2.2 adds support for the ECMAScript 2015 mixin class pattern as well as rules for combining mixin construct signatures with regular construct signatures in intersection types. - a mixin constructor type refers to a type that has a single construct signature with a single rest argument of type any[] and an object-like return type. - a mixin class is a class declaration or expression that extends an expression of a type parameter type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -class PointXY { - public x: number; - public y: number; - constructor(x: number = 0, y: number = 0) { - this.x = x; - this.y = y; - } - toString() { - return '(' + this.x + ', ' + this.y + ')'; - } -} -type MIXType = new (...members: any[]) => T; -function mixC>(BC: T) { - return class extends BC { - constructor(...members: any[]) { - super(...members); - } - public pname: string = ""; - setPname(pname: string) { - this.pname = pname; - } - getPname() { - return this.pname; - } - }; -} -const PointMix = mixC(PointXY); -var a = new PointMix(4, 4); -var b = new PointMix(); -a.setPname("A"); -b.setPname("B"); -Assert.equal(a.toString(), "(4, 4)"); -Assert.equal(b.getPname(), "B"); - -class PointMixCopy extends mixC(PointXY) { - public occupied: boolean = false; - setOccupied(occupied: boolean) { - this.occupied = occupied; - } - getOccupied() { - return this.occupied; - } -} -var c = new PointMixCopy(5, 5); -c.setPname("C"); -c.setOccupied(true); -Assert.equal(c.toString(), "(5, 5)"); -Assert.equal(c.getPname(), "C"); -Assert.equal(c.getOccupied(), true); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_mix_in_classes/support_for_mix_in_classes_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_mix_in_classes/support_for_mix_in_classes_2.ts deleted file mode 100644 index 3a83122940..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_mix_in_classes/support_for_mix_in_classes_2.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - mixin classes can constrain the types of classes they can mix into by specifying a construct signature return type in the constraint for the type parameter. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -class Color { - public Red: number; - public Green: number; - public Blue: number; - constructor(red: number = 0x00, green: number = 0x00, blue: number = 0x00) { - this.Red = red; - this.Green = green; - this.Blue = blue; - } - toString() { - return 'Color(' + this.Red + ', ' + this.Green + ', ' + this.Blue + ')'; - } -} -type MIXTypeCopy = new (...members: any[]) => T; -function ColorClassMix>(BC: T) { - return class extends BC { - getColors(): [number, number, number] { - return [this.Red, this.Green, this.Blue]; - } - } -} - -const ColorMix = ColorClassMix(Color); -var color = new ColorMix(255, 255, 255); -Assert.equal(color.toString(), "Color(255, 255, 255)"); -Assert.equal(color.getColors()[0], 255); - diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_new.target/support_for_new.target_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_new.target/support_for_new.target_1.ts deleted file mode 100644 index 2d348065ea..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_new.target/support_for_new.target_1.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the new.target meta-property is new syntax introduced in ES2015. When an instance of a constructor is created via new, the value of new.target is set to be a reference to the constructor function initially used to allocate the instance. - if a function is called rather than constructed via new, new.target is set to undefined. - options: - lib: es2015 - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -class A { - public cname: string; - constructor() { - this.cname = new.target.name; - } -} - -class B extends A { constructor() { super(); } } - -var na = new A(); -Assert.equal(na.cname, "A"); -var nb = new B(); -Assert.equal(nb.cname, "B"); - -class C { - public data: any; - constructor() { - this.data = new.target; - } -} -class D extends C { constructor() { super(); } } - -var nc = new C(); -Assert.equal(nc.data.name, "C"); -var nd = new D(); -Assert.equal(nd.data.name, "D"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_new.target/support_for_new.target_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_new.target/support_for_new.target_2.ts deleted file mode 100644 index bce50c3003..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.2/support_for_new.target/support_for_new.target_2.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the new.target meta-property is new syntax introduced in ES2015. When an instance of a constructor is created via new, the value of new.target is set to be a reference to the constructor function initially used to allocate the instance. - if a function is called rather than constructed via new, new.target is set to undefined. - options: - lib: es2015 - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -var gstr: string = ""; -function newTarget(): void { - if (new.target === undefined) { - gstr = "The function is called without \"new\""; - } else { - gstr = "The function is called with \"new\""; - } -} -newTarget(); -var ntf1: string = gstr; -Assert.equal(ntf1, "The function is called without \"new\""); - -new (newTarget as any)(); -var ntf2: string = gstr; -Assert.equal(ntf2, "The function is called with \"new\""); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.3/async_iteration/async_generators/async_generators.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.3/async_iteration/async_generators/async_generators.ts deleted file mode 100644 index 95369ceef3..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.3/async_iteration/async_generators/async_generators.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the Async Iteration proposal introduces "Async Generators", which are async functions that also can be used to yield partial computation results. Async Generators can also delegate calls via yield* to either an iterable or async iterable. - as with Generators, Async Generators can only be function declarations, function expressions, or methods of classes or object literals. Arrow functions cannot be Async Generators. Async Generators require a valid, global Promise implementation (either native or an ES2015-compatible polyfill), in addition to a valid Symbol.asyncIterator reference. - options: - lib: es2018 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -async function* fun() { - let i = 0; - let c = 0; - yield* [0, 0, 0, 0]; - while (true) { - if (i % 3 == 0) { - yield c -= 1; - } else { - yield c += 1; - } - i++; - if (i > 30) { - break; - } - } -} -function newArray() { - let arr: number[] = [0, 0, 0, 0]; - let i = 0; - let c = 0; - while (true) { - if (i % 3 == 0) { - c -= 1; - arr[i + 4] = c; - } else { - c += 1; - arr[i + 4] = c; - } - i++; - if (i > 30) { - break; - } - } - return arr; -} -let arr = fun(); -async function showAsyncGenerator(arr: AsyncGenerator) { - let i = 0; - for await (let x of arr) { - Assert.equal(x as number, arr2[i++]); - } -} -let arr2 = newArray(); -showAsyncGenerator(arr); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.3/async_iteration/async_iterators/async_iterators_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.3/async_iteration/async_iterators/async_iterators_1.ts deleted file mode 100644 index 53ba33954d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.3/async_iteration/async_iterators/async_iterators_1.ts +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the Async Iteration introduces an AsyncIterator, which is similar to Iterator. The difference lies in the fact that the next, return, and throw methods of an AsyncIterator return a Promise for the iteration result, rather than the result itself. - this allows the caller to enlist in an asynchronous notification for the time at which the AsyncIterator has advanced to the point of yielding a value. - options: - lib: es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function createAsyncInterator(arr: any[]): AsyncIterator { - let index = 0; - let len = arr.length; - return { - async next() { - return new Promise((resolve, reject) => { - if (index < len) { - resolve({ value: arr[index++], done: false }); - } else { - resolve({ value: undefined, done: true }); - } - }); - }, - }; -} - -let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]; - -async function exp(arr: any[]) { - let asy = createAsyncInterator(arr); - let i = 0; - let fg; - while (true) { - if (fg == true) { - break; - } - await asy.next().then((v) => { - if (v.done == true) { - fg = true; - } - Assert.equal(v.value, arr[i++]); - return; - }); - } -} -exp(arr); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.3/async_iteration/async_iterators/async_iterators_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.3/async_iteration/async_iterators/async_iterators_2.ts deleted file mode 100644 index 5ffde8c1a8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.3/async_iteration/async_iterators/async_iterators_2.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - an object that supports async iteration is said to be "iterable" if it has a Symbol.asyncIterator method that returns an AsyncIterator object. - options: - lib: es2018 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -async function asc(arr: any[]) { - let i = 0; - for await (let x of arr) { - Assert.equal(x, arr[i]); - i++ - } -} -let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]; -asc(arr); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_1.ts deleted file mode 100644 index d62a1d01cc..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_1.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - es2015 also introduced "Generators", which are functions that can be used to yield partial computation results via the Iterator interface and the yield keyword. - options: - lib: es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function* generators() { - var i = 0; - while (true) { - yield i += 3; - if (i > 33) { - break; - } - } -} -let gen = generators(); -let c = 0; -while (true) { - let next = gen.next(); - if (next.done == true) { - break; - } - Assert.equal(next.value, c += 3); -} diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_2.ts deleted file mode 100644 index 5a529605fb..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/generators/generators_2.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - generators can also internally delegate calls to another iterable through yield *. - options: - lib: es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let arr2 = ["A", "B", "C", "D", "E", "F"]; -function* generators2() { - yield* arr2; - let s = arr2[arr2.length - 1].charCodeAt(0); - for (let i = 0; i < 20; i++) { - s++; - yield String.fromCharCode(s); - } -} -let gen2 = generators2(); -let c = 65; -while (true) { - let next = gen2.next(); - if (next.done == true) { - break; - } - Assert.equal(next.value, String.fromCharCode(c++)); -}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_1.ts deleted file mode 100644 index ea70a82050..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_1.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - es2015 introduced Iterator, which is an object that exposes three methods, next, return, and throw. - options: - lib: es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function createInterator(arr: any[]): Iterator { - let index = 0; - let len = arr.length; - return { - next() { - return index < len - ? { value: arr[index++], done: false } - : { value: undefined, done: true } - } - } -} -var arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]; -var iterator = createInterator(arr); -let i = 0; -while (true) { - let n = iterator.next(); - if (n.done == true) { - break; - } - Assert.equal(n.value, arr[i++]); -}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_2.ts deleted file mode 100644 index 1b4b1622d2..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generators_and_iteration_for_ES5,ES3/iterators/iterators_2.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - es2015 introduced Iterator, which is an object that exposes three methods, next, return, and throw. - options: - lib: es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let arr: string[] = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]; -let iter = arr[Symbol.iterator](); -let i = 0; -while (true) { - let n = iter.next(); - if (n.done == true) { - break; - } - Assert.equal(n.value, arr[i++]); -} -i = 0; -for (let x of arr) { - Assert.equal(x, arr[i++]); -}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generic_parameter_defaults/generic_parameter_defaults_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generic_parameter_defaults/generic_parameter_defaults_1.ts deleted file mode 100644 index 81461a48fd..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generic_parameter_defaults/generic_parameter_defaults_1.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - typescript 2.3 adds support for declaring defaults for generic type parameters. - a type parameter is deemed optional if it has a default.Required type parameters must not follow optional type parameters. - when specifying type arguments, you are only required to specify type arguments for the required type parameters. Unspecified type parameters will resolve to their default types.If a default type is specified and inference cannot choose a candidate, the default type is inferred. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -type ALL = string | number | boolean | object; -function fun1(v: V, t: T) { - return JSON.stringify({ v, t }); -} -let f1 = fun1(1, [1, 0]); -Assert.equal(f1, "{\"v\":1,\"t\":[1,0]}") - -let f2 = fun1("A", 0); -Assert.equal(f2, "{\"v\":\"A\",\"t\":0}"); - -let f3 = fun1("A", [1, "A"]); -Assert.equal(f3, "{\"v\":\"A\",\"t\":[1,\"A\"]}"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generic_parameter_defaults/generic_parameter_defaults_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generic_parameter_defaults/generic_parameter_defaults_2.ts deleted file mode 100644 index de7f4fb640..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generic_parameter_defaults/generic_parameter_defaults_2.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - typescript 2.3 adds support for declaring defaults for generic type parameters. - a class or interface declaration that merges with an existing class or interface declaration may introduce a default for an existing type parameter. - a class or interface declaration that merges with an existing class or interface declaration may introduce a new type parameter as long as it specifies a default. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -class CA{ - ca0: V; - ca1: T; - ca2: U; - constructor(ca0: V, ca1: T, ca2: U) { this.ca0 = ca0; this.ca1 = ca1; this.ca2 = ca2; } - creatOBJ() { - let a = this.ca0; - let b = this.ca1; - let c = this.ca2; - return { a, b, c }; - } - toJSON() { - return JSON.stringify(this.creatOBJ()); - } -} -class CCA extends CA{ } -let cca1 = new CCA(0, [0, 0], "[0]"); -Assert.equal(cca1.toJSON(), "{\"a\":0,\"b\":[0,0],\"c\":\"[0]\"}"); -let cca2 = new CCA("A", ["A"], [["A"], ["B"]]); -Assert.equal(cca2.toJSON(), "{\"a\":\"A\",\"b\":[\"A\"],\"c\":[[\"A\"],[\"B\"]]}"); - -interface IB { - ia: V; - ib: T; - ic: U; -} -interface CIB extends IB { } -let cib1: CIB = { ia: 0, ib: [0], ic: [[0], [1, 2]] }; -Assert.equal(JSON.stringify(cib1), "{\"ia\":0,\"ib\":[0],\"ic\":[[0],[1,2]]}"); -let cib2: CIB = { ia: "A", ib: ["A", "B"], ic: [["A"], ["B", "C"]] }; -Assert.equal(JSON.stringify(cib2), "{\"ia\":\"A\",\"ib\":[\"A\",\"B\"],\"ic\":[[\"A\"],[\"B\",\"C\"]]}"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generic_parameter_defaults/generic_parameter_defaults_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generic_parameter_defaults/generic_parameter_defaults_3.ts deleted file mode 100644 index 2fcb7540ac..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.3/generic_parameter_defaults/generic_parameter_defaults_3.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - typescript 2.3 adds support for declaring defaults for generic type parameters. - default types for a type parameter must satisfy the constraint for the type parameter, if it exists. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -interface Length { - length: number; -} -type STRS = string | string[] -function fun3(s: T) { - return s.length; -} -Assert.equal(fun3("ABC"), 3); -Assert.equal(fun3([1, 2, 3, 4]), 4); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/1_dynamic_import_expressions/1_dynamic_import_expressions.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/1_dynamic_import_expressions/1_dynamic_import_expressions.ts deleted file mode 100644 index fd34d118ee..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/1_dynamic_import_expressions/1_dynamic_import_expressions.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: Dynamic import expressions are a new feature and part of ECMAScript that allows users to asynchronously request a module at any arbitrary point in your program. -module: ESNext -isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' -async function func(x: number, y: number): Promise { - const add = await import("./lib.js"); - const sum = add.add(x, y); - return sum; -} - -func(10, 20).then((sum) => { - Assert.equal(30, sum); -}); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/1_dynamic_import_expressions/lib.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/1_dynamic_import_expressions/lib.ts deleted file mode 100644 index 8fca6c85ac..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/1_dynamic_import_expressions/lib.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -export function add(x: number, y: number) { - return x + y; -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/2_string_enums/string_enums_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/2_string_enums/string_enums_1.ts deleted file mode 100644 index c4b851149f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/2_string_enums/string_enums_1.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: TypeScript 2.4 now allows enum members to contain string initializers. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -enum Option { - END = "End", - START = "START", - STOP = "STOP" -}; - -Assert.equal(Option.END, "End"); -Assert.equal(Option.START, "START"); -Assert.equal(Option.STOP, "STOP"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts deleted file mode 100644 index e9b28a447b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/3_improved_inference_for_generics/3_improved_inference_for_generics.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: TypeScript 2.4 introduces a few wonderful changes around the way generics are inferred. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -function func(a: number, b: string) { - return a + b; -} -Assert.isString(func(10, 'a')); - -type T1 = (x: T, y: U) => [T, U]; -type T2 = (x: T, y: T) => [T, T]; -function f(a: T1, b: T2) { - b = a; - Assert.isTrue(b == a); -} - -let a: T1 = function funA(x: T, y: U): [T, U] { - return [x, y]; -} -let b: T2 = function funB(x: T, y: T): [T, T] { - return [x, y]; -} -f(a, b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/4_strict_contravariance_for_callback_parameters/4_strict_contravariance_for_callback_parameters.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/4_strict_contravariance_for_callback_parameters/4_strict_contravariance_for_callback_parameters.ts deleted file mode 100644 index e9db170dbe..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/4_strict_contravariance_for_callback_parameters/4_strict_contravariance_for_callback_parameters.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: TypeScript 2.4 introduces tightens this up when relating two callback types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -function f(arg: U): U{ - if (typeof arg === 'number') { - return arg; - } - return arg; -} -function func(a: T, callback: (arg: U) => U){ - return callback(a); -} - -let a = func(5, f); -let b = func('a', f); -Assert.isNumber(a); -Assert.isString(b); -b = a; -Assert.equal(a, b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/5_weak_type_detection/5_weak_type_detection.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.4/5_weak_type_detection/5_weak_type_detection.ts deleted file mode 100644 index 3b27b4915e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.4/5_weak_type_detection/5_weak_type_detection.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: TypeScript 2.4 introduces the concept of "weak types". Any type that contains nothing but a set of all-optional properties is considered to be weak. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -interface I { - month?: string; - type?: number; - value?: number; -} - -function check(i: I) { - if (i !== undefined && i !== null) { - return true; - } else { - return false; - } -} - -const obj1 = { - month: "January" -}; -Assert.isTrue(check(obj1)); - - -const obj2: { - [index: string]: { mem: string }; -} = {}; -Assert.isTrue(check(obj2)); - -const obj3 = { - str: "string", - trueOrFalse: true -} as I; -Assert.isTrue(check(obj3)); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.5/1_optional_catch_clause_variables.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.5/1_optional_catch_clause_variables.ts deleted file mode 100644 index 9584bf048c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.5/1_optional_catch_clause_variables.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: TypeScript 2.5 implements a new ECMAScript feature that allows users to omit the variable in catch clauses. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../suite/assert.js' - -function func(str: string) { - try { - return JSON.parse(str); - } catch { - return str + " is Error JSON"; - } -} - -let arrjson: string = '[1,3,5]'; -let arr = func(arrjson); -Assert.equal(arr[0], 1); -Assert.equal(arr[1], 3); -Assert.equal(arr[2], 5); - -let str: string = 'string'; -Assert.equal(func(str), 'string is Error JSON'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.6/suppress_errors_in_ts_files_using_ts_ignore_comments/suppress_errors_in_ts_files_using_ts_ignore_comments.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.6/suppress_errors_in_ts_files_using_ts_ignore_comments/suppress_errors_in_ts_files_using_ts_ignore_comments.ts deleted file mode 100644 index 455e574f5b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.6/suppress_errors_in_ts_files_using_ts_ignore_comments/suppress_errors_in_ts_files_using_ts_ignore_comments.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A // @ts-ignore comment suppresses all errors that originate on the following line. - It is recommended practice to have the remainder of the comment following @ts-ignore explain which error is being suppressed. - Please note that this comment only suppresses the error reporting, and we recommend you use this comments very sparingly. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -function addString(str: string, str2: string): string { - str += ""; - str2 += ""; - return str + str2; -} -// @ts-ignore -let n: number = addString(114, 514); -Assert.isString(n); -Assert.equal(n, "114514"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/10_numeric_separators/10_numeric_separators.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/10_numeric_separators/10_numeric_separators.ts deleted file mode 100644 index 4e1a4e3a17..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/10_numeric_separators/10_numeric_separators.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: TypeScript 2.7 brings support for ES Numeric Separators. Numeric literals can now be separated into segments using _. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -const num999 = 999_999_999; -const xnum = 0xFF_00_FF; -const bnum = 0b10_01; - -Assert.equal(999999999, num999); -Assert.equal(0xFF00FF, xnum); -Assert.equal(9, bnum); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/1_constant_named_properties/1_constant_named_properties.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/1_constant_named_properties/1_constant_named_properties.ts deleted file mode 100644 index 417bd39528..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/1_constant_named_properties/1_constant_named_properties.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: TypeScript 2.7 adds support for declaring const-named properties on types including ECMAScript symbols. -module: ESNext -isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" - -const sym = Symbol(); -interface I{ - [sym](func: Function): Function; -} -class C implements I{ - [sym](func: Function) { - return func; - } -} -let f = new C(); -Assert.isFunction(f[sym]); - - -const num = 5; -const str = 'a'; - -let obj = { - [num]: 5, - [str]: "string" -} - -let para1 = obj[num]; -let para2 = obj[str]; -Assert.isNumber(para1); -Assert.isString(para2); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/2_unique_symbol/2_unique_symbol.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/2_unique_symbol/2_unique_symbol.ts deleted file mode 100644 index cf3251ec6c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/2_unique_symbol/2_unique_symbol.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: To enable treating symbols as unique literals a new type unique symbol is available. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -const usym1: unique symbol = Symbol(); -const usym2: unique symbol = Symbol.for("Bar"); - -let t1: typeof usym1 = usym1; -let t2: typeof usym2 = usym2; - -class C { - static readonly StaticUsym: unique symbol = Symbol(); -} - -Assert.isTrue('symbol' === typeof t1); -Assert.isTrue('symbol' === typeof t2); -Assert.isTrue('symbol' === typeof C.StaticUsym); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/3_strict_class_initialization/3_strict_class_initialization.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/3_strict_class_initialization/3_strict_class_initialization.ts deleted file mode 100644 index f47984ee0d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/3_strict_class_initialization/3_strict_class_initialization.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: TypeScript 2.7 introduces a new flag called strictPropertyInitialization. This flag performs checks to ensure that each instance property of a class gets initialized in the constructor body, or by a property initializer. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -class C { - t01: number = 1; - t02!: number; - t03 = "hello"; - t04: boolean = true; - - constructor() { - this.initialize(); - } - - initialize() { - this.t02 = 2; - } -} - -let c = new C(); -Assert.equal(1, c.t01); -Assert.equal(2, c.t02); -Assert.equal('hello', c.t03); -Assert.isTrue(c.t04); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/4_definite_assignment_assertions/4_definite_assignment_assertions.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/4_definite_assignment_assertions/4_definite_assignment_assertions.ts deleted file mode 100644 index 20eb817087..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/4_definite_assignment_assertions/4_definite_assignment_assertions.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The definite assignment assertion is a feature that allows a ! to be placed after instance property and variable declarations to relay to TypeScript that a variable is indeed assigned for all intents and purposes, even if TypeScript's analyses cannot detect so. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -function func(arg: number | undefined) { - let sum = arg! + arg!; - return sum; -} -let num = func(5); -Assert.isFalse(Number.isNaN(num)); - -let x: number; -let add = x! + x!; -Assert.isTrue(Number.isNaN(add)); - -let num1: number; -later1(); -let sum1 = num1! + num1!; -function later1() { - num1 = 5; -} -Assert.equal(sum1, 10); - -let num2!: number; -later2(); -let sum2 = num2 + num2; -function later2() { - num2 = 5; -} -Assert.equal(sum2, 10); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/5_fixed_length_tuples/5_fixed_length_tuples.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/5_fixed_length_tuples/5_fixed_length_tuples.ts deleted file mode 100644 index 4604dd7470..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/5_fixed_length_tuples/5_fixed_length_tuples.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: tuple types now encode their arity into the type of their respective length property. This is accomplished by leveraging numeric literal types, which now allow tuples to be distinct from tuples of different arities. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -interface NSTup extends Array { - 0: number; - 1: string; - length: 2; -} - -const numstr01: NSTup = [1, "string"]; - -interface NS extends Array { - 0: number; - 1: string; -} - -let numstr02: NS = [2, "string"]; -numstr02= [2, "string", 3, "string2"]; - -Assert.equal(numstr01.length, 2); - -Assert.equal(numstr02.length, 4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/6_improved_type_inference_for_object_literals/6_improved_type_inference_for_object_literals.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/6_improved_type_inference_for_object_literals/6_improved_type_inference_for_object_literals.ts deleted file mode 100644 index e4531e8768..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/6_improved_type_inference_for_object_literals/6_improved_type_inference_for_object_literals.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: TypeScript 2.7 improves type inference for multiple object literals occurring in the same context. When multiple object literal types contribute to a union type, we now normalize the object literal types such that all properties are present in each constituent of the union type. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -let obj1 = [{ a: 1, b: 2 }, { a: "abc" }, {}][0]; -obj1.a = 5; -Assert.isNumber(obj1.a); -obj1.a = 'a'; -Assert.isString(obj1.a); -obj1.a = undefined; -Assert.isUndefined(obj1.a); - -obj1.b = 6; -Assert.isNumber(obj1.b); -obj1.b = undefined; -Assert.isUndefined(obj1.b); - -function fun(...args: T[]): T { - return args[1]; -}; -let obj2 = fun({ a: 1, b: 2 }, { a: "abc", b: "ABC" }, {}); - -obj2.a = 5; -Assert.isNumber(obj2.a); -obj2.a = 'a'; -Assert.isString(obj2.a); -obj2.a = undefined; -Assert.isUndefined(obj2.a); - -obj2.b = 6; -Assert.isNumber(obj2.b); -obj2.b = 'b'; -Assert.isString(obj2.b); -obj2.b = undefined; -Assert.isUndefined(obj2.b); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/7_improved_handling/7_improved_handling.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/7_improved_handling/7_improved_handling.ts deleted file mode 100644 index 68cd086851..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/7_improved_handling/7_improved_handling.ts +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 2.7 improves the handling of structurally identical classes in union types and instanceof expressions: - Structurally identical, but distinct, class types are now preserved in union types (instead of eliminating all but one). - Union type subtype reduction only removes a class type if it is a subclass of and derives from another class type in the union. - Type checking of the instanceof operator is now based on whether the type of the left operand derives from the type indicated by the right operand (as opposed to a structural subtype check). - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -class C1{ - num: number; - constructor(num: number) { - this.num = num; - } -} -class C2 extends C1{ - str: string; - constructor(num: number,str:string) { - super(5); - this.num = num; - this.str = str; - } -} -class C3 extends C1{ - boo: boolean; - constructor(num: number,boo:boolean) { - super(6); - this.num = num; - this.boo = boo; - } -} -class C4 extends C1{ - obj: object; - constructor(num: number, obj: object) { - super(7); - this.obj = obj; - this.num = num; - } -} - -let t1 = !true ? new C1(10) : new C2(11, 'a'); -function func1(arg: C1 | C2 | C3 | C4) { - if (arg instanceof C1) { - arg.num = 20; - return arg.num - } - return false; -} -Assert.equal(func1(t1), 20); - -let t2 = !true ? new C2(12, 'b') : new C3(13, false); -function func2(arg: C1 | C2 | C3 | C4) { - if (arg instanceof C3) { - arg.num = 20; - return arg.num - } - return false; -} -Assert.equal(func2(t2), 20); - -let t3 = !true ? new C3(14, true) : new C4(15, { a: 'a' }); -function func3(arg: C1 | C2 | C3 | C4) { - if (arg instanceof C4) { - arg.num = 20; - return arg.num - } - return false; -} -Assert.equal(func3(t3), 20); - - -function func(x: C2 | C3 | C4) { - if (x instanceof C2 ) { - return x.str; - } else if (x instanceof C3) { - return x.boo; - } else { - return x.obj - } -} -Assert.isString(func(new C2(1, 'C2'))); -Assert.isBoolean(func(new C3(2, true))); -Assert.isObject(func(new C4(3, { o: 'obj' }))); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/8_Type_guards_inferred_from_in_operator/8_Type_guards_inferred_from_in_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.7/8_Type_guards_inferred_from_in_operator/8_Type_guards_inferred_from_in_operator.ts deleted file mode 100644 index 5390cca33a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.7/8_Type_guards_inferred_from_in_operator/8_Type_guards_inferred_from_in_operator.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The in operator now acts as a narrowing expression for types. - For a n in x expression, where n is a string literal or string literal type and x is a union type, the “true” branch narrows to types which have an optional or required property n, and the “false” branch narrows to types which have an optional or missing property n. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -type myType = { [T in 'key1' | 'key2' | 'key3']: string }; -let mt: myType = { - key1: 'a', - key2: 'b', - key3: 'c' -} -Assert.isObject(mt); - -interface I1{ - name: string; - age: number; -} -interface I2{ - height: number; -} -let i1: I1 = { - name: 'xiao', - age: 18 -}; -let i2: I2 = { - height: 180 -}; -function func(arg: I1 | I2) { - if ('name' in arg) { - arg.age = 20; - return arg.age; - } - arg.height = 185; - return arg.height; -} -Assert.equal(func(i1), 20); -Assert.equal(func(i2), 185); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/Defaulted_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/Defaulted_declarations.ts deleted file mode 100644 index a52a3eb2cd..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/Defaulted_declarations.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Defaulted declarations - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../suite/assert.js' - -let x; -x = x || 1; -Assert.equal(x, 1); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/IIFEs_as_namespace_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/IIFEs_as_namespace_declarations.ts deleted file mode 100644 index cddb233030..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/IIFEs_as_namespace_declarations.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - IIFEs as namespace declarations - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../suite/assert.js' - -let C:any = (function() { - function C(this:any, net:any):void { - this.x = net; - } - return C; -})(); -let c = new C(1); - -Assert.equal(c.x, 1) \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/Improved_keyof_with_intersection_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/Improved_keyof_with_intersection_types_1.ts deleted file mode 100644 index d4042482d6..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/Improved_keyof_with_intersection_types_1.ts +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - With TypeScript 2.8 keyof applied to an intersection type is transformed to a union of keyof applied to each intersection constituent. - In other words, types of the form keyof (A & B) are transformed to be keyof A | keyof B. This change should address inconsistencies with inference from keyof expressions. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../suite/assert.js" - -type A = { a: string }; -type B = { b: number }; - -type TAB = keyof (A & B); -let tab: TAB; -tab = "a"; -tab = "b"; - -type TTB = keyof (T & B); -let ttb: TTB; -ttb = "b"; -ttb = "valueOf"; - -type TAU = keyof (A & U); -let tau: TAU; -tau = "a"; -tau = "charCodeAt"; - -type TTU = keyof (T & U); -let ttu: TTU; -ttu = "charAt"; -ttu = "toString"; - -type IsEqual = - (() => T extends X ? 1 : 2) extends - (() => T extends Y ? 1 : 2) ? true : false - - -let f1: IsEqual = true; -Assert.isTrue(f1); - -let f2: IsEqual, keyof boolean | keyof B> = true; -Assert.isTrue(f2); - -let f3: IsEqual, keyof A | keyof string> = true; -Assert.isTrue(f3); - -let f4: IsEqual, keyof number | keyof string> = true; -Assert.isTrue(f4); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/Improved_keyof_with_intersection_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/Improved_keyof_with_intersection_types_2.ts deleted file mode 100644 index 77c1f130f2..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/Improved_keyof_with_intersection_types_2.ts +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - With TypeScript 2.8 keyof applied to an intersection type is transformed to a union of keyof applied to each intersection constituent. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../suite/assert.js' - -{ - type myType1 = 'a' | 4; - type myType2 = { str: string }; - interface I { - mem: string; - } - - type TA = keyof (myType1 & myType2); - type TB = keyof (T & myType2); - type TC = keyof (myType1 & U); - type TD = keyof (T & U); - type TE = TB; - type TF = TC; - type TG = TD; - - let a: TA = 'str'; - a = 'toString'; - a = 'valueOf'; - Assert.equal(a, 'valueOf'); - let b: TE = "str"; - b = 'toString'; - b = 'valueOf'; - Assert.equal(b, 'valueOf'); - let c: TF = "str"; - c = 'toString'; - c = 'valueOf'; - Assert.equal(c, 'valueOf'); - let d: TG = "str"; - d = 'toString'; - d = 'valueOf'; - Assert.equal(d, 'valueOf'); - - type T11 = keyof (I & myType2); - type T22 = keyof (T & myType2); - type T33 = keyof (I & U); - type T44 = keyof (T & U); - type T55 = T22; - type T66 = T33; - type T77 = T44; - - let aa: T11 = 'mem'; - aa = 'str'; - Assert.equal(aa, 'str'); - let bb: T55 = 'mem'; - bb = 'str'; - Assert.equal(bb, 'str'); - let cc: T66 = 'mem'; - cc = 'str'; - Assert.equal(cc, 'str'); - let dd: T77 = 'mem'; - dd = 'str'; - Assert.equal(dd, 'str'); - -}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/conditional_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/conditional_types.ts deleted file mode 100644 index ca35f0e50d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/conditional_types.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: > - Conditional Types. -module: ESNext -isCurrent: true - ---*/ - - -import { Assert } from "../../suite/assert.js" - -interface I1{ - str: string; -} -interface I2{ - num: number; -} -type mT = T extends I1 ? boolean : T extends I2 ? number : string; -function func1>(arg: T) { - return arg; -} -Assert.isBoolean(func1(true)); -function func2>(arg: T) { - return arg; -} -Assert.isNumber(func2(5)); -function func3>(arg: T) { - return arg; -} -Assert.isString(func3('a')); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/distributive_conditional_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/distributive_conditional_types.ts deleted file mode 100644 index d0b067b48f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/distributive_conditional_types.ts +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: > - Distributive conditional types -module: ESNext -isCurrent: true ----*/ - - -import { Assert } from "../../suite/assert.js" -type TypeGather = - T extends string ? string : - T extends number ? number : - T extends boolean ? boolean : - T extends undefined ? undefined : - T extends Function ? Function : - object; - - -type TSF = TypeGather void)>; -type TSSA = TypeGather; -type TSANA = TypeGather; - -type GatherValue = { value: T }; -type GatherArray = { array: T[] }; -type Gather = T extends any[] ? GatherArray : GatherValue; - -type TGS = Gather; -type TGNA = Gather; -type TGSNA = Gather; - -let a: TSF = 's'; -let b: TSF = (() => { }); -let c: TSSA = 's'; -let d: TSSA = ['s']; -let e: TSSA = undefined; -let f: TSANA = ['s']; -let g: TSANA = [1]; -let h: TGS = { value: "s" }; -let i: TGNA = { array: [1] }; -let j: TGSNA = { value: "s" }; -let k: TGSNA = { array: [1] }; - -Assert.equal(typeof a, 'string'); -Assert.equal(typeof b, 'function'); -Assert.equal(typeof c, 'string'); -Assert.equal(typeof d, 'object'); -Assert.equal(typeof e, 'undefined'); -Assert.equal(typeof f, 'object'); -Assert.equal(typeof g, 'object'); -Assert.equal(typeof h, 'object'); -Assert.equal(typeof i, 'object'); -Assert.equal(typeof j, 'object'); -Assert.equal(typeof k, 'object'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/filter_union_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/filter_union_types.ts deleted file mode 100644 index 18ba9b10f9..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/filter_union_types.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The distributive property of conditional types can conveniently be used to filter union types - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../suite/assert.js' - -{ - type TA = T extends U ? never : T; - type TB = T extends U ? T : never; - - type T0 = TA; - type T1 = TB; - - let a: T0 = 'b'; - let b: T0 = true; - let c: T1 = 1; - - Assert.equal(typeof a, 'string'); - Assert.equal(typeof b, 'boolean'); - Assert.equal(typeof c, 'number'); -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/improved_control_over_mapped_type_modifiers_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/improved_control_over_mapped_type_modifiers_1.ts deleted file mode 100644 index bf24b3e123..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/improved_control_over_mapped_type_modifiers_1.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 2.8 adds the ability for a mapped type to either add or remove a particular modifier. - Specifically, a readonly or ? property modifier in a mapped type can now be prefixed with either + or - to indicate that the modifier should be added or removed. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../suite/assert.js"; - -type RU = { +readonly [key in "A" | "B" | "C"]-?: number }; -type NR = { -readonly [key in 1 | 2 | 3]+?: string }; - -let ru: RU = { 'A': 1, 'B': 2, 'C': 3 }; -let nr: NR = { 1: 'A', 3: 'C' }; -nr[1] = 'Z'; -Assert.equal(JSON.stringify(ru), '{"A":1,"B":2,"C":3}'); -Assert.equal(JSON.stringify(nr), '{"1":"Z","3":"C"}'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/improved_control_over_mapped_type_modifiers_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/improved_control_over_mapped_type_modifiers_2.ts deleted file mode 100644 index 3813580fec..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/improved_control_over_mapped_type_modifiers_2.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Using this ability, lib.d.ts now has a new Required type. - This type strips ? modifiers from all properties of T, thus making all properties required. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../suite/assert.js"; - -type ABCU = { 'A'?: number, 'B'?: number, 'C'?: number, 'D'?: number }; -type ABC = Required; - -let abcu: ABCU = { 'C': 3 }; -let abc: ABC = { A: 1, B: 2, C: 3, D: 4 }; -Assert.equal(JSON.stringify(abcu), '{"C":3}'); -Assert.equal(JSON.stringify(abc), '{"A":1,"B":2,"C":3,"D":4}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/predefined_conditional_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/predefined_conditional_types.ts deleted file mode 100644 index bbf58c8b5f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/predefined_conditional_types.ts +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Predefined conditional types - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../suite/assert.js' - -{ - - type TypeA = Exclude<"a" | "b" | "c" | "d", "a" | "c" | "f">; - - type TypeB = Extract<"a" | "b" | "c" | "d", "a" | "c" | "f">; - - - type TypeC = Exclude void), Function>; - - type TypeD = Extract void), Function>; - - function fun(s: string) { - return { a: 1, b: s }; - } - - class C { - x = 0; - y = 0; - } - - - type TypeE = ReturnType; - - type TypeF = InstanceType; - - let a: TypeA = "b"; - let b: TypeA = "d"; - let c: TypeB = "a"; - let d: TypeB = "c"; - let e: TypeC = "c"; - let f: TypeD = ((): string => { return 's' }); - let x: TypeE = { a: 1, b: 's' } - let y: TypeF = { x: 1, y: 2 } - - Assert.equal(a, 'b'); - Assert.equal(b, 'd'); - Assert.equal(c, 'a'); - Assert.equal(d, 'c'); - Assert.equal(e, 'c'); - Assert.equal(typeof f, "function"); - Assert.equal(x.a, 1); - Assert.equal(y.x, 1); - - type G = number[] | number | null | undefined - type TypeG = NonNullable; - let g: TypeG; - g = [0, 1, 2]; - Assert.equal(g.length, 3); - g = -1; - Assert.equal(g, -1); -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/prototype_assignment.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/prototype_assignment.ts deleted file mode 100644 index 4f041e19a8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/prototype_assignment.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - You can assign an object literal directly to the prototype property. Individual prototype assignments still work too. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../suite/assert.js" - -let q: number = 0; -let c: any = function (p: number) { q = p; } -c.sub = { - m() { - Assert.equal(q, 5); - } -} -c(5); -c.sub.m(); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/type_inference.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.8/type_inference.ts deleted file mode 100644 index acbaa22bfe..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.8/type_inference.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Type inference in conditional types - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../suite/assert.js' - -{ - type Type00 = - T extends (infer U)[] ? U : - T extends (...args: any[]) => infer U ? U : - T extends Promise ? U : - T; - - type TS = Type00; - type TSA = Type00; - type TF = Type00<() => string>; - type TPS = Type00>; - type TTPS = Type00[]>>; - - let a: TS = 's'; - let b: TSA = 's'; - let c: TF = 's'; - let d: TPS = 's'; - let e: TTPS = 's'; - - Assert.equal(typeof a, 'string'); - Assert.equal(typeof b, 'string'); - Assert.equal(typeof c, 'string'); - Assert.equal(typeof d, 'string'); - Assert.equal(typeof e, 'string'); - - type F = T extends { a: infer U, b: infer U } ? U : never; - type TF1 = F<{ a: string, b: string }>; - type TF2 = F<{ a: string, b: number }>; - - let f: TF1 = 's'; - let g: TF2 = 's'; - let h: TF2 = 1; - - Assert.equal(typeof f, 'string'); - Assert.equal(typeof g, 'string'); - Assert.equal(typeof h, 'number'); -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/generic_type_arguments_in_tt/generic_type_arguments_in_tt.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/generic_type_arguments_in_tt/generic_type_arguments_in_tt.ts deleted file mode 100644 index e635600b33..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/generic_type_arguments_in_tt/generic_type_arguments_in_tt.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: TypeScript 2.9 allows passing generic type arguments to tagged template strings. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -let jianbing = "jianbing" -function kitchen(xx: TemplateStringsArray, value: string) { - Assert.equal(2, xx.length); -} -kitchen`lunch_is${jianbing}!`; -function f(yy: TemplateStringsArray, args: T): T { - Assert.equal(2, yy.length); - return args; -}; -let a = f `lunch_is${jianbing}!`; -Assert.equal("jianbing", a); -let b = f `lunch_is${"dessert"}!`; -Assert.equal("dessert", b); -Assert.equal("dessert", b); -let c = f`sss${2}`; -Assert.equal(2, c); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/import_types/import_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/import_types/import_types.ts deleted file mode 100644 index 7306d9cd8d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/import_types/import_types.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Modules can import types declared in other modules. But non-module global scripts cannot access types declared in modules. Enter import types. - Using import("mod") in a type annotation allows for reaching in a module and accessing its exported declaration without importing it. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -function func1(i: import("../module").I) { - Assert.equal(5, `${i.num}`); - Assert.equal(5, i.num); -} -let i: import("../module.js").I = { - num: 5 -} -func1(i); -function func(p: import("../module").C) { - Assert.equal('aa', `${p.str}`); - Assert.equal('aa', p.str); -} -let p: import("../module.js").C = { - str: "aa", -}; -func(p); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/module.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/module.ts deleted file mode 100644 index d38ce3a37c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/module.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -export declare class C { - str: string; -}; - -export declare interface I{ - num: number; -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts deleted file mode 100644 index 52f705f74c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_1.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 2.9 adds support for number and symbol named properties in index types and mapped types. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -const str = "x"; -const num = 1; -const sym = Symbol(); - -type Obj = { - 2: string; - [str]: string; - [num]: string; - [sym]: string; -} -type T1 = keyof Obj; -let x1: T1 = "x"; -let x2: T1 = sym; -let x3: T1 = 1; -let x4: T1 = 2; -Assert.equal("x", x1); -Assert.isString(x1); -Assert.equal(sym, x2); -Assert.isSymbol(x2); -Assert.equal(1, x3); -Assert.isNumber(x3); -Assert.equal(2, x4); -Assert.isNumber(x4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts deleted file mode 100644 index 3f67dfe55b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/2.9/support_number_and_symbol_nam/1_support_number_and_symbol_nam_2.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 2.9 adds support for number and symbol named properties in index types and mapped types. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -const str = 'x' -const num = 1 -const sym = Symbol() -type Objs1 = { - [str]: string, - [num]: number, - [sym]: symbol -} -type Types = { - [P in keyof T]: T[P] -} -let objs2: Types = { - x: 'xx', - 1: 11, - [sym]: Symbol() -} -Assert.isString(objs2[str]); -Assert.isNumber(objs2[num]); -Assert.isSymbol(objs2[sym]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/new_unknown_top_type/new_unknown_top_type.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/new_unknown_top_type/new_unknown_top_type.ts deleted file mode 100644 index d13540ea67..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/new_unknown_top_type/new_unknown_top_type.ts +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - typescript 3.0 introduces a new top type unknown. unknown is the type-safe counterpart of any. - anything is assignable to unknown, but unknown isn't assignable to anything but itself and any without a type assertion or a control flow based narrowing. - likewise, no operations are permitted on an unknown without first asserting or narrowing to a more specific type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -type T1 = unknown & undefined; -let t1: T1 = undefined; -Assert.isUndefined(t1); -type T2 = unknown & string; -let t2: T2 = 'a'; -Assert.isString(t2); -type T3 = unknown | undefined; -let t3: T3 = undefined; -Assert.isUndefined(t3); -type T4 = unknown | null | undefined; -let t4: T4 = null; -t4 = undefined; -Assert.isUndefined(t4); -type T5 = unknown | string; -let t5: T5 = 'a'; -Assert.isString(t5); -type T6 = T & {}; -let t6: T6 = { arg: 'arg' }; -Assert.isObject(t6); -type T7 = T | {}; -let t7: T7 = 10; -t7 = {}; -Assert.isObject(t7); -type T8 = T & unknown; -let t8: T8 = 10; -Assert.isNumber(t8); -type T9 = T | unknown; -let t9: T9 = 10; -Assert.isNumber(t9); -type T10 = unknown extends T ? true : false; -let t10: T10 = false; -Assert.isFalse(t10); -type T11 = T extends unknown ? true : false; -let t11: T11 = true; -Assert.isTrue(t11); -type T12 = never extends T ? true : false; -let t12: T12 = true; -Assert.isTrue(t12); -type T13 = T extends never ? true : false; -let t13: T13 = false; -Assert.isFalse(t13); -function func1(x: unknown): unknown { - x = 10; - return x; -} -Assert.equal(func1(0), 10); -function func2(x: unknown) { - return typeof x; -} -Assert.equal(func2("N"), "string"); -function func3(x: unknown) { - if (x instanceof Error) { - return 0; - } - return false; -} -let e: Error = Error(); -Assert.isNumber(func3(e)); -type T14 = { [P in keyof T]: number }; -type T15 = T14; -type T16 = T14; -let t15: T15 = {}; -Assert.isObject(t15); -let t16: T16 = {}; -Assert.isObject(t16); -function func4(pAny: any, pundefined: undefined, pT: T) { - let x: unknown; - x = 123; - Assert.isNumber(x); - x = "hello"; - Assert.isString(x); - x = [1, 2, 3]; - x = new Error(); - x = x; - x = pAny; - x = pundefined; - x = pT; -} -func4(1024, undefined, "A"); -function fun5(x: unknown) { - let v: unknown = x; - return v; -} -Assert.equal(fun5(1024), 1024); -function fun6() { - let a: unknown; - let b = a; - b = 2; - return b; -} -Assert.equal(fun6(), 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts deleted file mode 100644 index 224eb8e721..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Optional elements in tuple types , Rest elements in tuple types - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -let o1:[number, ...string[]] = [1, '1', '2'] -let o2:[number, ...string[]] = [1, '1', '2', '3'] -Assert.equal(o1.length, 3) -Assert.equal(o2.length, 4) - -let o3: [string, string?, number?] -o3 = ['test', "hello", 1]; -Assert.equal(o3.length, 3) -o3 = ['test', "hello"]; -Assert.equal(o3.length, 2) -o3 = ['test']; -Assert.equal(o3.length, 1) - diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/reference_lib/reference_lib.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/reference_lib/reference_lib.ts deleted file mode 100644 index 8f4d332536..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/reference_lib/reference_lib.ts +++ /dev/null @@ -1,26 +0,0 @@ -/// -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript adds a new triple-slash-reference directive (/// ), allowing a file to explicitly include an existing built-in lib file. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js"; -let sym: symbol = Symbol("es2015"); -Assert.isSymbol(sym); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts deleted file mode 100644 index 3ca47e82df..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Rest parameters with tuple types - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -function test1(...ar:[string,number,boolean]):number { - return 0 -} -function test2(ar:string,ar1: number,ar2:boolean):number { - return 1 -} - -Assert.equal(test1("11",2,true), 0); -Assert.equal(test2("11",2,true), 1); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/generic_rest_parameters/generic_rest_parameters.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/generic_rest_parameters/generic_rest_parameters.ts deleted file mode 100644 index f64b88960f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/generic_rest_parameters/generic_rest_parameters.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - a rest parameter is permitted to have a generic type that is constrained to an array type, and type inference can infer tuple types for such generic rest parameters. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function fun1(f: (x: T, ...args: U) => V): (...args: U) => V { - function f2(...args: U) { let json = JSON.stringify(args); return json as unknown as V; } - return f2; -}; -function fun2(x: number, y: string, z: boolean): string { - let a: any[] = [x, y, z]; - let json = JSON.stringify(a); - return json; -} -let a = fun2(5, "A", true); -let ff1 = fun1(fun2); -let b = ff1("B", true); -let ff2 = fun1(ff1); -let c = ff2(true); -let ff3 = fun1(ff2); -let d = ff3(); -Assert.equal(a, "[5,\"A\",true]"); -Assert.equal(b, "[\"B\",true]"); -Assert.equal(c, "[true]"); -Assert.equal(d, "[]"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts deleted file mode 100644 index 7dd6d242cc..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/optional_elements_in_tuple_types/optional_elements_in_tuple_types.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - tuple types now permit a ? postfix on element types to indicate that the element is optional.In strictNullChecks mode, a ? modifier automatically includes undefined in the element type, similar to optional parameters. - a tuple type permits an element to be omitted if it has a postfix ? modifier on its type and all elements to the right of it also have ? modifiers. - The length property of a tuple type with optional elements is a union of numeric literal types representing the possible lengths. For example, the type of the length property in the tuple type [number, string?, boolean?] is 1 | 2 | 3. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let opt: [number, string?, boolean?, number[]?]; -opt = [1024, "str", true, [1, 2]]; -Assert.equal(JSON.stringify(opt), "[1024,\"str\",true,[1,2]]"); -Assert.equal(opt.length, 4); -opt = [1024, "str", true]; -Assert.equal(JSON.stringify(opt), "[1024,\"str\",true]"); -Assert.equal(opt.length, 3); -opt = [1408, "N"]; -Assert.equal(JSON.stringify(opt), "[1408,\"N\"]"); -Assert.equal(opt.length, 2); -opt = [0]; -Assert.equal(JSON.stringify(opt), "[0]"); -Assert.equal(opt.length, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_elements_in_tuple_types/rest_elements_in_tuple_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_elements_in_tuple_types/rest_elements_in_tuple_types.ts deleted file mode 100644 index 447825ad5a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_elements_in_tuple_types/rest_elements_in_tuple_types.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the last element of a tuple type can be a rest element of the form ...X, where X is an array type. A rest element indicates that the tuple type is open-ended and may have zero or more additional elements of the array element type. - the type of the length property of a tuple type with a rest element is number. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function fun1(...args: T): T { - return args; -} -function fun2() { - let arr: number[] = []; - for (let i = 0; i <= 10; i++) { - arr.push(i); - } - return arr; -} -const numbers: number[] = fun2(); -const t1 = fun1("AAA", 1, true); -const t2 = fun1("BBB", ...numbers); -const t3 = ["A", true, ...numbers, false]; -Assert.equal(JSON.stringify(t1), "[\"AAA\",1,true]"); -Assert.equal(JSON.stringify(t2), "[\"BBB\",0,1,2,3,4,5,6,7,8,9,10]"); -Assert.equal(JSON.stringify(t3), "[\"A\",true,0,1,2,3,4,5,6,7,8,9,10,false]"); -Assert.isNumber(t1.length); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts deleted file mode 100644 index 23c9f57e85..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/rest_parameters_with_tuple_types/rest_parameters_with_tuple_types.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - when a rest parameter has a tuple type, the tuple type is expanded into a sequence of discrete parameters. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function rfun1(a: string, b: number, c: boolean, ...v: [number, string, boolean]) { - return { number: v[0], string: v[1], boolean: v[2] }; -} -function rfun2(a: string, b: number, c: boolean, v1: number, v2: string, v3: boolean) { - return { number: v1, string: v2, boolean: v3 }; -} -var r1 = rfun1("a", 1, true, 1, "rfun", true); -var r2 = rfun2("a", 1, true, 1, "rfun", true); -var jr1 = JSON.stringify(r1); -var jr2 = JSON.stringify(r2); -Assert.equal(jr1, jr2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/spread_expressions_with_tuple_types/spread_expressions_with_tuple_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/spread_expressions_with_tuple_types/spread_expressions_with_tuple_types.ts deleted file mode 100644 index 532a39263a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.0/tuples_in_rest_parameters_and_spread_expressions/spread_expressions_with_tuple_types/spread_expressions_with_tuple_types.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - when a function call includes a spread expression of a tuple type as the last argument, the spread expression corresponds to a sequence of discrete arguments of the tuple element types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function fun1(...v: [number, string, boolean]) { - return { number: v[0], string: v[1], boolean: v[2] }; -} -const args: [number, string, boolean] = [11, "str", true]; -var v1 = fun1(...args); -var v2 = fun1(args[0], args[1], args[2]); -var v3 = fun1(11, "str", true); -var jv1 = JSON.stringify(v1); -var jv2 = JSON.stringify(v2); -var jv3 = JSON.stringify(v3); -var flag = false; -if (jv1 === jv2 && jv2 === jv3 && jv3 === jv1) { - flag = true; -} -Assert.isTrue(flag); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.1/mapped_types_on_tuples_and_arrays/mapped_types_on_tuples_and_arrays_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.1/mapped_types_on_tuples_and_arrays/mapped_types_on_tuples_and_arrays_1.ts deleted file mode 100644 index a18fba4537..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.1/mapped_types_on_tuples_and_arrays/mapped_types_on_tuples_and_arrays_1.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In TypeScript 3.1, mapped object types over tuples and arrays now produce new tuples/arrays, - rather than creating a new type where members like push(), pop(), and length are converted. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -type Type = { - [k in keyof T]: Array; -}; -type tuple = [number, string, boolean]; -type tt = Type; -let cc: tt = [ - [0, 1, 2, 3], - ["a", "b", "c", "d"], - [false, true], -]; -Assert.equal(Array.isArray(cc), true); -Assert.equal(cc.length, 3); -cc.push([1, 2, 3]); -cc.push([false, false]); -cc.push(["hello", "world"]); -Assert.equal(cc.length, 6); - -let vv: any = cc.pop(); -Assert.equal(vv[0], "hello"); -Assert.equal(vv[1], "world"); -Assert.equal(cc.length, 5); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.1/properties_declarations_on_functions/properties_declarations_on_functions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.1/properties_declarations_on_functions/properties_declarations_on_functions_1.ts deleted file mode 100644 index f18d78287b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.1/properties_declarations_on_functions/properties_declarations_on_functions_1.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 3.1 brings the ability to define properties on function declarations and const-declared functions, - simply by assigning to properties on these functions in the same scope. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -function add(a: T, b: K) { - if (typeof a == "number" && typeof b == "number") { - return a + b; - } else { - return `${a}${b}`; - } -} - -add.description = "this"; -add.aa = 0; -add.bb = false; - -Assert.equal(add.description, "this"); -Assert.equal(add.aa, 0); -Assert.equal(add.bb, false); - -add.showInfo = () => { - return 1; -}; -Assert.equal(add.showInfo(), 1); - - -const link = () => { - return 11; -}; - -link.aa = 0; -link.bb = false; -link.cc = "this"; -link.showInfo = () => { - return 1; -}; -Assert.equal(link.cc, "this"); -Assert.equal(link.aa, 0); -Assert.equal(link.bb, false); -Assert.equal(link.showInfo(), 1); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/bigint/bigint_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/bigint/bigint_1.ts deleted file mode 100644 index b802830d80..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/bigint/bigint_1.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - BigInts are part of an upcoming proposal in ECMAScript that allow us to model theoretically arbitrarily large integers. - Brings type-checking for BigInts, as well as support for emitting BigInt literals when targeting esnext. - BigInt support in TypeScript introduces a new primitive type called the 'bigint' (all lowercase). - You can get a bigint by calling the BigInt() function or by writing out a BigInt literal by adding an n to the end of any integer numeric litera. - options: - target: es2020 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -let b1: bigint = 10n; -let b2: bigint = BigInt(10n); -Assert.equal(b1, b2); - -function func(bnum: bigint) { - for (let i = 0; i < 10; i++){ - bnum++; - } - return bnum; -} -Assert.equal(func(10n), 20n); - -class C{ - bigN: bigint - constructor(bigN: bigint) { - this.bigN = bigN; - } -} -let c = new C(10n); -Assert.equal(c.bigN, 10n); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/bigint/bigint_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/bigint/bigint_2.ts deleted file mode 100644 index a2f5c2267d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/bigint/bigint_2.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - As specified in ECMAScript, mixing numbers and bigints in arithmetic operations is an error. - You'll have to explicitly convert values to BigInts. - options: - target: es2020 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -var x: number = 10; -var bi: bigint = 100n; - -var y = BigInt(x) * bi; -Assert.equal(y, 1000n); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/bigint/bigint_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/bigint/bigint_3.ts deleted file mode 100644 index db0c1ad380..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/bigint/bigint_3.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - bigints produce a new string when using the typeof operator: the string "bigint". - Thus, TypeScript correctly narrows using typeof as you’d expect. - options: - target: es2020 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -function num_or_bigint(x: number | bigint) { - if (typeof x === "bigint") { - return x; - } - else { - return x + 1; - } -} -var a = num_or_bigint(10); -var b = num_or_bigint(10n); -Assert.equal(a, 11); -Assert.equal(b, 10n); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_object_rest_variables_and_parameters/generic_object_rest_variables_and_parameters.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_object_rest_variables_and_parameters/generic_object_rest_variables_and_parameters.ts deleted file mode 100644 index 78a4d19001..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_object_rest_variables_and_parameters/generic_object_rest_variables_and_parameters.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Allows destructuring a rest binding from a generic variable. - This is achieved by using the predefined Pick and Exclude helper types from lib.d.ts, - and using the generic type in question as well as the names of the other bindings in the destructuring pattern. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -function func1(arg: T) { - let { ...restPara } = arg; - return restPara; -} -const obj1 = { x: 10, y: 'a' }; -const o1 = func1(obj1); -Assert.isObject(o1); -Assert.equal(JSON.stringify(o1), '{"x":10,"y":"a"}'); - -function func2(obj: T) { - let { str, ...rest } = obj; - return rest; -} - -const obj2 = { x: 10, y: 20, str: "string" }; -const o2 = func2(obj2); -Assert.isObject(o2); -Assert.equal(JSON.stringify(o2), '{"x":10,"y":20}'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_1.ts deleted file mode 100644 index cff47c0606..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_1.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Object literals now allow generic spread expressions which now produce intersection types, - similar to the Object.assign function and JSX literals. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -function func(arg: T, other: U) { - return { ...arg, other }; -} -let f1 = { num: 5, str: 'a' }; -let f2 = { num: 8, str: 'b', boo: true }; - -Assert.isObject(func(f1, 'a')); -Assert.isObject(func(f2, 'b')); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts deleted file mode 100644 index 0ea5538293..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_2.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Property assignments and non-generic spread expressions are merged to the greatest extent possible on either side of a generic spread expression. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -function func(arg1: T, arg2: { str: string }) { - let obj = { n: 5, ...arg1, s: 's', ...arg2 }; - return obj; -} -let o1 = { - str: 'a' -}; -let f = func({ s: "string" }, o1); -Assert.isObject(f); -Assert.equal(JSON.stringify(f), '{"n":5,"s":"s","str":"a"}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_3.ts deleted file mode 100644 index 27fa8ad98b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/generic_spread_expressions_in_object_literals/generic_spread_expressions_in_object_literals_3.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Non-generic spread expressions continue to be processed as before: Call and construct signatures are stripped, - only non-method properties are preserved, and for properties with the same name, the type of the rightmost property is used. - This contrasts with intersection types which concatenate call and construct signatures, - preserve all properties, and intersect the types of properties with the same name. - Thus, spreads of the same types may produce different results when they are created through instantiation of generic types - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -function func(arg1: T, arg2: U) { - return { ...arg1, ...arg2 }; -} - -let x: { mem1: string; mem2: { num: number } } = { mem1: "a", mem2: { num: 10 } }; -let y: { mem1: string; mem2: object } = { mem1: "b", mem2: { str: 'a' } }; - -let s1 = { ...x, ...y }; -Assert.isObject(s1); -let s2 = func(x, y); -Assert.isObject(s2); -let b1 = s1.mem2; -Assert.isObject(b1); -let b2 = s2.mem2; -b2 = { num: 20 }; -Assert.isObject(b2); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/non-unit_types_as_union_discriminants/non-unit_types_as_union_discriminants.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.2/non-unit_types_as_union_discriminants/non-unit_types_as_union_discriminants.ts deleted file mode 100644 index 550e160720..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.2/non-unit_types_as_union_discriminants/non-unit_types_as_union_discriminants.ts +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Common properties of unions are now considered discriminants as long as they contain some singleton type, - and they contain no generics. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -interface I{ - mem: { x: Error, y: undefined } | { x: undefined, y: T }; -} -function fun(arg: I) { - if (arg.mem.x) { - throw arg.mem.x; - } - return arg.mem.y; -} - -let i1 = { - mem: { x: undefined, y: undefined, } -}; -let result1 = fun(i1); -Assert.isUndefined(result1); - -let i2 = { - mem: { x: undefined, y: 10 } -}; -let result2 = fun(i2); -Assert.isNumber(result2); - -type R = { e: Error; data: null } | { e: null; data: T }; - -function func(result: R) { - if (result.e) { - throw result.e; - } - return result.data; -} - -var a = { - e: null, - data: null, -}; -var b = func(a); -let f = false; -if (b == null) { - f = true; -} -Assert.isTrue(f); - -var c = { - e: null, - data: 10, -}; -var d = func(c); -Assert.equal(d, 10); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.3/improved_behavior_for_calling_union_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.3/improved_behavior_for_calling_union_types.ts deleted file mode 100644 index 60bbc2c964..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.3/improved_behavior_for_calling_union_types.ts +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Improved behavior for calling union types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../suite/assert.js' - -{ - type DamageType = "XO" | "EXP"; - type ColorType = "red" | "green" | "blue"; - - type ATK = (atk: DamageType) => number; - - let s: ATK = (atk: DamageType) => 1; - - type newColorConstructor = (color: ColorType) => string; - - let sp: newColorConstructor = (color: ColorType) => 'good'; - - Assert.equal(s("XO"), 1) - Assert.equal(sp("green"), 'good') - - interface Dog { - kind: "dog"; - dogProp: any; - } - - interface Cat { - kind: "cat"; - catProp: any; - } - - const petArray: Dog[] | Cat[] = [{ kind: "dog", dogProp: 1 }, { kind: "dog", dogProp: 2 }]; - let ex: number[] = []; - petArray.forEach((animal: Dog | Cat) => { - if (animal.kind === "dog") { - ex.push(animal.dogProp); - } else if (animal.kind === "cat") { - ex.push(animal.catProp); - } - }); - - Assert.equal(ex[0], 1); - Assert.equal(ex[1], 2); -}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.4/Caveats.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.4/Caveats.ts deleted file mode 100644 index 6f9ae0fabd..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.4/Caveats.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - One thing to note is that const assertions can only be applied immediately on simple literal expressions. - Another thing to keep in mind is that const contexts don’t immediately convert an expression to be fully immutable. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../suite/assert.js" - -let math = 1/3; -let compare = math<0.5? 1 as const:3 as const; -Assert.isNumber(compare); -Assert.equal(compare,1); - -let list = [9,8,7,6,5]; - -let bar = { - name: "foo", - age:1, - contents: list, -} as const; - -bar.contents.push(21); -Assert.equal(list[5],21); - -bar.contents.pop(); -Assert.equal(list.length,5); -Assert.equal(list[5],undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.4/Type_checking_for_globalThis.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.4/Type_checking_for_globalThis.ts deleted file mode 100644 index 224330f3e1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.4/Type_checking_for_globalThis.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - globalThis provides a standard way for accessing the global scope which can be used across different environments. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../suite/assert.js" - -var nm = 10010; -let gt:any = globalThis -gt.nm = 10086; -Assert.equal(gt.nm,10086); -Assert.equal(typeof gt.nm,"number"); - -var np = "sss"; -let gp:any = globalThis -gp.np = "nanj"; -Assert.equal(gp.np,"nanj"); -Assert.notEqual(typeof gp.np,"number"); -Assert.isString(gp.np); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.4/a_new_syntax_for_readonly_array.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.4/a_new_syntax_for_readonly_array.ts deleted file mode 100644 index 078ba79959..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.4/a_new_syntax_for_readonly_array.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 3.4 introduces a new syntax for ReadonlyArray using a new readonly modifier for array types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../suite/assert.js" - -let arr1: ReadonlyArray = ["1", "2"]; -let arr2: readonly string[] = ["1", "2"]; - -Assert.equal(arr1[1], "2"); -Assert.equal(arr2[1], "2"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.4/const_assertions.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.4/const_assertions.ts deleted file mode 100644 index a1d1900ab1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.4/const_assertions.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 3.4 introduces a new construct for literal values called const assertions. Its syntax is a type assertion with const in place of the type name. - The angle bracket assertion syntax can also be used. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../suite/assert.js" - -let a1 = 1408 as const; -let a2 = 1408; -Assert.equal(a1, 1408); -Assert.equal(a2, 1408); -let b1 = 'NARC' as const; -let b2 = 'NARC'; -Assert.equal(b1, 'NARC'); -Assert.equal(b2, 'NARC'); -let c1 = [255, 0, 0] as const; -let c2 = [255, 0, 0]; -Assert.equal(JSON.stringify(c1), '[255,0,0]'); -Assert.equal(JSON.stringify(c2), '[255,0,0]'); -let d1 = { mem: 'member' } as const; -let d2 = { mem: 'member' }; -Assert.equal(JSON.stringify(d1), '{"mem":"member"}'); -Assert.equal(JSON.stringify(d2), '{"mem":"member"}'); - - -let obj1 = { kind: "circle", length: 80 }; -let obj2 = { kind: "square", length: 50 }; - -function func() { - let result = [obj1, obj2] as const; - return result; -} -for (const shape of func()) { - if (shape.kind === "circle") { - Assert.equal(shape.length, 80); - } else { - Assert.equal(shape.length, 50); - } -}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.4/higher_order_type_inference.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.4/higher_order_type_inference.ts deleted file mode 100644 index 9fd47c8f43..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.4/higher_order_type_inference.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Higher order type inference from generic functions. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../suite/assert.js' - -function Func(f: (arg: A) => B, g: (arg: B) => C): (arg: A) => C { - return (x) => g(f(x)); -} - -interface A { - arr: T; -} - -function func1(index: T): T[] { - return [index]; -} - -function func2(arr: U): A { - return { arr }; -} - -const result = Func( - func1, - func2, -) - -Assert.equal(result("hello").arr[0].toUpperCase(), 'HELLO'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.4/readonly_tuples.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.4/readonly_tuples.ts deleted file mode 100644 index 93d85342f5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.4/readonly_tuples.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 3.4 introduces new support for readonly tuples. - a readonly tuple with elements 'T1, T2, … Tn' extends from ReadonlyArray'< T1 | T2 | … Tn >'. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../suite/assert.js" - -let arr1: ReadonlyArray = [10, 'b', false]; -let arr2: readonly [number, string, boolean] = [5, 'a', true]; - -Assert.isNumber(arr1[0]); -Assert.isNumber(arr2[0]); -Assert.isString(arr1[1]); -Assert.isString(arr2[1]); -Assert.isBoolean(arr1[2]); -Assert.isBoolean(arr2[2]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.5/higher_order_type_inference.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.5/higher_order_type_inference.ts deleted file mode 100644 index 92578f067c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.5/higher_order_type_inference.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 3.5 generalizes TypeScript 3.4's inference behavior to work on constructor functions as well. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../suite/assert.js' - -{ - class A { - mem: T; - constructor(mem: T) { - this.mem = mem; - } - } - - class B { - mem: U; - constructor(mem: U) { - this.mem = mem; - } - } - - function func( - F: new (x: T) => U, - G: new (y: U) => V - ): (x: T) => V { - return x => new G(new F(x)); - } - - - let f = func(A, B); - - let a = f(10); - - Assert.equal(a.mem.mem, 10); -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.5/improved_excess_property_checks_in_union_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.5/improved_excess_property_checks_in_union_types.ts deleted file mode 100644 index 144e5d91df..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.5/improved_excess_property_checks_in_union_types.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In TypeScript 3.5, the type-checker at least verifies that all the provided properties belong to some union member and have the appropriate type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../suite/assert.js' - -interface I{ - num: number; - mem2: string; -} -type T = { - num: number; - str: string; -} - -type ut = I | T; -let result: ut = { - mem2: 'member', - num: 10, - str: 'string' -} -Assert.isNumber(result.num); -Assert.isObject(result); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.5/omit_helper_type.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.5/omit_helper_type.ts deleted file mode 100644 index 5712d517e0..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.5/omit_helper_type.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 3.5 introduces the new Omit helper type, which creates a new type with some properties dropped from the original. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../suite/assert.js' - -{ - type TA = { - a: string; - b: number; - c: string; - }; - type TB = Omit; - let s: TB = { - a: 'string', - b: 1, - } - let s1: TA = { - a: 'string', - b: 1, - c: 'string' - } - Assert.isFalse("c" in s) - Assert.isTrue("c" in s1); -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.5/smarter_union_type_checking.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.5/smarter_union_type_checking.ts deleted file mode 100644 index 03e60b4220..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.5/smarter_union_type_checking.ts +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In TypeScript 3.5, when assigning to types with discriminant properties like in T, - the language actually will go further and decompose types like S into a union of every possible inhabitant type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../suite/assert.js' - -{ - type newTest = { mem: string } | { mem: number }; - interface I1{ - num: number; - boo: newTest; - } - interface I2{ - num: number; - boo: { mem: string }; - } - interface I3{ - num: number; - boo: { mem: number }; - } - let i1: I1 = { - num: 10, - boo: { mem: 'member' } - } - let i2: I2 | I3 = { - num: 20, - boo: { mem: 15 } - } - - i1 = i2; - Assert.equal(i1, i2); - - type T1 = { mem1: number, mem2: boolean }; - type T2 = { mem1: number, mem2: true } | { mem1: number, mem2: false }; - let t1: T1 = { - mem1: 10, - mem2: true - } - let t2: T2 = { - mem1: 20, - mem2: false - } - t1 = t2; - Assert.equal(t1, t2); -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/better_unicode_support_for_identifiers/better_unicode_support_for_identifiers_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/better_unicode_support_for_identifiers/better_unicode_support_for_identifiers_1.ts deleted file mode 100644 index 37a080fd4c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/better_unicode_support_for_identifiers/better_unicode_support_for_identifiers_1.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: TypeScript 3.6 contains better support for Unicode characters in identifiers when emitting to ES2015 and later targets. - options: - target:es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -const 𝓱𝓮 = "ok"; -Assert.equal(𝓱𝓮, "ok"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/get_and_set_accessors_are_allowed_in_ambient_contexts_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/get_and_set_accessors_are_allowed_in_ambient_contexts_1.ts deleted file mode 100644 index f25d224be1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/get_and_set_accessors_are_allowed_in_ambient_contexts_1.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: users can write getters and setters in ambient contexts in TypeScript 3.6 and later. -module: ESNext -isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" -import { C } from "./test.js" - -let obj: C = { m: 1 }; - -Assert.equal(1, obj.m); - -class mC { - mem: string; - constructor(mem: string) { - this.mem = mem; - } - get mC_mem() { - return this.mem; - } - set mC_mem(str:string) { - this.mem = str; - } -} -let eg = new mC('member'); -Assert.equal(eg.mC_mem, 'member'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/test.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/test.ts deleted file mode 100644 index 8c3cbedea9..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/get_and_set_accessors_are_allowed_in_ambient_contexts/test.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -declare class C { - get m(): number; - set m(value: number); -} -export { C }; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/improved_UX_Around_Promises/improved_UX_Around_Promises.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/improved_UX_Around_Promises/improved_UX_Around_Promises.ts deleted file mode 100644 index 3c7addaed1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/improved_UX_Around_Promises/improved_UX_Around_Promises.ts +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: For example, it’s often very common to forget to .then() or await the contents of a Promise before passing - it to another function. TypeScript’s error messages are now specialized, and inform the user that perhaps they should - consider using the await keyword. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -let s = 1; -let t = 1; -function d1() { - s = 2 -} -let i = 0; -async function d2(this:any):Promise { - s = 3; - return s; -} -async function d3(this:any):Promise { - t = 3; - return t; -} - - - -async function d4() { - d1(); - Assert.equal(s, 2); - d2().then( - () => { - s = 5 - } - ); - Assert.equal(s, 3); - await d3().then( - () => { - t = 5 - } - ); - Assert.equal(t, 5); -} -d4().then(r => {}); - - - diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/more_accurate_array_spread/more_accurate_array_spread_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/more_accurate_array_spread/more_accurate_array_spread_1.ts deleted file mode 100644 index 075f30c799..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/more_accurate_array_spread/more_accurate_array_spread_1.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: More Accurate Array Spread. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -const t1 = { name: "John", age: 30 }; -const t2 = ["javascript", "typescript", "react"]; -const t3 = { ...t1, skills: t2 }; -Assert.equal("name" in t3, true); -Assert.equal("age" in t3, true); -Assert.equal("skills" in t3, true); -Assert.equal("isJob" in t3, false); - -let arr = [...Array(3)]; -Assert.equal(arr[0], undefined); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_1.ts deleted file mode 100644 index cdc9c54341..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_1.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: In TypeScript 3.6, the checker now knows that the correct type for iter.next().value - options: - lib:es2015 - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -function* func() { - yield 100; - yield "Finished!"; - return false; -} -let t1 = func(); -let t2 = t1.next(); -Assert.isNumber(t2.value); -t2 = t1.next(); -Assert.isString(t2.value); -t2 = t1.next(); -Assert.isBoolean(t2.value); -t2 = t1.next(); -Assert.equal(t2.done, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_2.ts deleted file mode 100644 index b13864663e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_2.ts +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The Iterator type now allows users to specify the yielded type, the returned type, and the type that next can accept. - To allow differentiation between returned values and yielded values, - TypeScript 3.6 converts the IteratorResult type to a discriminated union type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -class C { - name: string; - age: number; - isJob: boolean; - constructor(name: string, age: number, isJob: boolean) { - this.name = name; - this.age = age; - this.isJob = isJob; - } -} - -let c1 = new C("caihua", 12, false); - -const keys = Object.keys(c1); -let nextIndex = 0; -let x: Iterator = { - next() { - return nextIndex < keys.length - ? { - value: keys[nextIndex++], - done: false, - } - : { value: 0, done: true }; - }, -}; - -let dd = x.next(); -Assert.isString(dd.value); -Assert.isBoolean(dd.done); -Assert.equal(dd.value, "name"); -Assert.equal(dd.done, false); -x.next(); -x.next(); - -dd = x.next(); -Assert.isNumber(dd.value); -Assert.isBoolean(dd.done); -Assert.equal(dd.value, 0); -Assert.equal(dd.done, true); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_3.ts deleted file mode 100644 index 7422d03f1a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_3.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: the new Generator type is an Iterator that always has both the return and throw methods present, and is also iterable. - options: - lib:es2017 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -function* func(): Generator { - let i = 0; - while (true) { - if (yield i++) { - break; - } - } - return "done!"; -} - -let t1 = func(); -let t2 = t1.next(); -while (!t2.done) { - Assert.equal(typeof t2.value, "number"); - t2 = t1.next(typeof t2.value == "number"); -}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_4.ts deleted file mode 100644 index 3c04f98e76..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_4.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - To correctly represent the types that can be passed in to a generator from calls to next(), - TypeScript 3.6 also infers certain uses of yield within the body of a generator function. - options: - lib:es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -function* func() { - let x: number = yield; - Assert.isNumber(x); -} -let x = func(); -x.next(); -x.next(1); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_5.ts deleted file mode 100644 index d2a21ffb7d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.6/stricter_generators/stricter_generators_5.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - To correctly represent the types that can be passed in to a generator from calls to next(), - TypeScript 3.6 also infers certain uses of yield within the body of a generator function. - options: - lib:es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -function* func(): Generator { - let i = 0; - while (true) { - let cc = yield i++; - Assert.isBoolean(cc); - if (cc) { - break; - } - } - return "done!"; -} - -let t1 = func(); -let t2 = t1.next(); -while (!t2.done) { - t2 = t1.next(t2.value === 5); -}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/assertion_functions/assertion_functions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/assertion_functions/assertion_functions_1.ts deleted file mode 100644 index fb4269a3e4..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/assertion_functions/assertion_functions_1.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: > - Assertions in JavaScript are often used to guard against improper types being passed in. -module: ESNext -isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" - - -function func(x: any, y: any) { - Assert.equal(typeof x, "number"); - Assert.equal(typeof y, "number"); - - return x * y; -} -Assert.equal(typeof func(6, 8), "number"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/better_support_for_never/better_support_for_never.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/better_support_for_never/better_support_for_never.ts deleted file mode 100644 index cad8262fc7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/better_support_for_never/better_support_for_never.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/**--- - description: > - Better Support for never -Returning Functions - module: ESNext - isCurrent: true - ---*/ - -import {Assert} from "../../../suite/assert.js"; -function test() { - process.exit(1); -} -Assert.equal(test(), 'never') \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/nullish_coalescing/nullish_coalescing_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/nullish_coalescing/nullish_coalescing_1.ts deleted file mode 100644 index 8368cd3d74..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/nullish_coalescing/nullish_coalescing_1.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: > - We can think of this feature - the ?? operator - as a way to "fall back" to a default value when dealing with null or undefined. -module: ESNext -isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" -let nn: number | null; -nn = 1408; -let str: string = "NARC"; -let x = nn ?? str; - -nn = null; -let y = nn ?? str; - -Assert.equal(typeof x, "number"); -Assert.equal(typeof y, "string"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/nullish_coalescing/nullish_coalescing_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/nullish_coalescing/nullish_coalescing_2.ts deleted file mode 100644 index 8e9aa84741..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/nullish_coalescing/nullish_coalescing_2.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: > - The ?? operator can replace uses of || when trying to use a default value. -module: ESNext -isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" - -let n = 0; -function func() { - n = n ?? 0.5; - return n; -} - -Assert.equal(func(), 0); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_1.ts deleted file mode 100644 index 5fc9d90f47..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_1.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: > - The star of the show in optional chaining is the new ?. operator for optional property accesses. -module: ESNext -isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" - -const obj1 = { - x: { - y: 'NARC' - } -}; - -let str = obj1?.x.y; - -Assert.equal(str, "NARC"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_2.ts deleted file mode 100644 index fa7fa04c8c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_2.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: > - You might find yourself using ?. to replace a lot of code that performs repetitive nullish checks using the && operator. -module: ESNext -isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" - -const obj = { - x: { - y: 'e2' - } -}; - -if (obj?.x?.y) { - Assert.equal(obj?.x?.y, "e2", "true"); -} -if (obj && obj.x && obj.x.y) { - Assert.equal(obj && obj.x && obj.x.y, "e2", "true"); -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_3.ts deleted file mode 100644 index 33526523ee..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_3.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: > - One use of optional chain is optional element access, which acts similarly to optional property accesses, but allows us to access non-identifier properties (e.g. arbitrary strings, numbers). -module: ESNext -isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" - -function func(arr?: T[]) { - return arr?.[0]; -} - -const arr: number[] = [1, 25, 8]; -Assert.equal(func(arr), 1, "true"); - -const arrStr: string[] = ["flower", "xian"]; -Assert.equal(func(arrStr), "flower", "true"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_4.ts deleted file mode 100644 index 5970e1f4c8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_4.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - There's also optional call, which allows us to conditionally call expressions if they’re not null or undefined. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -class C{ - mem: string; - constructor(mem: string) { - this.mem = mem; - } - func(mem: string) { - this.mem = mem; - return this.mem; - } -} -async function method(str: string): Promise { - return str; -} - -async function func(str: string, arg?: (str: string) => void): Promise{ - let c = new C('member'); - let para = c.func('member'); - let x = arg?.(para); - Assert.isUndefined(x); - const result: string = await method(str); - let y = arg?.(para); - Assert.isUndefined(y); - return result; -} -func('string').then(res => { - Assert.isObject(res); -}).catch(err => { -}); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_5.ts deleted file mode 100644 index 63facc273c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/optional_chaining/optional_chaining_5.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The "short-circuiting" behavior that optional chains have is limited property accesses, calls, element accesses - it doesn't expand any further out from these expressions. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -const obj = { - n1: { - n2: 10 - } -}; -function func(divisor: number) { - return divisor + 4; -} -let result = obj?.n1?.n2 / func(1); -Assert.equal(typeof result, "number"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/recursive_type_aliases/recursive_type_aliases_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/recursive_type_aliases/recursive_type_aliases_1.ts deleted file mode 100644 index 67b78880da..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/recursive_type_aliases/recursive_type_aliases_1.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - That's exactly what TypeScript 3.7 introduces. At the "top level" of a type alias, TypeScript will defer resolving type arguments to permit these patterns. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -type JSONType = - | string - | number - | boolean - | null - | JsonObjectX - | JsonArray; - -interface JsonObjectX { - [property: string]: JSONType; -} - -interface JsonArray extends Array { } -const myJson: JSONType = ["a", 2, true, null, { - "Damage": 1024, - "DamageType": "XO", -}, []]; - -Assert.equal(typeof myJson, "object"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/ts_nocheck_in_typescript_files/ts_nocheck_in_typescript_files.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.7/ts_nocheck_in_typescript_files/ts_nocheck_in_typescript_files.ts deleted file mode 100644 index 47db4dd102..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.7/ts_nocheck_in_typescript_files/ts_nocheck_in_typescript_files.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 3.7 allows us to add // @ts-nocheck comments to the top of TypeScript files to disable semantic checks. Historically this comment was only respected in JavaScript source files in the presence of checkJs, but we’ve expanded support to TypeScript files to make migrations easier for all users. - module: ESNext - isCurrent: true ----*/ - - -// @ts-nocheck - -import { Assert } from "../../../suite/assert.js"; - -function add(a, b) { - let s = a + b; - return s; -} -Assert.isTrue(isNaN(add())); -Assert.equal(add("NARC"), "NARCundefined"); -Assert.isTrue(isNaN(add(1408))); -Assert.equal(add(1, 2), 3); -Assert.equal(add('A', 'B'), "AB"); -Assert.equal(add(10, "false"), "10false"); -Assert.equal(add(10, true), 11); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/1_type_only_imports_and_export.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/1_type_only_imports_and_export.ts deleted file mode 100644 index 8bafe780ee..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/1_type_only_imports_and_export.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: TypeScript 3.8 adds a new syntax for type-only imports and exports. -module: ESNext -isCurrent: true ----*/ - - -import { Assert } from "../../suite/assert.js"; -import type { T } from "./some_module.js"; - -export type { T }; - -let sth: T = { legs: 5 }; -Assert.equal(5, sth.legs); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_1.ts deleted file mode 100644 index 892d70d776..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_1.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: TypeScript 3.8 brings support for ECMAScript’s private fields - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -class student { - #name: string; - constructor(name: string) { - this.#name = name; - } - - getName(): string { - return this.#name; - } -} - -let students = new student("NARC"); -Assert.equal("NARC", students.getName()); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_2.ts deleted file mode 100644 index fb3b26cc3e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_2.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: With private fields, each field name is unique to the containing class. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -class stu { - #x = 10; - getX() { - return this.#x; - } -} - -class Dtu extends stu { - #y = 20; - getY() { - return this.#y; - } -} - -let dt = new Dtu(); - -Assert.equal(10, dt.getX()); -Assert.equal(20, dt.getY()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_3.ts deleted file mode 100644 index 74b146fe49..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/2_ecmsscript_private_fields/2_ecmsscript_private_fields_3.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: Accessing a private field on any other type will result in a TypeError! - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -class stu { - #len: number; - constructor(len: number) { - this.#len = len; - } - compare(other: any) { - return this.#len === other.#len; - } -} - -const a = new stu(300); -const c = new stu(300); - - -Assert.isTrue(a.compare(c)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/3_which_should_i_use.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/3_which_should_i_use.ts deleted file mode 100644 index 1cb4dec00e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/3_which_should_i_use.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: the difference between private and # - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../suite/assert.js' - -class One { - private x = 10; -} - -Assert.equal(10, new One()["x"]); - -class Two { - #x: number; - constructor(x: number) { - this.#x = x; - } - getX(): number { - return this.#x; - } -} - -let three = new Two(5); -Assert.equal(three.getX(), 5); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/4_export_star_as_ns_syntax.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/4_export_star_as_ns_syntax.ts deleted file mode 100644 index 4e0cb9b799..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/4_export_star_as_ns_syntax.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: ECMAScript 2020 recently added a new syntax to support this pattern! -module: ESNext -isCurrent: true ----*/ - - -import { Assert } from "../../suite/assert.js" -import { NUMX } from "./export_star.js" - -Assert.equal(1024, NUMX.x); -Assert.equal("STRING", NUMX.getX("STRING")); - diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/export_star.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/export_star.ts deleted file mode 100644 index 9c768b7b42..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/export_star.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -export * as NUMX from "./my_module.js"; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/my_module.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/my_module.ts deleted file mode 100644 index 55187964d7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/my_module.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -export let x = 1024; -export function getX(x: string) { return x; }; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/some_module.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.8/some_module.ts deleted file mode 100644 index ffb0e823ce..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.8/some_module.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -const cat: any = { legs: 4 }; - -export type T = typeof cat; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.9/Parsing_differences_in_optional_assertions/Parsing_differences_in_optional_assertions.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.9/Parsing_differences_in_optional_assertions/Parsing_differences_in_optional_assertions.ts deleted file mode 100644 index 6488e62012..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.9/Parsing_differences_in_optional_assertions/Parsing_differences_in_optional_assertions.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/**--- - description: > - Parsing Differences in Optional Chaining and Non-Null Assertions - module: ESNext - isCurrent: true - ---*/ - -import {Assert} from "../../../suite/assert.js"; - -let s; -s = { a:1, b:{c:2}}; -Assert.equal(s?.a, 1); -Assert.equal((s.b!).c, 2); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.9/improvements_in_inference_and_Promise.all/improvements_in_inference_and_Promise.all.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.9/improvements_in_inference_and_Promise.all/improvements_in_inference_and_Promise.all.ts deleted file mode 100644 index 9e490ea851..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.9/improvements_in_inference_and_Promise.all/improvements_in_inference_and_Promise.all.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - recrent versions of TypeScript (around 3.7) have had updates to the declarations of functions like Promise.all and Promise.race. - unfortunately, that introduced a few regressions, especially when mixing in values with null or undefined. - this issue has now been fixed. - options: - lib: es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -interface I1 { - func1(): number; -} - -interface I2 { - func2(): number; -} - -async function func( - arg1: Promise, - arg2: Promise -) { - let [t1, t2] = await Promise.all([arg1, arg2]); - return t1.func1(); -} - -let para1: Promise = new Promise(() => { return 10; }); -let para2: Promise = new Promise(() => { return 5; }); -func(para1, para2); -Assert.isObject(func(para1, para2)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/3.9/ts-expect-error_comments/ts-expect-error_comments.ts b/es2panda/test/ts_extra_tests/test_ts_cases/3.9/ts-expect-error_comments/ts-expect-error_comments.ts deleted file mode 100644 index 4f4396aff6..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/3.9/ts-expect-error_comments/ts-expect-error_comments.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - when a line is preceded by a // @ts-expect-error comment, TypeScript will suppress that error from being reported; but if there’s no error, TypeScript will report that // @ts-expect-error wasn’t necessary. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -function toASCIICode(s: string) { - s += ""; - let arr: number[] = []; - let char: string[] = s.split(''); - for (let i = 0; i < s.length; i++) { - arr[i] = char[i].charCodeAt(0); - } - return arr; -} -// @ts-expect-error -let json = JSON.stringify(toASCIICode(123)); - -Assert.equal(json, "[49,50,51]"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/class_property_Inference_from_constructors/class_property_Inference_from_constructors_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/class_property_Inference_from_constructors/class_property_Inference_from_constructors_1.ts deleted file mode 100644 index d245de2941..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/class_property_Inference_from_constructors/class_property_Inference_from_constructors_1.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 4.0 can now use control flow analysis to determine the types of properties in classes when noImplicitAny is enabled. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -class NA { - name; - - constructor(name: string) { - this.name = name; - } -} -const W = new NA("tom"); -Assert.equal(W.name, 'tom'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_1.ts deleted file mode 100644 index 6f9c5e6aec..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_1.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - To deepen the connection between parameter lists and tuple types, - the syntax for rest elements and optional elements mirrors the syntax for parameter lists. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -type Weapon = [Damage: number, DamageType?: string, ...rest: any[]]; -function getWeaponJSON(weapon: Weapon): string { - let len: number = weapon.length; - let obj: { [key: string | number]: any } = { 'Damage': 0 }; - for (let i = 0; i < len; i++) { - if (i == 0) { - obj['Damage'] = weapon[i]; - } else if (i == 1) { - obj['DamageType'] = weapon[i]; - } else { - obj[i] = weapon[i]; - } - } - return JSON.stringify(obj); -} -let weapon1: Weapon = [1024, 'XO', 0, 'NARC', true]; -let weapon2: Weapon = [100]; -let weapon3: Weapon = [333, 'EXP', ['A', 1024, false], { A: 1, B: 2 }]; -Assert.equal(getWeaponJSON(weapon1), '{"2":0,"3":"NARC","4":true,"Damage":1024,"DamageType":"XO"}'); -Assert.equal(getWeaponJSON(weapon2), '{"Damage":100}'); -Assert.equal(getWeaponJSON(weapon3), '{"2":["A",1024,false],"3":{"A":1,"B":2},"Damage":333,"DamageType":"EXP"}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_2.ts deleted file mode 100644 index 59b2dc0951..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_2.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - There are a few rules when using labeled tuples. - For one, when labeling a tuple element, all other elements in the tuple must also be labeled. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -type A01 = [name: string, age: number]; -type A02 = [name?: string, age?: number]; - -let a1: A01 = ['NARC', 0]; -let a2_1: A02 = []; -let a2_2: A02 = ['ACDC']; -Assert.equal(JSON.stringify(a1), '["NARC",0]'); -Assert.equal(JSON.stringify(a2_1), '[]'); -Assert.equal(JSON.stringify(a2_2), '["ACDC"]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_3.ts deleted file mode 100644 index 44a74e138c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/labeled_tuple_elements/labeled_tuple_elements_3.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - It’s worth noting - labels don’t require us to name our variables differently when destructuring. - They’re purely there for documentation and tooling. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -function funLTE01(x: [first: string, second: number]) { - const [a, b] = x; - Assert.equal(a, "hello"); - Assert.equal(b, 42); -} -funLTE01(["hello", 42]); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_1.ts deleted file mode 100644 index 42d5761db6..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_1.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - JavaScript, and a lot of other languages, support a set of operators called compound assignment operators. - Compound assignment operators apply an operator to two arguments, - and then assign the result to the left side. You may have seen these before: - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -let a: number = 1; -let b: number = 2; -a += b; -Assert.equal(a, 3); - -let c: number = 4; -let d: number = 3; -c -= d; -Assert.equal(c, 1); - -let e: number = 5; -let f: number = 6; -e *= f; -Assert.equal(e, 30); - -let g: number = 7; -let h: number = 8; -g /= h; -Assert.equal(g, 0.875); - -let j: number = 2; -let k: number = 3; -j **= k; -Assert.equal(j, 8); - -let m: number = 20; -let n: number = 30; -m <<= n; -Assert.equal(m, 0); - -let o: number = 4; -let p: number = 5; -let o1 = o && p; -o &&= p; -Assert.equal(o, 5); -Assert.equal(o1, 5); - -let s: number = 7; -let t: number = 8; -let s1 = s || t; -s ||= t; -Assert.equal(s, 7); -Assert.equal(s1, 7); - -let u: number = 10; -let v: number = 20; -let u1 = u ?? v; -u ??= v; -Assert.equal(u1, 10); -Assert.equal(u, 10); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_2.ts deleted file mode 100644 index 4c7bad2308..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_2.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - There are even some patterns we’ve seen (or, uh, written ourselves) to lazily initialize values, only if they’ll be needed. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -let arrStr: string[]; - -(arrStr ??= []).push("hello"); -(arrStr ??= []).push("world"); - -Assert.equal(arrStr[0], "hello"); -Assert.equal(arrStr[1], "world"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_3.ts deleted file mode 100644 index 431a93f8c1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/short_circuiting_assignment_operators/short_circuiting_assignment_operators_3.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - On the rare case that you use getters or setters with side-effects, it’s worth noting that these operators only perform assignments if necessary. - In that sense, not only is the right side of the operator “short-circuited” - the assignment itself is too. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -const obj = { - get prop() { - return true; - }, - set prop(_val: boolean) { }, -}; -function test01() { - return true; -} -obj.prop = obj.prop || test01(); -Assert.equal(obj.prop, true); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_1.ts deleted file mode 100644 index a698a64af2..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_1.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Since the beginning days of TypeScript, catch clause variables have always been typed as any. - This meant that TypeScript allowed you to do anything you wanted with them. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -function getErrorMessage(): never { - throw new Error("An error occurred"); -} -try { - getErrorMessage(); -} catch (error: any) { - Assert.equal(error.message, "An error occurred"); -}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_2.ts deleted file mode 100644 index ef8a9f770c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/unknow_on_catch_clause_bindings/unknow_on_catch_clause_bindings_2.ts +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The above has some undesirable behavior if we’re trying to prevent more errors from happening in our error-handling code! - Because these variables have the type any by default, they lack any type-safety which could have errored on invalid operations. - That’s why TypeScript 4.0 now lets you specify the type of catch clause variables as unknown instead. - unknown is safer than any because it reminds us that we need to perform some sorts of type-checks before operating on our values. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -let flag: boolean = false; - -function getErrorMessage(): never { - throw new Error("An error occurred"); -} -function getUnknown(): never { - let err: unknown; - throw err; -} -function getFlag(fun: Function) { - try { - fun(); - } catch (error: unknown) { - if (error instanceof Error) { - flag = true; - Assert.equal(error.message, "An error occurred"); - return error.message; - } else { - flag = false; - let errString = "An unknow error occurred"; - return errString; - } - } -} -getFlag(getErrorMessage); -Assert.isTrue(flag); -let errString = getFlag(getUnknown); -Assert.equal(errString, "An unknow error occurred"); -Assert.isFalse(flag); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_1.ts deleted file mode 100644 index b6ca4a49be..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_1.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The first change is that spreads in tuple type syntax can now be generic. - This means that we can represent higher-order operations on tuples and arrays even when we don’t know the actual types we’re operating over. - When generic spreads are instantiated (or, replaced with a real type) in these tuple types, they can produce other sets of array and tuple types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -function dropFrist(arr1: T[], arr2: U[]): Array { - const [first, ...others] = [...arr1, ...arr2]; - return others; -} -let num123: number[] = [1, 2, 3]; -let abc: string[] = ['a', 'b', 'c']; -let arr = dropFrist(num123, abc); -Assert.equal(JSON.stringify(arr), '[2,3,"a","b","c"]'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_2.ts deleted file mode 100644 index 8ff840a023..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_2.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The second change is that rest elements can occur anywhere in a tuple - not just at the end! - Note that in cases when we spread in a type without a known length, the resulting type becomes unbounded as well, and all the following elements factor into the resulting rest element type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -type N = [number, number, number]; -type S = [string, string, string]; -type NBSB = [...N, boolean, ...S, boolean] -function mergedArray1(nbsb: NBSB): string { - return JSON.stringify(nbsb); -} -let a: NBSB = [1, 2, 3, true, 'A', 'B', 'C', false]; -let s = mergedArray1(a); -Assert.equal(s, '[1,2,3,true,"A","B","C",false]'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_3.ts deleted file mode 100644 index 9f38c52975..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.0/variadic_tuple_types/variadic_tuple_types_3.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 4.0 improves the inference process for rest parameters and rest tuple elements so that we can type this and have it “just work”. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -type UnknownArray = readonly unknown[]; - -function lockType(f: (...list: [...T, ...U]) => R, ...listA: T) { - return (...listB: U) => f(...listA, ...listB); -} -function exp(num: number, str: string, bool: boolean): string { - let obj = { num: num, str: str, bool: bool }; - return JSON.stringify(obj); -} -const f1 = lockType(exp); -let f1str = f1(1, "A", true); -Assert.equal(f1str, '{"num":1,"str":"A","bool":true}'); - -const f2 = lockType(exp, 100); -let f2str = f2("B", false); -Assert.equal(f2str, '{"num":100,"str":"B","bool":false}'); - -const f3 = lockType(exp, 1024, "XO"); -let f3str = f3(true); -Assert.equal(f3str, '{"num":1024,"str":"XO","bool":true}'); - -const f4 = lockType(exp, 1408, "EXP", false); -let f4str = f4(); -Assert.equal(f4str, '{"num":1408,"str":"EXP","bool":false}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/Checked_Indexed_Accesses.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/Checked_Indexed_Accesses.ts deleted file mode 100644 index 4bf3596b59..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/Checked_Indexed_Accesses.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript has a way to describe objects which have unknown keys but known values on an object, via index signatures. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -interface I1 { - name: string; - age: number; - [pName: string]: string | number; -} -let env: I1 = { - name: "lll", - age: 22, -}; -function fun(op?: I1): I1 | undefined { - if (op) { - Assert.isString(op.name); - Assert.isNumber(op.age); - }; - return op; -}; -let env2 = fun(env); -Assert.equal(env2!.name, "lll"); -Assert.equal(env2!.age, 22); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_each_index.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_each_index.ts deleted file mode 100644 index c06681cff9..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_each_index.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - You can using a forEach call. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -let x: string[] = ["3", "4"]; -function fun(y: string[]) { - y.forEach((str: string) => { - if (str == "3") { - Assert.equal(str, "3"); - } else { - Assert.equal(str, "4") - } - }) -} -fun(x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_of_index.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_of_index.ts deleted file mode 100644 index b476b18586..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_of_index.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - You can using a for-of loop. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -let x: string[] = ["1", "2"]; -function fun(strs: string[]) { - for (let str of strs) { - if (str == "1") { - Assert.equal(str, "1"); - } else { - Assert.equal(str, "2") - } - } -} -fun(x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_traversal_index.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_traversal_index.ts deleted file mode 100644 index 4124efd187..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/Checked_Indexed_Accesses/for_traversal_index.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - You can traverse the fun. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -let x: string[] = ["1", "2"]; -function fun(strs: string[]) { - for (let i: number = 0; i < strs.length; i++) { - if (i < 1) { - Assert.equal(strs[i], "1"); - } else { - Assert.equal(strs[i], "2"); - } - } -} -fun(x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/abstract_members_can_not_be_marked_async/abstract_members_can_not_be_marked_async.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/abstract_members_can_not_be_marked_async/abstract_members_can_not_be_marked_async.ts deleted file mode 100644 index 2b2d5d5d6b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/abstract_members_can_not_be_marked_async/abstract_members_can_not_be_marked_async.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Members marked as abstract can no longer be marked as async. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -abstract class Animal { - abstract name: string; - abstract eat(): number; - run(): void { } -} -class Dog extends Animal { - name: string = "dog"; - gender: string; - constructor(gender: string) { - super(); - this.gender = gender; - } - eat(): number { - return 1; - } -} -let dog = new Dog("male"); -Assert.equal(dog.eat(), 1); -Assert.equal(dog.name, "dog"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/any_or_unknown_are_propagated_in_falsy_positions/any_or_unknown_are_propagated_in_falsy_positions.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/any_or_unknown_are_propagated_in_falsy_positions/any_or_unknown_are_propagated_in_falsy_positions.ts deleted file mode 100644 index b78c766086..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/any_or_unknown_are_propagated_in_falsy_positions/any_or_unknown_are_propagated_in_falsy_positions.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Since nothing is known about the type on the left side of the &&, - we propagate any and unknown outward instead of the type on the right side. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -let x: unknown; -declare let obj: { str: string }; -let y = x && obj; -function fun(x: any): boolean { - return x && typeof x === "object" && x.blah === "foo"; -} -let z = fun(y); -Assert.isUndefined(z); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/conditional_spreads_create_optional_properties/conditional_spreads_create_optional_properties_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/conditional_spreads_create_optional_properties/conditional_spreads_create_optional_properties_1.ts deleted file mode 100644 index 462ce5b402..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/conditional_spreads_create_optional_properties/conditional_spreads_create_optional_properties_1.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the returned type sometimes uses all-optional properties. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -interface I1 { - x: string; - y: number; - z: string; -} -interface I2 { - x: string; - owner: I1; -} -function fun(other?: I2) { - return { - ...(other && other.owner), - otherStuff: 123, - }; -} -let pet: I2 = { - x: "qiqi", - owner: { - x: "owner", - y: 11, - z: "qingdao", - }, -}; -let pet2 = fun(pet); -Assert.equal(pet2.y, 11); -Assert.equal(pet2.x, "owner"); -Assert.equal(pet2.z, "qingdao"); -Assert.equal(pet2.otherStuff, 123); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_1.ts deleted file mode 100644 index 41c7efa8a4..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_1.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - allows you to re-map keys in mapped types with a new as clause. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -type G = { - [K in keyof T as `get${Capitalize}`]: () => T[K]; -}; -interface I1 { - a: string; - b: number; - c: string; -} -type I1Type = G; -let k1: I1Type = { - getA() { - return "honny"; - }, - getB() { - return 2; - }, - getC() { - return "qingdao"; - }, -}; -Assert.equal(k1.getA(), "honny"); -Assert.equal(k1.getB(), 2); -Assert.equal(k1.getC(), "qingdao"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_2.ts deleted file mode 100644 index 67d448fbc4..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/key_remapping_in_mapped_types/key_remapping_in_mapped_types_2.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - you can even filter out keys by producing never - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -type TYPE1 = { - [K in keyof T as Exclude]: T[K]; -}; -interface I1 { - name: "ww"; - id: number; -} -type TYPE2 = TYPE1; -let k: TYPE2 = { id: 10 }; -Assert.equal(k.id, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/recursive_conditional_types/recursive_conditional_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/recursive_conditional_types/recursive_conditional_types.ts deleted file mode 100644 index 44909b8282..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/recursive_conditional_types/recursive_conditional_types.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - conditional types can now immediately reference themselves within their branches - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -type TYPE1 = T extends ReadonlyArray ? TYPE1 : T; - -function fun1(x: T): TYPE1[] { - return []; -} -let d1 = fun1([1, 2, 3]); -type typeofx = typeof d1; -let nx1: typeofx = [1, 2, 3]; -Assert.isNumber(nx1[0]); -let d2 = fun1([[1], [2, 3]]); -type typeofx2 = typeof d2; -let nx2: typeofx2 = [4, 5, 6]; -Assert.isNumber(nx2[0]); -let d3 = fun1([[1], [[2]], [[[3]]]]); -type typeofx3 = typeof d3; -let nx3: typeofx3 = [7, 8, 9]; -Assert.isNumber(nx3[0]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/resolvers_parameters_are_no_longer_optional_in_promises/resolves_parameters_are_no_longer_optional_in_promises.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/resolvers_parameters_are_no_longer_optional_in_promises/resolves_parameters_are_no_longer_optional_in_promises.ts deleted file mode 100644 index 4dab20ad9d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/resolvers_parameters_are_no_longer_optional_in_promises/resolves_parameters_are_no_longer_optional_in_promises.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - resolve’s Parameters Are No Longer Optional in Promises - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -var count: number = 1; -Assert.equal(count, 1); -let a: number = 10; -setTimeout(function () { - a = 1; -}, 0); -Promise.resolve().then(function () { - a = 2; -}); -Assert.equal(a, 10); -const p = Promise.resolve(1); -p.then(function (s) { - a = a + s; -}); -Assert.equal(a, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_1.ts deleted file mode 100644 index 091f4882eb..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_1.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - String literal types in TypeScript allow us to model functions and APIs that expect a set of specific strings. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -function getnum(x: "a" | "b" | "c") { - if (x == "a") return 1; - else if (x == "b") return 2; - else if (x == "c") return 3; -} -let num1 = getnum("a"); -let num2 = getnum("b"); -let num3 = getnum("c"); -Assert.equal(num1, 1); -Assert.equal(num2, 2); -Assert.equal(num3, 3); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_2.ts deleted file mode 100644 index 44529217d3..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_2.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - template literal string type has the same syntax as template literal strings in JavaScript, but is used in type positions. - When you use it with concrete literal types, it produces a new string literal type by concatenating the contents. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -type Go = "go"; -type Dong = `just ${Go}`; -function fun(w: Go | Dong) { - if (w == "go") return 1; - else if (w == "just go") return 2; -} -let saying1 = fun("go"); -Assert.equal(saying1, 1); -let saying2 = fun("just go"); -Assert.equal(saying2, 2); -type Size = "small" | "big"; -type Num = "one" | "two"; -type Food = `${Num | Size} food`; -function getfish(food: Food) { - if (food == "one food") return 1; - else if (food == "two food") return 2; - else if (food == "small food") return "small"; - else if (food == "big food") return "big"; -} -let x1 = getfish("one food"); -Assert.equal(x1, 1); -let x2 = getfish("two food"); -Assert.equal(x2, 2); -let x3 = getfish("small food"); -Assert.equal(x3, "small"); -let x4 = getfish("big food"); -Assert.equal(x4, "big"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_3.ts deleted file mode 100644 index f71571fefc..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.1/template_literal_types/template_literal_types_3.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The new type aliases are Uppercase, Lowercase, Capitalize and Uncapitalize. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -type UpperHello = `${Uppercase}`; -type LowerHello = `${Lowercase}`; -type CapHello = `${Capitalize}`; -type UncapHello = `${Uncapitalize}`; -type HELLO = UpperHello<"hello">; -type hello = LowerHello<"HEllO">; -type Hello = CapHello<"hello">; -type hELLO = UncapHello<"HELLO">; -function gethello(hi: HELLO | hello | Hello | hELLO) { - if (hi == "HELLO") return 1; - else if (hi == "hello") return 2; - else if (hi == "Hello") return 3; - else if (hi == "hELLO") return 4; -} -let hi1 = gethello("HELLO"); -Assert.equal(hi1, 1); -let hi2 = gethello("hello"); -Assert.equal(hi2, 2); -let hi3 = gethello("Hello"); -Assert.equal(hi3, 3); -let hi4 = gethello("hELLO"); -Assert.equal(hi4, 4); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/Reverting_Template_Literal_Inference/Reverting_Template_Literal_Inference.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/Reverting_Template_Literal_Inference/Reverting_Template_Literal_Inference.ts deleted file mode 100644 index c50fadb28c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/Reverting_Template_Literal_Inference/Reverting_Template_Literal_Inference.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - template string literals would either be given template string types or simplify to multiple string literal types. - These types would then widen to string when assigning to mutable variables. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -const logo: "just do it" = "just do it"; -const str1: string = `go ${logo}`; -let str2: string = `hello ${logo}`; -let str3: "luckily dog just do it" = `luckily dog ${logo}` as const; -function check(op?: string){ - if (op){ - Assert.isString(op); - } -} -check(str1 + str2 + str3); -Assert.equal(str1, "go just do it"); -Assert.equal(str2, "hello just do it"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures.ts deleted file mode 100644 index 866275dfa2..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript allows us to mark a class as abstract. This tells TypeScript that the class is only meant to be extended from, and that certain members need to be filled in by any subclass to actually create an instance. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -abstract class Color { - abstract red: number; - abstract green: number; - abstract blue: number; - protected abstract rgb: [number, number, number]; - - abstract getRGB(): [number, number, number]; -} - -class ColorCopy extends Color { - red: number = 0; - green: number = 0; - blue: number = 0; - protected rgb: [number, number, number] = [0, 0, 0]; - getRGB(): [number, number, number] { - this.rgb = [this.red, this.green, this.blue] - return this.rgb; - } - constructor(r: number, g: number, b: number) { - super(); - this.red = r; - this.green = g; - this.blue = b; - this.getRGB(); - } -} - -let color: ColorCopy = new ColorCopy(255, 0, 0); -Assert.equal(JSON.stringify(color.getRGB()), '[255,0,0]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures_1.ts deleted file mode 100644 index e3fecca282..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures_1.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Assign an abstract class to anything that expects a construct signature is the right thing in case we intend to run code. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -abstract class myClass { - abstract getMy(): number; -} -interface myInter { - getMy(): number; -} - -function func(myCode: new () => myInter) { - let test = new myCode(); - return test.getMy(); -} - -class my_C extends myClass { - getMy(): number { - return 10; - } -} - -Assert.equal(func(my_C), 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures_2.ts deleted file mode 100644 index b00228cffb..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures_2.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 4.2 allows you to specify an abstract modifier on constructor signatures. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -abstract class myClass { - abstract getMy(): number; -} -interface myInter { - getMy(): number; -} - -let myTest: abstract new () => myInter = myClass; -Assert.equal(myTest.toString(), 'class myClass {\n}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures_3.ts deleted file mode 100644 index 1ee46162c2..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/abstract_construct_signatures/abstract_construct_signatures_3.ts +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The feature allows us to write mixin factories in a way that supports abstract classes. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -abstract class Point { - abstract a: number; - abstract b: number; - abstract getPoint(): [number, number]; -} - -type MIX = abstract new (...args: any[]) => T - -function mixClass>(Ctor: T) { - abstract class CPColor extends Ctor { - abstract red: number; - abstract green: number; - abstract blue: number; - abstract getColor(): [number, number, number]; - } - return CPColor; -} - -class ColorPoint extends mixClass(Point) { - red: number = 0; - green: number = 0; - blue: number = 0; - a: number = 0; - b: number = 0; - getColor(): [number, number, number] { - return [this.red, this.green, this.blue]; - } - getPoint(): [number, number] { - return [this.a, this.b]; - } - constructor(red: number = 0, green: number = 0, blue: number = 0, a: number = 0, b: number = 0) { - super(); - this.a = a; this.b = b; - this.red = red; this.green = green; this.blue = blue; - } -} - -let cp = new ColorPoint(0, 255, 0, 25, 25); -Assert.equal(JSON.stringify(cp.getColor()), '[0,255,0]'); -Assert.equal(JSON.stringify(cp.getPoint()), '[25,25]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types1.ts deleted file mode 100644 index 6883648348..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types1.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In TypeScript, tuple types are meant to model arrays with specific lengths and element types. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -type myType = Function | object; - -let tup: [myType, string, boolean] = [() => { }, 'a', true]; -Assert.isFunction(tup[0]); -Assert.isString(tup[1]); -Assert.isBoolean(tup[2]); - -tup = [{ o: 'obj' }, 'b', false]; -Assert.isObject(tup[0]); -Assert.isString(tup[1]); -Assert.isBoolean(tup[2]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types2.ts deleted file mode 100644 index 95db41ca99..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types2.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - they can have optional elements and rest elements, and can even have labels for tooling and readability. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -type myType = Function | object; - -let tup1: [myType, string?] = [() => { }]; -tup1 = [{ o: "obj" }, "a"]; - -let tup2: [arg1: myType, arg2?: string] = [() => { }]; -tup2 = [{ o: "obj" }, "a"]; - -let tup3: [myType, string, ...unknown[]]; - -tup3 = [() => { }, "world"]; -tup3 = [{ o: "obj" }, "world", false]; -tup3 = [{ o: "obj" }, "world", true, 2]; - -Assert.equal(JSON.stringify(tup1), "[{\"o\":\"obj\"},\"a\"]"); -Assert.equal(JSON.stringify(tup2), "[{\"o\":\"obj\"},\"a\"]"); -Assert.equal(JSON.stringify(tup3), "[{\"o\":\"obj\"},\"world\",true,2]"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types3.ts deleted file mode 100644 index 7327dd2258..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types3.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In prior versions, TypeScript only allowed '...rest' elements at the very last position of a tuple type. - However, now rest elements can occur anywhere within a tuple. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -interface h_i{ - num: number; -} -interface h_f{ - str: string; -} -type myType = h_i | h_f; - -let tup1: [...myType[], boolean]; -tup1 = [true]; -tup1 = [{ num: 10 }, true]; -tup1 = [{ num: 10 }, { str: 'string' }, true]; - -let tup2: [string, ...myType[], boolean]; -tup2 = ['a', false]; -tup2 = ['a', { num: 10 }, false]; -tup2 = ['a', { num: 10 }, { str: 'string' }, false]; - -let tup3: [string, boolean, ...myType[]]; -tup3 = ['a', false]; -tup3 = ['a', false, { num: 10 }]; -tup3 = ['a', false, { num: 10 }, { str: 'string' }]; - -Assert.equal(JSON.stringify(tup1), "[{\"num\":10},{\"str\":\"string\"},true]"); -Assert.equal(JSON.stringify(tup2), "[\"a\",{\"num\":10},{\"str\":\"string\"},false]"); -Assert.equal(JSON.stringify(tup3), "[\"a\",false,{\"num\":10},{\"str\":\"string\"}]"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types4.ts deleted file mode 100644 index 7166f27057..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/leading_middle_rest_elements_in_tuple_types/leading_middle_rest_elements_in_tuple_types4.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - These non-trailing rest elements can be used to model functions that take any number of leading arguments, - followed by a few fixed ones. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -function func1(...arg: [...arr: unknown[], num: number]) { - return { ...arg }; -} -let result1 = func1(10); -Assert.equal(JSON.stringify(result1), '{"0":10}'); -let result2 = func1(5, 's', true, 10); -Assert.equal(JSON.stringify(result2), '{"0":5,"1":"s","2":true,"3":10}'); - -function func2(...arg: [str:string, ...arr: unknown[], num: number]) { - return { ...arg }; -} -let result3 = func2('a', 10); -Assert.equal(JSON.stringify(result3), '{"0":"a","1":10}'); -let result4 = func2('s', true, 10); -Assert.equal(JSON.stringify(result4), '{"0":"s","1":true,"2":10}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/relaxed_rules_between_optional_properties_and_string_index_signatures/relaxed_rules.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/relaxed_rules_between_optional_properties_and_string_index_signatures/relaxed_rules.ts deleted file mode 100644 index 655eba6671..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/relaxed_rules_between_optional_properties_and_string_index_signatures/relaxed_rules.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Previous versions of TypeScript treated optional object properties as - unassignable to otherwise compatible index signatures, due to the presence of undefined. - TypeScript 4.2 allows this assignment. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -interface I{ - [key: string]: number; -} - -type myType = { - 'a'?: number; - 'b'?: number; - 'c'?: number; -} -const eg: myType = { 'a': 10 }; -const i: I = eg; -Assert.isObject(i); - -const obj: { [key: string]: number } = eg; -Assert.isObject(obj); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation1.ts deleted file mode 100644 index 9ccb67a316..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation1.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript has always used a set of rules and guesses for when to reuse type aliases when printing out types. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -type T = number | string | boolean; -function func(value: T): T { - return value; -} -let arr = [1, "hello", false]; -Assert.equal(typeof func(arr[0]), "number"); - -class C{ - mem: T; - constructor(mem: T) { - this.mem = mem; - } -} -let c = new C(10); -Assert.isNumber(c.mem); -c.mem = 'a'; -Assert.isString(c.mem); -c.mem = true; -Assert.isBoolean(c.mem); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation2.ts deleted file mode 100644 index e6cd3461ba..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.2/smarter_type_alias_preservation/smarter_type_alias_preservation2.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If we hover our mouse over value in an editor like Visual Studio, Visual Studio Code, or the TypeScript Playground, we’ll get a quick info panel that shows the type BasicPrimitive. Likewise, if we get the declaration file output (.d.ts output) for this file, TypeScript will say that doStuff returns BasicPrimitive. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -type T = number | string | boolean; -function func(arg: T) { - return arg; -} - -let arr = [10, "hello", false]; -Assert.equal(typeof func(arr[0]), "number"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/always-truthy_promise_checks/always-truthy_promise_checks.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/always-truthy_promise_checks/always-truthy_promise_checks.ts deleted file mode 100644 index ee1719ad8c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/always-truthy_promise_checks/always-truthy_promise_checks.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Under strictNullChecks, checking whether a Promise is 'truthy' in a conditional will trigger an error. - options: - lib: es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -async function getFalse(): Promise { - return false; -} - -async function funPromise(): Promise { - if (!getFalse()) { - return 'false'; - } - return 'true'; -} - -var b = funPromise(); -Assert.equal(b, '[object Promise]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/constructorParameters_works_on_abstract_class/constructorParameters_works_on_abstract_class.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/constructorParameters_works_on_abstract_class/constructorParameters_works_on_abstract_class.ts deleted file mode 100644 index a3618c6e84..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/constructorParameters_works_on_abstract_class/constructorParameters_works_on_abstract_class.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The ConstructorParameters type helper now works on abstract classes. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -abstract class CPC { - a: string; - b: number; - constructor(a: string, b: number) { - this.a = a; - this.b = b; - } -} - -type TypeC = ConstructorParameters; -var c: TypeC = ["s", 10]; -Assert.equal(JSON.stringify(c), '["s",10]'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/contextual_narrowing_for_generic/contextual_narrowing_for_generics.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/contextual_narrowing_for_generic/contextual_narrowing_for_generics.ts deleted file mode 100644 index a1ee16262d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/contextual_narrowing_for_generic/contextual_narrowing_for_generics.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 4.3 now includes some slightly smarter type-narrowing logic on generic values. - This allows TypeScript to accept more patterns, and sometimes even catch mistakes. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -function funSetorArray | T[]>(collection: C): C { - if (collection instanceof Set) { - return collection; - } - return collection; -} - -let num: number[] = [1, 3, 2, 2, 4]; -let n = funSetorArray(num); -Assert.equal(JSON.stringify(funSetorArray(num)), "[1,3,2,2,4]"); - -let ss = new Set(); -ss.add("NARC"); -ss.add("TypeScript"); -let ts = funSetorArray(ss); -Assert.isTrue(ts.has("NARC")); -Assert.isTrue(ts.has("TypeScript")); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/ecmascript_private_class_elements/ecmascript_private_calss_elements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/ecmascript_private_class_elements/ecmascript_private_calss_elements.ts deleted file mode 100644 index 16ee873e22..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/ecmascript_private_class_elements/ecmascript_private_calss_elements.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 4.3 expands which elements in a class can be given #private #names to make them truly private at run-time. - In addition to properties, methods and accessors can also be given private names. - Even more broadly, static members can now also have private names. - options: - target: es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -class ClassP { - #FUN() { - return 1; - } - F1() { - return this.#FUN(); - } - static #something(num: number) { - return num; - } - F2() { - return ClassP.#something(10); - } - get #V() { - return 100; - } - mFUN() { - this.#FUN(); - return this.#V; - } -} - -let c = new ClassP(); -Assert.equal(c.F1(), 1); -Assert.equal(c.F2(), 10); -Assert.equal(c.mFUN(), 100); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/override_and_the_noImplicitOverride_Flag/override_and_the_noImplicitOverride_Flag.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/override_and_the_noImplicitOverride_Flag/override_and_the_noImplicitOverride_Flag.ts deleted file mode 100644 index 99a9b6f11f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/override_and_the_noImplicitOverride_Flag/override_and_the_noImplicitOverride_Flag.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - adds the override keyword.provides a new noImplicitOverride flag.When this option is turned on, it becomes an error to override any method from a superclass unless you explicitly use an override keyword. - In that last example, TypeScript would error under noImplicitOverride, and give us a clue that we probably need to rename our method inside of Derived. - And index signatures can now be declared as static. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -class Boss { - run(person?: string): string { - return person + " go" - } -} -class Manage extends Boss { - run(person?: string): string { - return super.run(person); - } -} -class Staff extends Boss { - override run(person?: string): string { - super.run(); - return person + " run"; - } -} -let boss = new Boss(); -Assert.equal(boss.run("boss"), "boss go"); - -let manage = new Manage(); -Assert.equal(manage.run("manage"), "manage go"); - -let staff = new Staff(); -Assert.equal(staff.run("staff"), "staff run"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_1.ts deleted file mode 100644 index a925554105..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_1.ts +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 4.3 allows to specify types for reading and writing to properties. - When considering how two properties with the same name relate to each other, TypeScript will only use the "reading" type. - "Writing" types are only considered when directly writing to a property. - options: - target: es2015 - lib: es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -class SWTC1 { - #data = 0; - get data(): number { - return this.#data; - } - set data(val: string | number | boolean) { - if (val === undefined || val === null) { - this.#data = NaN; - } else if (typeof val === "number") { - this.#data = val; - } else if (typeof val === "string") { - this.#data = val.length; - } else if (typeof val === "boolean") { - if (val === false) { - this.#data = 0; - } else if (val === true) { - this.#data = 1; - } - } - } -} - -let c = new SWTC1(); -let n: number = 0; - -c.data = "hello"; -n = c.data; -Assert.equal(n, 5); - -c.data = 42; -n = c.data; -Assert.equal(n, 42); - -c.data = true; -n = c.data; -Assert.equal(n, 1); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_2.ts deleted file mode 100644 index c765ea1462..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/separate_write_types_on_properties/separate_write_types_on_properties_2.ts +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Be able to write getters and setters with different types in object literals. - options: - lib: es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -interface SWTC2 { - get data(): number; - set data(val: number | string | boolean); -} - -function funSW(): SWTC2 { - let data = 0; - return { - get data(): number { - return data; - }, - set data(val: string | number | boolean) { - if (val === undefined || val === null) { - data = NaN; - } else if (typeof val === "number") { - data = val; - } else if (typeof val === "string") { - data = val.length; - } else if (typeof val === "boolean") { - if (val === false) { - data = 0; - } else if (val === true) { - data = 1; - } - } - }, - }; -} - -let t = funSW(); -t.data = "NARC"; -Assert.equal(t.data, 4); - -t.data = true; -Assert.equal(t.data, 1); - -t.data = 1024; -Assert.equal(t.data, 1024); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/static_index_signatures/static_index_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/static_index_signatures/static_index_signatures.ts deleted file mode 100644 index 99f3ab9544..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/static_index_signatures/static_index_signatures.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Index signatures allow us set more properties on a value than a type explicitly declares, - And index signatures can now be declared as static. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -class SIS { - hello = "hello"; - world = "1213"; - [propName: string]: string | number | undefined; -} - -let sis = new SIS(); -sis["Yes!Yes!Yes!"] = 42; -Assert.equal(sis["Yes!Yes!Yes!"], 42); - -let x = sis["No!No!No!"]; -x = undefined; -Assert.isUndefined(x); -x = 20; -Assert.equal(x, 20); -x = "x"; -Assert.equal(x, "x"); - -class B { - static hello = "hello"; - static world = 1342; - static [propName: string]: string | number | undefined; -} - -B["Yes!Yes!Yes!"] = 42; -Assert.equal(B["Yes!Yes!Yes!"], 42); - -let y = B["No!No!No!"]; -y = "y"; -Assert.equal(y, "y"); -y = 10; -Assert.equal(y, 10); -y = undefined; -Assert.isUndefined(y); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_1.ts deleted file mode 100644 index ff93498ef3..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_1.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Template string types are types that either construct new string-like types by concatenating, - or match patterns of other string-like types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -type Figure = "three-colour" | "pure color"; -type Num = "one" | "two"; - -type Cat1 = `${Num | Figure} cat`; -type Cat2 = "one cat" | "two cat" | "three-colour cat" | "pure color cat"; -var cat1: Cat1 = "pure color cat"; -var cat2: Cat2 = cat1; -cat1 = "one cat"; -cat2 = cat1; -cat1 = "three-colour cat"; -cat2 = cat1; -cat1 = "two cat"; -cat2 = cat1; - -let s1: `${number}-${number}-${number}`; -let s2: `1-2-3` = `1-2-3`; -s1 = s2; -Assert.equal(s1, "1-2-3"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_2.ts deleted file mode 100644 index d957eb3f4f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_2.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - When a template string is contextually typed by a string-literal-like type it will try to give that expression a template type. - This also kicks in when inferring types, and the type parameter extends string. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -function funStr(s: string): `hello ${string}` { - return `hello ${s}`; -} -var b = funStr("s"); -Assert.equal(b, "hello s"); - -let s: string = "s"; -function f(x: T): T { - return x; -} -let x: `hello ${string}` = f(`hello ${s}`); -Assert.equal(x, "hello s"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_3.ts deleted file mode 100644 index 87d00e6a13..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_3.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript can now better-relate, and infer between, different template string types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -let sn1: `${number}-${number}-${number}`; -let sn2: `1-2-3` = `1-2-3`; -let sn3: `${number}-2-3` = `${4}-2-3`; -let sn4: `1-${number}-3` = `1-${5}-3`; -let sn5: `1-2-${number}` = `1-2-${6}`; -let sn6: `${number}-2-${number}` = `${7}-2-${8}`; - -sn1 = sn2; -Assert.equal(sn1, "1-2-3"); -sn1 = sn3; -Assert.equal(sn1, "4-2-3"); -sn1 = sn4; -Assert.equal(sn1, "1-5-3"); -sn1 = sn5; -Assert.equal(sn1, "1-2-6"); -sn1 = sn6; -Assert.equal(sn1, "7-2-8"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_4.ts deleted file mode 100644 index 71d4db250f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/template_string_type_improvements/template_string_type_improvements_4.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript add better inference capabilities - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -function funStr01(arg: `*${V}*`): `*${V}*` { - return arg; -} -function funStr02(s: string, n: number, b: boolean, t: T) { - let x1 = funStr01("*hello*"); - Assert.equal(x1, "*hello*"); - - let x2 = funStr01("**hello**"); - Assert.equal(x2, "**hello**"); - - let x3 = funStr01(`*${s}*` as const); - Assert.equal(x3, "*s*"); - - let x4 = funStr01(`*${n}*` as const); - Assert.equal(x4, "*5*"); - - let x5 = funStr01(`*${b}*` as const); - Assert.equal(x5, "*true*"); - - let x6 = funStr01(`*${t}*` as const); - Assert.equal(x6, "*t*"); - - let x7 = funStr01(`**${s}**` as const); - Assert.equal(x7, "**s**"); -} - -funStr02("s", 5, true, "t"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/union_enums_cannot_be_compared_to_arbitrary_numbers/union_enums_cannot_be_compared_to_arbitrary_numbers.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.3/union_enums_cannot_be_compared_to_arbitrary_numbers/union_enums_cannot_be_compared_to_arbitrary_numbers.ts deleted file mode 100644 index 1ff166bc82..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.3/union_enums_cannot_be_compared_to_arbitrary_numbers/union_enums_cannot_be_compared_to_arbitrary_numbers.ts +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If a value with a union enum type is compared with a numeric literal that it could never be equal to, - then the type-checker will issue an error. - As a workaround, you can re-write an annotation to include the appropriate literal type. - You can also use a type-assertion on the value. - Alternatively, you can re-declare your enum to have a non-trivial initializer so that any number is both assignable and comparable to that enum. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -enum AB { - A = 0, - B = 1, -} - -function eFun01(x: AB | -1) { - if (x === -1) { - return -1; - } - return 1; -} -Assert.equal(eFun01(-1), -1); -Assert.equal(eFun01(AB.A), 1); - -function eFun02(x: AB) { - if ((x as number) === -1) { - return x; - } - return x + 1; -} -Assert.equal(eFun02(AB.A), 1); - -enum ab { - A = +0, - B = 1, -} -function eFun03(x: ab) { - if (x === 1) { - return x; - } - return x + 2; -} - -Assert.equal(eFun03(ab.A), 2); -Assert.equal(eFun03(ab.B), 1); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_1.ts deleted file mode 100644 index bfe2bf2e4e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_1.ts +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - When TypeScript sees that we are testing a constant value, it will do a little bit of extra work to see if it contains a type guard. - If that type guard operates on a const, a readonly property, or an un-modified parameter, - then TypeScript is able to narrow that value appropriately. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -function fun01(a: unknown) { - if (typeof a === "string") { - Assert.equal(a[0], "c"); - } - if (typeof a === "number") { - Assert.equal(a, 11); - } - if (typeof a === "boolean") { - Assert.equal(a, true); - } - if (typeof a === "undefined") { - Assert.isUndefined(a); - } - if (typeof a === "function") { - Assert.isFunction(a); - } - if (typeof a === "object") { - Assert.isObject(a); - } - if (typeof a === "symbol") { - Assert.isSymbol(a); - } -} -fun01("c"); -fun01(11); -fun01(true); -let x: undefined; -fun01(x); -let f = (a: number) => { a = 0; return a; }; -fun01(f); -let obj: object = { - x: 1 -} -fun01(obj); -let sym: symbol = Symbol('a'); -fun01(sym); -interface I { - readonly name: "caihua"; -} -function fun02() { - let tt: I = { name: "caihua" }; - let res = tt.name === "caihua"; - if (res) { - Assert.isNumber(tt.name.length); - Assert.equal(tt.name[0], "c"); - } -} -fun02(); -function fun03(a: number, b = "function" as const) { - let cc = typeof b === "function"; - if (cc) { - Assert.isNumber(b.length); - Assert.equal(b[0], "f"); - Assert.equal(cc, true); - } else { - Assert.equal(cc, false); - } -} -fun03(12); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_2.ts deleted file mode 100644 index 6327ee0e6c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_2.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: Different sorts of type guard conditions are preserved. For example, checks on discriminated unions - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -type T1 = { name: "x1"; size: number }; -type T2 = { name: "x2"; sideLength: number }; -type T3 = T1 | T2; -let c: T1 = { name: "x1", size: 2 }; -let s: T2 = { name: "x2", sideLength: 2 }; -function fun01(shape: T3): number { - const isx1 = shape.name === "x1"; - if (isx1) { - return Math.PI * shape.size ** 2; - } else { - return shape.sideLength ** 2; - } -} -Assert.equal(Math.round(fun01(c)), 13); -Assert.equal(fun01(s), 4); -function fun02(shape: T3): number { - const { name } = shape; - if (name === "x1") { - return Math.PI * shape.size ** 2; - } else { - return shape.sideLength ** 2; - } -} -Assert.equal(Math.round(fun02(c)), 13); -Assert.equal(fun02(s), 4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_3.ts deleted file mode 100644 index 1fd1125523..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_3.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Different sorts of type guard conditions are preserved. - As another example, here’s a function that checks whether two of its inputs have contents. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -function fun01(a: string | undefined, b: number | undefined, c: boolean) { - const res = a && b && c; - if (res) { - Assert.equal(a.toLowerCase(), "abc"); - Assert.equal(b, 1); - Assert.equal(c, true); - return 1; - } else { - return 0; - } -} -Assert.equal(fun01("abc", 1, true), 1); -Assert.equal(fun01("abc", undefined, true), 0); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_4.ts deleted file mode 100644 index 197743bae2..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/control_flow_analysis_of_aliased_conditions_and_discriminants/control_flow_analysis_of_aliased_conditions_and_discriminants_4.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - One neat feature here is that this analysis works transitively. - TypeScript will hop through constants to understand what sorts of checks you’ve already performed. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -function isBool(a: unknown) { - if (typeof a === "string") { - Assert.equal(a[0], "f"); - } - if (typeof a === "number") { - Assert.equal(a, 12); - } - if (typeof a === "boolean") { - Assert.isBoolean(a); - } - if (typeof a === "undefined") { - Assert.isUndefined(a); - } - if (typeof a === "function") { - Assert.isFunction(a); - } - if (typeof a === "object") { - Assert.isObject(a); - } - if (typeof a === "symbol") { - Assert.isSymbol(a); - } - const x = typeof a === "string"; - const y = typeof a === "number"; - const z = x || y; - if (z) { - return 0; - } else { - return 1; - } -} -Assert.equal(isBool(false), 1); -Assert.equal(isBool("false"), 0); -Assert.equal(isBool(12), 0); -let x: undefined; -Assert.equal(isBool(x), 1); -let f = (a: number) => { a = 0; return a; }; -Assert.equal(isBool(f), 1); -let obj: object = { - x: 1 -} -Assert.equal(isBool(obj), 1); -let sym: symbol = Symbol('a'); -Assert.equal(isBool(sym), 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_1.ts deleted file mode 100644 index 1b32668a96..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_1.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 4.4 introduces a new flag called useUnknownInCatchVariables. - This flag changes the default type of catch clause variables from any to unknown. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -function fun(a: any) { - if (typeof a === "number") { - } else { - throw new Error("type error"); - } -} - -try { - fun("string"); -} catch (err) { - Assert.equal(err instanceof Error, true); - if (err instanceof Error) { - Assert.equal(err.message, "type error"); - } -}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_2.ts deleted file mode 100644 index 47e6410eaa..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_2.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - useUnknownInCatchVariables flag is enabled under the strict family of options. - That means that if you check your code using strict, this option will automatically be turned on - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -function fun(a: any) { - if (typeof a === "number") { - } else { - throw new Error("type error"); - } -} - -try { - fun("string"); -} catch (err) { - Assert.equal(err instanceof Error, true); - if (err instanceof Error) { - Assert.equal(err.message, "type error"); - } -}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_3.ts deleted file mode 100644 index 7820b475cd..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/defaulting_to_the_unknown_type_in_catch_variables/defaulting_to_the_unknown_type_in_catch_variables_3.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In cases where we don’t want to deal with an unknown variable in a catch clause, - we can always add an explicit : any annotation so that we can opt out of stricter types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -function fun(a: any) { - if (typeof a === "number") { - } else { - throw new Error("type error"); - } -} - -try { - fun("string"); -} catch (err: any) { - Assert.equal(err instanceof Error, true); - Assert.equal(err.message, "type error"); -}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/exact_optional_property_types/exact_optional_property_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/exact_optional_property_types/exact_optional_property_types_1.ts deleted file mode 100644 index 3ec83281b8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/exact_optional_property_types/exact_optional_property_types_1.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In TypeScript 4.4, the new flag exactOptionalPropertyTypes specifies that optional property types - should be interpreted exactly as written, meaning that | undefined is not added to the type - This flag needs to be turned on explicitly. It also requires strictNullChecks to be enabled as well. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -interface I { - x: string; - y?: number; -} -const p: I = { - x: "aaaa", -}; -const keys = Object.keys(p); -Assert.equal(keys.indexOf("y"), -1); -Assert.equal(typeof p.y, "undefined"); -Assert.notEqual(typeof p.y, "number"); -p.y = 12; -Assert.equal(typeof p.y, "number"); -Assert.notEqual(typeof p.y, "undefined"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/static_blocks_in_classe/static_blocks_in_classes1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/static_blocks_in_classe/static_blocks_in_classes1.ts deleted file mode 100644 index 40f59e3ee2..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/static_blocks_in_classe/static_blocks_in_classes1.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - These static blocks allow you to write a sequence of statements with their own scope - that can access private fields within the containing class. - we can write initialization code with all the capabilities of writing statements, no leakage of variables, and full access to our class’s internals. - options: - target: es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -class C { - static #aa = 0; - - get aaValue() { - return C.#aa; - } - - static { - C.#aa++; - } -} -let x = new C(); -Assert.equal(x.aaValue, 1); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/static_blocks_in_classe/static_blocks_in_classes2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/static_blocks_in_classe/static_blocks_in_classes2.ts deleted file mode 100644 index 40a0eaa36d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/static_blocks_in_classe/static_blocks_in_classes2.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: a class can have multiple static blocks, and they’re run in the same order in which they’re written. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -class C { - static aa = 0; - - get aaValue() { - return C.aa; - } - static { - C.aa++; - Assert.equal(C.aa, 1); - } - static { - C.aa++; - Assert.equal(C.aa, 2); - } - static { - C.aa++; - Assert.equal(C.aa, 3); - } -} -new C(); -Assert.equal(C.aa, 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_1.ts deleted file mode 100644 index 8c3e13e57a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_1.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript lets us describe objects where every property has to have a certain type using index signatures. - This allows us to use these objects as dictionary-like types, where we can use string keys to index into them with square brackets. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -interface I { - [key: string]: any; -} -let t: I = {}; -t["1"] = 1; -t["2"] = "1"; -const keys = Object.keys(t); -keys.forEach((item) => { - Assert.isString(item); -}); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_2.ts deleted file mode 100644 index 856247e66a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_2.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: Array already defines a number index signature that lets us insert/retrieve values of type T - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -let x: Array = []; -x[0] = "a"; -Assert.equal(x[0], "a"); -Assert.isString(x[0]); -x[1] = 12; -Assert.equal(x[1], 12); -Assert.isNumber(x[1]); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_3.ts deleted file mode 100644 index 4943f196de..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_3.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: TypeScript 4.4 allows index signatures for symbols and template string patterns. - options: - lib:es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -interface I { - [keys: number | string]: any; -} -const x: any = Symbol("x"); -const y: any = Symbol("y"); -const z: any = Symbol("z"); -let c: I = {}; -c[x] = 0xff0000; -c[y] = 0x00ff00; -c[z] = 0x0000ff; -Assert.isNumber(c[x]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_4.ts deleted file mode 100644 index c169e0dcb6..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_4.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: we can write an index signature with template string pattern type - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -interface I { - name: string; - age: number; -} -interface I2 extends I { - [optName: number]: any; -} -let a: I2 = { - name: "wangcai", - age: 20 -}; -Assert.isString(a.name); -Assert.isNumber(a.age); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_5.ts deleted file mode 100644 index fd4ef12cf0..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.4/symbol_and_templates_string_pattern_index_signatures/symbol_and_templates_string_pattern_index_signatures_5.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - index signatures now permit union types,as long as they’re a union of infinite-domain primitive types - specifically:string,number,symbol,template string patterns - An index signature whose argument is a union of these types will de-sugar into several different index signatures. - options: - lib:es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -interface I1 { - [key: number]: any; -} -interface I2 { - - [key: number]: any; -} -interface I3 extends I2 { - [key: number]: any; -} -const one: 1 = 1; -let a: I1 = {}; -let b: I3 = {}; -b[one] = 1; -a = b; -Assert.equal(a[one], 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/disabling_import_elision/disabling_import_elision_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/disabling_import_elision/disabling_import_elision_1.ts deleted file mode 100644 index de587ac3da..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/disabling_import_elision/disabling_import_elision_1.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 4.5, you can enable a new flag called preserveValueImports to prevent TypeScript - from stripping out any imported values from your JavaScript outputs. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js"; -import { human } from "./human.js"; - -Assert.isFunction(human); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/disabling_import_elision/human.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/disabling_import_elision/human.ts deleted file mode 100644 index 53918940d0..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/disabling_import_elision/human.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -export class Human { - name: string; - age: number; - gender: string; - constructor(name: string, age: number, gender: string) { - this.name = name; - this.age = age; - this.gender = gender; - } -} - -export { Human as human }; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/private_field_presence_checks/private_field_presence_checks_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/private_field_presence_checks/private_field_presence_checks_1.ts deleted file mode 100644 index 3d042696a5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/private_field_presence_checks/private_field_presence_checks_1.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - You can now write a class with a #private field member and see whether another object has the same field by using the in operator. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../suite/assert.js' - -class RunP { - #type: string; - constructor(type: string) { - this.#type = type; - } - - combine(additional: any) { - return additional && - typeof additional === "object" && - #type in additional&& - this.#type === additional.#type; - } -} - -const men = new RunP('jack'); -const women = new RunP('marry'); -Assert.equal(women.combine(men), false); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types1.ts deleted file mode 100644 index e893954d60..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types1.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - As long as one branch of a conditional type is simply another conditional type, TypeScript can avoid intermediate instantiations. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" - -type project = T extends ` ${infer push}` ? project : T; - -type example = project<" tool">; -var t: example = "tool"; -Assert.equal(t, "tool"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts deleted file mode 100644 index c8756ae053..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/tail_recursion_elimination_on_conditional_types/tail_recursion_elimination_on_conditional_types2.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The following type won't be optimized, since it uses the result of a conditional type by adding it to a union. - You can introduce a helper that takes an "accumulator" type parameter to make it tail-recursive - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" - -type RunObtain = S extends `${infer Char}${infer Rest}` - ? Char | RunObtain - : never; -type gc = RunObtain<" getChar">; -var g1: gc = "e"; -Assert.isString(g1); - -type RunObtain1 = RunObtainHelper; -type RunObtainHelper = S extends `${infer Char}${infer Rest}` - ? RunObtainHelper - : Acc; - -type gch = RunObtainHelper; -var g2: gch = 10; -Assert.isNumber(g2); - -let g3: RunObtain1<' NEW'> = ' '; -Assert.equal(g3, ' '); -g3 = 'E'; -Assert.equal(g3, 'E'); - -let g4: RunObtainHelper<' NARC ', 'ACC'> = 'ACC'; -Assert.equal(g4, 'ACC'); -g4 = 'N'; -Assert.equal(g4, 'N'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/template_string_types_as_discriminants/template_string_types_as_discriminants_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/template_string_types_as_discriminants/template_string_types_as_discriminants_1.ts deleted file mode 100644 index 26938121c1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/template_string_types_as_discriminants/template_string_types_as_discriminants_1.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: > - TypeScript 4.5 now can narrow values that have template string types, and also recognizes template string types as discriminants. -module: ESNext -isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" - -interface Message { - pattern: string; - location: string; -} - -interface SMessage { - pattern: `${string}SMessage`; - location: string; -} - -interface EMessage { - pattern: `${string}EMessage`; - message: string; -} - -function RunTest(r: SMessage | EMessage |Message) { - if (r.pattern === "WinSMessage") { - let token = r.pattern; - Assert.equal(token, "WinSMessage"); - } else { - Assert.equal(r.pattern, "LostEMessage"); - } -} - -const successMessage: SMessage = { - pattern: "WinSMessage", - location: "request SMessage" -} - -const errorMessage: EMessage = { - pattern: "LostEMessage", - message: "100-continue" -} - -RunTest(successMessage); -RunTest(errorMessage); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/the_awaited_type_and_promise_improvements/the_awaited_type_and_promise_improvements_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/the_awaited_type_and_promise_improvements/the_awaited_type_and_promise_improvements_1.ts deleted file mode 100644 index bab72306a0..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/the_awaited_type_and_promise_improvements/the_awaited_type_and_promise_improvements_1.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 4.5 introduces a new utility type called the Awaited type. - This type is meant to model operations like await in async functions, - or the .then() method on Promises - specifically, the way that they recursively unwrap Promises; - some of the problems around inference with Promise.all served as motivations for Awaited. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" - - -function ToP(value: number): number | Promise | PromiseLike { - return new Promise((resolve, reject) => { - resolve(Math.random()); - }); -} - -async function operate(): Promise<[number, number]> { - const result = await Promise.all([ToP(100), ToP(200)]); - return result; -} - -let D = operate().then(res => { - Assert.isObject(res, "object"); -}); - -type E = Awaited>; - -let e: E; -Assert.equal(e, undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/some-module.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/some-module.ts deleted file mode 100644 index 3c939175fc..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/some-module.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -let num = 5; -export let privateF = function () { - return 10 + num; -}; - -export class PrivateType { }; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts deleted file mode 100644 index 6f5d5337cd..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.5/type_modifiers_on_import_names/type_modifiers_on_import_names_1.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- -description: > - That’s part of why TypeScript 4.5 allows a type modifier on individual named imports. - BaseType is always guaranteed to be erased and someFunc will be preserved under preserveValueImports. -module: ESNext -isCurrent: true ----*/ - - -import { Assert } from "../../../suite/assert.js" -import type { PrivateType } from "./some-module.js" -import { privateF } from "./some-module.js" - - -export class Type implements PrivateType { - func() { - return privateF(); - } -} - -const type = new Type(); -Assert.isFunction(Type); -Assert.equal(type.func(), 15); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/1_allowing_code_in_constructors.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/1_allowing_code_in_constructors.ts deleted file mode 100644 index 1ce1356b83..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/1_allowing_code_in_constructors.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: TypeScript 4.6 is now much more lenient in that check and permits other code to run before super()., all while still ensuring that super() occurs at the top-level before any references to this. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../suite/assert.js' - -class C { - a: number = 1; -} -class C2 extends C { - bool = true; - constructor() { - let x = 1; - Assert.equal(x, 1); - super(); - this.bool = false; - } - getBool(): boolean { - return this.bool; - } -} -let d = new C2(); -Assert.equal(d.getBool(), false); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/2_control_flow_analysis.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/2_control_flow_analysis.ts deleted file mode 100644 index 6632cb6201..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/2_control_flow_analysis.ts +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: TypeScript is able to narrow types based on what’s called a discriminant property. For example, in the following code snippet, TypeScript is able to narrow the type of action based on every time we check against the value of name. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../suite/assert.js' - -type T = - | { name: "Name"; size: number } - | { name: "Name2"; size: string }; -function fun1(action: T) { - if (action.name === "Name") { - let num = action.size * 2; - return num; - } else if (action.name === "Name2") { - const str = action.size.trim(); - return str; - } -} -let action1: T = { - name: "Name", - size: 1 -} -let action2: T = { - name: "Name2", - size: " 1234 " -} -Assert.equal(2, fun1(action1)); -Assert.equal("1234", fun1(action2)); -type Action2 = - | { name: "Name"; size: number } - | { name: "Name2"; size: string }; -function fun2(action: Action2) { - const { name, size } = action; - if (name === "Name") { - let num = size * 2; - return num; - } else if (name === "Name2") { - const str = size.trim(); - return str; - } -} -let action3: T = { - name: "Name", - size: 2 -} -let action4: T = { - name: "Name2", - size: " 5678 " -} -Assert.equal(fun2(action3), 4); -Assert.equal(fun2(action4), "5678"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/3_improved_recursion_depth_checks.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/3_improved_recursion_depth_checks.ts deleted file mode 100644 index cd07f12434..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/3_improved_recursion_depth_checks.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: Improved Recursion Depth Checks - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../suite/assert.js' - -interface I3 { - prop: T; -} -let x: I3>>>>>; -let y: I3>>>>; -y = { prop: { prop: { prop: { prop: { prop: "prop" } } } } } -x = { prop: y }; -Assert.notEqual(JSON.stringify(x), JSON.stringify(y)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/4_indexed_access_inference_improvements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/4_indexed_access_inference_improvements.ts deleted file mode 100644 index 80cc93cdaa..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/4_indexed_access_inference_improvements.ts +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: TypeScript now can correctly infer to indexed access types which immediately index into a mapped object type. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../suite/assert.js' - -interface I { - a: number; - b: string; - c: boolean; - d: object; -} -type T

= { - [K in P]: { - nameI: K; - v: I[K]; - f: (p: I[K]) => void; - }; -}[P]; -function fun(x: T) { - x.f(x.v); -} -fun({ - nameI: "a", - v: 11, - f: (x) => { - Assert.isNumber(x); - }, -}); -fun({ - nameI: "b", - v: "b", - f: (x) => { - Assert.isString(x); - }, -}); -fun({ - nameI: "c", - v: true, - f: (x) => { - Assert.isBoolean(x); - }, -}); -fun({ - nameI: "d", - v: {}, - f: (x) => { - Assert.isObject(x); - }, -}); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/5_control_flow_analysis_for_dependent_parameters.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.6/5_control_flow_analysis_for_dependent_parameters.ts deleted file mode 100644 index 8e83d91347..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.6/5_control_flow_analysis_for_dependent_parameters.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: A signature can be declared with a rest parameter whose type is a discriminated union of tuples. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../suite/assert.js' - -type T = (...args: [1, number] | [true, string] | ["a", boolean]) => void; -const fun: T = (x: true | 1 | "a", y: string | number | boolean) => { - if (x === 1) { - Assert.equal(10, y); - } - if (x === true) { - Assert.equal("hello", y); - } - if (x === "a") { - Assert.isBoolean(y); - } - -}; -fun(1, 10); -fun(true, "hello"); -fun("a", true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access.ts deleted file mode 100644 index c3295e44ae..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 4.7 now narrows the types of element accesses when the indexed key is unique symbols. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -let sym = Symbol(); -let func = function () { - return 5; -}; -let o = { - obj: "obejct" -}; - -let x = Math.random(); -let y = Math.random(); -const fo = x > y ? func() : o; - -const key = { - [sym]: fo -}; - -if (typeof key[sym] === "object") { - o.obj = 'Object'; -} else { - func = function () { - return 10; - } -} - -if (x < y) { - Assert.equal(o.obj, 'Object'); -} else { - Assert.equal(JSON.stringify(func), undefined); -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access_1.ts deleted file mode 100644 index c401307150..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/control-flow_analysis_for_bracketed_element_access/control-flow_analysis_for_bracketed_element_access_1.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 4.7 now narrows the types of element accesses when the indexed key is literal types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -type myType = "a" | 3 | "b"; -if (Math.random() > 0.8) { - var arg1: myType = "a"; -} else if (Math.random() < 0.3) { - var arg1: myType = "b"; -} else { - var arg1: myType = 3; -} - -const arg2 = Math.random() > 0.5 ? 15 : 'rand'; - -const o = { - [arg1]: arg2 -} -if (typeof o[arg1] === 'string') { - Assert.equal(arg2, 'rand'); -} else { - Assert.equal(arg2, 15); -}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/extends_constraints_on_infer_type_variables/extends_constraints_on_infer_type_variables.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/extends_constraints_on_infer_type_variables/extends_constraints_on_infer_type_variables.ts deleted file mode 100644 index 3d2071969e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/extends_constraints_on_infer_type_variables/extends_constraints_on_infer_type_variables.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Conditional types are a bit of a power-user feature. - They allow us to match and infer against the shape of types, and make decisions based on them. - TypeScript 4.7 now allows to place a constraint on any infer type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -type myType1 = T extends (...arg: infer R) => number ? R : boolean; - -const Add = (a: number, b: number) => a + b; -type add = typeof Add; -type t1 = myType1; -const arr: t1 = [1, 2]; -Assert.isObject(arr); - -type fs = Function | string; -type myType2 = T extends [infer S extends fs, ...any[]] ? S : boolean; - -const Min = (a: number, b: number)=>{ - if (a > b) { - return b; - } else { - return a; - } -} -type min = typeof Min; -type t2 = myType2<[min, number, string]>; -const func: t2 = Min; -Assert.isFunction(func); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/improved_function_inference_in_objects_and_methods/improved_function_inference_in_objects_and_methods.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/improved_function_inference_in_objects_and_methods/improved_function_inference_in_objects_and_methods.ts deleted file mode 100644 index 3669f0076b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/improved_function_inference_in_objects_and_methods/improved_function_inference_in_objects_and_methods.ts +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 4.7 can now perform more granular inferences from functions within objects and arrays. - This allows the types of these functions to consistently flow in a left-to-right manner just like for plain arguments. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -function func1(arg: T): T{ - return arg; -} -var f1 = func1(5); -Assert.isNumber(f1); -var f2 = func1('a'); -Assert.isString(f2); -var f3 = func1(true); -Assert.isBoolean(f3); -var f4 = func1({ num: 5 }); -Assert.isObject(f4); -var f5 = func1(() => { return; }); -Assert.isFunction(f5); - -function func2(arg: { member: (str: string) => T }) { - return arg; -} -var f6 = func2({ member: str => { return str; } }); -var result = f6.member('a'); -Assert.isString(result); - -function f(arg: { - arg1: (n: string) => T; - arg2: (x: T) => void; -}) { - arg.arg2 = function (x:T) { - Assert.equal(typeof x, "String"); - } - arg.arg2; -} -f({ - arg1: ():string => "string", - arg2: (x:string) => x.toLowerCase(), -}); -f({ - arg1: n => n, - arg2: (x:string) => x.toLowerCase(), -}); - - -class C{ - arg: { - mem: (str: string) => T; - t: T; - } - constructor(arg: { - mem: (str: string) => T; - t: T; - }) { - this.arg = arg; - this.arg.t = arg.t; - } -} -var c1 = new C({ - mem: function () { return 'a' }, - t: 't' -}) -Assert.isString(c1.arg.t); -var c2 = new C({ - mem() { return 'a' }, - t: 't' -}) -Assert.isString(c2.arg.t); -var c3 = new C({ - mem: str => str, - t: 't' -}) -Assert.isString(c3.arg.t); - - diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/instantiation_expressions/instantiation_expressions.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/instantiation_expressions/instantiation_expressions.ts deleted file mode 100644 index 0d230b89cb..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/instantiation_expressions/instantiation_expressions.ts +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 4.7 allows exactly that we can now take functions and constructors and feed them type arguments directly. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -const Data:any = Map; - -const data = new Data(); - -data.set("name",new Error("TS error")) - -Assert.equal(data.get("name").name, 'Error'); - - -interface I1 { - name: string; -} -interface I2 { - use: string; -} -function fc(value: T) { - return value; -} -let obj1 = fc({ name: 'xiao' }); -let obj2 = fc({ use: 'play' }); -Assert.equal(JSON.stringify(obj1), '{"name":"xiao"}'); -Assert.equal(JSON.stringify(obj2), '{"use":"play"}'); - -type myType1 = number | string; -type myType2 = { str: string } | (() => number); -function func(arg: T) { - return arg; -} - -var f1 = func(5); -Assert.isNumber(f1); -var f2 = func('a'); -Assert.isString(f2); -var f3 = func({str: 'str'}); -Assert.isObject(f3); -var f4 = func(() => { - return 10; -}); -Assert.isFunction(f4); - -let map = Map; -let map_instantiation = new map(); -map_instantiation.set('num', 8); -Assert.isNumber(map_instantiation.get('num')); - -let set = new Set([2]); -for (let arg of set) { - Assert.isNumber(arg); -}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/optional_variance_annotations_for_type_parameters/optional_variance_annotations_for_type_parameters.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/optional_variance_annotations_for_type_parameters/optional_variance_annotations_for_type_parameters.ts deleted file mode 100644 index 1efefdf64d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/optional_variance_annotations_for_type_parameters/optional_variance_annotations_for_type_parameters.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - With TypeScript 4.7, we're now able to explicitly specify variance on type parameters. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -interface P{ - num: number; -} -interface C extends P{ - str: string; -} - -type myType1 = Array

; -type myType2 = Array; - -var m_ins1: myType1 = [{ num: 5 }]; -var m_ins2: myType2 = [{ num: 10, str: 'a' }]; - -m_ins1 = m_ins2; -Assert.equal(m_ins1, m_ins2); - - -interface h_C{ - name: string; - age: number; -} - -type myType3 = () => T; -type myType4 = () => T; -var m_ins3: myType3 = () => { return { name: 'xiao', age: 18 } }; -var m_ins4: myType4 = () => { return { name: 'xi', age: 18, height: 18 } }; -m_ins3 = m_ins4; -Assert.equal(m_ins3, m_ins4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/readonly_tuples_have_a_readonly_length_property/readonly_tuples_have_a_readonly_length_property.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.7/readonly_tuples_have_a_readonly_length_property/readonly_tuples_have_a_readonly_length_property.ts deleted file mode 100644 index a3c17f788b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.7/readonly_tuples_have_a_readonly_length_property/readonly_tuples_have_a_readonly_length_property.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A readonly tuple will now treat its length property as readonly. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -class C{ - readonly arr: [number, string, boolean]; - constructor(arr: [number, string, boolean]) { - this.arr = arr; - } -} -let c = new C([10, 'a', true]); -Assert.equal(c.arr.length, 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.8/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.8/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing.ts deleted file mode 100644 index 14fe78034b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.8/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing/Improved_Intersection_Reduction_Union_Compatibility,_and_Narrowing.ts +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - consistency improvements under --strictNullChecks. - These changes affect how intersection and union types work, and are leveraged in how TypeScript narrows types. - Another change is that {} intersected with any other object type simplifies right down to that object type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -type T1 = {} & string; -let a: T1 = "sss"; -Assert.equal(a, "sss"); - -type T2 = {} & unknown; -let b: T2 = 2; -Assert.equal(b,2) - -let x: unknown = 1; -function f1(x: unknown) { - let y: null | undefined | {}; - y = x; - if (x) { - Assert.equal(y, 1); - } -} -f1(x); - -let z: T1 = "string"; -function f2(x: T, y?: T) { - y = x; - if (x) { - Assert.equal(y, "string"); - } -} -f2(z, undefined); - -let bar: unknown = 555; -function f3(x: unknown, y?: {} | null | undefined) { - y = x; - Assert.equal(y, 555); -} -f3(bar, null); - -function ensureNotNull(x: T) { - if (x != null){ - Assert.isNumber(x); - } -} -let run: unknown = 111; -ensureNotNull(run); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.8/improved_inference_for_infer_types_in_template_string_types/improved_inference_for_infer_types_in_template_string_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.8/improved_inference_for_infer_types_in_template_string_types/improved_inference_for_infer_types_in_template_string_types.ts deleted file mode 100644 index f47743cc54..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.8/improved_inference_for_infer_types_in_template_string_types/improved_inference_for_infer_types_in_template_string_types.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - typescript recently introduced a way to add extends constraints to infer type variables in conditional types. - if these infer types appear in a template string type and are constrained to a primitive type, TypeScript will now try to parse out a literal type. - this can now better convey what a library will do at runtime, and give more precise types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -type myType = T extends [infer U extends V, ...unknown[]] ? U : false; -function func(arr: any[], x: myType<[T, ...any], V>) { - arr[0] = x; - return arr; -} -let arr = ["A", "B", "C"]; -let first = func(arr, 65); -Assert.equal(JSON.stringify(first), "[65,\"B\",\"C\"]"); - -type S = "string" extends `${infer T extends string}` ? T : false; -let s: S = "string"; -Assert.equal(s, "string"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.9/auto_accessors_in_classes/auto_accessors_in_classes.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.9/auto_accessors_in_classes/auto_accessors_in_classes.ts deleted file mode 100644 index 48ab4e76df..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.9/auto_accessors_in_classes/auto_accessors_in_classes.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript 4.9 supports an upcoming feature in ECMAScript called auto-accessors. - options: - target: es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../suite/assert.js" - -class NormalClass { - #str: string; - constructor(str: string) { - this.#str = str; - } - get Str(): string { - return this.#str; - } - set Str(str: string) { - this.#str = str; - } -} -class AutoClass { - str: string; - constructor(str: string) { - this.str = str; - } -} - -let c1 = new NormalClass("0"); -let c2 = new AutoClass("0"); -c1.Str = "NormalClass"; -Assert.equal(c1.Str, "NormalClass"); -c2.str = "AutoClass"; -Assert.equal(c2.str, "AutoClass"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.9/checks_for_equality_on_NaN/checks_for_equality_on_NaN.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.9/checks_for_equality_on_NaN/checks_for_equality_on_NaN.ts deleted file mode 100644 index 1793962aa0..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.9/checks_for_equality_on_NaN/checks_for_equality_on_NaN.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - typescript now errors on direct comparisons against NaN, and will suggest using some variation of Number.isNaN instead. - options: - lib: es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -function notNaN(x: number) { - return !Number.isNaN(x); -} -Assert.isFalse(notNaN(NaN)); -Assert.isTrue(notNaN(0)); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.9/the_satisfies_operator/the_satisfies_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.9/the_satisfies_operator/the_satisfies_operator.ts deleted file mode 100644 index 84846a9a5a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.9/the_satisfies_operator/the_satisfies_operator.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the new satisfies operator lets us validate that the type of an expression matches some type, without changing the resulting type of that expression. - module: es2020 - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -const day = { - Mon: 'monday', - Wedn: "wednesday", - Fri: 'friday' -}; - -const hobby = { - "Mon": false, - "Wedn": false, - "Fri": true -}; - -const long = day.Mon.length; -const w = day.Wedn.toUpperCase(); -const g = hobby.Wedn; - -Assert.equal(long, 6); -Assert.equal(w, "WEDNESDAY"); -Assert.isFalse(g); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/4.9/unlisted_property_narrowing_with_the_in_operator/unlisted_property_narrowing_with_the_in_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/4.9/unlisted_property_narrowing_with_the_in_operator/unlisted_property_narrowing_with_the_in_operator.ts deleted file mode 100644 index 6aaac94c01..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/4.9/unlisted_property_narrowing_with_the_in_operator/unlisted_property_narrowing_with_the_in_operator.ts +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - typescript 4.9 makes the in operator a little bit more powerful when narrowing types that don’t list the property at all. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../suite/assert.js' - -type T1 = { num: number }; -type T2 = { str: string }; -function func(arg: T1 | T2) { - if ("num" in arg && "str" in arg) { - return "T1 | T2"; - } else if ("num" in arg) { - return "T1"; - } else if ("str" in arg) { - return "T2"; - } -} -let x: T1 = { num: 10 }; -let y: T2 = { str: 'a' }; -let z: T1 | T2 = { num: 10, str: 'a' }; -Assert.equal(func(x), "T1"); -Assert.equal(func(y), "T2"); -Assert.equal(func(z), "T1 | T2"); - -interface I{ - mem: any; -} -function check(arg: I) { - let mem = arg.mem; - if (mem && typeof mem === "object") { - if ("num" in mem && typeof mem.num === 'number') { - return mem.num; - } - } - return null; -} -let a: I = { mem: 10 }; -let b: I = { mem: { num: 10 } }; -Assert.isTrue(check(a) === null); -Assert.isNumber(check(b)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/Ambient_Class_Declarations/Ambient_Class_Declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/Ambient_Class_Declarations/Ambient_Class_Declarations.ts deleted file mode 100644 index 40efacf774..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/Ambient_Class_Declarations/Ambient_Class_Declarations.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - An ambient class declaration declares a class type and a constructor function in the containing declaration space. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -declare class Student { - constructor(sname?: string, sage?: number); - public sname: string; - public sage: number; - cl():number; -} -let s1 :Student ={ - sname:"static", - sage:12, - cl(){ - return 1; - } -} -Assert.equal(s1.sname,"static"); -Assert.equal(s1.sage,"12"); -Assert.equal(s1.cl(),1); -Assert.isFunction(s1.cl); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts deleted file mode 100644 index 60d3b91412..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - an ambient function declaration introduces a function in the containing declaration space. - ambient functions may be overloaded by specifying multiple ambient function declarations with the same name, but it is an error to declare multiple overloads that are considered identical or differ only in their return types. - ambient function declarations cannot specify a function bodies and do not permit default parameter values. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -declare type DF1 = () => void; -declare type DF2 = (a: string, b: string) => string; -declare type DF3 = (a: number, b?: number) => string; -const dFun1: DF1 = () => { Assert.isString("dFun1"); } -const dFun2: DF2 = (a: string, b: string) => { Assert.isString("dFun2"); return a + b; } -const dFun3: DF3 = (a: number, b?: number) => { - let c: any; - if (b != undefined) { - c = a + b; - } else { - c = a; - } - c = c.toString(); - Assert.isString("dFun3"); - return "$" + c; -} -dFun1(); -Assert.equal(dFun2("A", "B"), 'AB'); -Assert.equal(dFun3(10, 20), "$30"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_namespace_declarations/ambient_namespace_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_namespace_declarations/ambient_namespace_declarations.ts deleted file mode 100644 index ccc60c491c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_namespace_declarations/ambient_namespace_declarations.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - an ambient namespace declaration declares a namespace. - except for ImportAliasDeclarations, AmbientNamespaceElements always declare exported entities regardless of whether they include the optional export modifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -declare namespace AmbientNamespace { - var an1: string; - export var an2: string; - interface ColorInterface { - Red: number; - Green: number; - Blue: number; - } -} -var colorI: AmbientNamespace.ColorInterface = { Red: 0, Green: 1, Blue: 2 }; -Assert.equal(JSON.stringify(colorI), '{"Red":0,"Green":1,"Blue":2}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_variable_declarations/ambient_variable_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_variable_declarations/ambient_variable_declarations.ts deleted file mode 100644 index d76695a41e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_variable_declarations/ambient_variable_declarations.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - An ambient variable declaration introduces a variable in the containing declaration space. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -declare type variable1 = number; -declare type variable2 = string; -declare type variable3 = (vab1:number,vab2:string) => string;; - -var vab1:variable1 = 3; -let vab2:variable2 = "www"; -const vab3:variable3 = (vab1,vab2) =>{return vab1+vab2;} - -Assert.equal(typeof vab1,"number"); -Assert.equal(typeof vab2,"string"); -Assert.equal(vab3(vab1,vab2),"3www"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_1.ts deleted file mode 100644 index 6052602a32..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_1.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - ambient modules are "open-ended" and ambient module declarations with the same string literal name contribute to a single module. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../../suite/assert.js" - -declare module AMD1 { - export var a1: any; - export interface AMD1IF { - a1_1: any; - a1_2: number; - } -} -var am2: AMD1.AMD1IF = { a1_1: "am2", a1_2: 123 }; -Assert.equal(JSON.stringify(am2), '{"a1_1":"am2","a1_2":123}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts deleted file mode 100644 index 22d8b49755..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - if an ambient module declaration includes an export assignment, it is an error for any of the declarations within the module to specify an export modifier. - if an ambient module declaration contains no export assignment, entities declared in the module are exported regardless of whether their declarations include the optional export modifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -export declare module m1 { - interface I1 { - a3_1: boolean; - a3_2: number; - } - var AMD2Var1: string; -} -declare module m2 { - export interface I2 { - a3_1: boolean; - a3_2: string; - } - export var AMD2Var1: string; -} -var am3_1: m1.I1 = { a3_1: false, a3_2: 0 }; -var am3_2: m2.I2 = { a3_1: true, a3_2: "T" }; -Assert.equal(JSON.stringify(am3_1), '{"a3_1":false,"a3_2":0}'); -Assert.equal(JSON.stringify(am3_2), '{"a3_1":true,"a3_2":"T"}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_1.ts deleted file mode 100644 index bc0c2bd827..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_1.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A name that denotes a value has an associated type and can be referenced in expressions. - A name that denotes a type can be used by itself in a type reference or on the right hand side of a dot in a type reference. - A name that denotes a namespace can be used on the left hand side of a dot in a type reference. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let Rog: string = "a is string"; -Assert.equal("a is string1", Rog + "1"); -type Rog = String; -let newOne: Rog = "xx"; -Assert.equal("xx", newOne); -namespace Rog { - export type b = string; -} -let yoo: Rog.b = "ystr"; -Assert.equal("ystr", yoo); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_2.ts deleted file mode 100644 index b67f8f3601..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/declarations/declarations_2.ts +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Declarations introduce the following meanings for the name they declare: - A variable, parameter, function, generator, member variable, member function, member accessor, or enum member declaration introduces a value meaning. - An interface, type alias, or type parameter declaration introduces a type meaning. - A class declaration introduces a value meaning (the constructor function) and a type meaning (the class type). - An enum declaration introduces a value meaning (the enum instance) and a type meaning (the enum type). - A namespace declaration introduces a namespace meaning (the type and namespace container) and, if the namespace is instantiated, a value meaning (the namespace instance). - An import or export declaration introduces the meaning(s) of the imported or exported entity. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Myclass { - a: string; - constructor(a: string) { - this.a = a; - } - static a :number = 33; -} -var c: Myclass = new Myclass("x"); -Assert.equal(c.a, "x"); -Assert.equal(Myclass.a,33); -enum WeekDay { - MON = 1, - TUE, - WEN, - THU, - FRI, - SAT, - SUN -} -type a = WeekDay; -var mon: a = WeekDay.MON; -Assert.equal(mon, 1); -namespace X { - export let x: string = "x"; -} -Assert.equal(X.x, "x"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/computed_property_names/computed_property_names_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/computed_property_names/computed_property_names_1.ts deleted file mode 100644 index 48d8ce5dde..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/computed_property_names/computed_property_names_1.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - ECMAScript 2015 permits object literals and classes to declare members with computed property names. - A computed property name specifies an expression that computes the actual property name at run-time. - options: - lib: es6 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class ComputedName { - aa: 1 | undefined; - ["address"]: string; - constructor(x: string, y: 1) { - this.address = x; - if (y === 1) { - this.aa = y; - } else { - this.aa = undefined; - } - } -} -var c: ComputedName = new ComputedName("address No1", 1); -Assert.equal(1, c.aa); -Assert.equal("address No1", c.address); -var objectliteral = { ["xx" + "123".length]: 22, name: "string" }; -Assert.equal(22, objectliteral.xx3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/property_names/property_names_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/property_names/property_names_1.ts deleted file mode 100644 index f362919197..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/property_names/property_names_1.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A property name can be any identifier (including a reserved word), a string literal, a numeric literal, - or a computed property name. String literals may be used to give properties names that are not valid identifiers, - such as names containing blanks. Numeric literal property names are equivalent to string literal property names - with the string representation of the numeric literal, as defined in the ECMAScript specification. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Property { - break: string; - let: string; - any: string; - as: string; - "with blank": number; - 1: boolean; - constructor() { - this.break = "break"; - this["with blank"] = 12; - this[1] = true; - this.any = "any"; - this.let = "let"; - this.as = "as"; - } -} -var p: Property = new Property(); -Assert.equal("break", p.break); -Assert.equal(12, p["with blank"]); -Assert.equal(true, p[1]); -Assert.equal("any", p.any); -Assert.equal("let", p.let); -Assert.equal("as", p.as); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_1.ts deleted file mode 100644 index 6661d96beb..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_1.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: any cannot be type name, but are otherwise not restricted. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -function any(): string { - return "any"; -}; -Assert.isFunction(any); -Assert.equal(any(), "any"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_2.ts deleted file mode 100644 index 0af022ed9d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/any_cannot_be_type_name_2.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: any cannot be type name, but are otherwise not restricted. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -var any: string = "any"; -Assert.equal(any, "any"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_1.ts deleted file mode 100644 index ff57ecbf01..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_1.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: boolean cannot be type name, but are otherwise not restricted. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -function boolean(): number { - return 0; -} -Assert.isFunction(boolean); -Assert.equal(boolean(), 0); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_2.ts deleted file mode 100644 index 9743e8b5f3..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/boolean_cannot_be_type_name_2.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: boolean cannot be type name, but are otherwise not restricted. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -var boolean: number = 0; -Assert.equal(boolean, 0); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_1.ts deleted file mode 100644 index 7dbc611da4..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_1.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: number cannot be type name, but are otherwise not restricted. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -function number(): string { - return "number"; -} -Assert.isFunction(number); -Assert.equal(number(), "number"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_2.ts deleted file mode 100644 index 6de94bd7c0..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/number_cannot_be_type_name_2.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: number cannot be type name, but are otherwise not restricted. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -var number: string = "number"; -Assert.equal(number, "number"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_1.ts deleted file mode 100644 index d21a11ece2..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_1.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: string cannot be type name, but are otherwise not restricted. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -function string(): number { - return 10; -} -Assert.equal(string(), 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_2.ts deleted file mode 100644 index f45a26812e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/string_cannot_be_type_name_2.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: string cannot be type name, but are otherwise not restricted. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -var string: number = 10; -Assert.equal(string, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_1.ts deleted file mode 100644 index c99b03bda8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_1.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: symbol cannot be type name, but are otherwise not restricted. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -function symbol(): string { - return "symbol" -} -Assert.equal(symbol(), "symbol"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_2.ts deleted file mode 100644 index 280713ec74..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/cannot_be_type_name/symbol_cannot_be_type_name_2.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: symbol cannot be type name, but are otherwise not restricted. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -var symbol: string = "any"; -Assert.equal(symbol, "any"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_1.ts deleted file mode 100644 index f2245aa4c4..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_1.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: abstract is valid identifier - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -var abstract: string = "abstract"; -Assert.equal(abstract, "abstract"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_2.ts deleted file mode 100644 index 2b22fef997..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_2.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: abstract is valid identifier - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -function abstract(): string { - return "abstract"; -} -Assert.equal(abstract(), "abstract"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_3.ts deleted file mode 100644 index 7ce5b7d580..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_3.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: abstract is valid identifier - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -class abstract { - name: string; - constructor(name: string) { - this.name = name; - } - getName(): string { - return this.name; - } -} -var newobj = new abstract("abstract"); -Assert.equal(newobj.getName(), "abstract"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_4.ts deleted file mode 100644 index a06c5abb67..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/abstract_is_valid_identifier_4.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: abstract is valid identifier - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -interface abstruct { - name: string, - getName: () => string -} -var customer: abstruct = { - name: "abstruct", - getName(): string { - return this.name; - } -} -Assert.equal(customer.name, "abstruct"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_1.ts deleted file mode 100644 index 4a0cf23f27..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_1.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: as is valid identifier - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -var as: string = "as"; -Assert.equal(as, "as"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_2.ts deleted file mode 100644 index ec61e3aa21..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_2.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: as is valid identifier - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -function as(): string { - return "as"; -} -Assert.equal(as(), "as"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_3.ts deleted file mode 100644 index b42a1fdd7d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_3.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: as is valid identifier - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -class as { - name: string; - constructor(name: string) { - this.name = name; - } - getName(): string { - return this.name; - } -} -var newobj = new as("as"); -Assert.equal(newobj.getName(), "as"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_4.ts deleted file mode 100644 index 1eb01c1d3b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/as_is_valid_identifier_4.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: as is valid identifier - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -interface as { - name: string, - getName: () => string -} -var customer: as = { - name: "as", - getName(): string { - return this.name; - } -} -Assert.equal(customer.name, "as"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_1.ts deleted file mode 100644 index 676457a5b2..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_1.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: async is valid identifier - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -var async: string = "async"; -Assert.equal(async, "async"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_2.ts deleted file mode 100644 index 4b6e6e9b57..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_2.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: async is valid identifier - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -function async(): string { - return "async"; -} -Assert.equal(async(), "async"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_3.ts deleted file mode 100644 index fdb6480948..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_3.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: async is valid identifier - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -class async { - name: string; - constructor(name: string) { - this.name = name; - } - getName(): string { - return this.name; - } -} -var newobj = new async("async"); -Assert.equal(newobj.getName(), "async"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_4.ts deleted file mode 100644 index 6c20af07d1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/async_is_valid_identifier_4.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: async is valid identifier - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -interface async { - name: string, - getName: () => string -} -var customer: async = { - name: "async", - getName(): string { - return this.name; - } -} -Assert.equal(customer.name, "async"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_1.ts deleted file mode 100644 index 34de3bf84b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_1.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'constructor' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -var constructor: string = "constructor"; -Assert.equal(constructor, "constructor"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_2.ts deleted file mode 100644 index 17c7cc39a7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_2.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'constructor' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -function constructor(): string { - return "constructor"; -} -Assert.equal(constructor(), "constructor"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_3.ts deleted file mode 100644 index 711349b149..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_3.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'constructor' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -class constructor { - name: string; - constructor(name: string) { - this.name = name; - } - getName(): string { - return this.name; - } -} -var newobj = new constructor("constructor"); -Assert.equal(newobj.getName(), "constructor"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_4.ts deleted file mode 100644 index a0e571e0aa..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/constructor_is_valid_identifier_4.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'constructor' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -interface constructor { - name: string, - getName: () => string -} -var customer: constructor = { - name: "constructor", - getName(): string { - return this.name; - } -} -Assert.equal(customer.name, "constructor"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_1.ts deleted file mode 100644 index aac04f3d37..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_1.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'declare' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -var declare: string = "declare"; -Assert.equal(declare, "declare"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_2.ts deleted file mode 100644 index bb41f4d113..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_2.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'declare' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -function declare(): string { - return "declare"; -} -Assert.equal(declare(), "declare"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_3.ts deleted file mode 100644 index b81f44896d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_3.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'declare' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -class declare { - name: string; - constructor(name: string) { - this.name = name; - } - getName(): string { - return this.name; - } -} -var newobj = new declare("declare"); -Assert.equal(newobj.getName(), "declare"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_4.ts deleted file mode 100644 index f315768977..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/declare_is_valid_identifier_4.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'declare' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -interface declare { - name: string, - getName: () => string -} -var customer: declare = { - name: "declare", - getName(): string { - return this.name; - } -} -Assert.equal(customer.name, "declare"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_1.ts deleted file mode 100644 index f7c3ea544e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_1.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'from' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -var from: string = "from"; -Assert.equal(from, "from"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_2.ts deleted file mode 100644 index 1900fe5d1b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_2.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'from' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -function from(): string { - return "from"; -} -Assert.equal(from(), "from"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_3.ts deleted file mode 100644 index c1c86b2b49..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_3.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'from' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -class from { - name: string; - constructor(name: string) { - this.name = name; - } - getName(): string { - return this.name; - } -} -var newobj = new from("from"); -Assert.equal(newobj.getName(), "from"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_4.ts deleted file mode 100644 index 9862bfc8e5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/from_is_valid_identifier_4.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'from' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -interface from { - name: string, - getName: () => string -} -var customer: from = { - name: "from", - getName(): string { - return this.name; - } -} -Assert.equal(customer.name, "from"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_1.ts deleted file mode 100644 index 299b54e6cc..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_1.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'get' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -var get: string = "get"; -Assert.equal(get, "get"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_2.ts deleted file mode 100644 index 1ed9abdd41..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_2.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'get' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -function get(): string { - return "get"; -} -Assert.equal(get(), "get"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_3.ts deleted file mode 100644 index 48ade41aea..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_3.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'get' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -class get { - name: string; - constructor(name: string) { - this.name = name; - } - getName(): string { - return this.name; - } -} -var newobj = new get("get"); -Assert.equal(newobj.getName(), "get"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_4.ts deleted file mode 100644 index 7aeffc88a8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/get_is_valid_identifier_4.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'get' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -interface get { - name: string, - getName: () => string -} -var customer: get = { - name: "get", - getName(): string { - return this.name; - } -} -Assert.equal(customer.name, "get"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_1.ts deleted file mode 100644 index 1fe4f7ea78..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_1.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'is' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -var is: string = "is"; -Assert.equal(is, "is"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_2.ts deleted file mode 100644 index bd17391c72..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_2.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'is' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -function is(): string { - return "is"; -} -Assert.equal(is(), "is"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_3.ts deleted file mode 100644 index ae9fdb3c57..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_3.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'is' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -class is { - name: string; - constructor(name: string) { - this.name = name; - } - getName(): string { - return this.name; - } -} -var newobj = new is("is"); -Assert.equal(newobj.getName(), "is"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_4.ts deleted file mode 100644 index 21d321bf4f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/is_is_valid_identifier_4.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'is' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -interface is { - name: string, - getName: () => string -} -var customer: is = { - name: "is", - getName(): string { - return this.name; - } -} -Assert.equal(customer.name, "is"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_1.ts deleted file mode 100644 index a8439b34c1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_1.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'module' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -var module2: string = "module"; -Assert.equal(module2, "module"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_2.ts deleted file mode 100644 index 7cae555f33..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_2.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'module' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -function module1(): string { - return "module"; -} -Assert.equal(module1(), "module"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_3.ts deleted file mode 100644 index 0782ed97f8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_3.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'module' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -{ - class module { - name: string; - - constructor(name: string) { - this.name = name; - } - - getName(): string { - return this.name; - } - } - - var newobj = new module("module"); - Assert.equal(newobj.getName(), "module"); -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_4.ts deleted file mode 100644 index fe05033736..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/module_is_valid_identifier_4.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'module' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -interface module { - name: string, - getName: () => string -} -var customer: module = { - name: "module", - getName(): string { - return this.name; - } -} -Assert.equal(customer.name, "module"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_1.ts deleted file mode 100644 index bceffbe726..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_1.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'namespace' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -var namespace: string = "namespace"; -Assert.equal(namespace, "namespace"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_2.ts deleted file mode 100644 index 13b73f89b7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_2.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'namespace' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -function namespace(): string { - return "namespace"; -} -Assert.equal(namespace(), "namespace"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_3.ts deleted file mode 100644 index fa58b1e6c1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_3.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'namespace' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -class namespace { - name: string; - constructor(name: string) { - this.name = name; - } - getName(): string { - return this.name; - } -} -var newobj = new namespace("namespace"); -Assert.equal(newobj.getName(), "namespace"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_4.ts deleted file mode 100644 index 3be3526411..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/namespace_is_valid_identifier_4.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'namespace' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -interface namespace { - name: string, - getName: () => string -} -var customer: namespace = { - name: "namespace", - getName(): string { - return this.name; - } -} -Assert.equal(customer.name, "namespace"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_1.ts deleted file mode 100644 index d50c317607..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_1.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'of' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -var of: string = "of"; -Assert.equal(of, "of"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_2.ts deleted file mode 100644 index 08ffa6cddf..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_2.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'of' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -function of(): string { - return "of"; -} -Assert.equal(of(), "of"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_3.ts deleted file mode 100644 index 47d4f7a37f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_3.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'of' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -class of { - name: string; - constructor(name: string) { - this.name = name; - } - getName(): string { - return this.name; - } -} -var newobj = new of("of"); -Assert.equal(newobj.getName(), "of"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_4.ts deleted file mode 100644 index 8f31d65c4f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/of_is_valid_identifier_4.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'of' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -interface of { - name: string, - getName: () => string -} -var customer: of = { - name: "of", - getName(): string { - return this.name; - } -} -Assert.equal(customer.name, "of"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/require_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/require_is_valid_identifier_1.ts deleted file mode 100644 index d5908d19d8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/require_is_valid_identifier_1.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'require' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -interface require { - name: string, - getName: () => string -} -var customer: require = { - name: "require", - getName(): string { - return this.name; - } -} -Assert.equal(customer.name, "require"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_1.ts deleted file mode 100644 index e0b5607cf1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_1.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'set' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -var set: string = "set"; -Assert.equal(set, "set"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_2.ts deleted file mode 100644 index 65a32d4ed1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_2.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'set' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -function set(): string { - return "set"; -} -Assert.equal(set(), "set"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_3.ts deleted file mode 100644 index 0ce429bfbb..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_3.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'set' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -class set { - name: string; - constructor(name: string) { - this.name = name; - } - getName(): string { - return this.name; - } -} -var newobj = new set("set"); -Assert.equal(newobj.getName(), "set"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_4.ts deleted file mode 100644 index b0279a2228..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/set_is_valid_identifier_4.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'set' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -interface set { - name: string, - getName: () => string -} -var customer: set = { - name: "set", - getName(): string { - return this.name; - } -} -Assert.equal(customer.name, "set"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_1.ts deleted file mode 100644 index 3bec40eb37..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_1.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'type' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -var type: string = "type"; -Assert.equal(type, "type"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_2.ts deleted file mode 100644 index 4c9e57cc56..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_2.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'type' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -function type(): string { - return "type"; -} -Assert.equal(type(), "type"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_3.ts deleted file mode 100644 index d7ef405195..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_3.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'type' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -class type { - name: string; - constructor(name: string) { - this.name = name; - } - getName(): string { - return this.name; - } -} -var newobj = new type("type"); -Assert.equal(newobj.getName(), "type"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_4.ts deleted file mode 100644 index 995036f95a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/names/reserved_words/special_mean_but_valid_identifier/type_is_valid_identifier_4.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The keywords 'type' has special meaning in certain contexts, but is valid identifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -interface type { - name: string, - getName: () => string -} -var customer: type = { - name: "type", - getName(): string { - return this.name; - } -} -Assert.equal(customer.name, "type"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/let_scope.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/let_scope.ts deleted file mode 100644 index 83064a87ad..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/let_scope.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The scope of a local let declared immediately within a statement block is the body of that statement block. - The scope of a local let declaration declared immediately within the body of a function-like declaration is the body of that function-like declaration. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let GlobalScope = 1; -function someFunc() { - let FunctionScope = 2; - if (true) { - let BlockScope = 3; - Assert.equal(FunctionScope, 2); - Assert.equal(BlockScope, 3); - } - Assert.equal(GlobalScope, 1); -} -someFunc(); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_1.ts deleted file mode 100644 index 15310bd065..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_1.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The scope of a name declared in the global namespace is the entire program text. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../../suite/assert.js"; - -var a: number = 1024; -let b: string = 'NARC'; -Assert.equal(a, 1024); -Assert.equal(b, 'NARC'); -function add() { - return a + b; -} -Assert.equal(add(), '1024NARC'); -class OUT { - out: string; - constructor() { - this.out = b + a; - } -} -let out = new OUT(); -Assert.equal(out.out, 'NARC1024'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_10.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_10.ts deleted file mode 100644 index 065f551a2f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_10.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The scope of a local let, const, class, interface, type alias, or enum declaration declared immediately within the body of a function-like declaration is the body of that function-like declaration. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../../suite/assert.js"; - -function sfun() { - let s = 1024; - Assert.equal(s, 1024); - const n = 'NARC' - Assert.equal(n, 'NARC'); - class C { - c: number; - constructor(c: number) { - this.c = c; - } - } - let cc = new C(5); - Assert.equal(cc.c, 5); - - type S = keyof C | keyof number & keyof string; - let ss: S = "valueOf"; - Assert.equal(ss, "valueOf"); -} -sfun(); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_11.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_11.ts deleted file mode 100644 index bbcae824b7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_11.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The scope of a local let, const, class, interface, type alias, or enum declaration declared immediately within a statement block is the body of that statement block. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../../suite/assert.js"; - -{ - var v: number = 999; - Assert.equal(v, 999); - let l: number = 333; - Assert.equal(l, 333); - const con: "NARC" = 'NARC'; - Assert.equal(con, "NARC"); - class cla { - c: number = 1024; - } - let cl = new cla(); - Assert.equal(cl.c, 1024); - - interface I { - color: [number, number, number]; - } - let i: I = { color: [255, 0, 0] }; - Assert.equal(i.color[0], 255); - - type CV = keyof I | keyof string & keyof number; - let cv: CV = "color"; - Assert.equal(cv, "color"); -} -{ - Assert.equal(v / 9, 111); -} \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_12.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_12.ts deleted file mode 100644 index b7861c07e4..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_12.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Scopes may overlap, for example through nesting of namespaces and functions. When the scopes of two names overlap, - the name with the innermost declaration takes precedence and access to the outer name is either not possible or only possible by qualification. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../../suite/assert.js"; - -var x: number = -1; - -namespace X { - export var x: number = 1024; - export function X() { - var x: string = 'NARC'; - Assert.equal(x, 'NARC'); - return x; - } - Assert.equal(x, 1024); - Assert.equal(X(), 'NARC'); -} -Assert.equal(x, -1); -Assert.equal(X.x, 1024); -Assert.equal(X.X(), 'NARC'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_1.ts deleted file mode 100644 index 4fd14b6b00..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_1.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - When an identifier is resolved as a PrimaryExpression, only names in scope with a value meaning are considered and other names are ignored. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../../suite/assert.js"; - -var v: number = 333; -interface v { - v: string; -} -Assert.equal(v, 333); - -let v0: v = { v: "v" }; -Assert.equal(v0.v, "v"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_2.ts deleted file mode 100644 index 91dd3be53d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_2.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - When an identifier is resolved as a TypeName, only names in scope with a type meaning are considered and other names are ignored. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../../suite/assert.js"; - -var s: string = "TypeScript"; -type s = Number; -Assert.equal(s, "TypeScript"); - -let s0: s = 1408; -Assert.equal(s0, 1408); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_3.ts deleted file mode 100644 index 0d15c523cc..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_13_3.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - When an identifier is resolved as a NamespaceName, only names in scope with a namespace meaning are considered and other names are ignored. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../../suite/assert.js"; - -var f: boolean = false; -namespace f { - export interface f { - f: boolean; - } -} -Assert.equal(f, false); - -let f0: f.f = { f: true }; -Assert.equal(f0.f, true); - -type e = String; -namespace e { - export var e: number = -1; -} -let e0: e = 'NARC'; -Assert.equal(e0, 'NARC'); - -Assert.equal(e.e, -1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_14.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_14.ts deleted file mode 100644 index 56e85d91ab..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_14.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - locally declared entities in a namespace are closer in scope than exported entities declared in other namespace declarations for the same namespace. - isCurrent: true - ---*/ - - -import { Assert } from "../../../../suite/assert.js"; - -var i: number = -1; -namespace I { - export var i: number = 0; - Assert.equal(i, 0); -} -namespace I { - Assert.equal(i, 0); -} -namespace I { - var i: number = 1; - Assert.equal(i, 1); -} -Assert.equal(i, -1); -Assert.equal(I.i, 0); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_2.ts deleted file mode 100644 index e265a38f58..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_2.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The scope of a name declared in a module is the source file of that module. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../../suite/assert.js"; - -import * as m from "./scopes_2_m.js"; -Assert.equal(m.m3, 1970); -Assert.equal(m.m4, 'EXP'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_2_m.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_2_m.ts deleted file mode 100644 index 5f0e91b86d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_2_m.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The scope of a name declared in a module is the source file of that module. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../../suite/assert.js"; - -let m1 = 1969; -var m2 = 'XO'; -Assert.equal(m1, 1969); -Assert.equal(m2, 'XO'); -export let m3 = 1970; -export var m4 = 'EXP'; -Assert.equal(m3, 1970); -Assert.equal(m4, 'EXP'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_3.ts deleted file mode 100644 index bb23044007..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_3.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The scope of an exported name declared within a namespace declaration is the body of that namespace declaration and every namespace declaration with the same root and the same qualified name relative to that root. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../../suite/assert.js"; - -namespace X { - export var a: string = '404NotFound'; - export let b: number = 119; - export namespace Y { - export function pak() { - return { a, b }; - } - } -} -Assert.equal(X.a, '404NotFound'); -Assert.equal(X.b, 119); -Assert.equal(X.Y.pak().a, '404NotFound'); -Assert.equal(X.Y.pak().b, 119); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_4.ts deleted file mode 100644 index 4fdb88caf3..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_4.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The scope of a non-exported name declared within a namespace declaration is the body of that namespace declaration. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../../suite/assert.js"; - -namespace X { - var a: string = 'TypeScript'; - let b: number = 110; - export function assert() { - Assert.equal(a, 'TypeScript'); - Assert.equal(b, 110); - } -} -X.assert(); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_5.ts deleted file mode 100644 index cfc5708d18..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_5.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The scope of a type parameter name declared in a class or interface declaration is that entire declaration, - including constraints, extends clause, implements clause, and declaration body, but not including static member declarations. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../../suite/assert.js"; - -class C { - str: string = 'NAME'; - num: number = 333; - static flag: boolean = false; - fun() { - return [this.str, this.num, C.flag]; - } -} -let c = new C(); -Assert.equal(c.str, "NAME"); -Assert.equal(c.num, 333); -Assert.equal(C.flag, false); -interface I { - s: string; - n: number; -} -let i: I = { s: 'STR', n: 999 }; -Assert.equal(i.s, "STR"); -Assert.equal(i.n, 999); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_6.ts deleted file mode 100644 index b59a100269..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_6.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The scope of a type parameter name declared in a type alias declaration is that entire type alias declaration. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../../suite/assert.js"; - -type Tp = keyof T & keyof U; -let k: Tp = "toString"; -Assert.equal(k, "toString"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_7.ts deleted file mode 100644 index acb7c4447d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_7.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The scope of a member name declared in an enum declaration is the body of that declaration and every enum declaration with the same root and the same qualified name relative to that root. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../../suite/assert.js"; - -enum E1 { - a, b, c, -} -enum E2 { - a, b, c, -} -enum E1 { - d = 0, -} -Assert.equal(E1.a, 0); -Assert.equal(E2.a, 0); -Assert.equal(E1.d, 0); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_8.ts deleted file mode 100644 index 28cb75dab5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_8.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The scope of a parameter name declared in a call or construct signature is the remainder of the signature declaration. - If the signature is part of a function-like declaration with a body (including a function declaration, constructor declaration, member function declaration, member accessor declaration, function expression, or arrow function), - the scope includes the body of that function-like declaration. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../../suite/assert.js"; - -class CC { - a: number; b: number; - constructor(a: number, b: number) { - let c1: number = a + b; - let c2: number = a * b; - Assert.isNumber(c1); - Assert.isNumber(c2); - this.a = c1 + c2; - this.b = c2 - c1; - } -} -let cc = new CC(3, 5); -Assert.equal(cc.a, 23); -Assert.equal(cc.b, 7); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_9.ts deleted file mode 100644 index 2b736f6a31..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/scopes_9.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The scope of a local var or function name declared anywhere in the body of a function-like declaration is the body of that function-like declaration. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../../suite/assert.js"; - -function sfun(x: number, y: number): number { - var a: number = x + y; - let b: number = x - y; - function subfun() { - return a * b; - } - return subfun(); -} -Assert.equal(sfun(3, 5), -16); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/var_scope.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/var_scope.ts deleted file mode 100644 index ea58de6d9a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/basic_concepts/scopes/var_scope.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The scope of a local var name declared anywhere in the body of a function-like declaration is the body of that function-like declaration. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var GlobalScope = 1; -function someFunc() { - var FunctionScope = 2; - if (true) { - var BlockScope = 3; - } - Assert.equal(FunctionScope, 2); - Assert.equal(BlockScope, 3); -} -Assert.equal(GlobalScope, 1); -someFunc(); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_body/class_body.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_body/class_body.ts deleted file mode 100644 index 39d207bce6..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_body/class_body.ts +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The class body consists of zero or more constructor or member declarations. - Statements are not allowed in the body of a class—they must be placed in the constructor or in members. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Compute { - num1: number; - num2: number; - constructor(num1: number, num2: number) { - this.num1 = num1; - this.num2 = num2; - } - public hypot() { - return Math.sqrt(this.num1 * this.num1 + this.num2 * this.num2); - } - static initial = new Compute(0, 0); -} -let p: Compute = new Compute(10, 20); -Assert.equal(10, p.num1); -Assert.equal(20, p.num2); -Assert.equal(0, Compute.initial.num1); -Assert.equal(0, Compute.initial.num2); -let p2:Compute = new Compute(4,3) -Assert.equal(5,p2.hypot()) - -class Circle { - radius: number = 1; -} -let c = new Circle(); -Assert.equal(c.radius, 1); -type TypeSummation = { - width?: number; - height?: number; -}; -class summation { - public width: number; - public height: number; - constructor(width: number, height: number); - constructor(ParamObje_: TypeSummation); - constructor(ParamObje_Obj_: any, height_ = 0) { - if (typeof ParamObje_Obj_ === "object") { - const { width, height } = ParamObje_Obj_; - this.width = width; - this.height = height; - } else { - this.width = ParamObje_Obj_; - this.height = height_; - } - } - sunArea(): number { - return this.width * this.height; - } -} -let sun = new summation(4, 5); -Assert.equal(sun.sunArea(), 20); -let obj: TypeSummation = { width: 10, height: 2 }; -let sun2 = new summation(obj); -Assert.equal(sun2.sunArea(), 20); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_1.ts deleted file mode 100644 index 8f381f91de..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_1.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A class declaration declares a class type and a constructor function: class BindingIdentifieropt TypeParametersopt ClassHeritage { ClassBody } - module: ESNext - isCurrent: true - ---*/ -import { Assert } from '../../../../suite/assert.js' - -class Rectangle { - constructor(public height: number, public width: number) { }; - get area() { - return this.calcArea() - } - calcArea() { - return this.height * this.width; - } -} -let square = new Rectangle(10, 10); -Assert.equal(100, square.area); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_2.ts deleted file mode 100644 index eaa0ec471b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_2.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A class declaration declares a class type and a constructor function: class BindingIdentifieropt TypeParametersopt ClassHeritage { ClassBody } - module: ESNext - isCurrent: true - ---*/ -import { Assert } from '../../../../suite/assert.js' - -class MyClass { - constructor(public x: number, public y: number) { - this.x = x; - this.y = y; - } - static initial = new MyClass(0, 0); - static distance(a: MyClass, b: MyClass) { - let dx = a.x - b.x; - let dy = a.y - b.y; - return Math.hypot(dx, dy); - } -} -Assert.equal(0, MyClass.initial.x); -Assert.equal(0, MyClass.initial.y); -let p1 = new MyClass(0, 4); -let p2 = new MyClass(3, 0); -Assert.equal(0, p1.x); -Assert.equal(4, p1.y); -Assert.equal(3, p2.x); -Assert.equal(0, p2.y); -Assert.equal(5, MyClass.distance(p1, p2)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_3.ts deleted file mode 100644 index ea990b064c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_3.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A class with type parameters is called a generic class. - module: ESNext - isCurrent: true - ---*/ -import { Assert } from '../../../../suite/assert.js' - -class MyClass { - field: T; - constructor(field: T) { - this.field = field; - } - public getFieldName(): T { - return this.field; - } -} -class Compute { - constructor(public num1: number, public num2: number) { } - public hypot() { - return Math.sqrt(this.num1 * this.num1 + this.num2 * this.num2); - } -} -let mc1: MyClass = new MyClass("a"); -Assert.equal("a", mc1.field); -Assert.equal("a",mc1.getFieldName()); -let mc2: MyClass = new MyClass(1); -Assert.equal(1, mc2.field); -Assert.equal(1,mc2.getFieldName()); -let mc3: MyClass = new MyClass(false); -Assert.equal(false, mc3.field); -Assert.equal(false,mc3.getFieldName()); -let p: Compute = new Compute(8, 6); -let mc4: MyClass = new MyClass(p); -Assert.equal(8, mc4.field.num1); -Assert.equal(6, mc4.field.num2); -Assert.equal(10,mc4.field.hypot()); - -let obj: object = { - x: 1, - y: 2 -} -let mc5: MyClass = new MyClass(obj); -Assert.equal(obj, mc5.field); -let list: Array = [1, 2, 3]; -let mc6: MyClass> = new MyClass>(list); -Assert.equal(list, mc6.field); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts deleted file mode 100644 index eb1837f98c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A class that includes an extends clause is called a derived class, and the class specified in the extends clause is called the base class of the derived class. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Compute { - constructor(public num1: number, public num2: number) { } - public hypot() { - return Math.sqrt(this.num1 * this.num1 + this.num2 * this.num2); - } - static initial = new Compute(0, 0); -} -class ChildP extends Compute { - constructor(public x: number, public y: number) { - super(x, y); - } - public move() { - this.x += 1; - this.y += 1; - } -} -let pChild: ChildP = new ChildP(10, 20); -Assert.equal(10, pChild.x); -Assert.equal(20, pChild.y); -pChild.move(); -Assert.equal(11, pChild.x); -Assert.equal(21, pChild.y); -Assert.equal(0, ChildP.initial.num1); - -let count:ChildP = new ChildP(4,3); -Assert.equal(4, count.x); -Assert.equal(3, count.y); -Assert.equal(5,count.hypot()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts deleted file mode 100644 index cb1f816f5e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the implements clause specifies a set of interfaces for which to validate the class provides an implementation. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Compute { - constructor(public num1: number, public num2: number) { } - public hypot() { - return Math.sqrt(this.num1 * this.num1 + this.num2 * this.num2); - } - static initial = new Compute(0, 0); -} -let p: Compute = new Compute(4, 3); -Assert.equal(4, p.num1); -Assert.equal(3, p.num2); -Assert.equal(5,p.hypot()) - -interface InterP1 { - x: number; - y: number; -} -class P2 implements InterP1 { - x = 1; - y = 1; - setarea(x: number, y: number) { - return x * y; - } -} -let Ip = new P2(); -Assert.equal(1, Ip.x); -Assert.equal(1, Ip.y); -Assert.equal(2,Ip.setarea(1,2)) - -interface InterP2 { - Area(x: number, y: number): number; -} -class Rectangle implements InterP2 { - Area(x: number, y: number): number { - return x * y; - } -} -let rec = new Rectangle(); -Assert.equal(200, rec.Area(10, 20)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts deleted file mode 100644 index 57caf3cfdb..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The this-type (section 3.6.3) of the declared class must be assignable (section 3.11.4) to the base type reference - and each of the type references listed in the implements clause. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Addx { - constructor(public x: number) { } - public add(): this { - this.x++; - return this; - } -} -class ChildAddx extends Addx { - constructor(public x: number) { - super(x); - } - public move(): this { - this.x++; - return this; - } -} -let childadd: ChildAddx = new ChildAddx(10); -Assert.equal(11, childadd.move().x); -let a: Addx = childadd.move(); -Assert.equal(13, a.add().x); - -interface InterAddx { - x: number; -} -class Addx2 implements InterAddx { - x = 1; - setadd(): this { - this.x++; - return this; - } -} -let b1 = new Addx2(); -Assert.equal(2, b1.setadd().x); -let interb1: InterAddx = b1.setadd(); -Assert.equal(3, interb1.x); - -interface InterP { - Area(x: number, y: number): number; -} -class Rectangle implements InterP { - Area(x: number, y: number): number { - return x * y; - } - setRec(): this { - return this; - } -} -let b2 = new Rectangle(); -Assert.equal(200, b2.Area(10, 20)); -let interb2: InterP = b2.setRec(); -Assert.equal(200, interb2.Area(10, 20)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts deleted file mode 100644 index 4075363ecc..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - as is the case with every object type, type references (section 3.3.1) to the class - will appear to have the members of the global interface type named 'Object' - unless those members are hidden by members with the same name in the class. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Compute { - constructor(public num1: number, public num2: number) { } - public hypot() {return "what are you doing?" } - static initial = new Compute(0, 0); -} -let p = new Compute(1, 2); -let obj = new Object(); -Assert.equal(p.toString(), obj.toString()); -Assert.isString(p.hypot()); -Assert.equal(0,Compute.initial.num1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_5.ts deleted file mode 100644 index 7126a82c87..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_5.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The type parameters of a generic class declaration are in scope in the entire declaration and may be referenced in the ClassHeritage and ClassBody. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class MyClass{ - myArry: T[] = []; - add(num: T): void { - this.myArry.push(num); - } - max(): T { - let mNum = this.myArry[0]; - for (let i = 0; i < this.myArry.length; i++) { - if (mNum < this.myArry[i]) { - mNum = this.myArry[i]; - } - } - return mNum; - } -} -let h_m: MyClass = new MyClass(); -h_m.add(5); -h_m.add(4); -h_m.add(9); -h_m.add(15); -Assert.equal(h_m.max(), 15); -let h_m2: MyClass = new MyClass(); -h_m2.add('b'); -h_m2.add('a'); -h_m2.add('w'); -h_m2.add('f'); -Assert.equal(h_m2.max(), 'w'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_6.ts deleted file mode 100644 index 227a5aaefe..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_6.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The constructor function type created by the class declaration must be assignable to the base class constructor function type - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Person { - name: string; - age: number; - constructor(name: string, age: number) { - this.name = name; - this.age = age; - } -} -class Student extends Person { - constructor(name: string, age: number, public id: string) { - super(name, age); - this.id = id; - } -} -let stu1: Student = new Student("xiao", 18, "001"); -let per1: Person = stu1; -Assert.equal("xiao", per1.name); -Assert.equal(18, per1.age); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_1.ts deleted file mode 100644 index 3e40064410..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_1.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If a class omits a constructor declaration, an automatic constructor is provided. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class A { - x: number = 1; - y: string = "go"; -} -let a = new A(); -Assert.equal(a.x, 1); -Assert.equal(a.y, "go"); -class B { - x: number; - y: string; - constructor(x: number = 1, y: string = "go") { - this.x = x; - this.y = y; - } -} -let b = new B(); -Assert.equal(a.x, 1); -Assert.equal(a.y, "go"); -Assert.equal(b.x, 1); -Assert.equal(b.y, "go"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_2.ts deleted file mode 100644 index 1faf83d9b3..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_2.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a derived class, the automatic constructor has the same parameter list (and possibly overloads) as the base class constructor. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Point1 { - x: string; - y: string; - constructor(x: string, y: string) { - this.x = x; - this.y = y; - } - toString() { - return this.x + " " + this.y; - } -} -class ColorPoint extends Point1 { - color: string; - constructor(x: string, y: string, color: string) { - super(x, y); - this.color = color; - } - toString() { - return this.color + " " + super.toString(); - } -} -let co = new ColorPoint("A", "B", "blue"); -Assert.equal(co.x, "A"); -Assert.equal(co.y, "B"); -Assert.equal(co.color, "blue"); -Assert.equal(co.toString(), "blue A B"); -class ColorPoint2 extends Point1 { - constructor(x: string, y: string) { - super(x, y); - } -} -let co2 = new ColorPoint2("a", "b"); -Assert.equal(co2.x, "a"); -Assert.equal(co2.y, "b"); -Assert.equal(co2.toString(), "a b"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_3.ts deleted file mode 100644 index a7a294bd11..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_3.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a class with no extends clause, the automatic constructor has no parameters - and performs no action other than executing the instance member variable initializers (section 8.4.1), if any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Foo { - constructor(public x: number = 1, public y: string = "go") { - this.x = x; - this.y = y; - } -} -let foo = new Foo(); -Assert.equal(foo.x, 1); -Assert.equal(foo.y, "go"); -class Foo2 { - x: number; - y: string; - constructor(x: number, y: string) { - this.x = x; - this.y = y; - } -} -let foo2 = new Foo2(2, "go"); -Assert.equal(foo2.x, 2); -Assert.equal(foo2.y, "go"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts deleted file mode 100644 index 79d6a94147..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Constructor declarations that specify a body are called constructor implementations and - constructor declarations without a body are called constructor overloads. - It is possible to specify multiple constructor overloads in a class, - but a class can have at most one constructor implementation. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Animal1 { - name: string | undefined; - age: number | undefined; - constructor(); - constructor(name: string); - constructor(age: number); - constructor(name: string, age: number); - constructor(nameorage?: string | number, age?: number) { - if (typeof nameorage == "number") { - this.age = nameorage; - } - if (typeof nameorage == "string") { - this.name = nameorage; - } - if (age) { - this.age = age; - } - } -} -let tt1 = new Animal1("caihua1",NaN); -Assert.equal(tt1.name,"caihua1"); -Assert.equal(tt1.age, undefined); -let tt2 = new Animal1("caihua2", 12); -Assert.equal(tt2.name, "caihua2"); -Assert.equal(tt2.age, 12); -let tt3 = new Animal1("caihua3"); -Assert.equal(tt3.name, "caihua3"); -let tt4 = new Animal1(1230); -Assert.equal(tt4.age, 1230); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts deleted file mode 100644 index 2af41b9e05..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A parameter of a ConstructorImplementation may be prefixed with a public, private, or protected modifier. - This is called a parameter property declaration and is shorthand for declaring a property with the same name as the parameter - and initializing it with the value of the parameter. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class MyClass1 { - constructor(public num1: number, private num2: number = 1) { } - get foo(): number { - return this.num2; - } -} -class MyClass2 { - public num1: number; - protected num2: number; - constructor(num1: number, num2: number) { - this.num1 = num1; - this.num2 = num2; - } - get foo(): number { - return this.num2; - } -} -let p1 = new MyClass1(1, 2); -Assert.equal(p1.num1, 1); -Assert.equal(p1.foo, 2); -let p2 = new MyClass2(3, 4); -Assert.equal(p2.foo, 4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_3.ts deleted file mode 100644 index 8138bbfb04..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_3.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The function body of a constructor is permitted to contain return statements. If return statements specify expressions, - those expressions must be of types that are assignable to the this-type of the class. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - - -class myClass1 { - num: number; - constructor(num: number) { - this.num = num - return; - } -} -let myTest1 = new myClass1(5); -Assert.equal(myTest1.num, 5); -class myClass2 { - num: number; - constructor(num: number) { - this.num = num - return { num: 10 }; - } -} -let myTest2 = new myClass2(5); -Assert.equal(myTest2.num, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_4.ts deleted file mode 100644 index ce311d0f45..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_4.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The type parameters of a generic class are in scope and accessible in a constructor declaration. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class myClass{ - num: T; - constructor(num: T) { - this.num = num; - } -} -let myTest = new myClass(10); -Assert.equal(myTest.num, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_5.ts deleted file mode 100644 index 4ee4119aa9..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_5.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A parameter property declaration may declare an optional parameter, - but the property introduced by such a declaration is always considered a required property. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class myClass { - constructor(public num1: number, public num2?: number, public num3: number = 10) { - this.num1 = num1; - this.num2 = num2; - this.num3 = num3; - } -} -let myTest = new myClass(3); -Assert.equal(myTest.num1, 3); -Assert.equal(myTest.num3, 10); -Assert.equal(myTest.num2, undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_6.ts deleted file mode 100644 index 3c0093b044..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_6.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a class with no constructor declaration, an automatic constructor is provided, as described in section 8.3.3. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class myClass { - public a: string = "test"; - public b: number = 1; -} -class myClass2 { - public c: number = 2; -} -let myTest: myClass = new myClass(); -Assert.equal(myTest.a, "test"); -Assert.equal(myTest.b, 1); -let myTest2: myClass2 = new myClass2(); -Assert.equal(myTest2.c, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/super_calls/super_calls.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/super_calls/super_calls.ts deleted file mode 100644 index c938838f71..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/super_calls/super_calls.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Super calls (section 4.9.1) are used to call the constructor of the base class. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class P { - public num1: number; - public num2: number; - constructor(num1: number, num2: number) { - this.num1 = num1; - this.num2 = num2; - } -} -class HueP extends P { - constructor(num1: number, num2: number, public hue: string) { - super(num1, num2); - } -} -let p1 = new HueP(1, 2, "red"); -Assert.equal(p1.num1, 1); -Assert.equal(p1.num2, 2); -Assert.equal(p1.hue, "red"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/index_member_declarations/index_member_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/index_member_declarations/index_member_declarations.ts deleted file mode 100644 index d0584deafc..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/index_member_declarations/index_member_declarations.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - All instance property members of a class must satisfy - the constraints implied by the index members of the class as specified in section 3.9.4. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class ind { - name: string; - [index: string]: number | string; - constructor(name: string) { - this.name = name; - } -} -let a = new ind("aa"); -a.name = "pig"; -a.age = 12; -Assert.equal(a.age, 12); -a.add = "qindao"; -Assert.equal(a.add, "qindao"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_1.ts deleted file mode 100644 index 90ac66d160..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_1.ts +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Public property members can be accessed everywhere without restrictions. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Base { - public a: number; - constructor(a: number) { - this.a = a; - } - public add() { - this.a++; - } -} -class Derived extends Base { - public b: number; - constructor(a: number, b: number) { - super(a); - this.b = b; - } - public geta() { - return this.a; - } -} -let derived: Derived = new Derived(1, 2); -let x = derived.a; -Assert.equal(x, 1); -let y = derived.geta(); -Assert.equal(y, 1); -let z: Base = new Base(3); -Assert.equal(z.a, 3); -z.add(); -Assert.equal(z.a, 4); -class MyClass{ - public myArry: T[] = []; - public add(num: T): void { - this.myArry.push(num); - } - public max(): T { - let mNum = this.myArry[0]; - for (let i = 0; i < this.myArry.length; i++) { - if (mNum < this.myArry[i]) { - mNum = this.myArry[i]; - } - } - return mNum; - } -} -let h_m: MyClass = new MyClass(); -h_m.add(5); -h_m.add(4); -h_m.add(9); -h_m.add(15); -Assert.equal(h_m.max(), 15); -let h_m2: MyClass = new MyClass(); -h_m2.add('b'); -h_m2.add('a'); -h_m2.add('w'); -h_m2.add('f'); -Assert.equal(h_m2.max(), 'w'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_2.ts deleted file mode 100644 index 0a8a658283..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_2.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain m copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Private property members can be accessed only within their declaring class. Specifically, - m private member M declared in m class C can be accessed only within the class body of C. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Base { - private x: number = 1; - private y: number = 2; - addx() { - this.x++; - } - get foo() { - return this.x; - } - public addxy(): number { - return this.x + this.y; - } - static fun(m: Base, n: Derived) { - m.x = 1; - n.x = 1; - m.y = 1; - n.y = 1; - } -} -class Derived extends Base { } -let m: Base = new Base(); -m.addx(); -Assert.equal(m.foo, 2); -Assert.equal(m.addxy(), 4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_3.ts deleted file mode 100644 index b91989153a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_3.ts +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Protected property members can be accessed only within their declaring class and classes derived from their declaring class, - and a protected instance property member must be accessed through an instance of the enclosing class or a subclass thereof. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Base { - protected x: number = 1; - protected y: number = 4; - protected addxy() { - return this.x + this.y; - } - public addx() { - this.x++; - } - public get foo() { - return this.x; - } - static fun(m: Base, b: Derived) { - m.x = 1; - b.x = 1; - m.y = 1; - b.y = 1; - } -} -class Derived extends Base { - public get add(): number { - return this.addxy() - } - public get foo() { - return this.x; - } - static fun(b: Derived) { - b.x = 1; - b.y = 1; - } -} -let m: Base = new Base(); -m.addx(); -Assert.equal(m.foo, 2); -let b: Derived = new Derived(); -b.addx(); -Assert.equal(b.foo, 2); -Assert.equal(b.add, 6); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_1.ts deleted file mode 100644 index 25ab9d6c7f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_1.ts +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Within the constructor and instance member functions of a class, the type of this is the this-type of that class type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Ra { - public x: number; - public y: number; - constructor(x: number, y: number) { - this.x = x; - this.y = y; - } - public addx(): this { - this.x++; - return this - } - public addy(): this { - this.y++; - return this; - } - public add() { - return this.x + this.y; - } -} -class Rb extends Ra { - public z: number; - constructor(x: number, y: number, z: number) { - super(x, y); - this.z = z; - } - public addz(): this { - this.z++; - return this; - } -} -let a: Ra = new Ra(1, 1); -let b: Rb = new Rb(1, 1, 1); -Assert.equal(a.addx().x, 2); -Assert.equal(a.addx().y, 1); -Assert.equal(a.addx().add(), 5); -Assert.equal(a.addy().x, 4); -Assert.equal(a.addy().y, 3); -Assert.equal(a.add(), 7); -Assert.equal(b.addx().x, 2); -Assert.equal(b.addx().y, 1); -Assert.equal(b.addy().x, 3); -Assert.equal(b.addy().y, 3); -Assert.equal(b.addz().z, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_2.ts deleted file mode 100644 index 7686b8c6f2..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_2.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - All instance property members of a class must satisfy the constraints implied by the index members of the class . - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Ra { - public h_x: number; - constructor(h_x: number) { - this.h_x = h_x; - } - public h_f() { - this.h_x++; - } - public h_g(): any { - return this.h_x; - } - static h_s: string = "aa"; -} -let aa: Ra = new Ra(1); -Assert.equal(aa.h_x, 1); -aa.h_f(); -Assert.equal(aa.h_x, 2); -class Rb extends Ra { - public h_y: number; - constructor(h_x: number, h_y: number) { - super(h_x); - this.h_y = h_y; - } - public h_g(): boolean { return false; } -} -let bb: Rb = new Rb(1, 2); -Assert.equal(bb.h_x, 1); -Assert.equal(bb.h_y, 2); -bb.h_f(); -Assert.equal(bb.h_x, 2); -Assert.equal(bb.h_g(), false); -interface Rc { - h_x: number; - h_f: () => void; - h_g: () => any; -} -let c: Rc = aa; -Assert.equal(c.h_g(), 2); -interface Rd { - h_x: number; - h_y: number; - h_f: () => void; - h_g: () => boolean; -} -let d: Rd = bb; -Assert.equal(d.h_g(), false); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_3.ts deleted file mode 100644 index 870c54edb0..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_3.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The class type has a property for each constructor parameter declared with a public, private, or protected modifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Ra { - public x: number = 10; - private y: number = 10; - protected z: number = 10; - constructor() { }; - public f() { - this.x++; - return this; - } - public gety(): number { - return this.y; - } - public getz(): number { - return this.z; - } - protected fun(): boolean { - return false; - } - public getfun() { - return this.fun(); - } -} -class Rb extends Ra { - protected z: number = 20; - protected fun(): boolean { - return true; - } -} -let a: Ra = new Ra(); -Assert.equal(a.x, 10); -Assert.equal(a.gety(), 10); -Assert.equal(a.getz(), 10); -Assert.equal(a.getfun(), false); -Assert.equal(a.f().x, 11); -let b: Rb = new Rb(); -Assert.equal(b.x, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_1.ts deleted file mode 100644 index 0eeb7cee80..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_1.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the class contains no constructor declaration and has no base class, - a single construct signature with no parameters, - having the same type parameters as the class (if any) - and returning an instantiation of the class type with those type parameters passed as type arguments. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class A { - a: number = 0; - b: number = 0; - constructor() { } -} -let a = new A(); -Assert.equal(a.a, 0); -Assert.equal(a.b, 0); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_2.ts deleted file mode 100644 index 83f781677c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_2.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the class contains no constructor declaration and has a base class, - a set of construct signatures with the same parameters as those of the base class constructor function type - following substitution of type parameters with the type arguments specified in the base class type reference, - all having the same type parameters as the class. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class A1 { - public numa: number; - constructor(a: number) { - this.numa = a; - } -} -class B1 extends A1 { - public numb: number; - constructor(a: number, b: number) { - super(a); - this.numb = b; - } -} -let a: A1 = new A1(1); -Assert.equal(a.numa, 1); -let b: B1 = new B1(2, 2); -Assert.equal(b.numa, 2); -Assert.equal(b.numb, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_3.ts deleted file mode 100644 index 4d8e22be4b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_3.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the class contains a constructor declaration with no overloads, - a construct signature with the parameter list of the constructor implementation, - having the same type parameters as the class (if any) - and returning an instantiation of the class type with those type parameters passed as type arguments. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class A { - public x: number; - public y: number; - constructor(x: number, y: number) { - this.x = x; - this.y = y; - } -} -let a = new A(1, 2); -Assert.equal(a.x, 1); -Assert.equal(a.y, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_4.ts deleted file mode 100644 index 3ccc9e317d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_4.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the class contains a constructor declaration with overloads, a set of construct signatures - with the parameter lists of the overloads, all having the same type parameters as the class (if any) - and returning an instantiation of the class type with those type parameters passed as type arguments. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -type TypeSummation = { - width?: number; - height?: number; -}; -class summation { - public width; - public height; - constructor(width: number, height: number); - constructor(ParamObje_: TypeSummation); - constructor(ParamObje_Obj_: any, height_ = 0) { - if (typeof ParamObje_Obj_ === "object") { - const { width, height } = ParamObje_Obj_; - this.width = width; - this.height = height; - } else { - this.width = ParamObje_Obj_; - this.height = height_; - } - } - sunArea(): number { - return this.width * this.height; - } -} -const sun = new summation(4, 5); -Assert.equal(sun.sunArea(), 20); -const obj: TypeSummation = { width: 10, height: 20 }; -Assert.equal(new summation(obj).sunArea(), 200); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts deleted file mode 100644 index 98ad0473e6..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A property for each static member variable declaration in the class body. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class A1 { - public numa: number; - constructor(a: number) { - this.numa = a; - } - static c: number = 20; -} -class B1 extends A1 { - public numb: number; - constructor(a: number, b: number) { - super(a); - this.numb = b; - } -} -let a: A1 = new A1(10); -Assert.equal(a.numa, 10); -Assert.equal(A1.c, 20); -let b: B1 = new B1(10, 20); -Assert.equal(b.numa, 10); -Assert.equal(b.numb, 20); -Assert.equal(B1.c, 20); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_6.ts deleted file mode 100644 index d97b249c6e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_6.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A property of a function type for each static member function declaration in the class body. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class A1 { - public numa: number; - constructor(a: number) { - this.numa = a; - } - static c = 10; - static f(): void { - this.c++; - } -} -class B1 extends A1 { - public numb: number; - constructor(a: number, b: number) { - super(a); - this.numb = b; - } - static f() { - this.c++; - return this.c - } -} -Assert.equal(A1.c, 10); -A1.f(); -Assert.equal(A1.c, 11); -Assert.equal(B1.c, 11); -Assert.equal(B1.f(), 12); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_7.ts deleted file mode 100644 index 8435c66f74..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_7.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A property named 'prototype', the type of which is an instantiation of the class type with type Any supplied - as a type argument for each type parameter. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Animal { - public name: string; - constructor(name: string) { - this.name = name; - } -} -Assert.equal(typeof (Animal.prototype), "object"); -let cat = new Animal("Cat") -Assert.equal(Object.getPrototypeOf(cat) === Animal.prototype, true); -Assert.equal(Object.getPrototypeOf(Animal.prototype) === Object.prototype, true); -Assert.equal(Object.getPrototypeOf(Object.prototype) === null, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_1.ts deleted file mode 100644 index c813e63ef5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_1.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A derived class inherits all members from its base class it doesn't override. - Inheritance means that a derived class implicitly contains all non-overridden members of the base class. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Shape { - public color: string = "black"; - protected side: number = 10; - constructor() { }; - public switchColor() { - this.color = this.color === "black" ? "white" : "black"; - } -} -class Circle extends Shape { - get gside() { - return this.side; - } -} -let circle: Circle = new Circle(); -let a: string = circle.color; -Assert.equal(a, "black"); -circle.switchColor(); -let b: string = circle.color; -Assert.equal(b, "white"); -Assert.equal(10, circle.gside); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_2.ts deleted file mode 100644 index 093a81f893..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_2.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Only public and protected property members can be overridden. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Shape { - public color: string = "black"; - protected side: number = 10; - constructor() { }; - public switchColor() { - this.color = this.color === "black" ? "white" : "black"; - } -} -class Circle extends Shape { - public color: string = "red"; - protected side: number = 11; - get gside() { - return this.side; - } - public switchColor() { - this.color = this.color === "red" ? "white" : "black"; - } -} -let shape: Shape = new Shape(); -Assert.equal(shape.color, "black"); -shape.switchColor(); -Assert.equal(shape.color, "white"); -let circle: Circle = new Circle(); -Assert.equal(circle.color, "red"); -circle.switchColor(); -Assert.equal(circle.color, "white"); -Assert.equal(11, circle.gside); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_3.ts deleted file mode 100644 index 42c1eecee2..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_3.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Base class static property members can be overridden by derived class static property members - of any kind as long as the types are compatible. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Shape { - static color: string = "black"; - static switchColor() { - this.color = this.color === "black" ? "white" : "black"; - } -} -class Circle extends Shape { - static color: string = "red"; - static switchColor() { - this.color = this.color === "red" ? "green" : "red"; - } -} -let a = Circle.color; -Assert.equal(a, "red"); -Circle.switchColor(); -let b = Circle.color; -Assert.equal(b, "green"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_4.ts deleted file mode 100644 index 1b55b81f59..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_4.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Base class instance member variables and accessors can be overridden by derived class instance member variables and accessors. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class MyClass { - num: number = 20; - constructor(num: number) { - this.num = num; - } - get() { - return this.num - } - set(num: number) { - this.num = num; - } -} -class myClass extends MyClass { - constructor(num: number) { - super(num); - this.num = num; - } - get() { - return 10 - } - set(num: number) { - this.num = num; - } -} -let myTest = new myClass(5); -Assert.equal(myTest.num, 5); -Assert.equal(myTest.get(), 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_5.ts deleted file mode 100644 index aa473982b5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_5.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A property member in a derived class is said to override a property member in a base class - when the derived class property member has the same name and kind (instance or static) as the base class property member. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Shape { - public color: string = "black"; - protected name: string = "shape"; - public switchColor() { - this.color = this.color === "black" ? "white" : "black"; - } - protected f(a: Shape, b: Circle) { - a.color = "blue"; - b.color = "blue"; - } - static size: number = 10; -} -class Circle extends Shape { - public color: string = "red"; - protected name: string = "circle"; - public switchColor() { - this.color = this.color === "red" ? "green" : "red"; - } - static size: number = 12; - protected f(a: Shape, b: Circle) { - a.color = "pink"; - b.color = "pink"; - } -} -let shape: Shape = new Shape(); -Assert.equal(shape.color, "black"); -shape.switchColor(); -Assert.equal(shape.color, "white"); -Assert.equal(Shape.size, 10); -let circle = new Circle(); -Assert.equal(circle.color, "red"); -circle.switchColor(); -Assert.equal(circle.color, "green"); -Assert.equal(Circle.size, 12); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_1.ts deleted file mode 100644 index 5683f2888a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_1.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Members are either instance members or static members. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Person { - private _name: string; - public age: number; - constructor(name: string, age: number) { - this._name = name; - this.age = age; - } - public set name(name: string) { - this._name = name; - } - public get name() { - return this._name; - } - static language: string = "english"; - static ageAdd() { - return this.language + "aaa"; - } -} -let per: Person = new Person("rain", 22); -Assert.equal(per.name, "rain"); -Assert.equal(per.age, 22); -Assert.equal(Person.language, "english"); -Assert.equal(Person.ageAdd(), "englishaaa"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts deleted file mode 100644 index 478ebc4313..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Instance members are members of the class type and its associated this-type. Within constructors, - instance member functions, and instance member accessors, - the type of this is the this-type of the class. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Counter { - private count: number = 0; - constructor(count_: number) { - this.count = count_; - } - public add(): this { - this.count++; - return this; - } - public subtract(): this { - this.count--; - return this; - } - public get Result(): number { - return this.count; - } -} -let counter = new Counter(1); -counter.add(); -Assert.equal(counter.add(), counter); -Assert.equal(counter.Result, 3); -counter.subtract(); -Assert.equal(counter.subtract(), counter); -Assert.equal(counter.Result, 1); -class Compute { - constructor(public num1: number, public num2: number) { } - public hypot() { - return Math.sqrt(this.num1 * this.num1 + this.num2 * this.num2); - } - static initial = new Compute(0, 0); -} -class ChildP extends Compute { - constructor(public x: number, public y: number, public z: number) { - super(x, y); - this.z = z; - } - public move(): this { - this.x += 1; - this.y += 1; - this.z += 1; - return this - } -} -let childp: ChildP = new ChildP(1, 2, 3); -childp.move(); -Assert.equal(childp.x, 2); -Assert.equal(childp.y, 3); -Assert.equal(childp.z, 4); -Assert.equal(childp.move(), childp); -let count: ChildP = new ChildP(4,3,1); -Assert.equal(count.hypot(),5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts deleted file mode 100644 index 234ee19637..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Static members are declared using the static modifier and are members of the constructor function type. - Within static member functions and static member accessors, - the type of this is the constructor function type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Person { - static n2: number = 20; - tool(): number { - return 30; - } - static tool1(): number { - return this.n2; - } - static tool2() { - this.n2++; - return this; - } - static get foo(): number { - return this.n2; - } -} -let a: number = Person.n2; -Assert.equal(a, 20); -let b: number = Person.tool1(); -Assert.equal(b, 20); -let c: number = Person.foo; -Assert.equal(c, 20); -Assert.equal(Person, Person.tool2()); -let d: Person = new Person(); -Assert.equal(d.tool(),30); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/dynamic_property_declarations/dynamic_property_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/dynamic_property_declarations/dynamic_property_declarations.ts deleted file mode 100644 index c11af2fa48..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/dynamic_property_declarations/dynamic_property_declarations.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A dynamic property declaration does not introduce a property in the class type or constructor function type. - The property name expression of a dynamic property assignment must be of type Any or the String, Number, or Symbol primitive type. - The name associated with a dynamic property declarations is considered to be a numeric property name if the property name expression is of type Any or the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class computer { - [compute:string]:any - constructor( - public name:string, - public age:number - ){} - sayOne(){return "one"} -} -let uce = new computer("aa",22); -uce.pid = "223"; -uce.id=1; -Assert.equal(uce.name,"aa"); -Assert.equal(typeof uce,"object"); -Assert.equal(uce.id+uce.pid,"1223"); -Assert.equal(uce.sayOne(),"one"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_accessor_declarations/member_accessor_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_accessor_declarations/member_accessor_declarations.ts deleted file mode 100644 index d4789e76dc..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_accessor_declarations/member_accessor_declarations.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A member accessor declaration declares an instance member accessor or a static member accessor. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class A { - private _foo: number = 0; - get foo(): number { - return this._foo; - } - set foo(value: number) { - this._foo = value; - } - private static a: number = 0; - static get aa(): number { - return this.a; - } - static set aa(value: number) { - this.a = value; - } -} -let x = new A(); -Assert.equal(x.foo, 0); -x.foo = 10; -Assert.equal(x.foo, 10); -Assert.equal(A.aa, 0); -A.aa = 20; -Assert.equal(A.aa, 20); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts deleted file mode 100644 index 81ff4b1d7b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A member function declaration declares an instance member function or a static member function. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class MyClass { - constructor(public x: number, public y: number) { } - public distance(p: MyClass) { - let dx = this.x - p.x; - let dy = this.y - p.y; - return Math.sqrt(dx * dx + dy * dy); - } - static add(p1: MyClass) { - p1.x++; - return p1.x - } -} -let p1: MyClass = new MyClass(2, 2); -let p2: MyClass = new MyClass(1, 1); -Assert.equal(p1.distance(p2), Math.sqrt(2)); -Assert.equal(MyClass.add(p1), 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_2.ts deleted file mode 100644 index 913abdd47c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_2.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In the body of an instance member function declaration, this is of the this-type (section 3.6.3) of the class. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Circle { - radius: number = 1; - area(): number { - return Math.PI * this.radius * this.radius; - } -} -let c = new Circle(); -Assert.equal(c.radius, 1); -Assert.equal(c.area(), Math.PI); -c.radius = 2; -Assert.equal(c.area(), Math.PI * 4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts deleted file mode 100644 index b5b27f92c4..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In the body of a static member function declaration, the type of this is the constructor function type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class MyClass { - constructor(public x: number = 3, public y: number = 3) { } - static z: number; - static pro() { - return this.prototype; - } - static returnz() { - this.z; - } -} -Assert.equal(MyClass.pro(), "[object Object]"); -Assert.equal(MyClass.returnz(), undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts deleted file mode 100644 index 00b736c2f0..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A member function can access overridden base class members using a super property access (section 4.9.2). - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class MyClass { - constructor(public x: number, public y: number) { } - public add() { - return this.x + this.y; - } -} -class MyClass2 extends MyClass { - constructor(x: number, y: number, public z: number) { - super(x, y); - } - public add() { - return super.add() + this.z; - } -} -let p = new MyClass(1, 2); -Assert.equal(p.x, 1); -Assert.equal(p.y, 2); -Assert.equal(p.add(), 3); -let cp = new MyClass2(1, 2, 3); -Assert.equal(cp.z, 3); -Assert.equal(cp.add(), 6); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts deleted file mode 100644 index 9d52a76633..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a static member function,a call to 'new this()' may actually invoke a derived class constructor - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class TP { - constructor(public a: number = 1, public b: number = 1) { } - static createthis() { - return new this(); - } -} -class CP extends TP { - constructor(public a: number = 2, public b = 2) { - super(); - } -} -let x = TP.createthis(); -let y = CP.createthis(); -Assert.equal(x.a, 1); -Assert.equal(y.a, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts deleted file mode 100644 index 0858958081..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Initializers in static member variable declarations are executed once when the containing script or module is loaded. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class MyClass { - constructor(public x: number, public y: number) { } - public addc() { - MyClass.c++; - } - static po = new MyClass(0, 0); - static c: number = 10; -} -let a: MyClass = new MyClass(1, 1); -Assert.equal(MyClass.c, 10); -a.addc(); -Assert.equal(MyClass.c, 11); -let b: MyClass = new MyClass(1, 1); -b.addc(); -Assert.equal(MyClass.c, 12); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_2.ts deleted file mode 100644 index f6709f6ede..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_2.ts +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Instance member variable initializers are equivalent to assignments to properties of this in the constructor - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Staff1 { - public name: string; - public place: string; - public work: boolean; - constructor(name: string, place: string, work: boolean) { - this.name = name; - this.place = place; - this.work = work; - } - initializer(name: string, place: string, work: boolean) { - this.name = name; - this.place = place; - this.work = work; - } -} -class Staff2 { - public name: string; - public place: string; - public work: boolean; - constructor(name: string, place: string, work: boolean) { - this.name = name; - this.place = place; - this.work = work; - } -} -let em1 = new Staff1("zhangsan", "shanghai", true); -em1.initializer("wangwu", "hainan", true); -let em2 = new Staff2("lisi", "qingdao", true); -Assert.equal(em1.name, "wangwu"); -Assert.equal(em1.place, "hainan"); -Assert.equal(em1.work, true); -Assert.equal(em2.name, "lisi"); -Assert.equal(em2.place, "qingdao"); -Assert.equal(em2.work, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts deleted file mode 100644 index 562151a0f7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A member variable declaration declares an instance member variable or a static member variable. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class MyClass { - public x: number; - public y: number; - constructor(x: number, y: number) { - this.x = x; - this.y = y; - } - static z: number = 3; -} -class MyClass2 extends MyClass { - constructor(x: number, y: number, public color: string) { - super(x, y); - } - static r: number = 10; -} -let p = new MyClass(1, 2); -Assert.equal(p.x, 1); -Assert.equal(p.y, 2); -Assert.equal(MyClass.z, 3); -let cp = new MyClass2(4, 5, "red"); -Assert.equal(cp.x, 4); -Assert.equal(cp.y, 5); -Assert.equal(MyClass2.r, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts deleted file mode 100644 index 04668be36d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Instance member variable initializers are equivalent to assignments to properties of this in the constructor - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class A { - public x: number = 1; - public y: string = "name"; - public z: boolean = false; - constructor() { } -} -class B { - public x: number = 1; - public y: string = "name"; - public z: boolean - constructor(z: boolean = false) { - this.z = z; - } -} -let a = new A(); -Assert.equal(a.z, false); -let b = new B(); -Assert.equal(b.z, false); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_1.ts deleted file mode 100644 index f6eacfb220..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_1.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Member declarations with a static modifier are called static member declarations. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Compute { - constructor(public x: number, public y: number) { } - public range(p1: Compute, p2: Compute) { - let dx = p1.x - p2.x; - let dy = p1.y - p2.y; - return Math.sqrt(dx * dx + dy * dy); - } - static getx() { - return this.x; - } - static po = new Compute(0, 0); - static x: number = 10; -} -let p1: Compute = new Compute(2, 2); -let p2: Compute = new Compute(1, 1); -Assert.equal(p1.range(p1, p2), Math.sqrt(2)); -Assert.equal(Compute.getx(), 10); -Assert.equal(p1.range(p1, Compute.po), Math.sqrt(8)); -Assert.equal(Compute.x, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_2.ts deleted file mode 100644 index 12ffdf3f7d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_2.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - it is possible to have instance and static property members with the same name. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../../suite/assert.js" - -class myClass { - public x: number; - public y: number; - constructor(x: number, y: number) { - this.x = x; - this.y = y; - } - public add(): number { - return this.x + this.y; - } - static x: number = 3; - static add(): number { - this.x++; - return this.x; - } -} -let myTest = new myClass(1, 2); -Assert.equal(myTest.x, 1); -Assert.equal(myTest.y, 2); -Assert.equal(myTest.add(), 3); -Assert.equal(myClass.x, 3); -Assert.equal(myClass.add(), 4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_3.ts deleted file mode 100644 index e8432500f8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_3.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Every class automatically contains a static property member named 'prototype' - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Compute { - public x: number; - public y: number; - constructor(x: number, y: number) { - this.x = x; - this.y = y; - } - static p = new Compute(0, 0); -} -class ColoredPoint extends Compute { - constructor(x: number, y: number, public color: string) { - super(x, y); - } -} -Assert.equal(ColoredPoint.prototype.color, undefined); -Assert.equal(ColoredPoint.prototype.x, undefined); -Assert.equal(ColoredPoint.prototype.y, undefined); -Assert.equal(Compute.prototype.x, undefined); -Assert.equal(Compute.prototype.y, undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/constant_enum_declarations/constant_enum_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/constant_enum_declarations/constant_enum_declarations.ts deleted file mode 100644 index 4c56963def..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/constant_enum_declarations/constant_enum_declarations.ts +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - in a constant enum declaration, all members must have constant values and it is an error for a member declaration to specify an expression that isn't classified as a constant enum expression. - it is an error to reference a constant enum object in any other context than a property access that selects one of the enum's members. - the only permitted references to the enum object are those that are replaced with an enum member value. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -const enum CED { - None = -1, - False, - True = 1, - DEF = 1024, - Val = DEF / 8, -} -Assert.equal(CED.None, -1); -Assert.equal(CED.False, 0); -Assert.equal(CED.True, 1); -Assert.equal(CED.DEF, 1024); -Assert.equal(CED.Val, 128); -Assert.equal(CED["None"], -1); -Assert.equal(CED["False"], 0); -Assert.equal(CED["True"], 1); -Assert.equal(CED["DEF"], 1024); -Assert.equal(CED["Val"], 128); - -enum CED_COPY { - None = -1, - False, - True = 1, - DEF = 1024, - Val = DEF / 8, -} -Assert.equal(CED_COPY[-1], "None"); -Assert.equal(CED_COPY[0], "False"); -Assert.equal(CED_COPY[1], "True"); -Assert.equal(CED_COPY[1024], "DEF"); -Assert.equal(CED_COPY[128], "Val"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_1.ts deleted file mode 100644 index 3cad444c10..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_1.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - enums are "open-ended" and enum declarations with the same qualified name relative to a common root define a single enum type and contribute to a single enum object. - it isn't possible for one enum declaration to continue the automatic numbering sequence of another, and when an enum type has multiple declarations, only one declaration is permitted to omit a value for the first member. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -enum A { - A1, - A2, -} -enum A { - A3 = 3, - A4, -} -Assert.equal(A.A1, 0); -Assert.equal(A.A2, 1); -Assert.equal(A.A3, 3); -Assert.equal(A.A4, 4); -namespace NSP { - export enum A { - A1, - A2, - } - export enum A { - A3 = 2, - A4, - } -} -Assert.equal(NSP.A.A1, 0); -Assert.equal(NSP.A.A2, 1); -Assert.equal(NSP.A.A3, 2); -Assert.equal(NSP.A.A4, 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_2.ts deleted file mode 100644 index f7efe29be5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_2.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - when enum declarations are merged, they must either all specify a const modifier or all specify no const modifier. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -const enum T1 { - Tex0, - Tex1, -} -const enum T1 { - Tex2 = 2, - Tex3, -} -Assert.equal(T1.Tex0, 0); -Assert.equal(T1.Tex1, 1); -Assert.equal(T1.Tex2, 2); -Assert.equal(T1.Tex3, 3); -enum T2 { - Tex0, - Tex1, -} -enum T2 { - Tex2 = 2, - Tex3, -} -Assert.equal(T2.Tex0, 0); -Assert.equal(T2.Tex1, 1); -Assert.equal(T2.Tex2, 2); -Assert.equal(T2.Tex3, 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_1.ts deleted file mode 100644 index cca34206d6..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_1.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - an EnumDeclaration introduces a named type and a named value in the containing declaration space. - The enum type is a distinct subtype of the Number primitive type. - the enum object is a value of an anonymous object type containing a set of properties, - all of the enum type, corresponding to the values declared for the enum type in the body of the declaration. - The enum object's type furthermore includes a numeric index signature with the signature '[x: number]: string'. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -enum Animal { - cat = 0xff0000, - dog = 0x00ff00, - pig = 0x0000ff, -} -Assert.isString(Animal[0xff0000]); -Assert.equal(Animal[0x00ff00], "dog"); -Assert.isNumber(Animal.pig); -enum TypeABC { - A, - B, - C, -} -var index = TypeABC.A; -Assert.equal(TypeABC.A, 0); -Assert.equal(TypeABC.B, index + 1); -Assert.equal(TypeABC.C, index + 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_2.ts deleted file mode 100644 index 78e6995c4d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_2.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the numeric index signature reflects a "reverse mapping" that is automatically generated in every enum object. - the reverse mapping provides a convenient way to obtain the string representation of an enum value - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -enum Animal { - Cat = 0xff0000, - Dog = 0x00ff00, - Pig = 0x0000ff, -} -var dog = Animal.Dog; -Assert.isNumber(dog); -Assert.isString(Animal[dog]); -Assert.equal("Dog", Animal[dog]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_3.ts deleted file mode 100644 index 481799d7ca..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_3.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - When an enum declaration includes a const modifier it is said to be a constant enum declaration. - The members of a constant enum declaration must all have constant values that can be computed at compile time. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -const enum H_Date { - Monday = 'Mon', - Tuesday = 'Tues', - Wednesday = 'Wed', - Thursday = 'Thur', - Friday = 'Fri', - Saturday = 'Satur', - Sunday = 'Sun' -} -let h_date1 = H_Date.Monday; -Assert.equal(h_date1, 'Mon'); -let h_date2 = H_Date.Tuesday; -Assert.equal(h_date2, 'Tues'); -let h_date3 = H_Date.Wednesday; -Assert.equal(h_date3, 'Wed'); -let h_date4 = H_Date.Thursday; -Assert.equal(h_date4, 'Thur'); -let h_date5 = H_Date.Friday; -Assert.equal(h_date5, 'Fri'); -let h_date6 = H_Date.Saturday; -Assert.equal(h_date6, 'Satur'); -let h_date7 = H_Date.Sunday; -Assert.equal(h_date7, 'Sun'); -const enum H_Odd { - a = 1, - b = a + 2, - c = a + 4, - d = c + 2, - e = b * b, -} -Assert.equal(H_Odd.a, 1); -Assert.equal(H_Odd.b, 3); -Assert.equal(H_Odd.c, 5); -Assert.equal(H_Odd.d, 7); -Assert.equal(H_Odd.e, 9); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_members/enum_members_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_members/enum_members_1.ts deleted file mode 100644 index 3a272a6a11..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_members/enum_members_1.ts +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - if the member declaration specifies no value, the member is considered a constant enum member. - If the member is the first member in the enum declaration, it is assigned the value zero. - Otherwise, it is assigned the value of the immediately preceding member plus one, and an error occurs if the immediately preceding member is not a constant enum member. - if the member declaration specifies a value that can be classified as a constant enum expression, - the member is considered a constant enum member.otherwise, the member is considered a computed enum member. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function toLength(str: string): number { - return str.length; -} -let k = 999; -enum ABCList { - A, - B, - C = "string".length, - D = 10, - E, - F = ~17, - G = 0x0f << 0x02, - H = 0xff & 0xaa, - I = E | F, - J = toLength(ABCList[11]), - K = k++, - L = k--, - M = 1 + 2, - N = 1 - 2, - O = 1 / 2, - P = 1 % 2, - Q = 1 >> 2, - R = 1 >>> 2, - S = 1 ^ 2, -} -Assert.equal(ABCList.A, 0); -Assert.equal(ABCList.B, 1); -Assert.equal(ABCList.C, 6); -Assert.equal(ABCList.D, 10); -Assert.equal(ABCList.E, 11); -Assert.equal(ABCList.F, -18); -Assert.equal(ABCList.G, 60); -Assert.equal(ABCList.H, 170); -Assert.equal(ABCList.I, -17); -Assert.equal(ABCList.J, 1); -Assert.equal(ABCList.K, 999); -Assert.equal(ABCList.L, 1000); -Assert.equal(ABCList.M, 3); -Assert.equal(ABCList.N, -1); -Assert.equal(ABCList.O, 0.5); -Assert.equal(ABCList.P, 1); -Assert.equal(ABCList.Q, 0); -Assert.equal(ABCList.R, 0); -Assert.equal(ABCList.S, 3); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_1.ts deleted file mode 100644 index 32a416d660..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_1.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.23) - by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, - the element expression is contextually typed by the type of that property. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface MyArray { - 0: number; - 1: string; - length: 2; -} -const myArray: MyArray = [42, "hello"]; -Assert.isNumber(myArray[0]); -Assert.isString(myArray[1]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_2.ts deleted file mode 100644 index 78b09fffd4..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_2.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the array literal is contextually typed by a type T with a numeric index signature, - the element expression is contextually typed by the type of the numeric index signature - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let MyArray: { - [key: number]: string; -} = ["aaa", "bbb", "ccc"]; -Assert.isString(MyArray[0]); -Assert.isString(MyArray[1]); -Assert.isString(MyArray[2]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_3.ts deleted file mode 100644 index 270c64722a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_3.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the array literal is empty, the resulting type is an array type with the element type Undefined. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -const emptyArray: any[] = []; -Assert.isUndefined(emptyArray[0]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_4.ts deleted file mode 100644 index 81a90b45b6..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_4.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the array literal contains no spread elements and is contextually typed by a tuple-like type (section 3.3.3), - the resulting type is a tuple type constructed from the types of the element expressions - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let myTuple: [string, number] = ["hello", 42]; -Assert.isString(myTuple[0]); -Assert.isNumber(myTuple[1]); -function foo(pair: [string, number]) { - return pair -} -Assert.equal(JSON.stringify(foo(["hello", 42])), '["hello",42]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_5.ts deleted file mode 100644 index b620932604..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_5.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.21.1), - the resulting type is a tuple type constructed from the types of the element expressions. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let [x, y]: [string, number] = ["hello", 42]; -Assert.isString(x); -Assert.isNumber(y); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_6.ts deleted file mode 100644 index 4e51f2a244..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_6.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The resulting type is an array type with an element type that is the union of the types of - the non-spread element expressions and the numeric index signature types of the spread element expressions. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let arr = [1, 2, ...["three", "four"], 5]; -Assert.isNumber(arr[0]); -Assert.isNumber(arr[1]); -Assert.isString(arr[2]); -Assert.isString(arr[3]); -Assert.isNumber(arr[4]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_1.ts deleted file mode 100644 index d2d837d32c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_1.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Arrow functions are extended from JavaScript to optionally include parameter and return type annotations. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -const addNumbers = (num1: number, num2: number): number => { - return num1 + num2; -}; -const result1 = addNumbers(5, 10); -Assert.equal(result1, 15); -const greet = (name: string) => { - return name; -}; -const result2 = greet("Alice"); -Assert.equal(result2, "Alice"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_2.ts deleted file mode 100644 index d483ad0bc0..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_2.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - 1.( ... ) => expr is exactly equivalent to ( ... ) => { return expr ; } - 2.id => { ... } id => expr are exactly equivalent to - ( id ) => { ... } ( id ) => expr - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -const myFunctionA = (num: string): string => { - return num; -}; -const resultA = myFunctionA("hello,world"); -Assert.equal(resultA, "hello,world"); -const myFunctionB: () => string = () => "hello,world"; -const resultB = myFunctionB(); -Assert.equal(resultB, "hello,world"); -let getTempItem = (id: any) => ({ id: id, name: "Temp" }); -const TempAResult = getTempItem(123); -Assert.equal(TempAResult.id, 123); -let getTempItemB = function (id: any) { - return { - id: id, - name: "Temp", - }; -}; -const TempBResult = getTempItemB(123); -Assert.equal(TempBResult.id, 123); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_3.ts deleted file mode 100644 index 96cefe3ddd..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_3.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - When an arrow function with an expression body and no return type annotation is contextually typed - by a function type T and a contextual signature S can be extracted from T, - the expression body is contextually typed by the return type of S. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let myFunction = (h_x: number, h_y: number) => { return h_x + h_y; } -function myFunc(myValue: (x: number, y: number) => number) { - return myValue; -} -Assert.isFunction(myFunc(myFunction)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_4.ts deleted file mode 100644 index f7e54b5fac..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_4.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A function expression introduces a new dynamically bound this, whereas an arrow function expression preserves the this of its enclosing context. - Arrow function expressions are particularly useful for writing callbacks, which otherwise often have an undefined or unexpected this. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class ToAlert { - information = "Have a good time!"; - F() { - let for_this = this; - for_this.information = "sad boy"; - Assert.equal(for_this.information, "sad boy") - } -}; -let a = new ToAlert(); -a.F(); -a.information = "boy!"; -Assert.isString(a.information); -Assert.equal(a.information, "boy!"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts deleted file mode 100644 index 2dba576210..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - An assignment of the form 'v = expr' requires v to be classified as a reference or as an assignment pattern. - The expr expression is contextually typed by the type of v, and the type of expr must be assignable to the type of v, - or otherwise a compile-time error occurs. The result is a value with the type of expr. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var sum: Function = function (x: number, y: number) { - return x + y -} -let result = sum(5, 10); -Assert.equal(result, 15); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_2.ts deleted file mode 100644 index 5a32e54a54..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_2.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A compound assignment of the form 'v ??= expr' where '??=' is one of the compound assignment operators, - is subject to the same requirements, and produces a value of the same type, as the corresponding non-compound operation. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var x: number = 10 -var y: number = 20 -x *= y -Assert.isNumber(x) -x /= y -Assert.isNumber(x) -x %= y -Assert.isNumber(x) -x += y -Assert.isNumber(x) -x -= y -Assert.isNumber(x) -x <<= y -Assert.isNumber(x) -x >>= y -Assert.isNumber(x) -x >>>= y -Assert.isNumber(x) -x &= y -Assert.isNumber(x) -x ^= y -Assert.isNumber(x) -x |= y -Assert.isNumber(x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_3.ts deleted file mode 100644 index 025a430f02..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_3.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A compound assignment furthermore requires v to be classified as a reference and the type of the non-compound operation to be assignable to the type of v. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let obj = { - name: 'xiao', - age: 18 -} -let v = obj -v.age += v.age -Assert.equal(v.age, 36); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_1.ts deleted file mode 100644 index 731c9d1407..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_1.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. - An expression of type S is considered assignable to an assignment target V, if V is variable and S is assignable to the type of V. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let arr = [1, 2] -let [first, second] = arr -Assert.equal(first, 1) -Assert.equal(second, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_2.ts deleted file mode 100644 index 8555c425b6..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_2.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. - An expression of type S is considered assignable to an assignment target V if V is an object assignment pattern and, - for each assignment property P in V, S is the type Any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let obj: any = { - a: "foo", - b: 15, - c: "bar" -} -let { a, b, c } = obj; -Assert.equal(a, 'foo') -Assert.equal(b, 15) -Assert.equal(c, 'bar'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_3.ts deleted file mode 100644 index 722f536d89..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_3.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. - An expression of type S is considered assignable to an assignment target V if V is an object assignment pattern and, - for each assignment property P in V, S has an apparent property with the property name specified in P of a type that is assignable to the target given in P. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let obj = { - a: "foo", - b: 15, - c: "bar" -} -let { a, b } = obj; -Assert.equal(a, 'foo'); -Assert.equal(b, 15); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_4.ts deleted file mode 100644 index 0d12823371..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_4.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. - An expression of type S is considered assignable to an assignment target V if V is an object assignment pattern and, - for each assignment property P in V, P specifies a numeric property name and S has a numeric index signature of a type that is assignable to the target given in P. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface Foo { - [key: number]: string - 18: string - 180: string -} -let t: Foo = { - 18: 'age', - 180: 'height' -} -let v = { - 18: 'Age', - 180: 'Height' -} -v = t -Assert.equal(v[18], 'age'); -Assert.equal(v[180], 'height'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_5.ts deleted file mode 100644 index bcbbee18d3..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_5.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. - An expression of type S is considered assignable to an assignment target V if V is an object assignment pattern and, - for each assignment property P in V,S has a string index signature of a type that is assignable to the target given in P. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface Foo { - [key: string]: string - name: string - house: string -} -let t: Foo = { - name: 'xiao', - house: 'nanjing' -} -let v = { - name: '', - house: '' -} -v = t -Assert.equal(v.house, 'nanjing'); -Assert.equal(v.name, 'xiao'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_6.ts deleted file mode 100644 index 10a776d67d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_6.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. - An expression of type S is considered assignable to an assignment target V if V is an array assignment pattern, - for each assignment element E in V, S is the type Any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let arr: any = [1, 2] -let [first, second]: [number, number] = arr -Assert.equal(first, 1) -Assert.equal(second, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_7.ts deleted file mode 100644 index b7bb0e33ea..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_7.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. - An expression of type S is considered assignable to an assignment target V if V is an array assignment pattern, - for each assignment element E in V, S is a tuple-like type with a property named N of a type that is assignable to the target given in E, - where N is the numeric index of E in the array assignment pattern. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let s: ['0', string, number] = ['0', 'str', 10] -let [x, y, z]: [string, string, number] = s -Assert.equal(x, '0') -Assert.equal(y, 'str') -Assert.equal(z, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_8.ts deleted file mode 100644 index 5fe003b1d5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_8.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. - An expression of type S is considered assignable to an assignment target V if V is an array assignment pattern, - S is the type Any or an array-like type, and, for each assignment element E in V, - S is not a tuple-like type and the numeric index signature type of S is assignable to the target given in E. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface A { - [key: number]: string -} -let a: A = ['a', 'b', 'c'] -let [x, y, z] = [a[0], a[1], a[2]] -Assert.equal(x, 'a') -Assert.equal(y, 'b') -Assert.equal(z, 'c'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts deleted file mode 100644 index 9f13b77ca8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The binary + operator requires both operands to be of the Number primitive type or an enum type, - or at least one of the operands to be of type Any or the String primitive type. - Operands of an enum type are treated as having the primitive type Number. - If one operand is the null or undefined value, it is treated as having the type of the other operand. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: number = 10 -var b: number = 20 -var x = a + b -Assert.equal(x, 30) -enum e1 { - A, - B, - C -} -enum e2 { - D, - E, - F -} -var c = e1.A -Assert.equal(c, 0) -var d = e2.D -Assert.equal(d, 0) -var y = c + d -Assert.equal(y, 0) -var e: any = true -Assert.isTrue(e) -var f: string = 's' -Assert.equal(f, 's') -var w = a + e -Assert.equal(w, 11) -var v = c + f -Assert.equal(v, '0s'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts deleted file mode 100644 index 46e7e069c5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The binary + operator, - If one or both operands are of the String primitive type, the result is of the String primitive type. - Otherwise, the result is of type Any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = true -var b: any = 's' -var c: boolean = false -var d: string = 'str' -var e: number = 10 -var f: any = 20 -var w = a + b -var v = a + f -Assert.isString(w) -Assert.isNumber(v) -var x = a + c -Assert.isNumber(x) -var y = a + d -Assert.isString(y) -var z = a + e -Assert.isNumber(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts deleted file mode 100644 index 278986a94b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The binary + operator, - A value of any type can converted to the String primitive type by adding an empty string. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -function func() { } -let s = func() + "" -Assert.isString(s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts deleted file mode 100644 index 616c89f5c7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The && operator permits the operands to be of any type and produces a result of the same type as the second operand. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = 10 -var b: any = 's' -var c: boolean = false -var d: boolean = true -var e: number = 20 -var f: number = 15 -var g: string = 'a' -var h: string = 'b' -var i: undefined = undefined -var j: undefined = undefined -var k = a && b -Assert.isString(k) -var l = c && d -Assert.isBoolean(l) -var m = e && f -Assert.isNumber(m) -var n = g && h -Assert.isString(n) -var o = i && j -Assert.isUndefined(o) -var p = a && c -Assert.isBoolean(p) -var q = a && e -Assert.isNumber(q) -var r = a && g -Assert.isString(r) -var s = a && i -Assert.isUndefined(s) -var t = c && e -Assert.isBoolean(t) -var u = c && g -Assert.isBoolean(u) -var v = c && i -Assert.isBoolean(v) -var w = e && g -Assert.isString(w) -var x = e && i -Assert.isUndefined(x) -var y = g && i -Assert.isUndefined(y); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_congruence_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_congruence_operator.ts deleted file mode 100644 index 5a466b5eb0..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_congruence_operator.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '===' operator require one or both of the operand types to be assignable to the other. - The result is always of the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = undefined -var b: boolean = true -var c: number = 10 -var d: string = 'str' -Assert.isBoolean(a === b) -Assert.isBoolean(a === c) -Assert.isBoolean(a === d); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_equal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_equal_operator.ts deleted file mode 100644 index 5be5e1f6c1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_equal_operator.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '==' operator require one or both of the operand types to be assignable to the other. - The result is always of the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = undefined -var b: boolean = true -var c: number = 10 -var d: string = 'str' -Assert.isBoolean(a == b) -Assert.isBoolean(a == c) -Assert.isBoolean(a == d); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_operator.ts deleted file mode 100644 index 1b9295b48c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_operator.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '>' operator require one or both of the operand types to be assignable to the other. - The result is always of the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = undefined -var b: boolean = true -var c: number = 10 -var d: string = 'str' -Assert.isBoolean(a > b) -Assert.isBoolean(a > c) -Assert.isBoolean(a > d); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_or_equal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_or_equal_operator.ts deleted file mode 100644 index 8018af54ef..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_or_equal_operator.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '>=' operator require one or both of the operand types to be assignable to the other. - The result is always of the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = undefined -var b: boolean = true -var c: number = 10 -var d: string = 'str' -Assert.isBoolean(a >= b) -Assert.isBoolean(a >= c) -Assert.isBoolean(a >= d); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_incongruence_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_incongruence_operator.ts deleted file mode 100644 index 762038e557..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_incongruence_operator.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '!==' operator require one or both of the operand types to be assignable to the other. - The result is always of the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = undefined -var b: boolean = true -var c: number = 10 -var d: string = 'str' -Assert.isBoolean(a !== b) -Assert.isBoolean(a !== c) -Assert.isBoolean(a !== d); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_operator.ts deleted file mode 100644 index 484705dcb8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_operator.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '<' operator require one or both of the operand types to be assignable to the other. - The result is always of the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = undefined -var b: boolean = true -var c: number = 10 -var d: string = 'str' -Assert.isBoolean(a < b) -Assert.isBoolean(a < c) -Assert.isBoolean(a < d); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_or_equal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_or_equal_operator.ts deleted file mode 100644 index 1f580108e5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_or_equal_operator.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '<=' operator require one or both of the operand types to be assignable to the other. - The result is always of the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = undefined -var b: boolean = true -var c: number = 10 -var d: string = 'str' -Assert.isBoolean(a <= b) -Assert.isBoolean(a <= c) -Assert.isBoolean(a <= d); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_unequal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_unequal_operator.ts deleted file mode 100644 index 388d7b4c6f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_unequal_operator.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '!=' operator require one or both of the operand types to be assignable to the other. - The result is always of the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = undefined -var b: boolean = true -var c: number = 10 -var d: string = 'str' -Assert.isBoolean(a != b) -Assert.isBoolean(a != c) -Assert.isBoolean(a != d); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts deleted file mode 100644 index d188766c18..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, - and the right operand to be of type Any, an object type, or a type parameter type. - The result is always of the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface A { - num: number -} -interface B { - str: string -} -function isString(k: A | B) { - if ('num' in k) { - Assert.isBoolean('num' in k) - return false; - } - return true; -} -let result = isString({ num: 20 }); -Assert.isFalse(result); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_instanceof_operator/the_instanceof_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_instanceof_operator/the_instanceof_operator.ts deleted file mode 100644 index 580fd1a26b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_instanceof_operator/the_instanceof_operator.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type, - and the right operand to be of type Any or a subtype of the 'Function' interface type. - The result is always of the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface Animal { - species: string -} -class Felidae implements Animal { - kind: string - species: string - constructor(species: string, kind: string) { - this.species = species - this.kind = kind - } -} -class Canidae implements Animal { - species: string - name: string - constructor(species: string, name: string) { - this.species = species - this.name = name - } -} -const getRandomAnimal = () => { - return Math.random() < 0.5 ? - new Canidae('Canidae', 'Wolf') : - new Felidae('Felidae', 'Tiger') -} -let Animal = getRandomAnimal() -if (Animal instanceof Canidae) { - Assert.isBoolean(Animal instanceof Canidae) -} -if (Animal instanceof Felidae) { - Assert.isBoolean(Animal instanceof Felidae); -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_and_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_and_operator.ts deleted file mode 100644 index 85ddf4aa3f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_and_operator.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '&' operator require its operands to be of type Any, the Number primitive type, or an enum type. - Operands of an enum type are treated as having the primitive type Number. - If one operand is the null or undefined value, it is treated as having the type of the other operand. - The result is always of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = '10' -var b: any = true -var c: number = 20 -var x = a & b -var y = a & c -Assert.isNumber(x) -Assert.isNumber(y) -enum e { - A, - B, - C -} -var d = e.A -var z = a & d -Assert.isNumber(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_division_method_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_division_method_operator.ts deleted file mode 100644 index 80df8d49d7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_division_method_operator.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '/' operator require its operands to be of type Any, the Number primitive type, or an enum type. - Operands of an enum type are treated as having the primitive type Number. - If one operand is the null or undefined value, it is treated as having the type of the other operand. - The result is always of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = '10' -var b: any = true -var c: number = 20 -var x = a / b -var y = a / c -Assert.isNumber(x) -Assert.isNumber(y) -enum e { - A, - B, - C -} -var d = e.A -var z = a / d -Assert.isNumber(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_left_shift_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_left_shift_operator.ts deleted file mode 100644 index 8deb5bd73d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_left_shift_operator.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '<<' operator require its operands to be of type Any, the Number primitive type, or an enum type. - Operands of an enum type are treated as having the primitive type Number. - If one operand is the null or undefined value, it is treated as having the type of the other operand. - The result is always of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = '10' -var b: any = true -var c: number = 20 -var x = a << b -var y = a << c -Assert.isNumber(x) -Assert.isNumber(y) -enum e { - A, - B, - C -} -var d = e.A -var z = a << d -Assert.isNumber(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_multiplication_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_multiplication_operator.ts deleted file mode 100644 index b67909d056..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_multiplication_operator.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '*' operator require its operands to be of type Any, the Number primitive type, or an enum type. - Operands of an enum type are treated as having the primitive type Number. - If one operand is the null or undefined value, it is treated as having the type of the other operand. - The result is always of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = '10' -var b: any = true -var c: number = 20 -var x = a * b -var y = a * c -Assert.isNumber(x) -Assert.isNumber(y) -enum e { - A, - B, - C -} -var d = e.A -var z = a * d -Assert.isNumber(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_or_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_or_operator.ts deleted file mode 100644 index 4458dbe61b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_or_operator.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '|' operator require its operands to be of type Any, the Number primitive type, or an enum type. - Operands of an enum type are treated as having the primitive type Number. - If one operand is the null or undefined value, it is treated as having the type of the other operand. - The result is always of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = '10' -var b: any = true -var c: number = 20 -var x = a | b -var y = a | c -Assert.isNumber(x) -Assert.isNumber(y) -enum e { - A, - B, - C -} -var d = e.A -var z = a | d -Assert.isNumber(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_remainder_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_remainder_operator.ts deleted file mode 100644 index 654e0b83cc..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_remainder_operator.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '%' operator require its operands to be of type Any, the Number primitive type, or an enum type. - Operands of an enum type are treated as having the primitive type Number. - If one operand is the null or undefined value, it is treated as having the type of the other operand. - The result is always of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = '10' -var b: any = true -var c: number = 20 -var x = a % b -var y = a % c -Assert.isNumber(x) -Assert.isNumber(y) -enum e { - A, - B, - C -} -var d = e.A -var z = a % d -Assert.isNumber(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_right_shift_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_right_shift_operator.ts deleted file mode 100644 index bba1c4ac7f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_right_shift_operator.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '>>' operator require its operands to be of type Any, the Number primitive type, or an enum type. - Operands of an enum type are treated as having the primitive type Number. - If one operand is the null or undefined value, it is treated as having the type of the other operand. - The result is always of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = '10' -var b: any = true -var c: number = 20 -var x = a >> b -var y = a >> c -Assert.isNumber(x) -Assert.isNumber(y) -enum e { - A, - B, - C -} -var d = e.A -var z = a >> d -Assert.isNumber(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_subtraction_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_subtraction_operator.ts deleted file mode 100644 index fd4c8ae72b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_subtraction_operator.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '-' operator require its operands to be of type Any, the Number primitive type, or an enum type. - Operands of an enum type are treated as having the primitive type Number. - If one operand is the null or undefined value, it is treated as having the type of the other operand. - The result is always of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = '10' -var b: any = true -var c: number = 20 -var x = a - b -var y = a - c -Assert.isNumber(x) -Assert.isNumber(y) -enum e { - A, - B, - C -} -var d = e.A -var z = a - d -Assert.isNumber(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_unsigned_shift_to_the_right.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_unsigned_shift_to_the_right.ts deleted file mode 100644 index bd046685b1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_unsigned_shift_to_the_right.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '>>>' operator require its operands to be of type Any, the Number primitive type, or an enum type. - Operands of an enum type are treated as having the primitive type Number. - If one operand is the null or undefined value, it is treated as having the type of the other operand. - The result is always of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = '10' -var b: any = true -var c: number = 20 -var x = a >>> b -var y = a >>> c -Assert.isNumber(x) -Assert.isNumber(y) -enum e { - A, - B, - C -} -var d = e.A -var z = a >>> d -Assert.isNumber(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_xor_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_xor_operator.ts deleted file mode 100644 index 4c3fa45c49..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_xor_operator.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '^' operator require its operands to be of type Any, the Number primitive type, or an enum type. - Operands of an enum type are treated as having the primitive type Number. - If one operand is the null or undefined value, it is treated as having the type of the other operand. - The result is always of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = '10' -var b: any = true -var c: number = 20 -var x = a ^ b -var y = a ^ c -Assert.isNumber(x) -Assert.isNumber(y) -enum e { - A, - B, - C -} -var d = e.A -var z = a ^ d -Assert.isNumber(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts deleted file mode 100644 index 2b960edfea..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The || operator permits the operands to be of any type. - The type of the result is the union type of the two operand types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = 10 -var b: any = 's' -var c: boolean = false -var d: boolean = true -var e: number = 20 -var f: number = 15 -var g: string = 'a' -var h: string = 'b' -var i: undefined = undefined -var j: undefined = undefined -var k = a || b -Assert.isNumber(k) -var l = c || d -Assert.isBoolean(l) -var m = e || f -Assert.isNumber(m) -var n = g || h -Assert.isString(n) -var o = i || j -Assert.isUndefined(o) -var p = a || c -Assert.isNumber(p) -var q = a || e -Assert.isNumber(q) -var r = a || g -Assert.isNumber(r) -var s = a || i -Assert.isNumber(s) -var t = c || e -Assert.isNumber(t) -var u = c || g -Assert.isString(u) -var v = c || i -Assert.isUndefined(v) -var w = e || g -Assert.isNumber(w) -var x = e || i -Assert.isNumber(x) -var y = g || i -Assert.isString(y); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_2.ts deleted file mode 100644 index 728fc4b74c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_2.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the || expression is contextually typed, the operands are contextually typed by the same type. - Otherwise, the left operand is not contextually typed and the right operand is contextually typed by the type of the left operand. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var sum = function (x: number, y: number) { - return x + y -} -var average = function (a: number, b: number) { - return (a + b) / 2 -} -var rela = sum || average -Assert.equal(typeof rela, 'function'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/class_expressions/class_expressions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/class_expressions/class_expressions_1.ts deleted file mode 100644 index e768b3d9eb..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/class_expressions/class_expressions_1.ts +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Just as with class declarations, class expressions would create a constructor function that can be used to construct instances. - Like class declarations, you may also declare property members and index members, as well as use the constructor parameters. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var Square = class { - acreage: number; - - constructor(public h_length: number, public h_width: number) { - this.acreage = this.h_length * this.h_width; - } -}; -var square = new Square(5, 10); -Assert.equal(square.acreage, 50); -class Reflmpl { - public readonly _v = true; - constructor(private _rawValue: T, public _shaw = false) { - this._rawValue = _rawValue; - this._shaw = this._shaw; - } - get value() { - return this._rawValue; - } - set value(newVal) { - this._rawValue = newVal; - } - get shaw() { - return this._shaw; - } - set shaw(newShaw) { - this._shaw = newShaw; - } -} -let ref = new Reflmpl(10, true); -Assert.equal(ref.value, 10); -Assert.equal(ref._shaw, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts deleted file mode 100644 index 0868288f8f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a variable, parameter, binding property, binding element, or member declaration, - an initializer expression is contextually typed by the type given in the declaration's type annotation. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let a: number -a = 10 -Assert.isNumber(a) -function fun(x: string) { - let y = x + 'ing' - return y -} -Assert.isString(fun('str')) -interface Obj { - name: string - age: number -} -let obj: Obj = { - name: 'xiao', - age: 18 -} -Assert.isString(obj.name) -Assert.isNumber(obj.age); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_10.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_10.ts deleted file mode 100644 index c9649d460a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_10.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a contextually typed array literal expression containing no spread elements, an element expression at index N is contextually typed by - the type of the property with the numeric name N in the contextual type, if any, or otherwise - the numeric index type of the contextual type, if any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let arr: { - [key: number]: string -} = { - 1: 'a', - 2: 'b', - 3: 'c', - 4: 'd' -} -Assert.isString(arr[1]) -Assert.isString(arr[2]) -Assert.isString(arr[3]) -Assert.isString(arr[4]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_11.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_11.ts deleted file mode 100644 index 46c0bdd684..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_11.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a contextually typed array literal expression containing one or more spread elements, - an element expression at index N is contextually typed by the numeric index type of the contextual type, if any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let first = [1, 2] -let second = [3, 4] -let bothPlus = [0, ...first, ...second, 5] -Assert.isNumber(bothPlus[2]) -Assert.isNumber(bothPlus[4]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts deleted file mode 100644 index 5c60fa1c14..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a contextually typed parenthesized expression, the contained expression is contextually typed by the same type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var a: number = 10 -var b: number = 5 -var c = (a + b) * (a - b) -Assert.isNumber(c) -interface Foo { - num: number - str: string -} -const x: Foo[] = [{ num: 18, str: 'hello' }, { num: 20, str: 'world' }] -Assert.isNumber(x[0].num) -Assert.isNumber(x[1].num) -Assert.isString(x[0].str) -Assert.isString(x[1].str); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts deleted file mode 100644 index 76c8be1985..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a || operator expression, if the expression is contextually typed, the operands are contextually typed by the same type. - Otherwise, the right expression is contextually typed by the type of the left expression. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var sum = function (x: number, y: number) { - return x + y -} -var average1 = function (a: number, b: number) { - return (a + b) / 2 -} -var rela1 = sum || average1 -Assert.equal(typeof rela1, 'function') -var average2: number = 10 -var rela2 = average2 || sum -Assert.equal(typeof rela2, 'number'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_15.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_15.ts deleted file mode 100644 index d7a649f139..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_15.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a contextually typed conditional operator expression, the operands are contextually typed by the same type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function processValue(value: number | (() => number)) { - var x = typeof value !== "number" ? value() : value - Assert.isNumber(x) -} -processValue(5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_16.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_16.ts deleted file mode 100644 index 940f31181e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_16.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In an assignment expression, the right hand expression is contextually typed by the type of the left hand expression. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface A { - (a: number): void -} -const fn: A = function (a) { - Assert.isNumber(a) -} -fn(5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_2.ts deleted file mode 100644 index d24a9bad0e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_2.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a variable, parameter, binding property, binding element, or member declaration, - an initializer expression is contextually typed by for a parameter, the type provided by a contextual signature. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var f: (s: string) => string = function (x) { - Assert.isString(x) - return x.toLowerCase() -} -f('str'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_3.ts deleted file mode 100644 index b94a14a8f5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_3.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a variable, parameter, binding property, binding element, or member declaration, - an initializer expression is contextually typed by the type implied by the binding pattern in the declaration. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function f({ a = true, b = "hello", c = 1 }) { - Assert.isBoolean(a) - Assert.isString(b) - Assert.isNumber(c) -} -f({ a: false }); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts deleted file mode 100644 index d15947b430..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In the body of a function declaration, function expression, arrow function, method declaration, - or get accessor declaration that has a return type annotation, - return expressions are contextually typed by the type given in the return type annotation. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function add(x: number, y: number): number { - return x + y -} -let sum = add(10, 20) -Assert.isNumber(sum) -type Fun = (a: number, b: number) => number -function fun(fn: Fun, x: number, y: number) { - return fn(x, y) -} -function minus(a: number, b: number) { - return a - b -} -function mul(a: number, b: number) { - return a * b -} -let m = fun(minus, 15, 7) -let n = fun(mul, 3, 6) -Assert.isNumber(m) -Assert.isNumber(n); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_5.ts deleted file mode 100644 index dadabf1676..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_5.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In the body of a function expression or arrow function that has no return type annotation, - if the function expression or arrow function is contextually typed by a function type with exactly one call signature, - and if that call signature is non-generic, return expressions are contextually typed by the return type of that call signature. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -type Fun = { - description: string - (someThing: number): boolean -} -function fun1(fn: Fun) { - return fn.description + fn(100) -} -function fun2(num: number) { - Assert.equal(num, 100) - return false -} -fun2.description = 'hello' -Assert.equal(fun1(fun2), 'hellofalse'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_6.ts deleted file mode 100644 index 3d70a3597e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_6.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In the body of a constructor declaration, return expressions are contextually typed by the containing class type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Person { - name: string - age: number - constructor(name: string, age: number) { - this.name = name - this.age = age - } -} -const p = new Person("xiao", 18) -Assert.isString(p.name) -Assert.isNumber(p.age); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts deleted file mode 100644 index f910a94072..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In the body of a get accessor with no return type annotation, - if a matching set accessor exists and that set accessor has a parameter type annotation, - return expressions are contextually typed by the type given in the set accessor's parameter type annotation. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class C { - private _str = '' - private _arr: string[] = [] - get func() { - return this._str - } - set func(value: string) { - this._str= value - } - get f() { - return this._arr - } - set f(value: string[]) { - this._arr = value - } -} -const c = new C() -c.func= 'TS' -Assert.isString(c.func) -c.f = ['develop', 'test'] -c.f.push('ship') -Assert.equal(c.f, 'develop,test,ship'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts deleted file mode 100644 index 2036c81219..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a typed function call, argument expressions are contextually typed by their corresponding parameter types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -const obj: Record = { - boo: false, - arr: ['a', 'b', 'c'] -} -const para = (str: string): [T, Function] => { - const result1: T = obj[str]; - const result2: Function = (value: T) => { - obj[str] = value; - return obj[str]; - } - return [result1, result2]; -} -const [boo, mem2] = para('boo'); -const [arr, mem4] = para('arr'); -Assert.isBoolean(boo); -Assert.equal(arr, 'a,b,c'); -let x = mem2(true); -let y = mem4(false); -Assert.isTrue(x); -Assert.isFalse(y); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_9.ts deleted file mode 100644 index e6fc7d38b7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_9.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a contextually typed object literal, each property value expression is contextually typed by - the type of the property with a matching name in the contextual type, if any, or otherwise - for a numerically named property, the numeric index type of the contextual type, if any, or otherwise - the string index type of the contextual type, if any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface Person { - (a: number): void -} -interface B { - fn: Person -} -const obj: B = { - fn: function (a) { - Assert.isNumber(a) - } -} -obj.fn(10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts deleted file mode 100644 index f93221902a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The inclusion of type arguments in the Arguments production gives rise to certain ambiguities in the grammar for expressions. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var h_g: number = 5 -var h_A: number = 3 -var h_B: number = 6 -function f(a: any, b?: any) { - return a -} -Assert.isFalse(f(h_g < h_A, h_B > 7)) -Assert.isFalse(f(h_g < h_A, h_B > +(7))) -type A1 = number -type B1 = number -function g1(a: T) { - return a; -} -function f1(a: any, b?: any) { - return a -} -Assert.equal(f1(g1(7)), 7); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts deleted file mode 100644 index 3a90a3f947..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The compile-time processing of a typed function call consists, - a list of candidate signatures is constructed from the call signatures in the function type in declaration order. - A generic signature is a candidate in a function call with type arguments when the signature has the same number of type parameters - as were supplied in the type argument list, the type arguments satisfy their constraints, - and once the type arguments are substituted for their associated type parameters, - the signature is applicable with respect to the argument list of the function call. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface IFnCall { - (fn: () => T, age: number): string -} -interface IFnCall { - (func: () => T, str: string): string -} -const foo: IFnCall = function () { - return 'a' -} -var f = foo(() => { - return 'f' -}, 10) -Assert.equal(f, 'a'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts deleted file mode 100644 index 90e344f3e6..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The compile-time processing of a typed function call consists, - a list of candidate signatures is constructed from the call signatures in the function type in declaration order. - A generic signature is a candidate in a function call without type arguments when type inference succeeds for each type parameter, - once the inferred type arguments are substituted for their associated type parameters, - the signature is applicable with respect to the argument list of the function call. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface IFnCall { - (fn: (name: S) => T, age: number): T -} -interface IFnCall { - (func: (str: S) => T, name: string): T -} -const foo: IFnCall = function (fn:any) { - return fn('xiao') -} -const res = foo((name:string) => { - return name -}, 10) -Assert.isString(res); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_3.ts deleted file mode 100644 index a1c2449b15..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_3.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - list of candidate signatures is constructed from the call signatures in the function type in declaration order. - A non-generic signature is a candidate when - the function call has no type arguments, and - the signature is applicable with respect to the argument list of the function call. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface IfnCall { - (name: string, age: number): string -} -interface IfnCall { - (str: string, num: string): string -} -const foo: IfnCall = function (name:any, age:any):string { - return name + ":" + age -} -let f = foo("xiao", 18) -Assert.isString(f); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_4.ts deleted file mode 100644 index e1398bb043..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_4.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A signature is said to be an applicable signature with respect to an argument list when - the number of arguments is not less than the number of required parameters, - the number of arguments is not greater than the number of parameters, and - for each argument expression e and its corresponding parameter P, when e is contextually typed by the type of P, - no errors ensue and the type of e is assignable to the type of P. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface IfnCall { - (name: string, age?: number): string -} -const foo1: IfnCall = function (name, age) { - return name + ":" + age -} -const foo2: IfnCall = function (name) { - return name -} -var f1 = foo1("xiao", 18) -var f2 = foo2("xi") -f1 = f2 -Assert.equal(f1, f2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts deleted file mode 100644 index fb9d601be9..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Given a type parameter T and set of candidate types, the actual inferred type argument is determined, - if at least one of the candidate types is a supertype of all of the other candidate types, - let C denote the widened form of the first such candidate type. - If C satisfies T's constraint, the inferred type argument for T is C. - Otherwise, the inferred type argument for T is T's constraint. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -type t = number | null | undefined -function select(h_x: T, h_y: T): T { - return h_x ? h_x : h_y; -} -var y = select(10, undefined) -if (typeof y === 'number') { - Assert.isNumber(y); -} -else { - Assert.isUndefined(y); -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts deleted file mode 100644 index a133fc3c7c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - When a function expression is inferentially typed and a type assigned to a parameter in that expression references type parameters for which inferences are being made, - the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -function func(arg1: T, arg2:T) { - return [arg1, arg2]; -} -let a = func(3, 5); -let b = func('a', 'b'); -Assert.equal(a, '3,5'); -Assert.equal(b, 'a,b'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts deleted file mode 100644 index 173b602bbb..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If e is an expression of a function type that contains exactly one generic call signature and no other members, - and T is a function type with exactly one non-generic call signature and no other members, - then any inferences made for type parameters referenced by the parameters of T's call signature are fixed, - and e's type is changed to a function type with e's call signature instantiated in the context of T's call signature. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -type T = (arg: number) => number; -let f = (arg: T): T => { return arg }; -let para: T = function func(arg: number) { - return arg; -} -let result = f(para(20)); -Assert.equal(result, 20); -Assert.isFunction(f); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_1.ts deleted file mode 100644 index 36ee6593be..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_1.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If T is a union type, let U be the set of element types in T that have call signatures. - If each type in U has exactly one call signature and that call signature is non-generic, and if all of the signatures are identical ignoring return types, - then S is a signature with the same parameters and a union of the return types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -type MyUnionType = ((x: number) => string) | ((x: number) => number); -function myFunction(fn: MyUnionType, arg: number) { - return fn(arg); -} -const fn1 = (x: number): string => `Hello,${x}`; -const fn2 = (x: number): number => x * 2; -const result1 = myFunction(fn1, 123); -const result2 = myFunction(fn2, 456); -Assert.equal(result1, "Hello,123"); -Assert.equal(result2, 912); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_2.ts deleted file mode 100644 index b7dd95ab05..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_2.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If T is a function type with exactly one call signature, - and if that call signature is non-generic, S is that signature. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -type MyFunctionType = (x: number, y: number) => number; -function myFunction(fn: MyFunctionType) { - return fn(2, 3); -} -const add: MyFunctionType = function (x: number, y: number) { - return x + y; -}; -const result = myFunction(add); -Assert.equal(result, 5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_3.ts deleted file mode 100644 index efdd1e8157..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_3.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Otherwise, no contextual signature can be extracted from T. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -type MyType = { - fn: (a: number, b: string) => boolean; -}; -function myFunction(obj: MyType) { - const { fn } = obj; - const result = fn(123, "hello"); - Assert.isTrue(result); -} -let h_x: MyType = { - fn: function func() { - return true; - } -} -myFunction(h_x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/class.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/class.ts deleted file mode 100644 index 8341313a6e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/class.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: For a class, the constructor type associated with the constructor function object. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Car { - engine: string; - agelimit: number; - constructor(engine: string, agelimit: number) { - this.engine = engine; - this.agelimit = agelimit; - } -} -let car = new Car("Benchi", 2); -Assert.equal(car.agelimit, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/enum.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/enum.ts deleted file mode 100644 index 49f197edf1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/enum.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: For an enum, the object type associated with the enum object. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -enum Direction { - up = 1, - down, - Left, - right, -} -const direction: Direction = Direction.up; -Assert.isNumber(direction); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/function.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/function.ts deleted file mode 100644 index d1513c3bf3..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/function.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: For a function, the function type associated with the function object. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function myFunction(x: number): number { - return x * 2; -} -Assert.isFunction(myFunction); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/name_space.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/name_space.ts deleted file mode 100644 index dedd915898..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/name_space.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - When an expression is an IdentifierReference, the expression refers to the most nested namespace, class, enum, function, variable, - or parameter with that name whose scope (section 2.4) includes the location of the reference. - The type of such an expression is the type associated with the referenced entity: - For a namespace, the object type associated with the namespace instance - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -namespace MyNamespace { - export interface Person { - name: string; - age: number; - } - export function greet(person: Person) { - Assert.equal(person.name, "John"); - Assert.equal(person.age, 30); - } -} -const person: MyNamespace.Person = { - name: "John", - age: 30, -}; -MyNamespace.greet(person); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/parameter.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/parameter.ts deleted file mode 100644 index 050218eaba..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/parameter.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - For a parameter, the type of the parameter. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class paramMethod { - person: string; - age: number; - constructor(person: string, age: number) { - this.person = person; - this.age = age; - Assert.isString(person); - Assert.isNumber(age); - } -} -let newparam = new paramMethod("xiaoli", 18); -Assert.equal(newparam.age, 18); -Assert.equal(newparam.person, "xiaoli"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/variable.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/variable.ts deleted file mode 100644 index b95d6d191a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/variable.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - For a variable, the type of the variable. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let uname: string = "Runoob"; -let score1: number = 50; -Assert.isString(uname); -Assert.isNumber(score1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/boolean.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/boolean.ts deleted file mode 100644 index cfd5252d24..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/boolean.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The type of the literals true and false is the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -Assert.equal(typeof false, "boolean"); -Assert.equal(typeof true, "boolean"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/null.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/null.ts deleted file mode 100644 index f014d23c13..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/null.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The type of the null literal is the Null primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -Assert.isTrue(typeof null === "object"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/number.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/number.ts deleted file mode 100644 index 070870d0f5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/number.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The type of numeric literals is the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -Assert.equal(typeof 1, "number"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/regexp.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/regexp.ts deleted file mode 100644 index bb9d378516..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/regexp.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The type of regular expression literals is the global interface type 'RegExp'. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -Assert.isTrue(/hello world/ instanceof RegExp); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/string.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/string.ts deleted file mode 100644 index 3a97e72e58..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/string.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The type of string literals is the String primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -Assert.isString("Hello world"); -Assert.isString("kitty"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_1.ts deleted file mode 100644 index e23968a8c9..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_1.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the object literal is contextually typed and the contextual type contains a property with a matching name, - the property assignment is contextually typed by the type of that property. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let obj1: { - str: string; - num: number; - bool: boolean; -} = { - str: 'string', - num: 5, - bool: true -} -Assert.isString(obj1.str); -Assert.isNumber(obj1.num); -Assert.isBoolean(obj1.bool); - -interface I{ - num: number; - str: string; -} -let obj2 = {} as I; -obj2.num = 10; -obj2.str = 'string'; -Assert.isNumber(obj2.num); -Assert.isString(obj2.str); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_2.ts deleted file mode 100644 index 94500c72a7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_2.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - if the object literal is contextually typed, - if the contextual type contains a numeric index signature, - and if the property assignment specifies a numeric property name, - the property assignment is contextually typed by the type of the numeric index signature. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let obj1: { - 1: string; - [key: number]: string; -} = { - 1: 'string', - 2: 'number', - 3: 'boolean' -} -Assert.isString(obj1[2]); -Assert.isString(obj1[3]); - -interface I{ - 1: string; - [key: number]: string; -} -let obj2 = {} as I; -obj2 = { - 1: 'string', - 2: 'number', - 3: 'boolean' -} -Assert.isString(obj2[2]); -Assert.isString(obj2[3]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_3.ts deleted file mode 100644 index 0d7ec34ce5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_3.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the object literal is contextually typed and the contextual type contains a string index signature, - the property assignment is contextually typed by the type of the string index signature. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let obj1: { - 'str': string; - [key: string]: string; -} = { - 'str': 'string', - 'num': 'number', - 'bool': 'boolean' -} -Assert.isString(obj1['num']); -Assert.isString(obj1['bool']); - -interface I{ - 'str': string; - [key: string]: string; -} -let obj2 = {} as I; -obj2 = { - 'str': 'string', - 'num': 'number', - 'bool': 'boolean' -} -Assert.isString(obj2['num']); -Assert.isString(obj2['bool']); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_4.ts deleted file mode 100644 index 6cc575365a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_4.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The property assignment is processed without a contextual type - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface Iperson { - name: String; - age: Number; - gender?: string; - sayName(): void; -} -const P: Iperson = { - name: "Tom", - age: 21, - gender: "male", - sayName() { - return this.name; - }, -}; -Assert.equal(P.gender, "male"); -P.gender = "female"; -Assert.equal(P.gender, "female"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_5.ts deleted file mode 100644 index 456393ae28..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_5.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A get accessor declaration is processed in the same manner as an ordinary function declaration (section 6.1) with no parameters. - A set accessor declaration is processed in the same manner as an ordinary function declaration with a single parameter and a Void return type. - When both a get and set accessor is declared for a property: - If both accessors include type annotations, the specified types must be identical. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Example { - private _count: number = 0; - get count(): number { - return this._count; - } - set count(value: number) { - this._count = value; - } -} -const example = new Example(); -Assert.isNumber(example.count); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_6.ts deleted file mode 100644 index 09c5532834..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_6.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If only one accessor includes a type annotation, the other behaves as if it had the same type annotation - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Person1 { - private _name: string = ""; - get name(){ - return this._name; - } - set name(value: string) { - this._name = value; - } -} -const person1 = new Person1(); -Assert.isString(person1.name); - -class Person2 { - private _name: string = ""; - get name(): string{ - return this._name; - } - set name(value) { - this._name = value; - } -} -const person2 = new Person2(); -Assert.isString(person2.name); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_7.ts deleted file mode 100644 index 1c5358d3eb..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_7.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If neither accessor includes a type annotation, - the inferred return type of the get accessor becomes the parameter type of the set accessor. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Example { - private _count: number = 0; - get count() { - return this._count; - }; - set count(value) { - Assert.isNumber(value); - this._count = value; - } -} -const example = new Example(); -Assert.isNumber(example.count); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_8.ts deleted file mode 100644 index 3fb79b27f7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_8.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If a get accessor is declared for a property, - the return type of the get accessor becomes the type of the property. - If only a set accessor is declared for a property, - the parameter type of the set accessor becomes the type of the property. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class C{ - private mem; - constructor(mem: string) { - this.mem = mem; - } - get Mem(): string { - return this.mem; - } - set Mem(mem: string) { - this.mem = mem; - } -} -let c = new C('a'); -Assert.isString(c.Mem); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_9.ts deleted file mode 100644 index f364ccedab..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_9.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - When an object literal is contextually typed by a type that includes a string/numeric index signature, - the resulting type of the object literal includes a string/numeric index signature with the union type - of the types of the properties declared in the object literal, or the Undefined type if the object literal is empty. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface I1{ - 1: string; - [key: string]: string; -} -let obj1: I1 = { - 1: 'number', - 'str': 'string' -} -Assert.isString(obj1[1]); -Assert.isString(obj1['str']); -let obj2: I1 = { - 1: 'number' -} -Assert.isString(obj2[1]); -Assert.isUndefined(obj2['str']); - -interface I2{ - 'string': string; - [key: number]: string; -} -let obj3: I2 = { - 'string': 'number', - 1: 'string' -} -Assert.isString(obj3['string']); -Assert.isString(obj3[1]); -let obj4: I2 = { - 'string': 'number' -} -Assert.isString(obj4['string']); -Assert.isUndefined(obj4[1]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/parentheses/parentheses.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/parentheses/parentheses.ts deleted file mode 100644 index 2037db98f1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/parentheses/parentheses.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A parenthesized expression has the same type and classification as the contained expression itself. - Specifically, if the contained expression is classified as a reference, so is the parenthesized expression. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let addparent = function (n1: number, n2: number): number { - return n1 + n2; -}; -let addnoparent = (n1: number, n2: number): number => n1 + n2; -let isCorrect = addparent(11, 22) === addnoparent(11, 22); -Assert.isTrue(isCorrect); -let foo: string = "hello"; -let bar: string = foo; -Assert.isString(foo); -Assert.isString(bar); -const obj = { value: "world" }; -function printValue(value: string) { - Assert.equal(value, "world"); - Assert.isString(value); -} -printValue(obj.value); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_access_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_access_2.ts deleted file mode 100644 index fc245d3fd9..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_access_2.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If name denotes an accessible apparent property (section 3.11.1) in the widened type (section 3.12) of object, - the property access is of the type of that property. Public members are always accessible, - but private and protected members of a class have restricted accessibility, as described in 8.2.2. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var sites = { - site1: "Runoob", - site2: "Google", - sayHello: function () { }, -}; -sites.sayHello = function () { - return "hello " + sites.site1; -}; -Assert.isString(sites.sayHello()); -class Person { - name: string; - age: string; - constructor(name: any, age: any) { - this.name = name; - this.age = age; - } - greet() { } -} -const person1 = new Person("Alice", 30); -const person2 = { name: "Bob", age: 35 }; -person1["greet"](); -Assert.equal(person1.name, "Alice"); -Assert.equal(person2.name, "Bob"); -Assert.equal(person1.age, 30); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_1.ts deleted file mode 100644 index 167baf148f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_1.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If object is of type Any, any name is permitted and the property access is of type Any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let myVariable: any = { name: "John", age: 30 }; -Assert.isString(myVariable.name); -myVariable.name = 42; -Assert.isNumber(myVariable.name); - -Assert.isNumber(myVariable.age); -myVariable.age = "Hello World"; -Assert.isString(myVariable.age); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_type_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_type_6.ts deleted file mode 100644 index 87e41c23ce..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_type_6.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If index is of type Any, the String or Number primitive type, - or an enum type, the property access is of type Any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface MyObject { - [key: string]: number; -} -const obj: MyObject = { - prop1: 1, - prop2: 2, - prop3: 3, -}; -const value2 = obj[0]; -Assert.equal(value2, undefined); -enum MyEnum { - Prop1 = "prop1", - Prop2 = "prop2", - Prop3 = "prop3", -} -const value3 = obj[MyEnum.Prop3]; -Assert.equal(value3, 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_apprent_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_apprent_5.ts deleted file mode 100644 index 0cfac703a8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_apprent_5.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If object has an apparent string index signature and index is of type Any, - the String or Number primitive type, or an enum type, the property access is of the type of that index signature. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface ExampleObject { - [key: string]: string; -} -const myObject: ExampleObject = { - foo: "bar", - baz: "qux", -}; -const myIndex: any = "foo"; -const myValue = myObject[myIndex]; -Assert.isString(myValue); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_index_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_index_4.ts deleted file mode 100644 index 8a09d000a1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_index_4.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If object has an apparent numeric index signature and index is of type Any, - the Number primitive type, or an enum type, the property access is of the type of that index signature - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface MyObj { - [index: number]: string; -} -const obj: MyObj = { - 0: "foo", - 1: "bar", - 2: "baz", -}; -Assert.equal(obj[0], "foo"); -Assert.equal(obj[1], "bar"); -Assert.equal(obj[2], "baz"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_string_number_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_string_number_3.ts deleted file mode 100644 index 9e4293dba4..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_string_number_3.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If index is a string literal or a numeric literal and object has an apparent property with the name given by that literal, - the property access is of the type of that property. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -const sites = { - siteName: "Runoob", - site2: 999, - sayHello: function () { }, -}; -Assert.isString(sites["siteName"]); -Assert.isNumber(sites["site2"]); -Assert.isFunction(sites["sayHello"]); -interface Person { - name: string; - age: number; - city: string; -} -const person: Person = { - name: "Alice", - age: 30, - city: "New York", -}; -Assert.equal(person["name"], "Alice"); -Assert.equal(person["city"], "New York"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_1.ts deleted file mode 100644 index 5dcfd232d9..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_1.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Properties are strongly typed when accessed using bracket notation with the literal representation of their name. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var myType = { - h_str: 'string', - h_bool: true -}; -var h_s = myType['h_str']; -Assert.isString(h_s); -var h_b = myType['h_bool']; -Assert.isBoolean(h_b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_2.ts deleted file mode 100644 index 3b624b2cdc..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_2.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Tuple types assign numeric names to each of their elements and elements are therefore strongly typed - when accessed using bracket notation with a numeric literal. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var myArry: [number, string, boolean] = [10, 'string', true]; -var h_n = myArry[0]; -Assert.isNumber(h_n); -var h_s = myArry[1]; -Assert.isString(h_s); -var h_b = myArry[2]; -Assert.isBoolean(h_b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_comma_operator/the_comma_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_comma_operator/the_comma_operator.ts deleted file mode 100644 index 37a507f5bd..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_comma_operator/the_comma_operator.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The comma operator permits the operands to be of any type and produces a result that is of the same type as the second operand. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let x: number = 20; -let y: boolean = true; -let z: string = 'a'; -function add(arg1: number, arg2: number) { - return arg1 + arg2; -} -let com1 = (x++, y); -let com2 = (x++, z = z + 'b'); -let com3 = (x++, add(3, 5)); -Assert.isBoolean(com1); -Assert.isString(com2); -Assert.isNumber(com3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts deleted file mode 100644 index 01e70a8364..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a conditional expression of the form 'test ? expr1 : expr2', the test expression may be of any type. - The type of the result is the union type of the types of expr1 and expr2. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var x: number = 10 -var y: string = '5' -var z = Math.random() < 0.5 ? x + y : y && x -if (typeof z === 'number') { - z++ - Assert.equal(z, 11); -} -else { - Assert.equal(z, '105'); -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_2.ts deleted file mode 100644 index f9a4095a63..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_2.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the conditional expression is contextually typed, expr1 and expr2 are contextually typed by the same type. - Otherwise, expr1 and expr2 are not contextually typed. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var sum = function (x: number, y: number) { - return x + y -} -var average = function (a: number, b: number) { - return (a + b) / 2 -} -var rela: number = Math.random() < 0.5 ? sum(5, 7) : average(6, 9) -Assert.isNumber(rela); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_1.ts deleted file mode 100644 index 6579559ced..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_1.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If C is of type Any, any argument list is permitted and the result of the operation is of type Any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let C: any; -C = function (this: any, x: number, y: number) { - this.sum = x + y; -}; -let myObject = new C(2, 3); -Assert.equal(myObject.sum, 5); -myObject = 5; -Assert.isNumber(myObject); -myObject = 'a'; -Assert.isString(myObject); -myObject = true; -Assert.isBoolean(myObject); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_2.ts deleted file mode 100644 index 42c673b0a3..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_2.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If C has one or more apparent construct signatures (section 3.11.1), the expression is processed in the same manner as a function call, - but using the construct signatures as the initial set of candidate signatures for overload resolution. - The result type of the function call becomes the result type of the operation. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Person { - constructor(public name: string, public age: number) { } -} -interface Animal { - speak(): void; -} -class Dog implements Animal { - speak() { - return "Woof!"; - } -} -const p = new Person("Alice", 30); -const d = new Dog(); -Assert.isString(p.name); -Assert.equal(d.speak(), "Woof!"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_3.ts deleted file mode 100644 index 7ee5e319d5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_3.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If C has no apparent construct signatures but one or more apparent call signatures, the expression is processed as a function call. - A compile-time error occurs if the result of the function call is not Void. The type of the result of the operation is Any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Person { - sayHello() { - return "Hello,world"; - } -} -let person: Person = new Person(); -Assert.equal(person.sayHello(), "Hello,world"); -let person2: any = new Person(); -person2.sayHello(); -Assert.equal(person2.sayHello(), "Hello,world"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_4.ts deleted file mode 100644 index 5b764b4ce4..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_4.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - new C - new C ( ... ) - new C < ... > ( ... ) - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Person { - name: string; - age: number; - constructor(name: string, age: number) { - this.name = name; - this.age = age; - } -} -const john = new Person("john", 30); -Assert.isString(john.name, "john"); -class Box { - contents: T; - constructor(value: T) { - this.contents = value; - } -} -const myBox = new Box("hello"); -Assert.equal(myBox.contents, "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/arguments.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/arguments.ts deleted file mode 100644 index 9658263480..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/arguments.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Type arguments cannot be explicitly specified in a super call. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class SuperClass { - value: T; - constructor(value: T) { - this.value = value; - } -} -class SubClass extends SuperClass { - constructor(value: T) { - super(value); - } -} -const sub = new SubClass("hello"); -Assert.equal(sub.value, "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts deleted file mode 100644 index 3243840b97..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the base class is a generic class, - the type arguments used to process a super call are always those specified in the extends clause that references the base class. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class BaseClass { - constructor(public value: T) { } -} -class SubClass extends BaseClass { - constructor(value: T) { - super(value); - } -} -class StringSubClass extends SubClass { - constructor() { - super("hello"); - } -} -const sub = new StringSubClass(); -Assert.equal(sub.value, "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/super_calls.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/super_calls.ts deleted file mode 100644 index b64f05916a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/super_calls.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The super keyword can be used in expressions to reference base class properties and the base class constructor. - Super calls consist of the keyword super followed by an argument list enclosed in parentheses. Super calls are only permitted in constructors of derived classes. - A super call invokes the constructor of the base class on the instance referenced by this. - A super call is processed as a function call (section 4.15) using the construct signatures of the base class constructor function type - as the initial set of candidate signatures for overload resolution. - The type of a super call expression is Void. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Animal { - private name: string; - constructor(name: any) { - this.name = name; - } - speak() { - return `${this.name} makes a noise`; - } -} -class Dog extends Animal { - private breed: string; - constructor(name: any, breed: any) { - super(name); - this.breed = breed; - } - extendsSpeak() { - super.speak(); - Assert.isString(super.speak(), "Fodo makes a noise"); - return `${this.breed}`; - } -} -const d = new Dog("Fido", "Golden Retriever"); -d.extendsSpeak(); -Assert.isString(d.extendsSpeak(), "Golden Retriever"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/derived_class_access.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/derived_class_access.ts deleted file mode 100644 index 6bdba30fa5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/derived_class_access.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance, - a super property access is permitted and must specify a public instance member function of the base class. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Animal { - public makeSound(): string { - return "the animal makes"; - } -} -class Dog extends Animal { - public makeSound(): string { - super.makeSound(); - Assert.equal(super.makeSound(), "the animal makes"); - return "the dog barks"; - } -} -const myDog = new Dog(); -myDog.makeSound(); -Assert.equal(myDog.makeSound(), "the dog barks"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/static_member_access.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/static_member_access.ts deleted file mode 100644 index d7c0f1dc7a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/static_member_access.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a static member function or static member accessor where this references the constructor function object of a derived class, - a super property access is permitted and must specify a public static member function of the base class. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Base { - static greet() { - return "hello world"; - } -} -class Derived extends Base { - static greet() { - super.greet(); - Assert.equal(super.greet(), "hello world"); - return "hola,mundo"; - } -} -Derived.greet(); -Assert.equal(Derived.greet(), "hola,mundo"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_1.ts deleted file mode 100644 index 61a7a65a42..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_1.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a constructor, instance member function, instance member accessor, - or instance member variable initializer, this is of the this-type (section 3.6.3) of the containing class. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class C{ - public mem: string; - private num: number; - constructor(mem: string, num: number) { - this.mem = mem; - this.num = num; - Assert.isObject(this); - } - func() { - return this; - } - get getNum() { - Assert.isObject(this); - return this.num; - } - set setNum(num: number) { - this.num = num; - } -} -let c = new C('a', 10); -c.getNum; -Assert.isObject(c.func()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_2.ts deleted file mode 100644 index af043bd290..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_2.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a static member function or static member accessor, the type of this is the constructor function type of the containing class. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class C{ - static mem: string = 'a'; - static get getMem() { - Assert.isFunction(this); - return this.mem; - } - static set setMem(mem: string) { - this.mem = mem; - } - static func() { - return this; - } -} -C.getMem; -Assert.isFunction(C.func()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_1.ts deleted file mode 100644 index 17020e1b08..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_1.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Type assertions check for assignment compatibility in both directions. - Thus, type assertions allow type conversions that might be correct, but aren't known to be correct. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class P{ } -class C extends P { } -function func(str: string): P { - if (str === "string") { - return new C(); - } - return C; -} -let c = func("string"); -Assert.equal(JSON.stringify(c), '{}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_2.ts deleted file mode 100644 index 2ec039e832..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_2.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - type assertions are not checked at run-time and it is up to the programmer to guard against errors, - for example using the instanceof operator - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Foo { - foo = 123; - common = '123' -} -class Bar { - bar = 123 - common = '123' -} -function doStuff(arg: Foo | Bar) { - if (arg instanceof Foo) { - Assert.equal(arg.foo, 123) - } else { - Assert.equal(arg.bar, 123) - } -} -doStuff(new Foo()) -doStuff(new Bar()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_3.ts deleted file mode 100644 index 076898c01c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_3.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a type assertion expression of the form < T > e, e is contextually typed by T and the resulting type of* e* is required to be assignable to T, - or T is required to be assignable to the widened form of the resulting type of e, or otherwise a compile-time error occurs. The type of the result is T. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function getLength(something: string | number): number { - if ((something).length) { - return (something).length - } else { - return something.toString().length - } -} -Assert.equal(getLength('length'), 6); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_1.ts deleted file mode 100644 index 08b585694d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_1.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Type guards are particular expression patterns involving the 'typeof' and 'instanceof' operators - that cause the types of variables or parameters to be narrowed to more specific types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function fun(x: boolean | number | string) { - if (typeof x === 'string') { - Assert.isString(x); - } - if (typeof x === 'boolean') { - x = true; - Assert.isTrue(x); - } - if (typeof x === 'number') { - Assert.isNumber(x); - } -} -fun('string'); -fun(10); -fun(false); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_10.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_10.ts deleted file mode 100644 index c96d649482..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_10.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A type guard of the form !expr, - when true, narrows the type of x by expr when false, - or when false, narrows the type of x by expr when true. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function func(x: string | number) { - if (!(typeof x === "string")) { - Assert.isNumber(x); - return x + 1; - } - else { - Assert.isString(x); - return x.length; - } -} -let a = func(10); -Assert.equal(a, 11); -let b = func('s'); -Assert.equal(b, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_11.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_11.ts deleted file mode 100644 index 9fcd82bbf2..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_11.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A type guard of the form expr1 && expr2, - when true, narrows the type of x by expr1 when true and then by expr2 when true, or - when false, narrows the type of x to T1 | T2, where T1 is the type of x narrowed by expr1 when false, - and T2 is the type of x narrowed by expr1 when true and then by expr2 when false. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function func(x: string | number | undefined) { - if (typeof x === "string" && typeof x === "number") { - return undefined; - } - else { - return x; - } -} -let a = func(10); -Assert.isNumber(a); -let b = func('s'); -Assert.isString(b); -let c = func(undefined); -Assert.isUndefined(c); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_12.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_12.ts deleted file mode 100644 index 23569fbadb..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_12.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A type guard of the form expr1 || expr2, - when true, narrows the type of x to T1 | T2, where T1 is the type of x narrowed by expr1 when true, - and T2 is the type of x narrowed by expr1 when false and then by expr2 when true, or - when false, narrows the type of x by expr1 when false and then by expr2 when false. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function func(x: string | number | undefined) { - if (typeof x === "string" || typeof x === "number") { - return x; - } - else { - return undefined; - } -} -let a = func(10); -Assert.isNumber(a); -let b = func('s'); -Assert.isString(b); -let c = func(undefined); -Assert.isUndefined(c); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_13.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_13.ts deleted file mode 100644 index 17c6536000..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_13.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A type guard of any other form has no effect on the type of x. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Person { - name: string - age: number - public constructor(name: string, age: number) { - this.name = name - this.age = age - } -} -class Animal { - height: number - weight: number - public constructor(height: number, weight: number) { - this.height = height - this.weight = weight - } -} -function func(arg: Person | Animal) { - if ('age' in arg) { - Assert.isString(arg.name) - } - if ('height' in arg) { - Assert.isNumber(arg.height) - } -} -let p = new Person('x', 18); -func(p); -let a = new Animal(200, 180); -func(a); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_2.ts deleted file mode 100644 index 8b8027f7cd..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_2.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In the false branch statement of an 'if' statement, - the type of a variable or parameter is narrowed by a type guard in the 'if' condition when false, - provided no part of the 'if' statement contains assignments to the variable or parameter. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function h_func(h_x: number | string) { - if (!(typeof h_x === 'string')) { - Assert.isNumber(h_x); - return h_x; - } - else { - return h_x.length - } -} -let a = h_func(10); -Assert.equal(a, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_3.ts deleted file mode 100644 index d092aec559..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_3.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In the true expression of a conditional expression, - the type of a variable or parameter is narrowed by a type guard in the condition when true, - provided no part of the conditional expression contains assignments to the variable or parameter. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function func(arg: string | (() => string)) { - let x = typeof arg == "string" ? arg : arg(); - return x; -} -let result = func("abc"); -Assert.isString(result); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_4.ts deleted file mode 100644 index 1497787e83..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_4.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In the false expression of a conditional expression, - the type of a variable or parameter is narrowed by a type guard in the condition when false, - provided no part of the conditional expression contains assignments to the variable or parameter. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function func(arg: string | (() => string)) { - var x = typeof arg !== "string" ? arg() : arg; - return x; -} -let result = func("abc"); -Assert.isString(result); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_5.ts deleted file mode 100644 index 8eaf5a06cf..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_5.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In the right operand of a && operation, - the type of a variable or parameter is narrowed by a type guard in the left operand when true, - provided neither operand contains assignments to the variable or parameter. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function fun(obj: any) { - typeof obj === "number" && obj - Assert.isNumber(obj) -} -fun(12); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_6.ts deleted file mode 100644 index 0040c18beb..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_6.ts +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A type guard of the form 'x instanceof C', where x is not of type Any, - C is of a subtype of the global type 'Function', and C has a property named 'prototype', - when true, narrows the type of x to the type of the 'prototype' property in C provided it is a subtype of the type of x, - or, if the type of x is a union type, removes from the type of x all constituent types that aren't subtypes of the type of the 'prototype' property in C, - or when false, has no effect on the type of x. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Person { - height: number - age: number - public constructor(height: number, age: number) { - this.height = height - this.age = age - } -} -class Animal { - height: number - weight: number - public constructor(height: number, weight: number) { - this.height = height - this.weight = weight - } -} -function func(arg: Person | Animal) { - if (arg instanceof Person) { - return arg.age = 18 - } - if (arg instanceof Animal) { - return arg.weight = 300 - } -} -var p = new Person(150, 18) -Assert.equal(func(p), 18) -var a = new Animal(200, 180) -Assert.equal(func(a), 300); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_7.ts deleted file mode 100644 index 7d3ef1a40d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_7.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A type guard of the form typeof x === s, where s is a string literal with the value 'string', 'number', or 'boolean', - when true, narrows the type of x to the given primitive type provided it is a subtype of the type of x, - or, if the type of x is a union type, removes from the type of x all constituent types that aren't subtypes of the given primitive type, - or when false, removes the primitive type from the type of x. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function func(x: string | number) { - if (typeof x === "string") { - Assert.isString(x); - return x.length; - } - else { - Assert.isNumber(x); - return x + 1; - } -} -let a = func(10); -Assert.equal(a, 11); -let b = func('s'); -Assert.equal(b, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_8.ts deleted file mode 100644 index 53c3fab073..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_8.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A type guard of the form typeof x === s, where s is a string literal with any value but 'string', 'number', or 'boolean', - when true, if x is a union type, removes from the type of x all constituent types that are subtypes of the string, number, or boolean primitive type, - or when false, has no effect on the type of x. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function f1(x: string | number | undefined) { - if (typeof x === "undefined") { - return undefined - } - else { - return x - } -} -var a = f1(10) -Assert.isNumber(a) -var b = f1('s') -Assert.isString(b) -var c = f1(undefined) -Assert.isUndefined(c) -function f2(x: string | number | boolean) { - if (typeof x === "undefined") { - return undefined - } - else { - return x - } -} -var a1 = f2(10) -Assert.isNumber(a1) -var b1 = f2('s') -Assert.isString(b1) -var c1 = f2(true) -Assert.isBoolean(c1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_9.ts deleted file mode 100644 index c026b9e2f7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_9.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A type guard of the form typeof x !== s, where s is a string literal, - when true, narrows the type of x by typeof x === s when false, - or when false, narrows the type of x by typeof x === s when true. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function func(x: string | number) { - if (typeof x !== "string") { - Assert.isNumber(x); - return x + 1; - } - else { - Assert.isString(x); - return x.length; - } -} -let a = func(10); -Assert.equal(a, 11); -let b = func('s'); -Assert.equal(b, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_!_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_!_operator.ts deleted file mode 100644 index 56c624381b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_!_operator.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The ! operator permits its operand to be of any type and produces a result of the Boolean primitive type. - Two unary ! operators in sequence can conveniently be used to convert a value of any type to the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var num1: number = 20 -var num2: number = 90 -var res = !((num1 > 50) && (num2 > 80)) -Assert.isBoolean(res) -function func(): any { -} -var b = !!func() -Assert.isBoolean(b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_++_and_--_operators.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_++_and_--_operators.ts deleted file mode 100644 index ece420a7dd..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_++_and_--_operators.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The ++ and -- operators in prefix or postfix form, require their operand to be of type Any, the Number primitive type, or an enum type, - and classified as a reference. They produce a result of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var a: any = '10'; -a++; -a--; ---a; -++a; -Assert.isNumber(a); -enum e { - A, - B, - C, - D -} -let b = e.A -b++; -b--; -++b; ---b; -Assert.isNumber(b); -var c: number = 10; -c++; -++c; ---c; -c--; -Assert.isNumber(c); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_+_and_~_operators.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_+_and_~_operators.ts deleted file mode 100644 index 1d08f3e221..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_+_and_~_operators.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The +, -, and ~ operators permit their operand to be of any type and produce a result of the Number primitive type. - The unary + operator can conveniently be used to convert a value of any type to the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var a: any = 'a' -a = a + 1 -a = a - 1 -a = ~a -Assert.isNumber(a) -function func() { } -var n = +func(); -Assert.isNumber(n); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_delete_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_delete_operator.ts deleted file mode 100644 index 159678417b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_delete_operator.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The 'delete' operator takes an operand of any type and produces a result of the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface Foo { - prop1?: string - prop2?: boolean - prop3?: number -} -let obj: Foo = { - prop1: 'value', - prop2: true, - prop3: 20 -} -Assert.isBoolean(delete obj.prop1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_typeof_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_typeof_operator.ts deleted file mode 100644 index 06eb874eda..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_typeof_operator.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The 'typeof' operator takes an operand of any type and produces a value of the String primitive type. In positions where a type is expected, 'typeof' can also be used in a type query to produce the type of an expression. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let aa = 1 -let bb = typeof aa -Assert.equal(bb, 'number') -let cc: typeof aa = 2 -Assert.equal(cc, 2) \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_void_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_void_operator.ts deleted file mode 100644 index 501fb22f61..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_void_operator.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The 'void' operator takes an operand of any type and produces the value 'undefined'. The type of the result is the Undefined type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let num: any = 10 -num = 'string' -let un = void num -Assert.isUndefined(un); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_1.ts deleted file mode 100644 index e5fa6f675c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_1.ts +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - An Async Function is a JavaScript Function, Parameterized Arrow Function, Method that has been prefixed with the async modifier. - An Async Function must provide a return type annotation that points to a compatible Promise type. - Return type inference can only be used if there is a globally defined, compatible Promise type. - options: - lib:es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let pp: Promise = Promise.resolve(1); -async function fetchTest1(): Promise { - return await pp; -} -fetchTest1().then((params) => { - Assert.equal(params, 1); -}); -async function fetchTest1NoReturnType() { - return await pp; -} -fetchTest1NoReturnType().then((params) => { - Assert.equal(params, 1); -}); -const fetchTest2 = async (): Promise => { - return await pp; -}; -fetchTest2().then((params) => { - Assert.equal(params, 1); -}); -const fetchTest2NoReturnType = async () => { - return await pp; -}; -fetchTest2NoReturnType().then((params) => { - Assert.equal(params, 1); -}); -class Person { - async fetchTest3(): Promise { - return await pp; - } - async fetchTest3NoReturnType() { - return await pp; - } -} -new Person().fetchTest3().then((params) => { - Assert.equal(params, 1); -}); -new Person().fetchTest3NoReturnType().then((params) => { - Assert.equal(params, 1); -}); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_2.ts deleted file mode 100644 index 1ddc1ac347..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_2.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Async Generator Functions - options: - lib:es2018 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -async function* ag() { - let i = 0; - let c = 0; - yield* [0, 0, 0, 0]; - while (true) { - yield c++; - i++; - if (i > 20) { - break; - } - } -} -function newArray() { - let arr: number[] = [0, 0, 0, 0]; - let i = 0; - let c = 0; - while (true) { - arr[i + 4] = c; - c++; - i++; - if (i > 20) { - break; - } - } - return arr; -} -let arr = ag(); -async function showAsyncGenerator(arr: AsyncGenerator) { - let i = 0; - for await (let x of arr) { - Assert.equal(x as number, arr2[i++]); - } -} -let arr2 = newArray(); -showAsyncGenerator(arr); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_3.ts deleted file mode 100644 index 2d547a96f0..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_3.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Async Iterators Functions - options: - lib:es2018 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function createAsyncInterator(arr: any[]): AsyncIterator { - let index = 0; - let len = arr.length; - return { - async next() { - return new Promise((resolve, reject) => { - if (index < len) { - resolve({ value: arr[index++], done: false }); - } else { - resolve({ value: undefined, done: true }); - } - }); - }, - }; -} -export function newArray(len: number, step: number = 1) { - if (len <= 0) { return [] }; - let arr: any[] = []; - let x: number = 0; - for (let i: number = 0; i < len; i++) { - arr[i] = x + step; - } - return arr; -} -let arr = newArray(15); -async function exp(arr: any[]) { - let asy = createAsyncInterator(arr); - let i = 0; - let fg; - while (true) { - if (fg == true) { - break; - } - await asy.next().then((v) => { - if (v.done == true) { - fg = true; - } - Assert.equal(v.value, arr[i++]); - return; - }); - } -} -exp(arr); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_4.ts deleted file mode 100644 index d6a9232379..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_4.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Async Iterators Functions - options: - lib:es2018 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' -import { newArray } from './asynchronous_functions_3.js'; - -async function asc(arr: any[]) { - let i = 0; - for await (let x of arr) { - Assert.equal(x, arr[i]); - i++ - } -} -let arr = newArray(15, 5); -asc(arr); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_1.ts deleted file mode 100644 index d3a47bc49d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_1.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - a destructuring parameter declaration introduces zero or more named locals - and initializes them with values extracted from properties or elements of the object or array passed as an argument for the parameter. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Person { - m_name: string; - m_age: number; - constructor(name: string, age: number) { - this.m_name = name; - this.m_age = age; - } -} -let tt: Person = new Person("caihua", 12); -function showInfo({ m_name, m_age }: Person) { - Assert.isString(m_name); - Assert.equal(m_name, tt.m_name); - Assert.isNumber(m_age); - Assert.equal(m_age, tt.m_age); -} -showInfo(tt); -let tt1: Person = new Person("caihua1", 121); -let tt2: Person = new Person("caihua2", 122); -let person_array: Person[] = [tt1, tt2]; -function showArrayInfo(v_array: Array) { - let [tt1, tt2] = v_array; - Assert.equal(tt1.m_name, v_array[0].m_name); - Assert.equal(tt1.m_age, v_array[0].m_age); - Assert.equal(tt2.m_name, v_array[1].m_name); - Assert.equal(tt2.m_age, v_array[1].m_age); -} -showArrayInfo(person_array); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_2.ts deleted file mode 100644 index ab5bf3ddd4..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_2.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the type T associated with a destructuring parameter declaration is determined as follows - If the declaration includes a type annotation, T is that type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Person { - m_name: string; - m_age: number; - constructor(name: string, age: number) { - this.m_name = name; - this.m_age = age; - } -} -let tt: Person = new Person("caihua", 12); -function showInfo(v: Person) { - let { m_name, m_age }: { m_name: string; m_age: number } = v; - Assert.isString(m_name); - Assert.equal(m_name, "caihua"); - Assert.isNumber(m_age); - Assert.equal(m_age, 12); -} -showInfo(tt); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_3.ts deleted file mode 100644 index 3c3293c70b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_3.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the type T associated with a destructuring parameter declaration is determined as follows - If the declaration occurs in a function expression for which a contextual signature is available, - T is the type obtained from the contextual signature. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Person { - m_name: string; - m_age: number; - constructor(name: string, age: number) { - this.m_name = name; - this.m_age = age; - } -} -let tt: Person = new Person("caihua", 12); -const showInfo: (v: Person) => void = function (v) { - let { m_name, m_age } = v; - Assert.isString(m_name); - Assert.equal(m_name, "caihua"); - Assert.isNumber(m_age); - Assert.equal(m_age, 12); -}; -showInfo(tt); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts deleted file mode 100644 index 2f9cefa6e8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the type T associated with a destructuring parameter declaration is determined as follows - if the declaration includes an initializer expression, T is the widened form of the type of the initializer expression. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -type testStr = "caihua"; -type testStrNum = 12; -class Person { - m_name: testStr | undefined; - m_age: testStrNum | undefined; - constructor(); - constructor(name?: testStr, age?: testStrNum) { - if (name && typeof name === "string") { - this.m_name = name; - } else { - this.m_name = undefined; - } - if (age && typeof age === "number") { - this.m_age = age; - } else { - this.m_age = undefined; - } - } -} -let tt: Person = new Person(); -function showInfo(v: Person) { - let { - m_name = "caihua", - m_age = 12, - }: { m_name: testStr | undefined; m_age: testStrNum | undefined } = v; - Assert.equal(typeof m_name === "string", true); - Assert.equal(typeof m_age === "number", true); -} -showInfo(tt); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_5.ts deleted file mode 100644 index cc30604e7e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_5.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the type T associated with a destructuring parameter declaration is determined as follows - if the declaration specifies a binding pattern, T is the implied type of that binding pattern - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -type cc = { - name: string; - age: number; - isJob: boolean; -}; -function showInfo({ age, name, isJob }: cc) { - Assert.isNumber(age); - Assert.isBoolean(isJob); - Assert.isString(name); -} -showInfo({ - name: "caihua", - age: 90, - isJob: true, -}); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_6.ts deleted file mode 100644 index 9e5149f23e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_6.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Destructuring parameter declarations do not permit type annotations on the individual binding patterns, - as such annotations would conflict with the already established meaning of colons in object literals. - Type annotations must instead be written on the top-level parameter declaration. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface information { - title?: string; - place?: [number, number]; - brave?: boolean; -} -function infor({ title, place, brave }: information) { - if (title) { - Assert.equal(typeof title == "string", true); - } - if (place) { - Assert.equal(Array.isArray(place), true); - } - if (brave) { - Assert.equal(typeof brave === "boolean", true); - } -} -infor({ title: "title" }); -infor({ brave: false }); -infor({ place: [0, 1] }); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts deleted file mode 100644 index 779bec1a95..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the type T associated with a destructuring parameter declaration is determined as follows - if the parameter is a rest parameter, T is any[]. - Otherwise,T is any - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function test(...v: any[]) { - Assert.isString(v[0]); - Assert.isNumber(v[1]); - Assert.isBoolean(v[2]); -} -test("caihua", 90, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_1.ts deleted file mode 100644 index 4ea5a16f19..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_1.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Function declarations are extended to permit the function body to be omitted in overload declarations. - a function can have at most one implementation. - When a function has both overloads and an implementation, the overloads must precede the implementation - and all of the declarations must be consecutive with no intervening grammatical elements. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function add(a: number, b: number): number; -function add(a: string, b: number): string; -function add(a: string, b: string): string; -function add(arg1: string | number, arg2: string | number) { - if (typeof arg1 === "number" && typeof arg2 === "number") { - return arg1 + arg2; - } - - if (typeof arg1 === "string" || typeof arg2 === "string") { - return `${arg1}${arg2}`; - } -} -Assert.equal(add(0, 1), 1); -Assert.equal(add("0", 1), "01"); -Assert.equal(add("0", "1"), "01"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_2.ts deleted file mode 100644 index 686fa6ef76..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_2.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - All declarations for the same function must specify the same set of modifiers (the same combination of declare, export, and default) - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -export function add1(a: string, b: string): string; -export function add1(a: number, b: number): number; -export function add1(a: string, b: number): string; -export function add1(arg1: string | number, arg2: string | number) { - if (typeof arg1 === "number" && typeof arg2 === "number") { - return arg1 + arg2; - } - if (typeof arg1 === "string" || typeof arg2 === "string") { - return `${arg1}${arg2}`; - } -} -Assert.equal(add1(0, 1), 1); -Assert.equal(add1("0", 1), "01"); -Assert.equal(add1("0", "1"), "01"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_1.ts deleted file mode 100644 index cc139d21f1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_1.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If there are no return statements with expressions in f's function body, the inferred return type is Void. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function func(h_x: number) { - Assert.isNumber(h_x); -} -type voidTest = ReturnType; -let tt1: void = undefined; -let tt2: voidTest = undefined; -Assert.equal(tt1, tt2); -Assert.equal(tt1 === tt2, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_2.ts deleted file mode 100644 index 3180469b8e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_2.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - if f is a contextually typed function expression - the inferred return type is the union type of the types of the return statement expressions in the function body, - ignoring return statements with no expressions. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function f(x: number) { - switch (x) { - case 0: - return "hello"; - case 1: - return 1; - default: - return true; - } -} -type testType = ReturnType; -type ttStr = testType & string; -let tt1: ttStr = "hello"; -Assert.isString(tt1); -type ttBoo = testType & boolean; -let tt2: ttBoo = true; -Assert.isBoolean(tt2); -type ttNum = testType & number; -let tt3: ttNum = 1; -Assert.isNumber(tt3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_3.ts deleted file mode 100644 index bbe98cd076..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_3.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the inferred return type is the first of the types of the return statement expressions in the function body - that is a supertype of each of the others, ignoring return statements with no expressions. - A compile-time error occurs if no return statement expression has a type that is a supertype of each of the others. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function foo(x: string | number, y: string | boolean) { - if (typeof x === "string") { - return x.toUpperCase(); - } else if (typeof x === "number") { - return x.toString(); - } else if (typeof y === "string") { - return y.toUpperCase(); - } else { - return y; - } -} -type cc = ReturnType; -let dd: cc = "string"; -Assert.isString(dd); -dd = true; -Assert.isBoolean(dd); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_4.ts deleted file mode 100644 index 15c7e92fda..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_4.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In the signature of a function implementation, a parameter can be marked optional by following it with an initializer. - When a parameter declaration includes both a type annotation and an initializer, the initializer expression is contextually typed by the stated type - and must be assignable to the stated type, or otherwise a compile-time error occurs. - When a parameter declaration has no type annotation but includes an initializer, - the type of the parameter is the widened form (section 3.12) of the type of the initializer expression - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Test { - a: number; - constructor(a: number) { this.a = a; } -} -function f(x: number, y: Test = { a: 1 }, z = "hello") { - Assert.isString(z); - return { - x, - yy: y, - z: z, - }; -} -Assert.equal(f(0).yy.a, 1); -Assert.equal(f(0).z, "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_5.ts deleted file mode 100644 index 1427e462ac..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_5.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Initializer expressions are evaluated in the scope of the function body but are not permitted to reference local variables - and are only permitted to access parameters that are declared to the left of the parameter they initialize, - unless the parameter reference occurs in a nested function expression. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let a = 3; -function f(n1: number = a, n2 = n1 * 2, n3 = n1 + 2) { - let b = 12; - function g(xx = b) { - return xx; - } - let c = g(); - return { n1, n2, n3, g: c }; -} -Assert.equal(f().n1, 3); -Assert.equal(f().n2, 6); -Assert.equal(f().n3, 5); -Assert.equal(f().g, 12); -Assert.equal(f(1).n1, 1); -Assert.equal(f(1).n2, 2); -Assert.equal(f(1).n3, 3); -Assert.equal(f(1).g, 12); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_overloads/function_overloads_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_overloads/function_overloads_1.ts deleted file mode 100644 index 734b89651c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_overloads/function_overloads_1.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The parameter list of a function overload cannot specify default values for parameters. - In other words, an overload may use only the ? form when specifying optional parameters. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function add(): number; -function add(x: number): number; -function add(x: number, y: number): number; -function add(x?: number, y?: number): number { - let sum: number = 0; - if (x) { - sum += x; - } - if (y) { - sum += y; - } - return sum; -} -Assert.equal(add(), 0); -Assert.equal(add(1), 1); -Assert.equal(add(1, 1), 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_1.ts deleted file mode 100644 index 2f8f1e1c03..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_1.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - for..of loops over an iterable object, invoking the Symbol.iterator property on the object. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let someArray = [1, "string", false]; -for (let item of someArray) { - if (typeof item === "number") { - Assert.equal(item, 1); - } else if (typeof item === "string") { - Assert.equal(item, "string"); - } else if (typeof item === "boolean") { - Assert.equal(item, false); - } -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_2.ts deleted file mode 100644 index 4601785d81..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_2.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: Generator Functions - options: - lib: es2015 - target: es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function* generator(): IterableIterator { - yield 0; - yield 1; - yield 2; -} -const iterator = generator(); -let cc = iterator.next(); -Assert.equal(cc.value, 0); -Assert.equal(cc.done, false); -cc = iterator.next(); -Assert.equal(cc.value, 1); -Assert.equal(cc.done, false); -cc = iterator.next(); -Assert.equal(cc.value, 2); -Assert.equal(cc.done, false); -cc = iterator.next(); -Assert.equal(cc.value, undefined); -Assert.equal(cc.done, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_3.ts deleted file mode 100644 index 237d92a46d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_3.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: Generator Functions - options: - lib: es2015 - target: es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function* g1(n: number, step: number = 1): Generator { - let i: number = 0, c: number = 0; - while (true) { - yield i += step; - c++; - if (c >= n) { - break; - } - } -} -function getGeneratorArray(gen: Generator, step: number = 1): any[] { - let c: number = 0; - let arr: any[] = []; - let i: number = 0; - while (true) { - let next = gen.next(); - if (next.done == true) { - break; - } - arr[i] = next.value; - i++; - Assert.equal(next.value, c += step); - } - return arr; -} -let genS1 = g1(10); -let arr: number[] = getGeneratorArray(genS1); -Assert.equal(JSON.stringify(arr), '[1,2,3,4,5,6,7,8,9,10]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_1.ts deleted file mode 100644 index 5a4a3a7ae1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_1.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Type parameters declared in the signature of a function implementation are - in scope in the signature and body of that function implementation. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -type XY = { x: number; y: number }; -function f1(arg: T): T { - return arg; -} -Assert.equal(f1(0), 0); -Assert.equal(f1("hello"), "hello"); -Assert.equal(f1(true), true); -function f2(arg: T): T { - return arg; -} -Assert.equal(JSON.stringify(f2<{ x: number, y: number, z: number }>({ x: 0, y: 0, z: 0 })), '{"x":0,"y":0,"z":0}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_2.ts deleted file mode 100644 index 4fb699c4f7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_2.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The type arguments of a call to a generic function may be explicitly specified in a call operation - or may, when possible, be inferred from the types of the regular arguments in the call. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function identity(arg: T): T { - return arg; -} -Assert.equal(identity(0), 0); -Assert.equal(identity(0), 0); -Assert.equal(identity("hello"), "hello"); -Assert.equal(identity("hello"), "hello"); -Assert.equal(identity(true), true); -Assert.equal(identity(true), true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/type_guard_functions/type_guard_functions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/type_guard_functions/type_guard_functions_1.ts deleted file mode 100644 index 538450c5fb..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/type_guard_functions/type_guard_functions_1.ts +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: TypeScript compiler narrows the type of a variable within a type guard. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Student { - name: string; - age: number; - constructor(name: string, age: number) { - this.name = name; - this.age = age; - } -} -class Teacher { - name: string; - age: number; - job: string; - constructor(name: string, age: number, job: string) { - this.name = name; - this.age = age; - this.job = job; - } -} -function isTeacher(obj: Student | Teacher): obj is Teacher { - return "job" in obj; -} -function printInfo(obj: Student | Teacher) { - if ( - isTeacher(obj) && - typeof obj.age === "number" && - obj instanceof Teacher - ) { - Assert.equal(obj.name, "caihuaTeacher"); - Assert.equal(obj.age, 20); - Assert.equal(obj.job, "teacher"); - return "teacher"; - } else { - Assert.equal(obj.name, "caihuaStudent"); - Assert.equal(obj.age, 20); - return "student"; - } -} -let tt: Teacher = new Teacher("caihuaTeacher", 20, "teacher"); -let ss: Student = new Student("caihuaStudent", 20); -Assert.equal(printInfo(tt), "teacher"); -Assert.notEqual(printInfo(tt), "student"); -Assert.equal(printInfo(ss), "student"); -Assert.notEqual(printInfo(ss), "teacher"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/classes/classes.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/classes/classes.ts deleted file mode 100644 index f72709bc48..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/classes/classes.ts +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - this appendix contains a summary of the grammar found in the main document. - typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface PointInterface { - x: number; - y: number; - z: number; - getPointArray(): number[]; -} -class Point implements PointInterface { - x: number = 0; - y: number = 0; - z: number = 0; - getPointArray() { - return [this.x, this.y, this.z]; - } - constructor(x: number, y: number, z: number) { - this.x = x; - this.y = y; - this.z = z; - } -} -class ColorC extends Point { - static Red: number = 0; - static Green: number = 0; - static Blue: number = 0; - static getColorArray(): number[] { - return [this.Red, this.Green, this.Blue] - } - toJSON() { - return JSON.stringify(ColorC.getColorArray()); - } - constructor(Red: number, Green: number, Blue: number, x: number = 0, y: number = 0, z: number = 0) { - super(x, y, z); - ColorC.Red = Red; - ColorC.Green = Green; - ColorC.Blue = Blue; - } -} -let colorPoint = new ColorC(255, 0, 0, 1, 1, 1); -Assert.equal(JSON.stringify(colorPoint.getPointArray()), "[1,1,1]"); -Assert.equal(colorPoint.toJSON(), "[255,0,0]"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/enums/enums.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/enums/enums.ts deleted file mode 100644 index 18f047adf9..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/enums/enums.ts +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - this appendix contains a summary of the grammar found in the main document. - typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -const enum CED { - None = -1, - False, - True = 1, - DEF = 1024, - Ver = "1.0.1", -} -Assert.equal(CED.None, -1); -Assert.equal(CED.False, 0); -Assert.equal(CED.True, 1); -Assert.equal(CED.DEF, 1024); -Assert.equal(CED["None"], -1); -Assert.equal(CED["False"], 0); -Assert.equal(CED["True"], 1); -Assert.equal(CED["DEF"], 1024); -Assert.equal(CED.Ver, "1.0.1"); - -function toLength(str: string): number { - return str.length; -} - -enum ABCList { - A, - B, - C = "string".length, - D = 10, - E, - F = ~17, - G = 0x0f << 0x02, - H = 0xff & 0xaa, - I = E | F, - J = toLength(ABCList[11]), -} -Assert.equal(ABCList.A, 0); -Assert.equal(ABCList.B, 1); -Assert.equal(ABCList.C, 6); -Assert.equal(ABCList.D, 10); -Assert.equal(ABCList.E, 11); -Assert.equal(ABCList.F, -18); -Assert.equal(ABCList.G, 60); -Assert.equal(ABCList.H, 170); -Assert.equal(ABCList.I, -17); -Assert.equal(ABCList.J, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/expressions/expressions.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/expressions/expressions.ts deleted file mode 100644 index 09327519a0..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/expressions/expressions.ts +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - this appendix contains a summary of the grammar found in the main document. - typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class EXP { - cname: string; - private _ver: number = -1; - addName(ad: string) { - this.cname = this.cname + " " + ad; - return this.cname; - } - get ver() { - return this._ver; - } - set ver(v: number) { - this._ver = v; - } - constructor(cname: string) { - this.cname = cname; - } -} -let exp = new EXP("EXP"); -exp.addName("Class"); -Assert.equal(exp.cname, "EXP Class"); - -exp.ver = 1; -Assert.equal(exp.ver, 1); - -function Ax2(a: number) { - return a * 2; -} -Assert.equal(Ax2(2), 4); - -let fun1: (a: number, b: number) => number = (a: number, b: number) => { - return a + b; -} -Assert.equal(fun1(1, 2), 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/functions/functions.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/functions/functions.ts deleted file mode 100644 index 031c95ec63..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/functions/functions.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - this appendix contains a summary of the grammar found in the main document. - typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function addXYZ(x: number, y: number, z: number): number { - return x + y + z; -} -Assert.equal(addXYZ(1, 2, 3), 6); - -function addXY(x: number, y: number): number; -function addXY(x: number, y: number): number { - return x + y; -} -Assert.equal(addXY(1, 2), 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/interfaces/interfaces.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/interfaces/interfaces.ts deleted file mode 100644 index 34eebfd537..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/interfaces/interfaces.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - this appendix contains a summary of the grammar found in the main document. - typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface X { - x: number; -} -interface Y { - y: number; -} -interface Z { - z: number; -} -interface PointXYZ extends X, Y, Z { - toJSON(): string; -} -let pa: PointXYZ = { - x: 3, - y: 4, - z: 5, - toJSON() { - let pArr = [this.x, this.y, this.z]; - return JSON.stringify(pArr); - }, -} -Assert.equal(pa.toJSON(), "[3,4,5]"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/namespaces/namespaces.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/namespaces/namespaces.ts deleted file mode 100644 index f272a45cb4..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/namespaces/namespaces.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - this appendix contains a summary of the grammar found in the main document. - typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -namespace ExampleG { - var namespace_name = "Example"; - export function exampleName(str: string): string { - return str + " " + namespace_name; - } - class Point { - x: number = 0; - y: number = 0; - } - interface PointXYZ { - x: number; - y: number; - z: number; - } - type StrNumBool = string | number | boolean; - export enum Color { - RED = 0xFF0000, - GREEN = 0x00FF00, - BLUE = 0x0000FF, - }; - namespace SubNamespace { } - declare var __TEST__: boolean; - export import EE = ExportExampleG; -} -namespace ExportExampleG { - export var namespace_name = "ExportExampleG"; - export function exampleEName(str: string): string { - return str + " " + namespace_name; - } - export class Point { - x: number = 0; - y: number = 0; - } - export interface PointXYZ { - x: number; - y: number; - z: number; - } - export type StrNumBool = string | number | boolean; - export enum Color { - RED = 0xFF0000, - GREEN = 0x00FF00, - BLUE = 0x0000FF, - } - export namespace SubNamespace { } - export declare var __TEST__: boolean; - export import E = ExampleG; -} -Assert.equal(ExampleG.exampleName("G"), "G Example"); -Assert.equal(ExampleG.Color.RED, 0xFF0000); -Assert.equal(ExportExampleG.exampleEName("G"), "G ExportExampleG"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/scripts_and_modules.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/scripts_and_modules.ts deleted file mode 100644 index f719c24c2e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/scripts_and_modules.ts +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - this appendix contains a summary of the grammar found in the main document. - typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. - module: ESNext - isCurrent: true - ---*/ - - -import * as sf1 from "./source_file_1.js"; -import checkGenerator from "./source_file_2.js"; -import arr1 from "./source_file_3.js"; -import PointXY from "./source_file_4.js"; -import { Assert } from "../../../../suite/assert.js"; - -Assert.equal(sf1.num, 1408); - -Assert.equal(sf1.show(), "show"); - -let a3: Generator = sf1.arr3(9); -checkGenerator(a3, 3); - -let green = new sf1.Color(0, 255, 0); -Assert.equal(JSON.stringify(green.ColorData), '[0,255,0]'); - -let p: sf1.Point = { x: 0, y: 0 }; -Assert.equal(p.x, 0); -Assert.equal(p.y, 0); - -let arrstrnum: sf1.ArrStrNum; -arrstrnum = ["a", "b", "c", "d", "e"]; -Assert.equal(JSON.stringify(arrstrnum), '["a","b","c","d","e"]'); -arrstrnum = [1, 2, 3, 4, 5]; -Assert.equal(JSON.stringify(arrstrnum), '[1,2,3,4,5]'); -arrstrnum = ["a", 2, "c"]; -Assert.equal(JSON.stringify(arrstrnum), '["a",2,"c"]'); -arrstrnum = "arrstrnum"; -Assert.isString(arrstrnum); -arrstrnum = 0; -Assert.isNumber(arrstrnum); - -Assert.equal(sf1.XXXX.x, 1024); -Assert.equal(sf1.XXXX.showXXXX(), "showXXXX"); - -let a1 = arr1(9); -checkGenerator(a1, 1); - -let p1 = new PointXY(10, 10); -Assert.equal(JSON.stringify(p1.point), '[10,10]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_1.ts deleted file mode 100644 index a19235627c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_1.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -export let num: number = 1408; -export function show() { return "show"; }; -export function* arr3(n: number): Generator { - let i = 0; - let c = 0; - if (n > 0) { - while (true) { - yield i += 3; - if (c >= n) { - break; - } else { - c++; - } - } - } -} -export class Color { - Red: number; - Green: number; - Blue: number; - ColorData: [number, number, number] = [0, 0, 0]; - getColor(): [number, number, number] { - this.ColorData = [this.Red, this.Green, this.Blue]; - return this.ColorData; - } - constructor(red: number, green: number, blue: number) { - this.Red = red; - this.Green = green; - this.Blue = blue; - this.getColor(); - } -} -export interface Point { - x: number; - y: number; -} -export type ArrStrNum = string[] | number[] | (string | number)[] | string | number; -export enum ABC { - A, B, C, D, E, -} -export namespace XXXX { - export let x: number = 1024; - export function showXXXX() { return "showXXXX"; }; -} -export declare let dnum: number; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_2.ts deleted file mode 100644 index 624f3d3f5a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_2.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -import { Assert } from "../../../../suite/assert.js"; -export default function checkGenerator(gen: Generator, step: number) { - let c = 0; - while (true) { - let next = gen.next(); - if (next.done == true) { - break; - } - Assert.equal(next.value, c += step); - } -} \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_3.ts deleted file mode 100644 index bc333e40b1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_3.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -export default function* arr1(n: number): Generator { - let i = 0; - let c = 0; - if (n > 0) { - while (true) { - yield i += 1; - if (c >= n) { - break; - } else { - c++; - } - } - } -} \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_4.ts deleted file mode 100644 index 67fbe4f588..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_4.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -export default class PointXY { - x: number; y: number; - point: [number, number] = [0, 0]; - getPoint(): [number, number] { - this.point = [this.x, this.y]; - return this.point; - } - constructor(x: number, y: number) { - this.x = x; - this.y = y; - this.getPoint(); - } -} \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/statements/statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/statements/statements.ts deleted file mode 100644 index 239165c974..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/statements/statements.ts +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - this appendix contains a summary of the grammar found in the main document. - typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface Skill { - SkillName: string; - Damage: number; - Data: string; -} -let aoe: Skill = { SkillName: "AoE", Damage: 495, Data: "AreaFire" }; -Assert.equal(aoe.SkillName, "AoE"); -Assert.equal(aoe.Damage, 495); -Assert.equal(aoe.Data, "AreaFire"); - -type NumStr = number | string; -let ns: NumStr; -ns = 1024; -Assert.isNumber(ns); -ns = "A"; -Assert.isString(ns); - -enum Color { - Red = 0xFF0000, - Green = 0x00FF00, - Bule = 0x0000FF, -} -Assert.equal(Color.Green, 0x00FF00); - -let aaa; -aaa = true; -Assert.isBoolean(aaa); -aaa = 1408; -Assert.isNumber(aaa); -let abc: string; -abc = "ABC"; -Assert.isString(abc); - -type TF = -1 | 0 | 1; -let tf0: TF = 0; -let tf1: TF = 1; -let tf2: TF = -1; -Assert.equal(tf0, 0); -Assert.equal(tf1, 1); -Assert.equal(tf2, -1); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/types/types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/types/types.ts deleted file mode 100644 index a7f8823b07..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/types/types.ts +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - this appendix contains a summary of the grammar found in the main document. - typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) - and this appendix lists only productions that are new or modified from the ECMAScript grammar. - options: - target: es2015 - lib: es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let num: number = 1024; -let str: string = "string"; -let bool: boolean = false; -let big: bigint = 1n; -let sym: symbol = Symbol(); -let obj: object = {}; -let fun: Function = () => { return "Function"; } -let udf: undefined = undefined; -Assert.isNumber(num); -Assert.isString(str); -Assert.isBoolean(bool); -Assert.equal(typeof big, "bigint"); -Assert.isSymbol(sym); -Assert.equal(typeof obj, "object"); -Assert.isFunction(fun); -Assert.isUndefined(udf); - -type Ver = { ver: string }; -interface Data extends Ver { - data: number; -} -let v: Data = { data: 1024, ver: "1.0.1" }; -Assert.equal(v.data, 1024); -Assert.equal(v.ver, "1.0.1"); - -function addNumbers(...num: number[]): number { - let n: number = 0; - for (let i: number = 0; i < num.length; i++) { - n += num[i]; - } - return n; -} -Assert.equal(addNumbers(5, 5, 5, 5, 5), 25); - -interface StrIndex { - [key: string]: number; -} -let si: StrIndex = { C: 3, D: 4 }; -si['A'] = 1; -si.B = 2; -Assert.equal(si.A, 1); -Assert.equal(si['B'], 2); -Assert.equal(si.C, 3); -Assert.equal(si['D'], 4); -Assert.equal(JSON.stringify(si), '{"C":3,"D":4,"A":1,"B":2}'); - -interface NumIndex { - [key: number]: string; -} -let ni: NumIndex = { 1: 'A' }; -ni[3] = 'C'; -Assert.equal(ni[1], 'A'); -Assert.equal(ni[3], 'C'); -Assert.equal(JSON.stringify(ni), '{"1":"A","3":"C"}'); - -class AB{ - a: T | undefined; - b: U | undefined; - public c: string = ""; - private d: string = ""; - protected e: string = ""; - setD(val: string) { - this.d = val; - } - setE(val: string) { - this.e = val; - } - show() { - return JSON.stringify({ d: this.d, e: this.e }); - } - constructor(a?: T, b?: U) { - this.a = a; - this.b = b; - } -} -let ab = new AB(123, "ABC"); -Assert.equal(ab.a, 123); -Assert.equal(ab.b, "ABC"); - -let ab2 = new AB(1024); -Assert.equal(ab2.a, 1024); -Assert.isUndefined(ab2.b); - -ab.c = "1024"; -Assert.equal(ab.c, "1024"); - -ab.setD("D"); -ab.setE("E"); -Assert.equal(ab.show(), "{\"d\":\"D\",\"e\":\"E\"}"); - -type ONS = { n1?: number | string, n2?: number | string }; -let ons: ONS = { n1: 0, n2: "ABC" }; -Assert.equal(ons.n1, 0); -Assert.equal(ons.n2, "ABC"); - - -type NumStrBool = number | string | boolean; -type NumObjBool = number | object | boolean; -type NumBool = NumObjBool & NumStrBool; -let nb: NumBool = 1; -Assert.isNumber(nb); -nb = true; -Assert.isBoolean(nb); - -type StrFun = (a: string, b: string) => string; -let strFun: StrFun = (a: string, b: string) => { return a + b; } -Assert.equal(strFun("AB", "CD"), "ABCD"); - -let a: any; -let vo: void; - -let arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; -Assert.equal(arr[0], 0); - -type type0 = "A" | "B" | "C" | "D"; -let t0: type0 = "A"; -Assert.equal(t0, "A"); - -type NumStrArray = number[] | string[] | (number | string)[]; -let nsa1: NumStrArray = [1, 3, 5]; -let ar1 = [1, 3, 5] -let nsa2: NumStrArray = ["A", "B", "C"]; -let ar2 = ["A", "B", "C"]; -let nsa3: NumStrArray = ["A", 1, "B", 2, "C", 3]; -let ar3 = ["A", 1, "B", 2, "C", 3]; -Assert.equal(JSON.stringify(nsa1), JSON.stringify(ar1)); -Assert.equal(JSON.stringify(nsa2), JSON.stringify(ar2)); -Assert.equal(JSON.stringify(nsa3), JSON.stringify(ar3)); - -type ABC = [number, string, boolean]; -let abc: ABC = [1, "A", true]; -let abc2 = [1, "A", true]; -Assert.equal(JSON.stringify(abc), JSON.stringify(abc2)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_1.ts deleted file mode 100644 index fa6621e1ed..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_1.ts +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - An interface declaration declares an interface type. - An InterfaceDeclaration introduces a named type (section 3.7) in the containing declaration space. - The BindingIdentifier of an interface declaration may not be one of the predefined type names (section 3.8.1). - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -{ - interface Worker { - x: number; - - work(): string; - - getS(): { rate: number,velocity: number; }; - } - - interface Tool { - y: number; - - tool(): string; - - getS(): { rate: number, velocity: number;}; - } - - interface Runer extends Tool,Worker{ - z:string, - - getS(): { rate: number, velocity: number,play:string}; - - run():string; - - tool(): string; - } - - let result1: { rate: number,velocity: number; } = { - rate: 1, - velocity:123, - }; - let result2: { velocity: number,rate: number,} = { - velocity: 1, - rate:999, - }; - let ToRun: {velocity: number, rate: number, play: string} = { - velocity: 1314, - rate:999, - play:"一万年", - } - - let point: Worker = { - x: 1, - getS(): {rate: number, velocity: number} { - return result2 - }, - work(): string { - return "work"; - } - }; - let pointer: Tool = { - y: 1, - getS(): {rate: number, velocity: number} { - return result1 - }, - tool(): string { - return "tool"; - }, - }; - let run:Runer = { - x: ++point.x, - y: --pointer.y, - z:"with z", - getS(): { rate: number; velocity: number; play: string } { - return ToRun; - }, - work(): string { - return "let it work"; - }, - run():string { - return "let it run"; - }, - tool(): string { - return "He is the tool of work"; - } - } - - Assert.equal(run.x,2); - Assert.equal(run.y,0); - Assert.equal(run.z,"with z"); - Assert.equal(run.getS(),ToRun); - Assert.equal(run.run()+","+run.work()+","+run.tool(),"let it run,let it work,He is the tool of work"); - Assert.equal(point.x, 2); - Assert.equal(pointer.y, 0); - Assert.equal(point.getS(), result2); - Assert.equal(pointer.getS(), result1); - Assert.equal(pointer.tool(), "tool"); - Assert.equal(point.work(), "work"); -}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_2.ts deleted file mode 100644 index 4040342f7f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_2.ts +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - An interface can inherit from zero or more base types which are specified in the InterfaceExtendsClause. - The base types must be type references to class or interface types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -{ - interface Worker { - x: number; - - work(): void; - - getS(): { velocity: number; }; - } - - interface Tool { - y: number; - - tool(): void; - - getS(): { rate: number; }; - } - - interface WorkerTool extends Worker, Tool { - z: string; - - getS(): { velocity: number; rate: number; }; - } - - let result: { velocity: number; rate: number; } = { - velocity: 1, - rate: 1 - }; - - let point: WorkerTool = { - x: 1 , - y: 1, - z: "zzz", - getS(): { velocity: number; rate: number; } { - return result - }, - tool(): string { - return "tool"; - }, - work(): string { - return "work"; - } - }; - - Assert.equal(point.x, 1); - Assert.equal(point.y, 1); - Assert.equal(point.z, "zzz"); - Assert.equal(point.getS(), result); - Assert.equal(point.tool(), "tool"); - Assert.equal(point.work(), "work"); -}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_3.ts deleted file mode 100644 index def71989e3..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_3.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Since function and constructor types are just object types containing call and construct signatures, interfaces can - be used to declare named function and constructor types - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -{ - interface Example1 { - (h_a: string, h_b: string): number; - } - - let sc: Example1 = (h_a: string, h_b: string): number => { return h_a.charCodeAt(0) + h_b.charCodeAt(0); }; - Assert.equal(sc('a', 'b'), 195); -}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_1.ts deleted file mode 100644 index d1a8386819..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_1.ts +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - When a generic interface has multiple declarations, all declarations must have identical type parameter lists, - i.e. identical type parameter names with identical constraints in identical order. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -{ - interface Ds { - createE1(a: T): number; - } - - interface Ds { - createE2(a: T): number; - - createE3(a: T): number; - } - - let name: Ds = { - createE1(a: string): number { - return 0 - }, - createE2(a: boolean): number { - return 0 - }, - createE3(a: number): number { - return 0 - } - }; - let src :Ds = { - createE1(a: number): number { - return 1 - }, - createE2(a: number | string): number { - return 2; - }, - createE3(a: number | string): number { - return 3; - }, - } - - class Get { - static getName(name: Ds): Ds { - return name; - }; - static getSrc(src :Ds){ - return src; - } - } - - Assert.equal(Get.getSrc(src).createE1(1),1); - Assert.equal(Get.getSrc(src).createE2(""),2); - Assert.equal(Get.getName(src).createE3("233"), 3); - Assert.equal(Get.getName(name).createE1(''), 0); - Assert.equal(Get.getName(name).createE3(0), 0); - Assert.equal(Get.getName(name).createE2(true), 0); -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_2.ts deleted file mode 100644 index 90d5543f22..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_2.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - multiple declarations is equivalent to the following single declaration. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -{ - interface D1 { - createE1(a: string): number; - } - - interface D1 { - createE2(a: boolean): number; - - createE3(a: number): number; - } - - interface DAssert { - createE4(a: string): number; - - createE5(a: boolean): number; - - createE6(a: number): number; - } - - let name: D1 & DAssert = { - createE1(a: string): number { - return 0 - }, - createE2(a: boolean): number { - return 0 - }, - createE3(a: number): number { - return 0 - }, - createE4(a: string): number { - return 0 - }, - createE5(a: boolean): number { - return 0 - }, - createE6(a: number): number { - return 0 - } - }; - - class Class { - static getName(name: D1 & DAssert): D1 & DAssert { - return name; - } - } - - Assert.equal(Class.getName(name).createE1(''), 0); - Assert.equal(Class.getName(name).createE3(0), 0); - Assert.equal(Class.getName(name).createE2(true), 0); - Assert.equal(Class.getName(name).createE4(''), 0); - Assert.equal(Class.getName(name).createE5(true), 0); - Assert.equal(Class.getName(name).createE6(0), 0); -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_1.ts deleted file mode 100644 index 12887890b3..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_1.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - When an interface type extends a class type it inherits the members of the class but not their implementations. - It is as if the interface had declared all of the members of the class without providing an implementation. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -{ - class h_C { - private state: any = 0; - point: number | unknown = 0; - } - - interface h_SC extends h_C { - choose(): number; - } - - class h_B extends h_C implements h_SC { - choose(): number { - return 0 - } - } - - Assert.equal(new h_B().point,0); - Assert.equal(typeof new h_B().point,"number"); - Assert.isTrue(new h_B().hasOwnProperty('point')); - Assert.isTrue(new h_B().hasOwnProperty('state')); - -}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_2.ts deleted file mode 100644 index 584bb73ebe..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_2.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Interfaces inherit even the private and protected members of a base class. - When a class containing private or protected members is the base type of an interface type, - that interface type can only be implemented by that class or a descendant class. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class h_C { - private h_pri: string; - constructor(h_pri: string) { - this.h_pri = h_pri; - } - get() { - return this.h_pri; - } - set() { - this.h_pri = this.h_pri; - } -} -interface h_I extends h_C { - choose(): string; -} -class h_c extends h_C implements h_I { - choose(): string { - return 'choose'; - } -} -let h_CC = new h_C('private'); -Assert.equal(h_CC.get(), 'private'); -let h_cc = new h_c('PRIVATE'); -Assert.equal(h_cc.get(), 'PRIVATE'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/4_dynamic_type_checks/dynamic_type_checks_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/4_dynamic_type_checks/dynamic_type_checks_1.ts deleted file mode 100644 index 58eccbd620..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/4_dynamic_type_checks/dynamic_type_checks_1.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - TypeScript does not provide a direct mechanism for dynamically testing whether an object implements a particular - interface. Instead, TypeScript code can use the JavaScript technique of checking whether an appropriate set of members - are present on the object - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - - -interface WorkerTool { - shift(): void; - - rock(): void; - - getS(): void; -} - -function asWorkerTool(o: any): WorkerTool { - return o && o.shift && o.rock && o.getS ? o : null; -} - -let point: WorkerTool = { - getS(): void { - }, - rock(): void { - }, - shift(): void { - } -}; - -Assert.equal(asWorkerTool(point), point); -Assert.equal(typeof asWorkerTool(point),"object") \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_1.ts deleted file mode 100644 index 1b184061c8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_1.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -namespace outside { - var native = 1; - export var h_a = native; - export namespace interior { - export var h_x = 10; - } - export interface OA { - OA: string; - } -}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_2.ts deleted file mode 100644 index 249f43f4be..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_2.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -namespace outside { - var native = 2; - export var h_b = native; - export namespace interior { - export var h_y = 20; - } - export interface OB { - OB: number; - } -}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_3.ts deleted file mode 100644 index 40f5e04746..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_3.ts +++ /dev/null @@ -1,30 +0,0 @@ -/// -/// -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - namespaces are "open-ended" and namespace declarations with the same qualified name relative to a common root (as defined in section 2.3) contribute to a single namespace. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var o1: outside.OA = { OA: "OA" }; -var o2: outside.OB = { OB: 1024 }; -Assert.isString(o1.OA); -Assert.isNumber(o2.OB); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_2.ts deleted file mode 100644 index d75e35c37e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_2.ts +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - declaration merging also extends to namespace declarations with the same qualified name relative to a common root as a function, class, or enum declaration. - when merging a non-ambient function or class declaration and a non-ambient namespace declaration, the function or class declaration must be located prior to the namespace declaration in the same source file. - this ensures that the shared object instance is created as a function object. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface Point { - x: number; - y: number; -} -function Point(x: number, y: number): Point { - return { x: x, y: y }; -} -namespace Point { - export var origin = Point(0, 0); - export function equals(p1: Point, p2: Point) { - return p1.x == p2.x && p1.y == p2.y; - } -} -var p1 = Point(0, 0); -var p2 = Point.origin; -var b = Point.equals(p1, p2); -Assert.equal(p1.x, 0); -Assert.equal(p1.y, 0); -Assert.equal(p2.x, 0); -Assert.equal(p2.y, 0); -Assert.equal(b, true); - -enum Color { - Red = 0xFF0000, - Green = 0x00FF00, - Blue = 0x0000FF, -} -namespace Color { - export interface Color { - Red: number; - Green: number; - Blue: number; - } -} -Assert.equal(Color.Red, 0xFF0000); -var color: Color.Color = { Red: 255, Green: 255, Blue: 255 }; -Assert.equal(color.Green, 255); - -class PointXYZ { - public x: number; - public y: number; - public z: number; - constructor(x: number = 0, y: number = 0, z: number = 0) { - this.x = x; - this.y = y; - this.z = z; - } - toString() { - return "( " + this.x + " , " + this.y + " , " + this.z + " )"; - } -} -namespace PointXYZ { - export var xyz = new PointXYZ(1, 1, 1); - export interface PointXYZ { - x: number; - y: number; - z: number; - } -} -var xyz1 = new PointXYZ(1, 3, 5); -var xyz2: PointXYZ.PointXYZ = { x: 2, y: 3, z: 4 }; -var xyz3 = PointXYZ.xyz; -Assert.equal(xyz1.toString(), "( 1 , 3 , 5 )"); -Assert.equal(xyz2.x, 2); -Assert.equal(xyz3.toString(), "( 1 , 1 , 1 )"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_1.ts deleted file mode 100644 index 8f240e609d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_1.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - an export declaration declares an externally accessible namespace member. An export declaration is simply a regular declaration prefixed with the keyword export. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -namespace ED1 { - export interface Weapon { WName: string, Damage: number } - export var def = 1024; -} -var weapon1: ED1.Weapon = { WName: "40mmAT", Damage: 40 }; -var def1 = ED1.def; -Assert.equal(weapon1.WName, "40mmAT"); -Assert.equal(weapon1.Damage, 40); -Assert.equal(def1, 1024); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_2.ts deleted file mode 100644 index 1ad82d5e7d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_2.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the members of a namespace's export declaration space constitute the namespace's export member set. - a namespace's instance type is an object type with a property for each member in the namespace's export member set that denotes a value. - module: ESNext - isCurrent: true - ---*/ - -import { Assert } from '../../../../suite/assert.js' - - -namespace ED2 { - export var def = 1024; - interface Weapon { WName: string, Damage: number } - export var weapon1: Weapon = { WName: "Lightting", Damage: 200 } - export var tf = "False"; -} -var ed2 = ED2; -var ed2_1 = ed2.def; -var ed2_2 = ed2.weapon1; -var ed2_3 = ed2.tf; -Assert.equal(typeof ed2, "object"); -Assert.isNumber(ed2_1); -Assert.equal(typeof ed2_2, "object"); -Assert.isString(ed2_3); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_3.ts deleted file mode 100644 index bea69bcc1b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_3.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - an exported member depends on a (possibly empty) set of named types. Those named types must be at least as accessible as the exported member, or otherwise an error occurs. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface WeaponDamage { DamageType: string, Damage: number } -namespace ED3 { - export interface WeaponData { WName: string, ROT: number, Range: number } - export interface Weapon { WeaponDamage: WeaponDamage, WeaponData: WeaponData } - export function getWeapon(Weapon: Weapon) { - return "WeaponName = " + Weapon.WeaponData.WName + "\n" + "DamageType = " + Weapon.WeaponDamage.DamageType + "\n" + "Damage = " + Weapon.WeaponDamage.Damage + "\n" + "ROT = " + Weapon.WeaponData.ROT + "\n" + "Range = " + Weapon.WeaponData.Range; - } -} -var weapon_damage: WeaponDamage = { DamageType: "EXPLODE", Damage: 1024 }; -var weapon_data: ED3.WeaponData = { WName: "AntiTankMissiles", ROT: 75, Range: 16 }; -var weapon: ED3.Weapon = { WeaponData: weapon_data, WeaponDamage: weapon_damage }; -var weaponStr = ED3.getWeapon(weapon); -Assert.isString(weaponStr); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/import_alias_declarations/import_alias_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/import_alias_declarations/import_alias_declarations_1.ts deleted file mode 100644 index 41e5d6172e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/import_alias_declarations/import_alias_declarations_1.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - import alias declarations are used to create local aliases for entities in other namespaces. - an EntityName consisting of a single identifier is resolved as a NamespaceName and is thus required to reference a namespace. The resulting local alias references the given namespace and is itself classified as a namespace. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -namespace hB { - interface hA { hn: number } - export import hY = hA; - import hZ = hA.hX; - export var vb: hZ = { hs: "v" }; -} -namespace hA { - export interface hX { hs: string } - export import va = hB.vb; -} -var v1: hB.hY.hX = hB.vb; -var v2 = hA.va; -let iadFlag: boolean = false; -if (v1 == v2) { - iadFlag = true; -} -Assert.isTrue(iadFlag); - diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/import_alias_declarations/import_alias_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/import_alias_declarations/import_alias_declarations_3.ts deleted file mode 100644 index dc177e8eaa..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/import_alias_declarations/import_alias_declarations_3.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - when an import statement includes an export modifier, all meanings of the local alias are exported. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../../suite/assert.js"; - -namespace IAD1 { - export var lv: number = 5; - export interface GGI { - UIName: string; - Cost: number; - } -} -namespace IAD2 { - import I1 = IAD1; - import I2 = IAD1.GGI; - export var i2 = I1.lv * 2; - export interface GI extends I2 { - Strength: number; - } -} -var i1 = IAD2.i2; -var gi: IAD2.GI = { UIName: "GI", Cost: 200, Strength: 100 }; -Assert.equal(i1, 10); -Assert.equal(gi.UIName, "GI"); -Assert.equal(gi.Cost, 200); -Assert.equal(gi.Strength, 100); - -namespace IAD3 { - export var i = 0; - interface U { - times: number; - } - var u1: U = { times: 5 }; - export function ux5() { - return u1.times * 5; - } -} -export namespace IAD4 { - export import I3 = IAD3; -} -Assert.equal(IAD4.I3.i, 0); -Assert.equal(IAD4.I3.ux5(), 25); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_body/namespace_body.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_body/namespace_body.ts deleted file mode 100644 index 34ad1291b8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_body/namespace_body.ts +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the body of a namespace corresponds to a function that is executed once to initialize the namespace instance. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -namespace Example { - var namespace_name = "Example"; - export function exampleName(str: string): string { - return str + " " + namespace_name; - } - class Point { - x: number = 0; - y: number = 0; - } - interface PointXYZ { - x: number; - y: number; - z: number; - } - type StrNumBool = string | number | boolean; - export enum Color { - RED = 0xFF0000, - GREEN = 0x00FF00, - BLUE = 0x0000FF, - } - namespace SubNamespace { } - declare var __TEST__: boolean; - import EE = ExportExample; -} -namespace ExportExample { - export var namespace_name = "ExportExample"; - export function exampleEName(str: string): string { - return str + " " + namespace_name; - } - export class Point { - x: number = 0; - y: number = 0; - } - export interface PointXYZ { - x: number; - y: number; - z: number; - } - export type StrNumBool = string | number | boolean; - export enum Color { - RED = 0xFF0000, - GREEN = 0x00FF00, - BLUE = 0x0000FF, - } - export namespace SubNamespace { } - export declare var __TEST__: boolean; - export import E = Example; -} -Assert.equal(Example.exampleName("G"), "G Example"); -Assert.equal(Example.Color.RED, 0xFF0000); -Assert.equal(ExportExample.exampleEName("G"), "G ExportExample"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_1.ts deleted file mode 100644 index 47588be5e2..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_1.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - namespaces are declared using the namespace keyword, - but for backward compatibility of earlier versions of TypeScript a module keyword can also be used. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -namespace A { - export interface TA { - TName: string; - Ver: number; - } -} -var varA: A.TA = { TName: "TA", Ver: 1.5 } -Assert.equal(varA.TName, "TA"); -Assert.equal(varA.Ver, 1.5); - -module B { - export interface TB { - SkillName: string; - Damage: number; - } -} -var varB: B.TB = { SkillName: "OverKill", Damage: 1024 }; -Assert.equal(varB.SkillName, "OverKill"); -Assert.equal(varB.Damage, 1024); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_2.ts deleted file mode 100644 index eef814ca13..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_2.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - namespaces are either instantiated or non-instantiated. A non-instantiated namespace is a namespace containing only interface types, type aliases, and other non-instantiated namespace. - an instantiated namespace is a namespace that doesn't meet this definition. In intuitive terms, an instantiated namespace is one for which a namespace instance is created, whereas a non-instantiated namespace is one for which no code is generated. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -namespace NonInstantiated { - export interface A { - TName: string; - Ver: number; - } - export type TF = boolean | number; - export namespace NI { - export interface B { - SkillName: string; - Damage: number; - } - export type StrNum = string | number; - } -} -var ni1: NonInstantiated.A = { TName: "Non", Ver: 1.0 }; -var ni2: NonInstantiated.NI.StrNum = "ni2"; -Assert.equal(ni1.Ver, 1.0); -Assert.equal(ni2, "ni2"); - -namespace Instantiated { - export function returnName() { - return "Instantiated"; - } - export var nsname: string = "Instantiated"; -} -Assert.equal(Instantiated.returnName(), "Instantiated"); -Assert.equal(Instantiated.nsname, "Instantiated"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_3.ts deleted file mode 100644 index ba7781ad29..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_3.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - when a namespace identifier is referenced as a NamespaceName it denotes a container of namespace and type names, and when a namespace identifier is referenced as a PrimaryExpression it denotes the singleton namespace instance. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -namespace A { - export interface TypeA { - AName: string; - Lv: number; - UID: number; - } - export var player: TypeA = { AName: "Player", Lv: 5, UID: 0x0000A0F0 }; - export var playerRandom: TypeA = { AName: "playerRandom", Lv: getRandomNumber(99), UID: getRandomNumber(0xFFFFFFFF) }; - function getRandomNumber(x: number): number { - return Math.floor(Math.random() * x); - } -} -var playerA = A.player; -var playerB = A.playerRandom; -var an = A; -var playerC: A.TypeA = { AName: "PlayerC", Lv: 95, UID: 6250 }; -var playerD = an.player; -Assert.equal(playerA.AName, "Player"); -Assert.equal(playerA.Lv, 5); -Assert.equal(playerA.UID, 41200); -Assert.equal(playerB.AName, "playerRandom"); -Assert.isNumber(playerB.Lv); -Assert.isNumber(playerB.UID); -Assert.equal(playerC.AName, "PlayerC"); -Assert.equal(playerC.Lv, 95); -Assert.equal(playerC.UID, 6250); -Assert.equal(playerD.AName, "Player"); -Assert.equal(playerD.Lv, 5); -Assert.equal(playerD.UID, 41200); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_4.ts deleted file mode 100644 index c2c09e42be..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_4.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - a namespace declaration that specifies an IdentifierPath with more than one identifier is equivalent to a series of nested single-identifier namespace declarations where all but the outermost are automatically exported. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -namespace h_A.h_B.h_C { - export var h_x = "This is equivalent to the code below."; -} -Assert.equal(h_A.h_B.h_C.h_x, "This is equivalent to the code below."); -namespace h_A { - export namespace h_B { - export namespace h_C { - export var h_x = "This is equivalent to the code above."; - } - } -} -Assert.equal(h_A.h_B.h_C.h_x, "This is equivalent to the code above."); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_00.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_00.ts deleted file mode 100644 index 4c22da7bc1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_00.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -type Color = [number, number, number]; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_files_dependencies.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_files_dependencies.ts deleted file mode 100644 index 257831a87f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_files_dependencies.ts +++ /dev/null @@ -1,28 +0,0 @@ -/// -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The TypeScript compiler automatically determines a source file's dependencies and includes those dependencies in the program being compiled. - Any files included as dependencies in turn have their references analyzed in a transitive manner until all dependencies have been determined. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../../../suite/assert.js"; - -let red: Color = [255, 0, 0]; -Assert.equal(JSON.stringify(red), '[255,0,0]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_1.ts deleted file mode 100644 index 9f6fb69cad..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_1.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -export function message():string { - return 'string'; -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_10.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_10.ts deleted file mode 100644 index fafe386049..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_10.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -export interface Point { x: number; y: number }; - -export function point(x: number, y: number): Point { - return { x, y }; -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_2.ts deleted file mode 100644 index 512c7b88a0..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_2.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -export let h_x: number = 0; -export let h_y: number = 1; -export let h_z: number = 2; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_3.ts deleted file mode 100644 index 1f005b1ecb..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_3.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -let x:number = 0; -export default x; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_4.ts deleted file mode 100644 index 15a51b3ab1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_4.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -export default function message():string { - return 'string'; -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_5.ts deleted file mode 100644 index 7bb278e263..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_5.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -function message():string { - return 'string'; -} - -export default message; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_6.ts deleted file mode 100644 index 0ad23bd163..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_6.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -function message():string { - return 'string'; -} - -export { message as default }; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_7.ts deleted file mode 100644 index fab5d937f6..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_7.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -function message():string { - return 'string'; -} - -interface message { - x: number; - y: number; -} - - -export default message; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_8.ts deleted file mode 100644 index 5f1327d564..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_8.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -export default 'hello'; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_9.ts deleted file mode 100644 index 899278f98f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_9.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -class Point { - public x: number; - public y: number; - constructor(a: number, b: number) { - this.x = a; - this.y = b; - } -} -export default Point; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/2_modules/modules_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/2_modules/modules_1.ts deleted file mode 100644 index 03406a4a93..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/2_modules/modules_1.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - An interface declaration declares an interface type. - An InterfaceDeclaration introduces a named type (section 3.7) in the containing declaration space. - The BindingIdentifier of an interface declaration may not be one of the predefined type names (section 3.8.1). - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' -import { message } from '../1_programs_and_source_files/source_1.js'; - -Assert.equal(message(), 'string'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_1.ts deleted file mode 100644 index 482d3537e4..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_1.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Import declarations are used to import entities from other modules and provide bindings for them in the current module. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' -import * as h_m from '../1_programs_and_source_files/source_2.js'; - -Assert.equal(h_m.h_x, 0); -Assert.equal(h_m.h_y, 1); -Assert.equal(h_m.h_z, 2); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_2.ts deleted file mode 100644 index 2fe3642b6b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_2.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - imports the module with the given name and creates a local binding for the module itself. The local binding is - classified as a value (representing the module instance) and a namespace (representing a container of types and - namespaces). - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' -import { h_x, h_y, h_z } from '../1_programs_and_source_files/source_2.js'; - -Assert.equal(h_x, 0); -Assert.equal(h_y, 1); -Assert.equal(h_z, 2); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_3.ts deleted file mode 100644 index b444779c3c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_3.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - imports a given module and creates local bindings for a specified list of exported members of the module. The specified - names must each reference an entity in the export member set (11.3.4.4) of the given module. The local bindings have t - he same names and classifications as the entities they represent unless as clauses are used to that specify different - local names. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' -import { h_x as a, h_y as b, h_z as c } from '../1_programs_and_source_files/source_2.js'; - -Assert.equal(a, 0); -Assert.equal(b, 1); -Assert.equal(c, 2); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_4.ts deleted file mode 100644 index 11c402ebe2..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_4.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - imports a given module and creates local bindings for a specified list of exported members of the module. The specified - names must each reference an entity in the export member set (11.3.4.4) of the given module. The local bindings have t - he same names and classifications as the entities they represent unless as clauses are used to that specify different - local names. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' -import x from '../1_programs_and_source_files/source_3.js'; -import { default as a } from '../1_programs_and_source_files/source_3.js'; - -Assert.equal(x, 0); -Assert.equal(a, 0); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/4_import_require_declarations/import_require_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/4_import_require_declarations/import_require_declarations_1.ts deleted file mode 100644 index 574384e19f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/4_import_require_declarations/import_require_declarations_1.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Import require declarations exist for backward compatibility with earlier versions of TypeScript. - An import require declaration of the form - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' -import * as m from "../1_programs_and_source_files/source_2.js" - -Assert.equal(m.h_x, 0); -Assert.equal(m.h_y, 1); -Assert.equal(m.h_z, 2); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_1.ts deleted file mode 100644 index 4cf7bf66f1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_1.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Export default declarations provide short-hand syntax for exporting an entity named default. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' -import message from '../1_programs_and_source_files/source_4.js'; - -Assert.equal(message(), 'string'); - diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_2.ts deleted file mode 100644 index 88e2c6d8c2..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_2.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Export default declarations provide short-hand syntax for exporting an entity named default. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' -import message from '../1_programs_and_source_files/source_5.js'; - -Assert.equal(message(), 'string'); - diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_3.ts deleted file mode 100644 index fc93b8382d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_3.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Export default declarations provide short-hand syntax for exporting an entity named default. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' -import message from '../1_programs_and_source_files/source_6.js'; - -Assert.equal(message(), 'string'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_4.ts deleted file mode 100644 index aaa19b5480..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_4.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Export default declarations provide short-hand syntax for exporting an entity named default. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' -import message from '../1_programs_and_source_files/source_7.js'; - -Assert.equal(message(), 'string'); - diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_5.ts deleted file mode 100644 index c214a7f21f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_5.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Export default declarations provide short-hand syntax for exporting an entity named default. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' -import message from '../1_programs_and_source_files/source_8.js'; - -Assert.equal(message, 'hello'); - diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/6_export_assignments/export_assignments_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/6_export_assignments/export_assignments_1.ts deleted file mode 100644 index c7b3dee269..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/6_export_assignments/export_assignments_1.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Export assignments exist for backward compatibility with earlier versions of TypeScript. An export assignment - designates a module member as the entity to be exported in place of the module itself. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' -import Pt from '../1_programs_and_source_files/source_9.js'; - -let point = new Pt(10, 20); -Assert.equal(point.x, 10); -Assert.equal(point.y, 20); - diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_1.ts deleted file mode 100644 index c386db17ba..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_1.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A variable declaration and 'require' call is emitted for a particular imported module only if the imported module, or - a local alias that references the imported module, is referenced as a PrimaryExpression somewhere in the body of the - importing module. If an imported module is referenced only as a NamespaceName or TypeQueryExpression,nothing is emitted. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' -import * as g from '../1_programs_and_source_files/source_10.js'; - -let p = g.point(10, 20); -Assert.equal(p.x, 10); -Assert.equal(p.y, 20); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_2.ts deleted file mode 100644 index c6efd439a1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_2.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A variable declaration and 'require' call is emitted for a particular imported module only if the imported module, or - a local alias that references the imported module, is referenced as a PrimaryExpression somewhere in the body of the - importing module. If an imported module is referenced only as a NamespaceName or TypeQueryExpression,nothing is emitted. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' -import * as g from '../1_programs_and_source_files/source_10.js'; - -let p: g.Point = { x: 10, y: 20 }; -Assert.equal(p.x, 10); -Assert.equal(p.y, 20); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_1.ts deleted file mode 100644 index 9c29f77149..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_1.ts +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: Expressions controlling 'if' statements can be of any type (and not just type Boolean). - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../../suite/assert.js' - -let a = true; - -if (a) { - a = false; -} - -Assert.isFalse(a); - -let b = "string b"; -if (b) { - b = "string b 2"; -} -Assert.equal("string b 2", b); - -let c = 1; -if (c) { - c = 2 -} -Assert.equal(2, c); - -var myObject = { - d: 4 -} -if (myObject) { - myObject.d = 5; -} -Assert.equal(5, myObject.d); - -let myObject2 = 1; -if (myObject2 == 2) { - myObject2 = 3; -} -Assert.equal(1, myObject2); - -let und: undefined; -let flag = false; -if (und) { - flag = true; -} else { - flag = false; -} -Assert.isFalse(flag); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_2.ts deleted file mode 100644 index b81710a25c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_2.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: Expressions controlling 'Do' statements can be of any type (and not just type Boolean). - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../../suite/assert.js' - -var num = 1; -do { - if (num % 5 == 0) { - - break; - } - num++; -} while (num); -Assert.equal(5, num); - -do { - num++; -} while (num < 100); - -Assert.equal(100, num); - - -var myObject = { - d: 1, -} -do { - if (myObject.d % 5 == 0) { - - break; - } - myObject.d++; -} while (myObject); -Assert.equal(5, myObject.d); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_1.ts deleted file mode 100644 index 2139e475db..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_1.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: Blocks are extended to include, local interface - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface BlocksInterface { - name: string; -} -class MyBlocks implements BlocksInterface { - name: string; - - constructor(name: string) { - this.name = name; - } - - public getName() { - return this.name; - } - -} -var myBlocks = new MyBlocks("Open Harmony"); - -Assert.equal("Open Harmony", myBlocks.getName()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_2.ts deleted file mode 100644 index 3f5e8ed75b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_2.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: Blocks are extended to include, type alias - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../../suite/assert.js' - -type Parent = { - name: string; -}; - -type Child = Parent & { - age: number -}; - - -const child: Child = { name: "name", age: 10 }; - -Assert.equal("name", child.name) -Assert.equal(10, child.age); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_3.ts deleted file mode 100644 index 803c7cab14..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_3.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: Blocks are extended to include, enum - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../../suite/assert.js' - -enum Direction { - Forward, - Back, - Left, - Right, -} - -class Car { - name!: string; - direction!: Direction; -} - -const car = new Car(); -car.name = "myCar"; -car.direction = Direction.Forward; - -Assert.equal("myCar", car.name) -Assert.equal(Direction.Forward, car.direction); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_4.ts deleted file mode 100644 index a884aa1e6c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_4.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: Blocks {} - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../../suite/assert.js' - -{ - var block1: number | undefined = 1024; - let block2: string | undefined = "NARC"; - Assert.equal(block1, 1024); - Assert.equal(block2, "NARC"); -} -{ - var block1: number | undefined; - let block2: string | undefined; - Assert.equal(block1, 1024); - Assert.isUndefined(block2); -} \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/break_statements/break_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/break_statements/break_statements.ts deleted file mode 100644 index e9b559590c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/break_statements/break_statements.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: A 'break' statement is required to be nested, directly or indirectly (but not crossing function boundaries), within an iteration ('do', 'while', 'for', or 'for-in') or 'switch' statement. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../../suite/assert.js' - -let num: number = 0; -let count: number = 0; -do { - num++; - if (num >= 5) { - break; - } -} while (num < 10); -Assert.equal(5, num); - - -num = 0; -for (num = 0; num <= 20; num++) { - if (num >= 5) { - break; - } -} -Assert.equal(5, num); - -let arr = [0, 1, 2, 3, 4, 5]; -for (let index in arr) { - if (arr[index] >= 2) { - break; - } - count++; -} -Assert.equal(2, count); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/continue_statements/continue_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/continue_statements/continue_statements.ts deleted file mode 100644 index 95dc3b4011..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/continue_statements/continue_statements.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: A 'continue' statement is required to be nested, directly or indirectly (but not crossing function boundaries), within an iteration ('do', 'while', 'for', or 'for-in') statement. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../../suite/assert.js' - -let num: number = 0; -let count: number = 0; -do { - num++; - if (num % 2 == 0) { - continue; - } - count++; -} while (num < 10); -Assert.equal(5, count); - - -num = 0; -count = 0; -for (num = 0; num <= 20; num++) { - if (num % 2 == 0) { - continue; - } - count++; -} -Assert.equal(10, count); - -count = 0; -let arr = [0, 1, 2, 3, 4, 5]; -for (let index in arr) { - if (arr[index] % 2 == 0) { - continue; - } - count++; -} -Assert.equal(3, count); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_in_statements/for_in_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_in_statements/for_in_statements.ts deleted file mode 100644 index 45124ed810..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_in_statements/for_in_statements.ts +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: test for (v in expr) statement - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../../suite/assert.js' - -let arr = [4, 5, 6]; - -let i = 0; -for (let index in arr) { - i++; -} -Assert.equal(3, i); - -const person = { - name: "opharmony", - role: "tools", - age: 3, -}; - -i = 0; -for (const key in person) { - i++; -} -Assert.equal(3, i); - -interface ABC { - a: number - b: string -} - -const x: ABC = { - a: 1, - b: '2' -} - -i = 0; -for (let key in x) { - i++; -} -Assert.equal(2, i); - -i = 0; -for (var key in x) { - i++; -} -Assert.equal(2, i); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_of_statements/for_of_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_of_statements/for_of_statements.ts deleted file mode 100644 index 774a0bd61a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_of_statements/for_of_statements.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: test for (v of expr) statement - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../../suite/assert.js' - -let count = 0; -for (let word of ["one", "two", "three"]) { - count++; -} -Assert.equal(3, count); - -count = 0; -let s = [0, 1, 2, 3, 4]; -for (let value of s) { - count++; -} -Assert.equal(5, count); - -count = 0; -let blogName: string = "openHarmony"; -for (let character of blogName) { - count++; -} -Assert.equal(11, count); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_statements/for_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_statements/for_statements.ts deleted file mode 100644 index 1205fd4b4a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_statements/for_statements.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: Variable declarations in 'for' statements are extended in the same manner as variable declarations in variable statements - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../../suite/assert.js' - -let result = 0; -for (let i: number = 0; i < 10; i++) { - result++; -} - -Assert.equal(10, result); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/let_and_const_declarations/let_and_const_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/let_and_const_declarations/let_and_const_declarations.ts deleted file mode 100644 index 82a9d8a39a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/let_and_const_declarations/let_and_const_declarations.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: Let and Const Declarations - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../../suite/assert.js' - -let a = 1; -Assert.equal(1, a); - -a = 2; -Assert.equal(2, a); - -const num = 9; -Assert.equal(9, num); - -const myname = 'openharmony'; -Assert.equal('openharmony', myname); - -const myBoolean = true; -Assert.isTrue(myBoolean); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/return_statements/return_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/return_statements/return_statements.ts deleted file mode 100644 index 015db368af..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/return_statements/return_statements.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: Return Statements - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../../suite/assert.js' - -function h_f(): (h_x: string) => number { - return h_s => h_s.length; -} - -Assert.equal(11, h_f()("openharmony")); - -function testReruen() { - for (let i = 0; i < 10; i++) { - - if (i == 5) { - return i; - } - } -} -Assert.equal(5, testReruen()); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/switch_statements/switch_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/switch_statements/switch_statements.ts deleted file mode 100644 index 5cd194a4b5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/switch_statements/switch_statements.ts +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from (section 3.11.4) the type of the 'switch' expression - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../../suite/assert.js' - -function testSwitch(inputVar: number) { - let outputVar: string; - switch (inputVar) { - case 1: - outputVar = 'a'; - break; - case 2: - outputVar = 'b'; - break; - case 3: - outputVar = 'c'; - break; - case 4: - outputVar = 'd'; - break; - default: - outputVar = 'e'; - break; - } - return outputVar; -} - -Assert.equal("a", testSwitch(1)); -Assert.equal("b", testSwitch(2)); -Assert.equal("c", testSwitch(3)); -Assert.equal("d", testSwitch(4)); -Assert.equal("e", testSwitch(5)); - -function testSwitchExpression(x: number, y: number) { - let outputVar: string; - switch (x + y) { - case 0: - outputVar = 'a'; - break; - case 5: - outputVar = 'b'; - break; - case 10: - outputVar = 'c'; - break; - - default: - outputVar = 'd'; - } - return outputVar; -} - -Assert.equal("a", testSwitchExpression(-1, 1)); -Assert.equal("b", testSwitchExpression(1, 4)); -Assert.equal("c", testSwitchExpression(5, 5)); -Assert.equal("d", testSwitchExpression(8, 10)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/throw_statements/throw_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/throw_statements/throw_statements.ts deleted file mode 100644 index 8af0522974..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/throw_statements/throw_statements.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The expression specified in a 'throw' statement can be of any type. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../../suite/assert.js' - -function testThrow(inputVar: number) { - let outputVar: string; - if (inputVar == 1) { - throw 100; - } - - if (inputVar == 2) { - throw 'a'; - } - - if (inputVar == 3) { - throw true; - } - - if (inputVar == 4) { - throw new Error('Something bad happened'); - } -} - -try { - testThrow(1); -} catch (error) { - Assert.equal(100, error); -} - -try { - testThrow(2); -} catch (error) { - Assert.equal('a', error); -} - -try { - testThrow(3); -} catch (error) { - Assert.isTrue(error); -} - -try { - testThrow(4); -} catch (error: any) { - Assert.equal('Something bad happened', error.message); -} - -try { - testThrow(4); -} catch (error) { - Assert.isTrue(error instanceof Error); -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/try_statements/try_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/try_statements/try_statements.ts deleted file mode 100644 index 7b1e992e7c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/try_statements/try_statements.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The variable introduced by a 'catch' clause of a 'try' statement is always of type Any. It is not possible to include a type annotation in a 'catch' clause. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../../suite/assert.js' - -try { - new Array(100000000000000000000); -} -catch (err) { - Assert.isTrue(err instanceof RangeError); -} - -try { - let a: any; - let b = a.name; -} -catch (err) { - Assert.isTrue(err instanceof TypeError); -} - -try { - decodeURI('%'); -} -catch (err) { - Assert.isTrue(err instanceof URIError); -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_1.ts deleted file mode 100644 index 8eae01c6f4..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_1.ts +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The type T of a variable introduced by a simple variable declaration is determined as follows: - If the declaration includes a type annotation, T is that type. - Otherwise, if the declaration includes an initializer expression, T is the widened form (section 3.12) of the type of the initializer expression. - Otherwise, T is the Any type. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var h_a; - -var h_b: number; - -var h_c = 30; - -var h_d = { x: 40, y: "hello" }; - -var h_e: any = "test"; -h_a = 1; -Assert.equal(1, h_a); - -h_a = '111'; -Assert.equal('111', h_a); - -h_b = 20; -Assert.equal(20, h_b); - -Assert.equal(30, h_c); - -Assert.equal(40, h_d.x); -Assert.equal("hello", h_d.y); - -var h_x = 50; -Assert.equal(50, h_x); -var h_x: number; -Assert.equal(50, h_x); -if (h_x == 50) { - var h_x = 100; - Assert.equal(100, h_x); - - h_x = 200; - - Assert.equal(200, h_x); -} - -Assert.equal(200, h_x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_2.ts deleted file mode 100644 index a9501014d5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_2.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The type T of a variable introduced by a simple variable declaration is determined as follows: - If the declaration includes a type annotation, T is that type. - Otherwise, if the declaration includes an initializer expression, T is the widened form (section 3.12) of the type of the initializer expression. - Otherwise, T is the Any type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface Point { h_x: number; h_y: number; } - -var h_a = { h_x: 0, h_y: 1 }; -var h_b: Point = { h_x: 10, h_y: 11 }; -var h_c = { h_x: 100, h_y: 111 }; -var h_d: { h_x: number; h_y: number; } = { h_x: 1000, h_y: 1001 }; -var h_e = <{ h_x: number; h_y: number; }>{ h_x: 10000, h_y: 10001 }; - -Assert.equal(0, h_a.h_x); -Assert.equal(1, h_a.h_y); - -Assert.equal(10, h_b.h_x); -Assert.equal(11, h_b.h_y); - -Assert.equal(100, h_c.h_x); -Assert.equal(111, h_c.h_y); - -Assert.equal(1000, h_d.h_x); -Assert.equal(1001, h_d.h_y); - -Assert.equal(10000, h_e.h_x); -Assert.equal(10001, h_e.h_y); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_3.ts deleted file mode 100644 index 7ca8929aa8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_3.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Multiple declarations for the same variable name in the same declaration space are permitted, - provided that each declaration associates the same type with the variable. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var h_a: number = 10; -var h_a: number = 20; -Assert.equal(h_a, 20); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_1.ts deleted file mode 100644 index 1d676f3b08..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_1.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: A destructuring variable declaration introduces zero or more named variables and initializes them with values extracted from properties of an object - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var object_name = { - key1: "value1", - key2: "value2", - key3: ["content1", "content2"], - key4: true, - key5: undefined -} - -var { key1, key2: y, key3, key4: z = false, key5: k = true } = object_name; - -Assert.equal("value1", key1); -Assert.equal("value2", y); -Assert.equal("content1", key3[0]); -Assert.equal("content2", key3[1]); -Assert.isTrue(z); -Assert.isTrue(k); - - diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_2.ts deleted file mode 100644 index 79e1b11698..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_2.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The type T associated with a destructuring variable declaration is determined as follows: - If the declaration includes a type annotation, T is that type. - Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. - Otherwise, T is the Any type. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface IPerson { - myname: string, - myage: number, -} - -var customer: IPerson = { - myname: "Tom", - myage: 10, -} -let { myname, myage } = customer; - -Assert.isString(myname); -Assert.isNumber(myage) - - -let o = { - a: "foo", - b: 12, - c: "bar" -}; -let { a: newName1 } = o; -Assert.isString(newName1); -var ohArray: number[] = [10, 20, 30]; - -var [x, y, z = 10, k = 10] = ohArray; -Assert.equal(10, x); -Assert.equal(20, y); -Assert.equal(30, z); -Assert.equal(10, k); - diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_3.ts deleted file mode 100644 index ec75bc8e66..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_3.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The type T associated with a binding property is determined as follows: - Let S be the type associated with the immediately containing destructuring variable declaration, binding property, or binding element. - If S is the Any type: - If the binding property specifies an initializer expression, T is the type of that initializer expression. - Otherwise, T is the Any type. - Let P be the property name specified in the binding property. - If S has an apparent property with the name P, T is the type of that property. - Otherwise, if S has a numeric index signature and P is a numerical name, T is the type of the numeric index signature. - Otherwise, if S has a string index signature, T is the type of the string index signature. - Otherwise, no type is associated with the binding property and an error occurs. - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var object_name = { - key1: "value1", - key2: "value2", - key3: ["content1", "content2"], - key4: true, - key5: undefined -} - - -var ohArray: number[] = [10, 20, 30]; - -var { key1, key3: [y, z = 10, k = 10] = ohArray, key5: [a, b] = ohArray } = object_name; - -Assert.equal("value1", key1); -Assert.equal("content1", y); -Assert.equal("content2", z); -Assert.equal(10, k); -Assert.equal(10, a); -Assert.equal(20, b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/3_implied_type/implied_type.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/3_implied_type/implied_type.ts deleted file mode 100644 index 13157d9199..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/3_implied_type/implied_type.ts +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: A variable, parameter, binding property, or binding element declaration that specifies a binding pattern has an implied type which is determined - module: ESNext - isCurrent: true ----*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var object_name = { - key1: "value1" -} - -function f({ aa = {}, b = "hello", c = 3, d = object_name }) { - Assert.equal("object", typeof (aa)); - Assert.equal("string", typeof (b)); - Assert.equal("number", typeof (c)); - Assert.equal("object", typeof (d)); -} - -var objectFun = { - a: [1, 2], - b: "2", - c: 3, - d: object_name -}; -f(objectFun); - -var [a1, b1, c1, d1] = [1, "hello", true, object_name]; - -Assert.equal("number", typeof (a1)); -Assert.equal("string", typeof (b1)); -Assert.equal("boolean", typeof (c1)); -Assert.equal("object", typeof (d1)); - -function testRest(...restElements: any[]): any { - Assert.isTrue(restElements.length > 0); - return restElements[0]; -} - -Assert.isString(testRest("str", "str2")); -Assert.isNumber(testRest(1, 2)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/Intersection_Types/Intersection_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/Intersection_Types/Intersection_types_1.ts index c242e8d390..14ce4b4a98 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/Intersection_Types/Intersection_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/Intersection_Types/Intersection_types_1.ts @@ -75,4 +75,12 @@ interface YY { obj: B1; } let x5: XX & YY = { obj: x }; -Assert.equal(x5.obj.num1, 1); \ No newline at end of file +Assert.equal(x5.obj.num1, 1); +interface A5 { + x: number; +} +interface B5 { + x: number; +} +let x6: A5 & B5 = { x: 1 }; +Assert.equal(x6.x, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_1.ts index 5a70e7896c..b950b0e7b3 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_1.ts @@ -40,4 +40,31 @@ Assert.equal(arr3.length, 2); Assert.equal(arr2.pop(), 9); Assert.equal(arr2.toString(), "1,3,5,7"); arr3[0] = false; -Assert.equal(arr3[0], false); \ No newline at end of file +Assert.equal(arr3[0], false); +interface ArrayNumber { + [x: number]: number; +} +let arr5: ArrayNumber = arr2; +Assert.equal(arr5[0], 1); +Assert.equal(arr5[1], 3); +class ArrayString { + [x: number]: string; +} +let arr6: ArrayString = arr1; +Assert.equal(arr6[0], "ABC"); +Assert.equal(arr6[1], "DEF"); +type ArrayType = { + [x: number]: number; +} +let arr7: ArrayType = [1, 2, 3]; +Assert.equal(arr7[0], 1); +Assert.equal(arr7[1], 2); +let arr8: Object[]; +arr8 = [ + 111, + true, + "aaa" +]; +Assert.equal(arr8[0], 111); +Assert.equal(arr8[1], true); +Assert.equal(arr8[2], "aaa"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/function_types/function_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/function_types/function_types_2.ts index ff197f56a8..30c20b90ce 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/function_types/function_types_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/function_types/function_types_2.ts @@ -26,8 +26,8 @@ import { Assert } from '../../../../../suite/assert.js' function add(x: number, y: number): number { return x + y; } -let a = add(1, 2); +let a: number = add(1, 2); Assert.equal(a, 3); let add2 = function (x: number, y: number): number { return x + y; }; -let b = add2(3, 4); +let b: number = add2(3, 4); Assert.equal(b, 7); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_1.ts index b502ee44e1..7581d7f67e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_1.ts @@ -23,16 +23,39 @@ import { Assert } from '../../../../../suite/assert.js' -Assert.notEqual(0.1 + 0.2, 0.3); -Assert.notEqual(0.7 + 0.1, 0.8); -Assert.notEqual(0.2 + 0.4, 0.6); -Assert.notEqual(1.5 - 1.2, 0.3); -Assert.notEqual(0.3 - 0.2, 0.1); -Assert.notEqual(19.9 * 100, 1990); -Assert.notEqual(0.8 * 3, 2.4); -Assert.notEqual(35.41 * 100, 3541); -Assert.notEqual(0.3 / 0.1, 3); -Assert.notEqual(0.69 / 10, 0.069); +let x1: number; +let x2: number; +let x3: number; +x1 = 0.1; +x2 = 0.2; +x3 = 0.3; +Assert.notEqual(x1 + x2, 0.3); +x2 = 0.7; +Assert.notEqual(x1 + x2, 0.8); +x1 = 0.2; +x2 = 0.4; +Assert.notEqual(x1 + x2, 0.6); +x1 = 1.5; +x2 = 1.2; +Assert.notEqual(x1 - x2, 0.3); +x1 = 0.3; +x2 = 0.2; +Assert.notEqual(x1 - x2, 0.1); +x1 = 19.9; +x2 = 100; +Assert.notEqual(x1 * x2, 1990); +x1 = 0.8; +x2 = 3; +Assert.notEqual(x1 * x2, 2.4); +x1 = 35.41; +x2 = 100; +Assert.notEqual(x1 * x2, 3541); +x1 = 0.3; +x2 = 0.1; +Assert.notEqual(x1 / x2, 3); +x1 = 0.69; +x2 = 10; +Assert.notEqual(x1 / x2, 0.069); Assert.equal((1.335).toFixed(2), 1.33); Assert.equal((1.3335).toFixed(3), 1.333); Assert.equal((1.33335).toFixed(4), 1.3334); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_2.ts index 4d35a834a8..7db2d38356 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_2.ts @@ -51,4 +51,11 @@ Assert.isNumber(n5); Assert.equal(n5, 0xf00d); n5 = 0xf01c; Assert.isNumber(n5); -Assert.equal(n5, 0xf01c); \ No newline at end of file +Assert.equal(n5, 0xf01c); +let n6: 1 | 2 = 1; +let n7: number; +n7 = n6; +Assert.equal(n7, 1); +n6 = 2; +n7 = n6; +Assert.equal(n7, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_2.ts index d7f422dfab..89495faeb2 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_2.ts @@ -15,7 +15,6 @@ /**--- description: > the only possible values for the Void type are null and undefined. - the void type can be assigned a null value, but this is only allowed in non-strict mode. module: ESNext isCurrent: true ---*/ diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_1.ts index 6e62eb349b..81644f8a3d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_1.ts @@ -50,4 +50,38 @@ point2 = { x: 0, y: 0, z: 0 }; let pp2 = point2; Assert.equal(pp2.x, 0); Assert.equal(pp2.y, 0); -Assert.equal(pp2.z, 0); \ No newline at end of file +Assert.equal(pp2.z, 0); + +class B { + add(x: T, y: number): string; + add(x: string, y: U): string; + add(x: T, y: U): string; + add(x: T, y: U): string { + return x.toString() + y.toString(); + } +} +let b1 = new B(); +Assert.equal(b1.add(1, 2), '12'); +Assert.equal(b1.add("A", 2), 'A2'); +Assert.equal(b1.add("B", 3), 'B3'); +Assert.equal(b1.add(true, false), 'truefalse'); +b1.add = (x: string, y: U) => { return typeof x + typeof y; }; +Assert.equal(b1.add("B", 3), 'stringnumber'); + +class C { + add1?(x: number): string; + add2?(x: number, y: boolean): number | boolean; +} +let c1 = new C(); +c1.add1 = (x: number): string => { return (x * x).toString() } +Assert.equal(c1.add1(5), '25'); + +let c2 = new C(); +c2.add2 = (x: number, y: boolean) => { + if (y == true) { + return x; + } else { + return y; + } +} +Assert.equal(c2.add2(5, true), 5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_2.ts index 055430d639..23960d1795 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_2.ts @@ -43,7 +43,7 @@ class A { } } } -let a = new A(); -Assert.equal(a.add(1, 2), 3); -let b = new A(); -Assert.equal(b.add(1, 2, 3), 6); \ No newline at end of file +let a1 = new A(); +Assert.equal(a1.add(1, 2), 3); +let a2 = new A(); +Assert.equal(a2.add(1, 2, 3), 6); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_2.ts index 40a0c6b1b4..09108a4f63 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_2.ts @@ -22,7 +22,7 @@ import { Assert } from '../../../../../suite/assert.js' -let arr = ['s', 5, true]; +let arr: (string | number | boolean)[] = ['s', 5, true]; Assert.equal(arr[0], 's'); Assert.equal(arr[1], 5); Assert.equal(arr[2], true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/constructor_type_literals/constructor_type_literals.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/constructor_type_literals/constructor_type_literals.ts index 267b0dedb7..a7841149ff 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/constructor_type_literals/constructor_type_literals.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/constructor_type_literals/constructor_type_literals.ts @@ -39,13 +39,40 @@ class I2 implements I1 { this.y = y; } } -function fun( +function fun1( cons: Constructor, x: number, y: number ): I1 { return new cons(x, y); } -let x1: I1 = fun(I2, 2, 2) +let x1: I1 = fun1(I2, 2, 2) Assert.equal(x1.x, 2); -Assert.equal(x1.y, 2); \ No newline at end of file +Assert.equal(x1.y, 2); + +interface F1 { + x: T; + y: U; +} +interface ConstructorF { + new(x: T, y: U): F1; +} +class F2 implements F1 { + readonly x: T; + readonly y: U; + + constructor(x: T, y: U) { + this.x = x; + this.y = y; + } +} +function fun2( + cons: ConstructorF, + x: T, + y: U +): F1 { + return new cons(x, y); +} +let f1: F1 = fun2(F2, 1, true); +Assert.equal(f1.x, 1); +Assert.equal(f1.y, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/function_type_literals/function_type_literals_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/function_type_literals/function_type_literals_1.ts similarity index 100% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/function_type_literals/function_type_literals_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/function_type_literals/function_type_literals_1.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/function_type_literals/function_type_literals_2.ts similarity index 59% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/function_type_literals/function_type_literals_2.ts index 7030557db6..6f4840816b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/function_type_literals/function_type_literals_2.ts @@ -14,8 +14,7 @@ */ /**--- description: > - Given a type parameter T and set of candidate types, the actual inferred type argument is determined, - if the set of candidate argument types is empty, the inferred type argument for T is T's constraint. + A function type literal specifies the type parameters, regular parameters, and return type of a call signature. module: ESNext isCurrent: true ---*/ @@ -23,9 +22,19 @@ import { Assert } from '../../../../../suite/assert.js' -type t = number | string -function select(h_x: T, h_y: T): T { - return h_x < h_y ? h_x : h_y; +let fun1: (x: number, y: number) => number = + function (x: number, y: number): number { return x + y; }; +Assert.equal(fun1(1, 2), 3); +let fun2: Function = (x: number, y: number): boolean => { + return x > y ? true : false; } -var x = select(10, 20); -Assert.isNumber(x); \ No newline at end of file +Assert.equal(fun2(1, 2), false); +interface Func { + fun(x: string): string; +} +let fun3: Func = { + fun(x: string): string { + return x; + } +} +Assert.equal(fun3.fun("aa"), "aa"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/object_type_literals/object_type_literals.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/object_type_literals/object_type_literals.ts index 897b990a08..4c5de86e4b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/object_type_literals/object_type_literals.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/object_type_literals/object_type_literals.ts @@ -27,21 +27,51 @@ let obj: { num: number; str: string; boo: boolean; + fun: Function; } = { num: 5, str: 'str', - boo: true + boo: true, + fun(): number { + return 123; + } } Assert.equal(obj.num, 5); Assert.equal(obj.str, 'str'); Assert.equal(obj.boo, true); +Assert.equal(obj.fun(), 123); interface I { name: string, - age: number + age: number, + readonly id: number } let i: I = { name: 'xiao', - age: 18 + age: 18, + id: 111 } Assert.equal(i.name, 'xiao'); -Assert.equal(i.age, 18); \ No newline at end of file +Assert.equal(i.age, 18); +Assert.equal(i.id, 111); +interface I2 { + name: string, + [oname: string]: string; +} +let i2: I2 = { + name: "join", + gender: "male" +}; +Assert.equal(i2.name, "join"); +Assert.equal(i2.gender, "male"); +class Myclass { + x: number = 1; + y: string = "aa"; + constructor() { } + fun(): number { + return 11; + } +} +let obj2: Myclass = new Myclass() +Assert.equal(obj2.fun(), 11); +Assert.equal(obj2.x, 1); +Assert.equal(obj2.y, "aa"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/predefined_types/predefined_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/predefined_types/predefined_types.ts index 29f12aae67..fbf293ec2e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/predefined_types/predefined_types.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/predefined_types/predefined_types.ts @@ -33,4 +33,13 @@ let x3: string = 's'; Assert.equal(x3.toString(), "s"); let x4: symbol = Symbol(); -Assert.equal(x4.toString(), "Symbol()"); \ No newline at end of file +Assert.equal(x4.toString(), "Symbol()"); + +let x5: any; +x5 = 1; +x5 = "aa" +x5 = true; +Assert.equal(x5, true); + +let x6: void = undefined; +Assert.equal(x6, undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/this_type_references/this_type_references_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/this_type_references/this_type_references_1.ts index f46dffe594..83357c7630 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/this_type_references/this_type_references_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/this_type_references/this_type_references_1.ts @@ -14,9 +14,10 @@ */ /**--- description: > - The meaning of a ThisType depends on the closest enclosing FunctionDeclaration, - FunctionExpression, PropertyDefinition, ClassElement, or TypeMember, known as the root declaration of the ThisType, - when the root declaration is an instance member or constructor of a class, the ThisType references the this-type of that class. + The meaning of a ThisType depends on the closest enclosing FunctionDeclaration, FunctionExpression, PropertyDefinition, ClassElement, + or TypeMember, known as the root declaration of the ThisType. + When the root declaration is an instance member or constructor of a class, the ThisType references the this-type of that class. + When the root declaration is a member of an interface type, the ThisType references the this-type of that interface. Otherwise, the ThisType is an error. module: ESNext isCurrent: true ---*/ @@ -25,14 +26,45 @@ import { Assert } from '../../../../../suite/assert.js' class myClass { - num: number; - constructor(num: number) { - this.num = num; + x: number; + y: number; + xy() { + return this.x * this.y; } - getnu() { - return this.num; + m?: this; + constructor(x: number, y: number) { + this.x = x; + this.y = y; } } +let mc = new myClass(2, 5); +let mc0 = new myClass(1, 2); +mc.m = mc0; +Assert.equal(mc.m.x, 1); +Assert.equal(mc.m.xy(), 2); -let my_c = new myClass(10); -Assert.equal(my_c.getnu(), 10); \ No newline at end of file +type PType = { A: T, B: T }; +interface Point { + x: number; + y: number; + PAdd?(a: this, b: this): this; + PObj?(a: this, b: this): PType; +} +let p1: Point = { x: 1, y: 2 }; +let p2: Point = { x: 2, y: 1 }; +let pa: Point = { + x: 0, + y: 0, + PAdd(a: Point, b: Point): Point { + let p: Point = { x: a.x + b.x, y: a.y + b.y }; + return p; + }, + PObj(a: Point, b: Point): PType { + let p: PType = { A: a, B: b }; + return p; + } +} +let p3: Point = pa.PAdd!(p1, p2); +let po: PType = pa.PObj!(p1, p2); +Assert.equal(JSON.stringify(p3), '{"x":3,"y":3}'); +Assert.equal(JSON.stringify(po), '{"A":{"x":1,"y":2},"B":{"x":2,"y":1}}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/this_type_references/this_type_references_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/this_type_references/this_type_references_2.ts deleted file mode 100644 index 098a4a3ca6..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/this_type_references/this_type_references_2.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The meaning of a ThisType depends on the closest enclosing FunctionDeclaration, - FunctionExpression, PropertyDefinition, ClassElement, or TypeMember, known as the root declaration of the ThisType, - when the root declaration is a member of an interface type, the ThisType references the this-type of that interface. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface I { - name: string; - getN(this: I): string; -} -let i: I = { - name: 'xiao', - getN() { - return this.name; - } -} -Assert.equal(i.getN(), 'xiao'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_queries/type_queries_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_queries/type_queries_1.ts index aea0866fa1..b2d3b21886 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_queries/type_queries_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_queries/type_queries_1.ts @@ -14,8 +14,9 @@ */ /**--- description: > - A type query obtains the type of an expression. - A type query consists of the keyword typeof followed by an expression. + A type query obtains the type of an expression.A type query consists of the keyword typeof followed by an expression. + Type queries are useful for capturing anonymous types that are generated by letious constructs + such as object literals, function declarations, and namespace declarations. module: ESNext isCurrent: true ---*/ @@ -23,12 +24,28 @@ import { Assert } from '../../../../../suite/assert.js' -function func(obj: string | number): void { - if (typeof obj === 'string') { - Assert.isString(obj); - } else { - Assert.isNumber(obj); - } +let a1: { x: number, y: string }; +let a2: typeof a1; +a2 = { + x: 10, + y: 'y' } -func('obj'); -func(5); \ No newline at end of file +Assert.equal(typeof a2, 'object'); + +function b1(x: number, y: number): number { return x + y; } +let b2: typeof b1; +b2 = (x: number, y: number): number => { return x - y; } +Assert.equal(typeof b2, 'function'); + +namespace CC { + export type C = keyof number & string; +} +let c1: CC.C; +let c2: typeof c1 = 'toExponential'; +c2 = 'toString'; +c1 = c2; +Assert.equal(c1, c2); + +let c3: CC.C; +let c4: typeof c3[] = ['toExponential', 'toFixed', 'toLocaleString', 'toPrecision', 'toString', 'valueOf']; +Assert.equal(JSON.stringify(c4), '["toExponential","toFixed","toLocaleString","toPrecision","toString","valueOf"]'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_queries/type_queries_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_queries/type_queries_2.ts deleted file mode 100644 index a20eba8f6c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_queries/type_queries_2.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Type queries are useful for capturing anonymous types that are generated by letious constructs - such as object literals, function declarations, and namespace declarations. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let a: { x: number, y: string }; - -let b: typeof a; -b = { - x: 10, - y: 'y' -} -Assert.equal(typeof b, 'object'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_13.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_4.ts similarity index 51% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_13.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_4.ts index b7a6cd652f..8e0473c29b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_13.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_4.ts @@ -14,7 +14,7 @@ */ /**--- description: > - In a type assertion, the expression is contextually typed by the indicated type. + The Any type is a supertype of all types, and is assignable to and from all types. module: ESNext isCurrent: true ---*/ @@ -22,12 +22,41 @@ import { Assert } from '../../../../suite/assert.js' -interface Person { - name: string - age: number -} -let student = {} as Person -student.name = 'xiao' -student.age = 18 -Assert.isNumber(student.age) -Assert.isString(student.name); \ No newline at end of file +let x: any +let y1: number; +x = 1024; +y1 = x; +Assert.equal(y1, 1024) +let y2: string; +x = "AAA"; +y2 = x; +Assert.equal(y2.length, 3); +let y3: boolean; +x = true; +y3 = x; +Assert.equal(y3, true); +let y4: number[]; +x = [1, 2, 3]; +y4 = x; +Assert.equal(y4[0], 1); +let y5: string[]; +x = ["aa", "bb"]; +y5 = x; +Assert.equal(y5[0], "aa"); +let y6: Function; +x = (a: number, b: number) => { return a + b }; +y6 = x; +Assert.equal(y6(1, 2), 3); +let y7: symbol; +x = Symbol("aa"); +y7 = x; +Assert.equal(y7.toString(), "Symbol(aa)"); +let y8: object; +x = { + toString() { + return 123; + } +}; +y8 = x; +Assert.isObject(x); +Assert.equal(y8.toString(), 123) \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_3.ts index 35cbfafab4..d9e10e8b06 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_3.ts @@ -37,4 +37,10 @@ var mytest: MyType = { h_y: 'y', h_b: true } -Assert.isString(mytest.h_y); \ No newline at end of file +Assert.isString(mytest.h_y); + +type KeyOf = keyof T & keyof U; +let key1: KeyOf = 'toString'; +let key2: KeyOf = 'valueOf'; +Assert.equal(key1, 'toString'); +Assert.equal(key2, 'valueOf'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_1.ts index 594bfae855..8057eac966 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_1.ts @@ -20,14 +20,32 @@ ---*/ - import { Assert } from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' type T = any; type U = any; +type IsEqual = + (() => T1 extends TT ? 1 : 2) extends + (() => T2 extends UU ? 1 : 2) + ? true + : false + let a1: T = 10; let b1: U = 10; Assert.equal(typeof a1, typeof b1); let a2: T = 10; let b2: U = 10; -Assert.equal(typeof a2, typeof b2); \ No newline at end of file +Assert.equal(typeof a2, typeof b2); + +let isEqual: IsEqual = true; +Assert.isTrue(isEqual); + +let a3: T = 'a3'; +let b3: U = 1024; +a3 = b3; +Assert.equal(a3, b3); +a3 = 'A3'; +b3 = false; +b3 = a3; +Assert.equal(b3, a3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_2.ts index a46fc6fc97..0aae0021bc 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_2.ts @@ -21,10 +21,30 @@ import { Assert } from '../../../../../suite/assert.js' - + type T = number; type U = number; +type IsEqual = + (() => T1 extends TT ? 1 : 2) extends + (() => T2 extends UU ? 1 : 2) + ? true + : false + let a: T = 5; let b: U = 10; -Assert.equal(typeof a, typeof b); \ No newline at end of file +Assert.equal(typeof a, typeof b); + +let isEqual1: IsEqual = true; +let isEqual2: IsEqual = true; +Assert.equal(isEqual1, isEqual2); +Assert.isTrue(isEqual1); + +let a1: T = 1024; +let b1: U = 999; +a1 = b1; +Assert.equal(a1, b1); +a1 = 37; +b1 = 111; +b1 = a1; +Assert.equal(b1, a1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_4.ts index ae758273e6..4c40674016 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_4.ts @@ -25,6 +25,12 @@ import { Assert } from '../../../../../suite/assert.js' type T = number | string | boolean; type U = number | string | boolean; +type IsEqual = + (() => T1 extends TT ? 1 : 2) extends + (() => T2 extends UU ? 1 : 2) + ? true + : false + let a1: T = 10; let a2: U = 5; Assert.equal(typeof a1, typeof a2); @@ -33,4 +39,16 @@ let b2: U = '5'; Assert.equal(typeof b1, typeof b2); let c1: T = true; let c2: U = false; -Assert.equal(typeof c1, typeof c2); \ No newline at end of file +Assert.equal(typeof c1, typeof c2); + +let isEqual: IsEqual = true; +Assert.isTrue(isEqual); + +let d1: T = true; +let d2: U = 555; +d1 = d2; +Assert.equal(d1, d2); +d1 = 'd1'; +d2 = false; +d2 = d1; +Assert.equal(d2, d1); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_3.ts deleted file mode 100644 index 7a6dc44683..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_3.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The type inferred for an object literal is considered a fresh object literal type. - The freshness disappears when an object literal type is widened or is the type of the expression in a type assertion. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -const p: { x: number, y: number } = { x: 0, y: 0 } -Assert.equal(JSON.stringify(p), '{"x":0,"y":0}') - -const p1: { x: number } = { x: 0, y: 0 } as { x: 0, y: 0 } -Assert.equal(JSON.stringify(p1), '{"x":0,"y":0}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_14.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_14.ts deleted file mode 100644 index c54c0ff060..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_14.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - S is a subtype of a type T, and T is a supertype of S, - if S has no excess properties with respect to T, - and S is an object type, an intersection type, an enum type, or the Number, Boolean, or String primitive type, T is an object type, - and for each member M in T, M is a string index signature of type U, - and U is the Any type or S has an apparent string index signature of a type that is a subtype of U. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface T { - name: string -} -interface S { - name: string - age: number -} -interface U { - [name: string]: any -} -let x: T = { name: "aa" }; -Assert.equal(x.name, "aa"); -let y: S = { name: "aa", age: 11 }; -Assert.equal(y.name, "aa"); -Assert.equal(y.age, 11); -let obj: U = { name: "xiao", age: 18 } -Assert.equal(JSON.stringify(obj), '{"name":"xiao","age":18}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_15.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_15.ts deleted file mode 100644 index 8410f41593..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_15.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - S is a subtype of a type T, and T is a supertype of S, - if S has no excess properties with respect to T, - and S is an object type, an intersection type, an enum type, or the Number, Boolean, or String primitive type, T is an object type, - and for each member M in T, M is a numeric index signature of type U, - and U is the Any type or S has an apparent string or numeric index signature of a type that is a subtype of U. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface T { - age: number -} -interface S { - age: number - height: number -} -interface U { - [age: number]: any -} -let x: T = { age: 11 }; -Assert.equal(x.age, 11); -let y: S = { age: 11, height: 11 }; -Assert.equal(y.age, 11); -Assert.equal(y.height, 11); -let obj: U = {} -obj[5] = { age: 18, height: 180 } -Assert.equal(JSON.stringify(obj[5]), '{"age":18,"height":180}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_16.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_16.ts deleted file mode 100644 index f4d3f7382f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_16.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the only subtypes of a type parameter T are T itself and other type parameters that are directly or indirectly constrained to T. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -function getProperty(obj: T, key: K) { - return obj[key]; -} -let x = { a: 1, b: 2, c: 3, d: 4 }; -Assert.equal(getProperty(x, 'a'), 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_7.ts index 83312bb861..885163cdc9 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_7.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_7.ts @@ -21,7 +21,7 @@ ---*/ -import {Assert} from '../../../../suite/assert.js' +import { Assert } from '../../../../suite/assert.js' type numType = { num: number }; type strType = { str: string }; @@ -38,4 +38,22 @@ Assert.equal(typeof nsv, "object"); Assert.equal(typeof obv, "object"); Assert.equal(typeof nsobv_1, "object"); Assert.equal(typeof nsobv_2, "object"); -Assert.equal(typeof nsobv_3, "object"); \ No newline at end of file +Assert.equal(typeof nsobv_3, "object"); +interface T1 { + x: number, + y: string, + z: boolean +} +interface T2 { + x: string, + y: string, + z: string +} +let t1: T1 | T2 = { x: 1, y: "yy", z: true }; +Assert.equal(t1.x, 1); +Assert.equal(t1.y, "yy"); +Assert.equal(t1.z, true); +let t2: T1 | T2 = { x: "aa", y: "bb", z: "cc" }; +Assert.equal(t2.x, "aa"); +Assert.equal(t2.y, "bb"); +Assert.equal(t2.z, "cc"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/tool/testcfg.py b/es2panda/test/ts_extra_tests/tool/testcfg.py index 9be3546be2..87d7aaead9 100644 --- a/es2panda/test/ts_extra_tests/tool/testcfg.py +++ b/es2panda/test/ts_extra_tests/tool/testcfg.py @@ -22,6 +22,8 @@ from tool.test_helper import read_declaration STRICT_OFF = ['--strict', 'false'] STRICT_ON = ['--strict', 'true'] MODULE = ['--module'] +Decorator = ['--experimentalDecorators'] +strictNullChecks = ['--strictNullChecks'] def get_error_message(str, filename): if len(re.findall(filename + r':(\d+)', str)) > 0: @@ -76,6 +78,14 @@ class TestCase(): if 'isCurrent' in self.declaration: return True return False + def experimentalDecorators(self): + if 'experimentalDecorators' in self.declaration: + return True + return False + def nullChecks(self): + if 'strictNullChecks' in self.declaration: + return True + return False def is_set_module(self): if 'module' in self.declaration: return True @@ -113,6 +123,12 @@ class TestCase(): if self.is_set_module(): cmd.extend(MODULE) cmd.append('es2020') + if self.experimentalDecorators(): + cmd.extend(Decorator) + cmd.append('true') + if self.nullChecks(): + cmd.extend(strictNullChecks) + cmd.append('false') if self.is_current(): cmd.append(self.path) cmd.append('--outDir') -- Gitee From 13483a647e8217dc83d630350f849e7e6b57c265 Mon Sep 17 00:00:00 2001 From: tanglizhen Date: Tue, 18 Jul 2023 16:31:44 +0800 Subject: [PATCH 14/18] Ts test cases --types Signed-off-by: tanglizhen --- es2panda/test/ts_extra_tests/run_ts_case.py | 31 +++++----- es2panda/test/ts_extra_tests/tool/testcfg.py | 59 ++++++++++++-------- 2 files changed, 53 insertions(+), 37 deletions(-) diff --git a/es2panda/test/ts_extra_tests/run_ts_case.py b/es2panda/test/ts_extra_tests/run_ts_case.py index 28dc55b3e2..737bc358bb 100644 --- a/es2panda/test/ts_extra_tests/run_ts_case.py +++ b/es2panda/test/ts_extra_tests/run_ts_case.py @@ -12,7 +12,6 @@ # limitations under the License. -# importing required modules import argparse import os import shutil @@ -21,7 +20,6 @@ import tempfile from tool.test_helper import get_path_file, get_disable_list, is_disable_case from tool.testcfg import TestCase - TEST_PATH = './' TEST_TMP_PATH = '/testTmp4/' TEMP_PATH = os.getcwd() + TEST_TMP_PATH @@ -29,13 +27,14 @@ TEMP_PATH = os.getcwd() + TEST_TMP_PATH if os.path.exists(TEMP_PATH): shutil.rmtree(TEMP_PATH) - if (os.path.exists(TEMP_PATH) == False): os.mkdir(TEMP_PATH) total_case = 0 failed_case = 0 TestCase.temp_path = TEMP_PATH + + def is_testcase_exist(parser, arg): if not os.path.isabs(arg): arg = TEST_PATH + arg @@ -43,19 +42,22 @@ def is_testcase_exist(parser, arg): parser.error("The directory or file '%s' does not exist" % arg) return os.path.abspath(arg) + def is_file(parser, arg): if not os.path.isfile(arg): parser.error("The file '%s' does not exist" % arg) return os.path.abspath(arg) + def is_directory(parser, arg): if not os.path.isdir(arg): parser.error("The directory '%s' does not exist" % arg) return os.path.abspath(arg) -def parse_and_execute(path, arkruntime = False, skip_negative = True): + +def parse_and_execute(path, arkruntime=False, skip_negative=True): if path.endswith(".ts"): test_case = TestCase(path) if not test_case.is_test_case: @@ -74,22 +76,23 @@ def parse_and_execute(path, arkruntime = False, skip_negative = True): return True, True return True, False + # create a parser object -parser = argparse.ArgumentParser(description = "TypeScript Spec&Feature Test Tool") +parser = argparse.ArgumentParser(description="TypeScript Spec&Feature Test Tool") # files or command -parser.add_argument("release", nargs = '*', metavar = "release", type = lambda arg: is_testcase_exist(parser, arg), - help = "All test case in the release will be execute") +parser.add_argument("release", nargs='*', metavar="release", type=lambda arg: is_testcase_exist(parser, arg), + help="All test case in the release will be execute") -parser.add_argument("-a", "--arkruntime", action="store_true", default=False, help= "test on arkruntime") +parser.add_argument("-a", "--arkruntime", action="store_true", default=False, help="test on arkruntime") -parser.add_argument("-s", "--skip-abnormal-case", action="store_true", default=False, help= "skip abnormal test case") +parser.add_argument("-s", "--skip-abnormal-case", action="store_true", default=False, help="skip abnormal test case") -parser.add_argument("-v", "--version", dest='limit_version', default=None, help= "version limit") +parser.add_argument("-v", "--version", dest='limit_version', default=None, help="version limit") # skip list -parser.add_argument("-d", "--disable-list", type= lambda arg: is_file(parser, arg), default=None, - help= "path to the file that contains test to skip") +parser.add_argument("-d", "--disable-list", type=lambda arg: is_file(parser, arg), default=None, + help="path to the file that contains test to skip") parser.add_argument( '--js-runtime', dest='js_runtime_path', default=None, type=lambda arg: is_directory(parser, arg), @@ -151,10 +154,10 @@ for file_path in args.release: continue if is_disable_case(file_path, disable_list): continue - is_test_count , failed = parse_and_execute(file_path, args.arkruntime, args.skip_abnormal_case) + is_test_count, failed = parse_and_execute(file_path, args.arkruntime, args.skip_abnormal_case) if is_test_count: total_case += 1 - if failed : + if failed: failed_case += 1 # delete abc files diff --git a/es2panda/test/ts_extra_tests/tool/testcfg.py b/es2panda/test/ts_extra_tests/tool/testcfg.py index 87d7aaead9..cebfe1ed6a 100644 --- a/es2panda/test/ts_extra_tests/tool/testcfg.py +++ b/es2panda/test/ts_extra_tests/tool/testcfg.py @@ -25,6 +25,7 @@ MODULE = ['--module'] Decorator = ['--experimentalDecorators'] strictNullChecks = ['--strictNullChecks'] + def get_error_message(str, filename): if len(re.findall(filename + r':(\d+)', str)) > 0: line_number = re.findall(filename + r':(\d+)', str) @@ -35,7 +36,6 @@ def get_error_message(str, filename): class TestCase(): - temp_path = "" ld_library_path = "" js_runtime_path = "" @@ -44,7 +44,7 @@ class TestCase(): def __init__(self, path): self.path = path - self.target_js_path ="" + self.target_js_path = "" try: data = yaml.load(read_declaration(path), yaml.SafeLoader) except: @@ -57,15 +57,14 @@ class TestCase(): self.abc_file_path = "" self.abc_file_path_temp = "" - - def execute(self, arkruntime = False): + def execute(self, arkruntime=False): if not self.is_test_case: return if arkruntime: with open(self.path, 'a') as fileAdded: fileAdded.write('\rprint("TESTCASE SUCCESS");') self.__test_es2abc() - if(os.path.exists(self.abc_file_path)): + if os.path.exists(self.abc_file_path): os.remove(self.abc_file_path) else: self.__tsc_test() @@ -74,29 +73,35 @@ class TestCase(): if 'error' in self.declaration: return True return False + def is_current(self): if 'isCurrent' in self.declaration: return True return False - def experimentalDecorators(self): + + def experimental_decorators(self): if 'experimentalDecorators' in self.declaration: return True return False - def nullChecks(self): + + def null_checks(self): if 'strictNullChecks' in self.declaration: return True return False + def is_set_module(self): if 'module' in self.declaration: return True return False + # check if def check_declaration(self): if self.declaration == {}: self.detail_result = "parse test case declaration failed, maybe bad format." return False if 'error' in self.declaration: - if self.declaration['error'] is None or 'code' not in self.declaration['error'] and 'type' not in self.declaration['error']: + if self.declaration['error'] is None or 'code' not in self.declaration['error'] and 'type' not in \ + self.declaration['error']: self.detail_result = "neither error code nor error type are defined in negative case." return False return True @@ -123,10 +128,10 @@ class TestCase(): if self.is_set_module(): cmd.extend(MODULE) cmd.append('es2020') - if self.experimentalDecorators(): + if self.experimental_decorators(): cmd.extend(Decorator) cmd.append('true') - if self.nullChecks(): + if self.null_checks(): cmd.extend(strictNullChecks) cmd.append('false') if self.is_current(): @@ -154,11 +159,13 @@ class TestCase(): # create abc files def create_abc(self, filename): - process = subprocess.Popen(self.__get_es2abc_cmd(filename), stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE) + process = subprocess.Popen(self.__get_es2abc_cmd(filename), stdin=subprocess.PIPE, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) out, err = process.communicate() returncode = process.returncode if returncode != 0: - err_msg, line = get_error_message(out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore"), filename) + err_msg, line = get_error_message( + out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore"), filename) self.detail_result = err_msg self.err_line = line self.fail = True @@ -171,14 +178,13 @@ class TestCase(): # get es2abc file commands def _get_ark_js_cmd(self): os.environ.setdefault("LD_LIBRARY_PATH", TestCase.ld_library_path) - run_abc_cmd = [os.path.join(TestCase.js_runtime_path, 'ark_js_vm')] - run_abc_cmd.append(self.abc_file_path_temp) + run_abc_cmd = [os.path.join(TestCase.js_runtime_path, 'ark_js_vm'), self.abc_file_path_temp] return run_abc_cmd pass def __get_js_basename(self): sp = '/' - return "test_ts_cases" + sp + self.path.split(sp+"test_ts_cases"+sp)[1].replace('.ts', '.js') + return "test_ts_cases" + sp + self.path.split(sp + "test_ts_cases" + sp)[1].replace('.ts', '.js') def __is_strict(self): if 'strict' in self.declaration: @@ -186,7 +192,8 @@ class TestCase(): return True def __tsc_test(self): - process = subprocess.Popen(self.__get_tsc_cmd(), stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE) + process = subprocess.Popen(self.__get_tsc_cmd(), stdin=subprocess.PIPE, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) out, err = process.communicate() returncode = process.returncode if self.is_negative(): @@ -200,7 +207,7 @@ class TestCase(): self.detail_result = "Error code not as expected." return # positive case - if returncode != 0 : + if returncode != 0: self.detail_result = out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore") self.fail = True return @@ -208,14 +215,16 @@ class TestCase(): with open(self.target_js_path, 'a') as fileAdded: fileAdded.write('console.log("TESTCASE SUCCESS");') # run node command - process = subprocess.Popen(self.__get_node_cmd(), stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE) + process = subprocess.Popen(self.__get_node_cmd(), stdin=subprocess.PIPE, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) out, err = process.communicate() returncode = process.returncode if self.is_current(): if os.path.exists(self.target_js_path): os.remove(self.target_js_path) if returncode != 0: - err_msg, line = get_error_message(out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore"), self.__get_js_basename()) + err_msg, line = get_error_message( + out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore"), self.__get_js_basename()) self.detail_result = err_msg self.err_line = line self.fail = True @@ -228,7 +237,8 @@ class TestCase(): def __test_es2abc(self): # compiler to abc - process = subprocess.Popen(self.__get_es2abc_cmd(self.path), stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE) + process = subprocess.Popen(self.__get_es2abc_cmd(self.path), stdin=subprocess.PIPE, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) out, err = process.communicate() returncode = process.returncode if self.is_negative(): @@ -241,16 +251,19 @@ class TestCase(): self.detail_result = "Error type not as expected." return # positive case - if returncode != 0 : + if returncode != 0: self.detail_result = out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore") self.fail = True return # execute ark_js_vm - process = subprocess.Popen(self._get_ark_js_cmd(), stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE) + process = subprocess.Popen(self._get_ark_js_cmd(), stdin=subprocess.PIPE, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) out, err = process.communicate() returncode = process.returncode if returncode != 0: - err_msg, line = get_error_message(out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore"), os.path.basename(self.abc_file_path)) + err_msg, line = get_error_message( + out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore"), + os.path.basename(self.abc_file_path)) self.detail_result = err_msg self.err_line = line self.fail = True -- Gitee From 535fc793b4857b131fbd021f672d0f7ead6324be Mon Sep 17 00:00:00 2001 From: tanglizhen Date: Tue, 18 Jul 2023 16:50:45 +0800 Subject: [PATCH 15/18] Ts test cases --types Signed-off-by: tanglizhen --- es2panda/test/ts_extra_tests/run_ts_case.py | 43 +++++++++---------- .../test/ts_extra_tests/tool/test_helper.py | 17 +++++--- es2panda/test/ts_extra_tests/tool/testcfg.py | 43 +++++++++---------- 3 files changed, 53 insertions(+), 50 deletions(-) diff --git a/es2panda/test/ts_extra_tests/run_ts_case.py b/es2panda/test/ts_extra_tests/run_ts_case.py index 737bc358bb..700fa40652 100644 --- a/es2panda/test/ts_extra_tests/run_ts_case.py +++ b/es2panda/test/ts_extra_tests/run_ts_case.py @@ -15,7 +15,6 @@ import argparse import os import shutil -import tempfile from tool.test_helper import get_path_file, get_disable_list, is_disable_case from tool.testcfg import TestCase @@ -27,7 +26,7 @@ TEMP_PATH = os.getcwd() + TEST_TMP_PATH if os.path.exists(TEMP_PATH): shutil.rmtree(TEMP_PATH) -if (os.path.exists(TEMP_PATH) == False): +if not os.path.exists(TEMP_PATH): os.mkdir(TEMP_PATH) total_case = 0 @@ -35,44 +34,44 @@ failed_case = 0 TestCase.temp_path = TEMP_PATH -def is_testcase_exist(parser, arg): +def is_testcase_exist(parsers, arg): if not os.path.isabs(arg): arg = TEST_PATH + arg if not os.path.exists(arg): - parser.error("The directory or file '%s' does not exist" % arg) + parsers.error("The directory or file '%s' does not exist" % arg) return os.path.abspath(arg) -def is_file(parser, arg): +def is_file(parsers, arg): if not os.path.isfile(arg): - parser.error("The file '%s' does not exist" % arg) + parsers.error("The file '%s' does not exist" % arg) return os.path.abspath(arg) -def is_directory(parser, arg): +def is_directory(parsers, arg): if not os.path.isdir(arg): - parser.error("The directory '%s' does not exist" % arg) + parsers.error("The directory '%s' does not exist" % arg) return os.path.abspath(arg) -def parse_and_execute(path, arkruntime=False, skip_negative=True): +def parse_and_execute(path, ark_runtime=False, skip_negative=True): if path.endswith(".ts"): - test_case = TestCase(path) - if not test_case.is_test_case: + test_cases = TestCase(path) + if not test_cases.is_test_case: return False, False # check test case declare - if not test_case.check_declaration(): - print(test_case.path, test_case.detail_result, sep='\t') + if not test_cases.check_declaration(): + print(test_cases.path, test_cases.detail_result, sep='\t') return True, True - if skip_negative and test_case.is_negative(): + if skip_negative and test_cases.is_negative(): return False, False else: - test_case.execute(arkruntime) - if test_case.fail: + test_cases.execute(ark_runtime) + if test_cases.fail: print('TESTCASE Fail! Fail reason is coming:') - print(test_case.path, test_case.detail_result, sep='\t') + print(test_cases.path, test_cases.detail_result, sep='\t') return True, True return True, False @@ -84,7 +83,7 @@ parser = argparse.ArgumentParser(description="TypeScript Spec&Feature Test Tool" parser.add_argument("release", nargs='*', metavar="release", type=lambda arg: is_testcase_exist(parser, arg), help="All test case in the release will be execute") -parser.add_argument("-a", "--arkruntime", action="store_true", default=False, help="test on arkruntime") +parser.add_argument("-a", "--arkruntime", action="store_true", default=False, help="test on ark_runtime") parser.add_argument("-s", "--skip-abnormal-case", action="store_true", default=False, help="skip abnormal test case") @@ -149,12 +148,12 @@ for file_path in args.release: if failed: failed_case += 1 continue - for file_path in get_path_file(file_path, None, True, args.limit_version): - if False == file_path.endswith(".ts"): + for file_paths in get_path_file(file_path, None, True, args.limit_version): + if not file_paths.endswith(".ts"): continue - if is_disable_case(file_path, disable_list): + if is_disable_case(file_paths, disable_list): continue - is_test_count, failed = parse_and_execute(file_path, args.arkruntime, args.skip_abnormal_case) + is_test_count, failed = parse_and_execute(file_paths, args.arkruntime, args.skip_abnormal_case) if is_test_count: total_case += 1 if failed: diff --git a/es2panda/test/ts_extra_tests/tool/test_helper.py b/es2panda/test/ts_extra_tests/tool/test_helper.py index 7e95369641..ef411a4357 100644 --- a/es2panda/test/ts_extra_tests/tool/test_helper.py +++ b/es2panda/test/ts_extra_tests/tool/test_helper.py @@ -15,11 +15,12 @@ import re import os + def read_declaration(path): start_pattern = re.compile(r'^\/\*\*\-*') end_pattern = re.compile(r'^\s*\-+\*\/') context = "" - with open(path,'r', encoding='utf-8', errors='ignore') as f: + with open(path, 'r', encoding='utf-8', errors='ignore') as f: declaration_begin = False while True: line = f.readline() @@ -31,14 +32,16 @@ def read_declaration(path): if end_pattern.match(line): declaration_begin = False break - if declaration_begin == True: + if declaration_begin: context += line return context + # LIMIT_VERSION = 4.2 -ROOT_FOLDER = 'test_ts_cases' + def get_path_file(dir_path, all_file_path=None, is_root=False, limit_version=None): + rf = 'test_ts_cases' if all_file_path is None: all_file_path = [] file_or_dir = os.listdir(dir_path) @@ -49,7 +52,7 @@ def get_path_file(dir_path, all_file_path=None, is_root=False, limit_version=Non is_root = False if is_root: root_folder = os.path.basename(dir_path) - if root_folder == ROOT_FOLDER: + if root_folder == rf: # file_or_dir like: ['2.0', '2.1', '2.2', ... '4.9', 'spec'] for f_item in file_or_dir: if limit_version is None: @@ -81,9 +84,10 @@ def get_path_file(dir_path, all_file_path=None, is_root=False, limit_version=Non return all_file_path + def get_disable_list(file_path): disable_list = [] - with open(file_path,'r', encoding='utf-8', errors='ignore') as f: + with open(file_path, 'r', encoding='utf-8', errors='ignore') as f: while True: line = f.readline() if not line: @@ -91,8 +95,9 @@ def get_disable_list(file_path): disable_list.append(os.path.abspath(line.strip())) return disable_list + def is_disable_case(file_path, disable_list): - if disable_list == None: + if disable_list is None: return False if file_path in disable_list: return True diff --git a/es2panda/test/ts_extra_tests/tool/testcfg.py b/es2panda/test/ts_extra_tests/tool/testcfg.py index cebfe1ed6a..0bf1e8d654 100644 --- a/es2panda/test/ts_extra_tests/tool/testcfg.py +++ b/es2panda/test/ts_extra_tests/tool/testcfg.py @@ -26,16 +26,16 @@ Decorator = ['--experimentalDecorators'] strictNullChecks = ['--strictNullChecks'] -def get_error_message(str, filename): - if len(re.findall(filename + r':(\d+)', str)) > 0: - line_number = re.findall(filename + r':(\d+)', str) +def get_error_message(strs, filename): + if len(re.findall(filename + r':(\d+)', strs)) > 0: + line_number = re.findall(filename + r':(\d+)', strs) else: line_number = 0 - err_message = str + err_message = strs return err_message, line_number -class TestCase(): +class TestCase: temp_path = "" ld_library_path = "" js_runtime_path = "" @@ -57,12 +57,12 @@ class TestCase(): self.abc_file_path = "" self.abc_file_path_temp = "" - def execute(self, arkruntime=False): + def execute(self, ark_runtime=False): if not self.is_test_case: return - if arkruntime: - with open(self.path, 'a') as fileAdded: - fileAdded.write('\rprint("TESTCASE SUCCESS");') + if ark_runtime: + with open(self.path, 'a') as file_added: + file_added.write('\rprint("TESTCASE SUCCESS");') self.__test_es2abc() if os.path.exists(self.abc_file_path): os.remove(self.abc_file_path) @@ -94,7 +94,6 @@ class TestCase(): return True return False - # check if def check_declaration(self): if self.declaration == {}: self.detail_result = "parse test case declaration failed, maybe bad format." @@ -162,8 +161,8 @@ class TestCase(): process = subprocess.Popen(self.__get_es2abc_cmd(filename), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = process.communicate() - returncode = process.returncode - if returncode != 0: + return_code = process.returncode + if return_code != 0: err_msg, line = get_error_message( out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore"), filename) self.detail_result = err_msg @@ -195,9 +194,9 @@ class TestCase(): process = subprocess.Popen(self.__get_tsc_cmd(), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = process.communicate() - returncode = process.returncode + return_code = process.returncode if self.is_negative(): - if returncode == 0: + if return_code == 0: self.fail = True self.detail_result = "No error found in negative case." return @@ -207,7 +206,7 @@ class TestCase(): self.detail_result = "Error code not as expected." return # positive case - if returncode != 0: + if return_code != 0: self.detail_result = out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore") self.fail = True return @@ -218,11 +217,11 @@ class TestCase(): process = subprocess.Popen(self.__get_node_cmd(), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = process.communicate() - returncode = process.returncode + return_code = process.returncode if self.is_current(): if os.path.exists(self.target_js_path): os.remove(self.target_js_path) - if returncode != 0: + if return_code != 0: err_msg, line = get_error_message( out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore"), self.__get_js_basename()) self.detail_result = err_msg @@ -240,9 +239,9 @@ class TestCase(): process = subprocess.Popen(self.__get_es2abc_cmd(self.path), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = process.communicate() - returncode = process.returncode + return_code = process.returncode if self.is_negative(): - if returncode == 0: + if return_code == 0: self.fail = True return if self.__error_type() in out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore"): @@ -251,7 +250,7 @@ class TestCase(): self.detail_result = "Error type not as expected." return # positive case - if returncode != 0: + if return_code != 0: self.detail_result = out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore") self.fail = True return @@ -259,8 +258,8 @@ class TestCase(): process = subprocess.Popen(self._get_ark_js_cmd(), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = process.communicate() - returncode = process.returncode - if returncode != 0: + return_code = process.returncode + if return_code != 0: err_msg, line = get_error_message( out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore"), os.path.basename(self.abc_file_path)) -- Gitee From bbcce03ccc8dd22d0551ac50af1f3a482e43995d Mon Sep 17 00:00:00 2001 From: tanglizhen Date: Thu, 20 Jul 2023 13:43:11 +0800 Subject: [PATCH 16/18] Ts test cases --others Signed-off-by: tanglizhen --- es2panda/test/ts_extra_tests/package.json | 6 - es2panda/test/ts_extra_tests/run_ts_case.py | 188 ------------ .../Ambient_Class_Declarations.ts | 41 +++ .../ambient_function_declarations.ts | 45 +++ .../ambient_namespace_declarations.ts | 36 +++ .../ambient_variable_declarations.ts} | 21 +- .../ambient_module_declarations_1.ts} | 19 +- .../ambient_module_declarations_3.ts | 43 +++ .../class_body/class_body.ts | 104 +++++++ .../class_declarations_1.ts | 33 +++ .../class_declarations_2.ts | 43 +++ .../class_declarations_3.ts | 61 ++++ .../class_heritage_specification_1.ts} | 48 +-- .../class_heritage_specification_2.ts | 62 ++++ .../class_heritage_specification_3.ts | 76 +++++ .../class_heritage_specification_4.ts | 36 +++ .../class_heritage_specification_5.ts | 51 ++++ .../class_heritage_specification_6.ts | 42 +++ .../automatic_constructors_1.ts} | 34 ++- .../automatic_constructors_2.ts} | 54 ++-- .../automatic_constructors_3.ts | 45 +++ .../constructor_parameters_1.ts} | 17 +- .../constructor_parameters_2.ts} | 33 ++- .../constructor_parameters_3.ts} | 35 +-- .../constructor_parameters_4.ts} | 13 +- .../constructor_parameters_5.ts} | 35 +-- .../constructor_parameters_6.ts} | 21 +- .../super_calls/super_calls.ts | 41 +++ .../spec/classes/decorators/decorators.ts | 46 +++ .../index_member_declarations.ts | 38 +++ .../members/accessibility/accessibility_1.ts | 79 +++++ .../members/accessibility/accessibility_2.ts | 49 ++++ .../members/accessibility/accessibility_3.ts} | 53 +++- .../members/class_types/class_types_1.ts | 67 +++++ .../members/class_types/class_types_2.ts | 70 +++++ .../members/class_types/class_types_3.ts | 60 ++++ .../constructor_function_types_1.ts | 35 +++ .../constructor_function_types_2.ts} | 44 ++- .../constructor_function_types_3.ts | 38 +++ .../constructor_function_types_4.ts} | 56 ++-- .../constructor_function_types_5.ts} | 33 ++- .../constructor_function_types_6.ts | 50 ++++ .../constructor_function_types_7.ts} | 35 +-- .../inheritance_and_overriding_1.ts} | 30 +- .../inheritance_and_overriding_2.ts | 51 ++++ .../inheritance_and_overriding_3.ts | 42 +++ .../inheritance_and_overriding_4.ts} | 36 ++- .../inheritance_and_overriding_5.ts | 59 ++++ .../instance_and_static_members_1.ts} | 35 +-- .../instance_and_static_members_2.ts} | 68 +++-- .../instance_and_static_members_3.ts} | 46 ++- .../dynamic_property_declarations.ts | 41 +++ .../member_accessor_declarations.ts | 47 +++ .../member_function_declarations_1.ts | 40 +++ .../member_function_declarations_2.ts} | 23 +- .../member_function_declarations_3.ts} | 20 +- .../member_function_declarations_4.ts} | 35 ++- .../member_function_declarations_5.ts} | 35 +-- .../member_variable_declarations_1.ts | 39 +++ .../member_variable_declarations_2.ts} | 41 ++- .../member_variable_declarations_3.ts} | 41 ++- .../member_variable_declarations_4.ts | 42 +++ .../property_member_declarations_1.ts | 43 +++ .../property_member_declarations_2.ts} | 33 ++- .../property_member_declarations_3.ts} | 39 +-- .../constant_enum_declarations.ts | 56 ++++ .../declaration_merging_1.ts | 51 ++++ .../declaration_merging_2.ts} | 41 +-- .../enum_declarations/enum_declarations_1.ts | 45 +++ .../enum_declarations/enum_declarations_2.ts | 34 +++ .../enum_declarations/enum_declarations_3.ts | 60 ++++ .../spec/enums/enum_members/enum_members_1.ts | 72 +++++ .../array_literals/array_literal_1.ts | 34 +++ .../array_literals/array_literal_2.ts | 31 ++ .../array_literals/array_literal_3.ts | 26 ++ .../array_literals/array_literal_4.ts | 32 ++ .../array_literals/array_literal_5.ts} | 17 +- .../array_literals/array_literal_6.ts | 31 ++ .../arrow_function/arrow_function_1.ts | 34 +++ .../arrow_function/arrow_function_2.ts} | 61 ++-- .../arrow_function/arrow_function_3.ts | 39 +++ .../arrow_function/arrow_function_4.ts | 38 +++ .../assignment_operator_1.ts | 31 ++ .../assignment_operator_2.ts | 80 +++++ .../assignment_operator_3.ts} | 13 +- .../destructing_assignment_1.ts} | 11 +- .../destructing_assignment_2.ts | 35 +++ .../destructing_assignment_3.ts | 34 +++ .../destructing_assignment_4.ts} | 38 +-- .../destructing_assignment_5.ts} | 38 +-- .../destructing_assignment_6.ts | 30 ++ .../destructing_assignment_7.ts} | 23 +- .../destructing_assignment_8.ts | 35 +++ .../the_add_operator/the_add_operator_1.ts} | 53 ++-- .../the_add_operator/the_add_operator_2.ts} | 31 +- .../the_add_operator/the_add_operator_3.ts} | 11 +- .../the_and_operator/the_and_operator.ts | 70 +++++ .../the_greater/the_congruence_operator.ts | 35 +++ .../the_greater/the_equal_operator.ts | 35 +++ .../the_greater/the_greater_operator.ts | 35 +++ .../the_greater_or_equal_operator.ts | 35 +++ .../the_greater/the_incongruence_operator.ts | 35 +++ .../the_greater/the_less_operator.ts | 35 +++ .../the_greater/the_less_or_equal_operator.ts | 35 +++ .../the_greater/the_unequal_operator.ts} | 24 +- .../the_in_operator/the_in_operator.ts} | 38 +-- .../the_instanceof_operator.ts} | 55 ++-- .../the_mul/the_and_operator.ts | 51 ++++ .../the_mul/the_division_method_operator.ts} | 30 +- .../the_mul/the_left_shift_operator.ts | 47 +++ .../the_mul/the_multiplication_operator.ts | 47 +++ .../the_mul/the_or_operator.ts} | 33 ++- .../the_mul/the_remainder_operator.ts | 47 +++ .../the_mul/the_right_shift_operator.ts | 47 +++ .../the_mul/the_subtraction_operator.ts | 47 +++ .../the_unsigned_shift_to_the_right.ts | 47 +++ .../the_mul/the_xor_operator.ts | 47 +++ .../the_or_operator/the_or_operator_1.ts} | 60 +++- .../the_or_operator/the_or_operator_2.ts | 41 +++ .../class_expressions/class_expressions_1.ts | 56 ++++ .../contextually_typed_expressions_1.ts | 43 +++ .../contextually_typed_expressions_10.ts | 38 +++ .../contextually_typed_expressions_11.ts} | 16 +- .../contextually_typed_expressions_12.ts | 37 +++ .../contextually_typed_expressions_13.ts} | 17 +- .../contextually_typed_expressions_14.ts | 36 +++ .../contextually_typed_expressions_15.ts} | 16 +- .../contextually_typed_expressions_16.ts} | 15 +- .../contextually_typed_expressions_2.ts} | 13 +- .../contextually_typed_expressions_3.ts | 31 ++ .../contextually_typed_expressions_4.ts | 45 +++ .../contextually_typed_expressions_5.ts | 39 +++ .../contextually_typed_expressions_6.ts | 35 +++ .../contextually_typed_expressions_7.ts | 48 +++ .../contextually_typed_expressions_8.ts | 44 +++ .../contextually_typed_expressions_9.ts} | 33 +-- .../grammar_ambiguities.ts} | 29 +- .../overload_resolution_1.ts | 41 +++ .../overload_resolution_2.ts | 42 +++ .../type_argument_inference_1.ts} | 32 +- .../type_argument_inference_2.ts} | 40 +-- .../type_argument_inference_3.ts} | 17 +- .../type_argument_inference_4.ts} | 23 +- .../function_expressions_1.ts | 36 +++ .../function_expressions_2.ts | 34 +++ .../function_expressions_3.ts} | 25 +- .../function_expressions_4.ts | 38 +++ .../spec/expressions/identifiers/class.ts | 33 +++ .../spec/expressions/identifiers/enum.ts | 31 ++ .../spec/expressions/identifiers/function.ts | 27 ++ .../expressions/identifiers/name_space.ts | 42 +++ .../spec/expressions/identifiers/parameter.ts | 37 +++ .../spec/expressions/identifiers/variable.ts | 28 ++ .../spec/expressions/literals/boolean.ts | 25 ++ .../spec/expressions/literals/null.ts | 25 ++ .../spec/expressions/literals/number.ts | 25 ++ .../literals/regexp.ts} | 6 +- .../literals/string.ts} | 9 +- .../object_literal/object_literal_1.ts | 47 +++ .../object_literal/object_literal_2.ts | 50 ++++ .../object_literal/object_literal_3.ts | 48 +++ .../object_literal/object_literal_4.ts | 41 +++ .../object_literal/object_literal_5.ts} | 51 ++-- .../object_literal/object_literal_6.ts | 41 +++ .../object_literal/object_literal_7.ts | 57 ++++ .../object_literal/object_literal_8.ts | 44 +++ .../object_literal/object_literal_9.ts | 51 ++++ .../expressions/parentheses/parentheses.ts | 51 ++++ .../property_access/object_access_2.ts | 50 ++++ .../property_access/object_any_1.ts | 32 ++ .../property_access/object_any_type_6.ts | 42 +++ .../property_access/object_apprent_5.ts | 35 +++ .../property_access/object_index_4.ts | 36 +++ .../property_access/object_string_number_3.ts | 45 +++ .../property_access/property_access_1.ts | 32 ++ .../property_access/property_access_2.ts | 32 ++ .../template_literals/template_literals.ts | 80 +++++ .../the_comma_operator/the_comma_operator.ts | 39 +++ .../the_conditional_operator_1.ts | 35 +++ .../the_conditional_operator_2.ts} | 41 +-- .../the_new_operator/new_operator_1.ts | 36 +++ .../the_new_operator/new_operator_2.ts | 41 +++ .../the_new_operator/new_operator_3.ts | 35 +++ .../the_new_operator/new_operator_4.ts} | 40 ++- .../super_calls/arguments.ts} | 24 +- .../super_calls/gengric_extends.ts} | 32 +- .../super_calls/super_calls.ts | 53 ++++ .../super_property_access_1.ts} | 56 ++-- .../super_property_access_2.ts} | 27 +- .../this_key_word/this_key_word_1.ts | 48 +++ .../this_key_word/this_key_word_2.ts | 39 +++ .../this_key_word/this_key_word_3.ts | 50 ++++ .../this_key_word/this_key_word_4.ts | 45 +++ .../type_assertion/type_assertion_1.ts | 35 +++ .../type_assertion/type_assertion_2.ts | 61 ++++ .../type_assertion/type_assertion_3.ts | 33 +++ .../expressions/type_guards/type_guards_1.ts | 40 +++ .../expressions/type_guards/type_guards_10.ts | 40 +++ .../expressions/type_guards/type_guards_11.ts | 41 +++ .../expressions/type_guards/type_guards_12.ts | 41 +++ .../expressions/type_guards/type_guards_13.ts | 52 ++++ .../type_guards/type_guards_2.ts} | 35 +-- .../expressions/type_guards/type_guards_3.ts | 32 ++ .../expressions/type_guards/type_guards_4.ts | 32 ++ .../expressions/type_guards/type_guards_5.ts | 31 ++ .../type_guards/type_guards_6.ts} | 76 ++--- .../expressions/type_guards/type_guards_7.ts | 41 +++ .../expressions/type_guards/type_guards_8.ts | 54 ++++ .../expressions/type_guards/type_guards_9.ts | 40 +++ .../unary_operators/the_!_operator.ts | 33 +++ .../the_++_and_--_operators.ts | 52 ++++ .../unary_operators/the_+_and_~_operators.ts | 34 +++ .../unary_operators/the_delete_operator.ts} | 22 +- .../unary_operators/the_typeof_operator.ts | 29 ++ .../unary_operators/the_void_operator.ts | 28 ++ .../asynchronous_functions_1.ts} | 75 +++-- .../asynchronous_functions_2.ts | 61 ++++ .../asynchronous_functions_3.ts | 69 +++++ .../asynchronous_functions_4.ts | 36 +++ .../destructuring_parameter_declarations_1.ts | 52 ++++ .../destructuring_parameter_declarations_2.ts | 42 +++ .../destructuring_parameter_declarations_3.ts | 43 +++ .../destructuring_parameter_declarations_4.ts | 54 ++++ ...destructuring_parameter_declarations_5.ts} | 29 +- ...destructuring_parameter_declarations_6.ts} | 35 ++- .../destructuring_parameter_declarations_7.ts | 32 ++ .../function_declarations_1.ts | 42 +++ .../function_declarations_2.ts | 38 +++ .../function_implementations_1.ts | 32 ++ .../function_implementations_2.ts | 46 +++ .../function_implementations_3.ts | 42 +++ .../function_implementations_4.ts | 42 +++ .../function_implementations_5.ts | 43 +++ .../function_overloads_1.ts | 41 +++ .../generator_functions_1.ts | 44 +++ .../generator_functions_2.ts | 54 ++++ .../generic_functions/generic_functions_1.ts} | 27 +- .../generic_functions/generic_functions_2.ts | 34 +++ .../type_guard_functions_1.ts} | 73 ++--- .../classes/classes.ts} | 98 +++---- .../test_ts_cases/spec/grammar/enums/enums.ts | 68 +++++ .../spec/grammar/expressions/expressions.ts | 58 ++++ .../spec/grammar/functions/functions.ts | 35 +++ .../spec/grammar/interfaces/interfaces.ts | 47 +++ .../spec/grammar/namespaces/namespaces.ts | 76 +++++ .../scripts_and_modules.ts} | 75 ++--- .../scripts_and_modules/source_file_1.ts} | 77 ++--- .../scripts_and_modules/source_file_2.ts | 27 ++ .../scripts_and_modules/source_file_3.ts | 30 ++ .../scripts_and_modules/source_file_4.ts | 29 ++ .../spec/grammar/statements/statements.ts | 65 +++++ .../test_ts_cases/spec/grammar/types/types.ts | 162 +++++++++++ .../interface_declarations_1.ts | 115 ++++++++ .../interface_declarations_2.ts | 75 +++++ .../interface_declarations_3.ts | 33 +++ .../declaration_merging_1.ts | 75 +++++ .../declaration_merging_2.ts | 77 +++++ .../interfaces_extending_classes_1.ts | 47 +++ .../interfaces_extending_classes_2.ts | 50 ++++ .../dynamic_type_checks_1.ts | 50 ++++ .../declaration_merging_1_1.ts | 26 ++ .../declaration_merging_1_2.ts | 26 ++ .../declaration_merging_1_3.ts | 30 ++ .../declaration_merging_2.ts | 91 ++++++ .../export_declarations_1.ts | 33 +++ .../export_declarations_2.ts | 39 +++ .../export_declarations_3.ts | 37 +++ .../import_alias_declarations_1.ts | 43 +++ .../import_alias_declarations_3.ts | 61 ++++ .../namespace_body/namespace_body.ts | 75 +++++ .../namespace_declarations_1.ts} | 36 +-- .../namespace_declarations_2.ts} | 65 ++--- .../namespace_declarations_3.ts | 53 ++++ .../namespace_declarations_4.ts} | 32 +- .../1_source_files_dependencies/source_00.ts | 17 ++ .../source_files_dependencies.ts | 28 ++ .../1_programs_and_source_files/source_1.ts | 19 ++ .../1_programs_and_source_files/source_10.ts | 21 ++ .../1_programs_and_source_files/source_2.ts | 19 ++ .../1_programs_and_source_files/source_3.ts | 18 ++ .../1_programs_and_source_files/source_4.ts | 19 ++ .../1_programs_and_source_files/source_5.ts | 21 ++ .../1_programs_and_source_files/source_6.ts | 21 ++ .../1_programs_and_source_files/source_7.ts | 27 ++ .../1_programs_and_source_files/source_8.ts | 17 ++ .../1_programs_and_source_files/source_9.ts | 25 ++ .../2_modules/modules_1.ts | 28 ++ .../import_declarations_1.ts} | 11 +- .../import_declarations_2.ts | 30 ++ .../import_declarations_3.ts | 31 ++ .../import_declarations_4.ts | 31 ++ .../import_require_declarations_1.ts | 29 ++ .../export_declarations_1.ts | 27 ++ .../export_declarations_2.ts | 27 ++ .../export_declarations_3.ts | 26 ++ .../export_declarations_4.ts | 27 ++ .../export_declarations_5.ts | 27 ++ .../export_assignments_1.ts | 30 ++ .../7_commonJS_modules/commonJS_modules_1.ts | 30 ++ .../7_commonJS_modules/commonJS_modules_2.ts | 30 ++ .../if_do_and_while_Statements_1.ts | 65 +++++ .../if_do_and_while_Statements_2.ts | 51 ++++ .../if_do_and_while_Statements_3.ts} | 27 +- .../spec/statements/blocks/blocks_1.ts | 41 +++ .../spec/statements/blocks/blocks_2.ts | 36 +++ .../spec/statements/blocks/blocks_3.ts | 41 +++ .../spec/statements/blocks/blocks_4.ts | 35 +++ .../break_statements/break_statements.ts | 50 ++++ .../continue_statements.ts | 54 ++++ .../for_in_statements/for_in_statements.ts | 64 ++++ .../for_of_statements/for_of_statements.ts | 42 +++ .../for_statements/for_statements.ts | 32 ++ .../let_and_const_declarations.ts | 37 +++ .../return_statements/return_statements.ts} | 26 +- .../switch_statements/switch_statements.ts | 74 +++++ .../throw_statements/throw_statements.ts | 71 +++++ .../try_statements/try_statements.ts | 44 +++ .../simple_variable_declarations_1.ts} | 62 ++-- .../simple_variable_declarations_2.ts | 49 ++++ .../simple_variable_declarations_3.ts} | 13 +- .../destructuring_variable_declarations_1.ts} | 40 ++- .../destructuring_variable_declarations_2.ts | 57 ++++ .../destructuring_variable_declarations_3.ts} | 76 ++--- .../3_implied_type/implied_type.ts} | 65 ++--- .../object_types/array_types/array_types_1.ts | 70 ----- .../function_types/function_types_1.ts | 40 --- .../the_boolean_type/the_boolean_type_2.ts | 52 ---- .../the_enum_type/the_enum_type_1.ts | 37 --- .../the_null_type/the_null_type_1.ts | 31 -- .../the_number_type/the_number_type_1.ts | 63 ---- .../the_number_type/the_number_type_2.ts | 61 ---- .../the_number_type/the_number_type_3.ts | 38 --- .../the_string_literal_type_1.ts | 32 -- .../the_string_type/the_string_type_3.ts | 35 --- .../the_symbol_type/the_symbol_type_2.ts | 43 --- .../the_symbol_type/the_symbol_type_3.ts | 32 -- .../the_undefined_type_1.ts | 44 --- .../the_void_type/the_void_type_1.ts | 29 -- .../the_void_type/the_void_type_3.ts | 31 -- .../parameter_list/parameter_list_4.ts | 33 --- .../parameter_list/parameter_list_5.ts | 34 --- .../parameter_list/parameter_list_6.ts | 58 ---- .../return_type/return_type_1.ts | 49 ---- .../return_type/return_type_2.ts | 36 --- .../return_type/return_type_3.ts | 42 --- .../type_parameters/type_parameters_1.ts | 43 --- .../type_parameters/type_parameters_2.ts | 32 -- .../construct_signatures.ts | 60 ---- .../index_signatures/index_signatures.ts | 45 --- .../method_signatures/method_signatures_1.ts | 87 ------ .../property_signatures.ts | 42 --- .../array_type_literals_3.ts | 34 --- .../object_type_literals.ts | 77 ----- .../this_type_references_1.ts | 70 ----- .../type_queries/type_queries_1.ts | 51 ---- .../type_argument_lists_1.ts | 32 -- .../type_argument_lists_3.ts | 46 --- .../type_parameter_lists_2.ts | 33 --- .../type_parameter_lists_4.ts | 30 -- .../type_parameter_lists_6.ts | 39 --- .../Type_and_Member_Identity_1.ts | 51 ---- .../Type_and_Member_Identity_2.ts | 50 ---- .../Type_and_Member_Identity_4.ts | 54 ---- .../apparent_members/apparent_members_1.ts | 34 --- .../apparent_members/apparent_members_2.ts | 34 --- .../apparent_members/apparent_members_5.ts | 43 --- .../apparent_members/apparent_members_7.ts | 43 --- .../apparent_members/apparent_members_8.ts | 29 -- .../assignment_compatibility_10.ts | 43 --- .../assignment_compatibility_11.ts | 34 --- .../assignment_compatibility_12.ts | 48 --- .../assignment_compatibility_13.ts | 46 --- .../assignment_compatibility_14.ts | 39 --- .../assignment_compatibility_15.ts | 42 --- .../assignment_compatibility_16.ts | 42 --- .../assignment_compatibility_17.ts | 35 --- .../assignment_compatibility_2.ts | 32 -- .../assignment_compatibility_3.ts | 35 --- .../assignment_compatibility_4.ts | 29 -- .../assignment_compatibility_6.ts | 30 -- .../assignment_compatibility_7.ts | 46 --- .../assignment_compatibility_8.ts | 45 --- .../assignment_compatibility_9.ts | 41 --- .../contextual_signature_instantiation.ts | 36 --- .../excess_properties/excess_properties_2.ts | 37 --- .../recursive_types/recursive_types.ts | 44 --- .../subtypes_and_supertypes_1.ts | 46 --- .../subtypes_and_supertypes_11.ts | 35 --- .../subtypes_and_supertypes_13.ts | 47 --- .../subtypes_and_supertypes_6.ts | 32 -- .../subtypes_and_supertypes_7.ts | 31 -- .../subtypes_and_supertypes_9.ts | 31 -- .../type_inference/type_inference_2.ts | 35 --- .../type_inference/type_inference_3.ts | 31 -- .../type_inference/type_inference_4.ts | 58 ---- .../type_inference/type_inference_5.ts | 37 --- .../type_inference/type_inference_6.ts | 33 --- .../type_inference/type_inference_7.ts | 31 -- .../spec/types/union_types/union_types_5.ts | 54 ---- .../spec/types/union_types/union_types_7.ts | 59 ---- .../spec/types/widend_types/widend_types_2.ts | 29 -- .../test/ts_extra_tests/tool/test_helper.py | 106 ------- es2panda/test/ts_extra_tests/tool/testcfg.py | 274 ------------------ 403 files changed, 11788 insertions(+), 5382 deletions(-) delete mode 100644 es2panda/test/ts_extra_tests/package.json delete mode 100644 es2panda/test/ts_extra_tests/run_ts_case.py create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/Ambient_Class_Declarations/Ambient_Class_Declarations.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_namespace_declarations/ambient_namespace_declarations.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/primitive_types/the_string_literal_type/the_string_literal_type_3.ts => ambients/ambient_declarations/ambient_variable_declarations/ambient_variable_declarations.ts} (62%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/specifying_members/call_signatures/parameter_list/parameter_list_3.ts => ambients/ambient_module_declarations/ambient_module_declarations_1.ts} (62%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_body/class_body.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_3.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_parameters/this_types/this_types.ts => classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts} (47%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_5.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_6.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/specifying_types/function_type_literals/function_type_literals_1.ts => classes/constructor_declarations/automatic_constructors/automatic_constructors_1.ts} (63%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/object_types/constructor_types/constructor_types_2.ts => classes/constructor_declarations/automatic_constructors/automatic_constructors_2.ts} (45%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_3.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/object_types/constructor_types/constructor_types_4.ts => classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts} (70%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/primitive_types/the_symbol_type/the_symbol_type_1.ts => classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts} (50%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_relationships/apparent_members/apparent_members_4.ts => classes/constructor_declarations/constructor_parameters/constructor_parameters_3.ts} (56%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_parameters/type_parameter_lists/type_parameter_lists_5.ts => classes/constructor_declarations/constructor_parameters/constructor_parameters_4.ts} (74%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_3.ts => classes/constructor_declarations/constructor_parameters/constructor_parameters_5.ts} (61%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_parameters/type_argument_lists/type_argument_lists_2.ts => classes/constructor_declarations/constructor_parameters/constructor_parameters_6.ts} (64%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/super_calls/super_calls.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/decorators/decorators.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/index_member_declarations/index_member_declarations.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_2.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/specifying_types/type_references/type_references_1.ts => classes/members/accessibility/accessibility_3.ts} (47%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_1.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/specifying_members/method_signatures/method_signatures_2.ts => classes/members/constructorc_function_types/constructor_function_types_2.ts} (52%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_3.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_parameters/type_parameter_lists/type_parameter_lists_1.ts => classes/members/constructorc_function_types/constructor_function_types_4.ts} (42%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/object_types/tuple_types/tuple_types_1.ts => classes/members/constructorc_function_types/constructor_function_types_5.ts} (65%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_6.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/specifying_types/predefined_types/predefined_types.ts => classes/members/constructorc_function_types/constructor_function_types_7.ts} (58%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_relationships/assignment_compatibility/assignment_compatibility_18.ts => classes/members/inheritance_and_overriding/inheritance_and_overriding_1.ts} (53%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_3.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_parameters/this_types/this_types_1.ts => classes/members/inheritance_and_overriding/inheritance_and_overriding_4.ts} (56%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_5.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/object_types/constructor_types/constructor_types_1.ts => classes/members/instance_and_static_members/instance_and_static_members_1.ts} (57%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_relationships/apparent_members/apparent_members_6.ts => classes/members/instance_and_static_members/instance_and_static_members_2.ts} (35%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_parameters/this_types/this_types_2.ts => classes/members/instance_and_static_members/instance_and_static_members_3.ts} (52%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/dynamic_property_declarations/dynamic_property_declarations.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_accessor_declarations/member_accessor_declarations.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/specifying_types/array_type_literals/array_type_literals_4.ts => classes/property_member_declarations/member_function_declarations/member_function_declarations_2.ts} (67%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/object_types/members/members_3.ts => classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts} (65%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/object_types/members/members_2.ts => classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts} (56%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_2.ts => classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts} (64%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/specifying_types/array_type_literals/array_type_literals_1.ts => classes/property_member_declarations/member_variable_declarations/member_variable_declarations_2.ts} (43%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/object_types/constructor_types/constructor_types_3.ts => classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts} (57%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_1.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/specifying_members/call_signatures/parameter_list/parameter_list_2.ts => classes/property_member_declarations/property_member_declarations_2.ts} (53%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/named_types/named_types_4.ts => classes/property_member_declarations/property_member_declarations_3.ts} (59%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/constant_enum_declarations/constant_enum_declarations.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_1.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/named_types/named_types_2.ts => enums/declaration_merging/declaration_merging_2.ts} (61%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_members/enum_members_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_4.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/union_types/union_types_1.ts => expressions/array_literals/array_literal_5.ts} (65%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_6.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_1.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/the_any_type/any_type_4.ts => expressions/arrow_function/arrow_function_2.ts} (48%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_4.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_2.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/specifying_types/intersection_type_literals/intersection_type_literals.ts => expressions/assignment_operators/assignment_operators/assignment_operator_3.ts} (74%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/object_types/array_types/array_types_2.ts => expressions/assignment_operators/destructing_assignment/destructing_assignment_1.ts} (66%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_3.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_8.ts => expressions/assignment_operators/destructing_assignment/destructing_assignment_4.ts} (54%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_10.ts => expressions/assignment_operators/destructing_assignment/destructing_assignment_5.ts} (55%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_6.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/object_types/array_types/array_types_3.ts => expressions/assignment_operators/destructing_assignment/destructing_assignment_7.ts} (53%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_8.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity.ts => expressions/binary_operators/the_add_operator/the_add_operator_1.ts} (50%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/specifying_types/union_type_literals/union_type_literals.ts => expressions/binary_operators/the_add_operator/the_add_operator_2.ts} (57%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/primitive_types/the_string_type/the_string_type_2.ts => expressions/binary_operators/the_add_operator/the_add_operator_3.ts} (77%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_congruence_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_equal_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_or_equal_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_incongruence_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_or_equal_operator.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/object_types/tuple_types/tuple_types_2.ts => expressions/binary_operators/the_greater/the_unequal_operator.ts} (65%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_relationships/apparent_members/apparent_members_3.ts => expressions/binary_operators/the_in_operator/the_in_operator.ts} (51%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_12.ts => expressions/binary_operators/the_instanceof_operator/the_instanceof_operator.ts} (43%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_and_operator.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_parameters/type_argument_lists/type_argument_lists_4.ts => expressions/binary_operators/the_mul/the_division_method_operator.ts} (54%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_left_shift_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_multiplication_operator.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_relationships/assignment_compatibility/assignment_compatibility_5.ts => expressions/binary_operators/the_mul/the_or_operator.ts} (51%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_remainder_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_right_shift_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_subtraction_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_unsigned_shift_to_the_right.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_xor_operator.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/specifying_types/tuple_type_literals/tuple_type_literals.ts => expressions/binary_operators/the_or_operator/the_or_operator_1.ts} (39%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/class_expressions/class_expressions_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_10.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/widend_types/widend_types_3.ts => expressions/contextually_typed_expressions/contextually_typed_expressions_11.ts} (67%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/union_types/union_types_6.ts => expressions/contextually_typed_expressions/contextually_typed_expressions_13.ts} (70%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_3.ts => expressions/contextually_typed_expressions/contextually_typed_expressions_15.ts} (68%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/specifying_types/array_type_literals/array_type_literals_2.ts => expressions/contextually_typed_expressions/contextually_typed_expressions_16.ts} (71%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/specifying_types/specifying_types_2.ts => expressions/contextually_typed_expressions/contextually_typed_expressions_2.ts} (66%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_5.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_6.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_aliases/type_aliases_1.ts => expressions/contextually_typed_expressions/contextually_typed_expressions_9.ts} (59%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_relationships/type_inference/type_inference_1.ts => expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts} (61%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_5.ts => expressions/function_calls/type_argument_inference/type_argument_inference_1.ts} (60%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/specifying_types/type_references/type_references_2.ts => expressions/function_calls/type_argument_inference/type_argument_inference_2.ts} (53%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/object_types/function_types/function_types_2.ts => expressions/function_calls/type_argument_inference/type_argument_inference_3.ts} (62%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_6.ts => expressions/function_calls/type_argument_inference/type_argument_inference_4.ts} (54%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_2.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_aliases/type_aliases_2.ts => expressions/function_expression/function_expressions_3.ts} (65%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_4.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/class.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/enum.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/function.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/name_space.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/parameter.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/variable.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/boolean.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/null.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/number.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/widend_types/widend_types_1.ts => expressions/literals/regexp.ts} (79%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/primitive_types/the_boolean_type/the_boolean_type_3.ts => expressions/literals/string.ts} (74%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_4.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/named_types/named_types_1.ts => expressions/object_literal/object_literal_5.ts} (51%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_6.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_7.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_8.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_9.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/parentheses/parentheses.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_access_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_type_6.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_apprent_5.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_index_4.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_string_number_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/template_literals/template_literals.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_comma_operator/the_comma_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/the_any_type/any_type_2.ts => expressions/the_conditional_operator/the_conditional_operator_2.ts} (56%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_3.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/named_types/named_types_3.ts => expressions/the_new_operator/new_operator_4.ts} (59%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/primitive_types/the_string_literal_type/the_string_literal_type_2.ts => expressions/the_super_keyword/super_calls/arguments.ts} (68%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_relationships/excess_properties/excess_properties_1.ts => expressions/the_super_keyword/super_calls/gengric_extends.ts} (60%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/super_calls.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/object_types/members/members_1.ts => expressions/the_super_keyword/super_property_access/super_property_access_1.ts} (42%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/specifying_types/function_type_literals/function_type_literals_2.ts => expressions/the_super_keyword/super_property_access/super_property_access_2.ts} (58%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_4.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_10.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_11.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_12.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_13.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/the_any_type/any_type_1.ts => expressions/type_guards/type_guards_2.ts} (61%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_4.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_5.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/the_any_type/any_type_3.ts => expressions/type_guards/type_guards_6.ts} (40%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_7.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_8.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_9.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_!_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_++_and_--_operators.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_+_and_~_operators.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_relationships/assignment_compatibility/assignment_compatibility_1.ts => expressions/unary_operators/the_delete_operator.ts} (67%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_typeof_operator.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_void_operator.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/union_types/union_types_4.ts => functions/asynchronous_functions/asynchronous_functions_1.ts} (36%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_4.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/union_types/union_types_2.ts => functions/destructuring_parameter_declarations/destructuring_parameter_declarations_5.ts} (61%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/specifying_members/call_signatures/parameter_list/parameter_list_1.ts => functions/destructuring_parameter_declarations/destructuring_parameter_declarations_6.ts} (50%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_4.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_5.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_overloads/function_overloads_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_2.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/Intersection_Types/intersection_types_2.ts => functions/generic_functions/generic_functions_1.ts} (61%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_2.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/object_types/named_type_reference/named_type_reference.ts => functions/type_guard_functions/type_guard_functions_1.ts} (36%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/Intersection_Types/Intersection_types_1.ts => grammar/classes/classes.ts} (34%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/enums/enums.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/expressions/expressions.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/functions/functions.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/interfaces/interfaces.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/namespaces/namespaces.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/specifying_members/call_signatures/specialized_signatures/specialized_signatures_1.ts => grammar/scripts_and_modules/scripts_and_modules.ts} (32%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/specifying_types/type_references/type_references_3.ts => grammar/scripts_and_modules/source_file_1.ts} (36%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_4.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/statements/statements.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/types/types.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/4_dynamic_type_checks/dynamic_type_checks_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/import_alias_declarations/import_alias_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/import_alias_declarations/import_alias_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_body/namespace_body.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/specifying_types/specifying_types_1.ts => namespaces/namespace_declarations/namespace_declarations_1.ts} (56%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/union_types/union_types_3.ts => namespaces/namespace_declarations/namespace_declarations_2.ts} (39%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_3.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_aliases/type_aliases_3.ts => namespaces/namespace_declarations/namespace_declarations_4.ts} (54%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_00.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_files_dependencies.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_10.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_4.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_5.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_6.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_7.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_8.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_9.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/2_modules/modules_1.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/primitive_types/the_string_type/the_string_type_1.ts => scripts_and_modules/3_import_declarations/import_declarations_1.ts} (67%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_4.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/4_import_require_declarations/import_require_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_4.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_5.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/6_export_assignments/export_assignments_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_2.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_5.ts => statements/If_do_and_while_Statements/if_do_and_while_Statements_3.ts} (65%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_1.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_2.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_3.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_4.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/break_statements/break_statements.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/continue_statements/continue_statements.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_in_statements/for_in_statements.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_of_statements/for_of_statements.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_statements/for_statements.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/let_and_const_declarations/let_and_const_declarations.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/object_types/tuple_types/tuple_types_3.ts => statements/return_statements/return_statements.ts} (64%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/switch_statements/switch_statements.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/throw_statements/throw_statements.ts create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/try_statements/try_statements.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_parameters/type_parameter_lists/type_parameter_lists_3.ts => statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_1.ts} (48%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_2.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/primitive_types/the_void_type/the_void_type_2.ts => statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_3.ts} (75%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_4.ts => statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_1.ts} (56%) create mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_2.ts rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/specifying_types/constructor_type_literals/constructor_type_literals.ts => statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_3.ts} (37%) rename es2panda/test/ts_extra_tests/test_ts_cases/spec/{types/primitive_types/the_boolean_type/the_boolean_type_1.ts => statements/variable_statements/3_implied_type/implied_type.ts} (44%) delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/function_types/function_types_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_enum_type/the_enum_type_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_null_type/the_null_type_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_type/the_string_type_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_symbol_type/the_symbol_type_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_symbol_type/the_symbol_type_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_undefined_type/the_undefined_type_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/return_type/return_type_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/return_type/return_type_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/return_type/return_type_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/construct_signatures/construct_signatures.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/index_signatures/index_signatures.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/property_signatures/property_signatures.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/object_type_literals/object_type_literals.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/this_type_references/this_type_references_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_queries/type_queries_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_7.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_8.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_10.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_11.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_12.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_13.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_14.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_15.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_16.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_17.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_7.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_8.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_9.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/contextual_signature_instantiation/contextual_signature_instantiation.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/recursive_types/recursive_types.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_11.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_13.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_7.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_9.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_7.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_7.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/types/widend_types/widend_types_2.ts delete mode 100644 es2panda/test/ts_extra_tests/tool/test_helper.py delete mode 100644 es2panda/test/ts_extra_tests/tool/testcfg.py diff --git a/es2panda/test/ts_extra_tests/package.json b/es2panda/test/ts_extra_tests/package.json deleted file mode 100644 index 33830f776a..0000000000 --- a/es2panda/test/ts_extra_tests/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "type": "module", - "devDependencies": { - "@types/node": "^18.15.11" - } -} diff --git a/es2panda/test/ts_extra_tests/run_ts_case.py b/es2panda/test/ts_extra_tests/run_ts_case.py deleted file mode 100644 index 700fa40652..0000000000 --- a/es2panda/test/ts_extra_tests/run_ts_case.py +++ /dev/null @@ -1,188 +0,0 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import argparse -import os -import shutil - -from tool.test_helper import get_path_file, get_disable_list, is_disable_case -from tool.testcfg import TestCase - -TEST_PATH = './' -TEST_TMP_PATH = '/testTmp4/' -TEMP_PATH = os.getcwd() + TEST_TMP_PATH - -if os.path.exists(TEMP_PATH): - shutil.rmtree(TEMP_PATH) - -if not os.path.exists(TEMP_PATH): - os.mkdir(TEMP_PATH) - -total_case = 0 -failed_case = 0 -TestCase.temp_path = TEMP_PATH - - -def is_testcase_exist(parsers, arg): - if not os.path.isabs(arg): - arg = TEST_PATH + arg - if not os.path.exists(arg): - parsers.error("The directory or file '%s' does not exist" % arg) - return os.path.abspath(arg) - - -def is_file(parsers, arg): - if not os.path.isfile(arg): - parsers.error("The file '%s' does not exist" % arg) - - return os.path.abspath(arg) - - -def is_directory(parsers, arg): - if not os.path.isdir(arg): - parsers.error("The directory '%s' does not exist" % arg) - - return os.path.abspath(arg) - - -def parse_and_execute(path, ark_runtime=False, skip_negative=True): - if path.endswith(".ts"): - test_cases = TestCase(path) - if not test_cases.is_test_case: - return False, False - # check test case declare - if not test_cases.check_declaration(): - print(test_cases.path, test_cases.detail_result, sep='\t') - return True, True - if skip_negative and test_cases.is_negative(): - return False, False - else: - test_cases.execute(ark_runtime) - if test_cases.fail: - print('TESTCASE Fail! Fail reason is coming:') - print(test_cases.path, test_cases.detail_result, sep='\t') - return True, True - return True, False - - -# create a parser object -parser = argparse.ArgumentParser(description="TypeScript Spec&Feature Test Tool") - -# files or command -parser.add_argument("release", nargs='*', metavar="release", type=lambda arg: is_testcase_exist(parser, arg), - help="All test case in the release will be execute") - -parser.add_argument("-a", "--arkruntime", action="store_true", default=False, help="test on ark_runtime") - -parser.add_argument("-s", "--skip-abnormal-case", action="store_true", default=False, help="skip abnormal test case") - -parser.add_argument("-v", "--version", dest='limit_version', default=None, help="version limit") - -# skip list -parser.add_argument("-d", "--disable-list", type=lambda arg: is_file(parser, arg), default=None, - help="path to the file that contains test to skip") - -parser.add_argument( - '--js-runtime', dest='js_runtime_path', default=None, type=lambda arg: is_directory(parser, arg), - help='the path of js vm runtime') -parser.add_argument( - '--LD_LIBRARY_PATH', dest='ld_library_path', default=None, help='LD_LIBRARY_PATH') - -parser.add_argument( - '--es2abc', dest='es2abc', default=None, help='ES2ABC_PATH') - -parser.add_argument( - '-tsc', dest='tsc', default="tsc", help='tsc') - -# parse the arguments from standard input -args = parser.parse_args() -if args.js_runtime_path: - TestCase.js_runtime_path = args.js_runtime_path -if args.ld_library_path: - TestCase.ld_library_path = args.ld_library_path -if args.es2abc: - TestCase.es2abc = args.es2abc - -TestCase.tsc = args.tsc - -disable_list = [] -if args.disable_list: - disable_list = get_disable_list(args.disable_list) - -# tsc + node / es2abc -print("TEST CASE", "FAIL REASON", "FAIL LINE", sep="\t") - -for file_path in args.release: - root = file_path - # gen abc file - if args.arkruntime: - for file_paths in get_path_file("suite", None, True): - if file_paths.endswith(".ts"): - test_case = TestCase(file_paths) - if not test_case.is_test_case: - test_case.create_abc(file_paths) - - for file_paths in get_path_file("test_ts_cases", None, True): - if file_paths.endswith(".ts"): - test_case = TestCase(file_paths) - if not test_case.is_test_case: - test_case.create_abc(file_paths) - - if is_disable_case(file_path, disable_list): - continue - if os.path.isfile(file_path): - is_test_count, failed = parse_and_execute(file_path, args.arkruntime, args.skip_abnormal_case) - if is_test_count: - total_case += 1 - if failed: - failed_case += 1 - continue - for file_paths in get_path_file(file_path, None, True, args.limit_version): - if not file_paths.endswith(".ts"): - continue - if is_disable_case(file_paths, disable_list): - continue - is_test_count, failed = parse_and_execute(file_paths, args.arkruntime, args.skip_abnormal_case) - if is_test_count: - total_case += 1 - if failed: - failed_case += 1 - -# delete abc files -if args.arkruntime: - for file_paths in get_path_file("suite", None, True): - if file_paths.endswith(".abc"): - if os.path.exists(file_paths): - os.remove(file_paths) - - for file_paths in get_path_file("test_ts_cases", None, True): - if file_paths.endswith(".abc"): - if os.path.exists(file_paths): - os.remove(file_paths) - if file_paths.endswith(".ts"): - if os.path.exists(file_paths): - file = open(file_paths, 'r') - lines = file.readlines() - if lines[-1] == 'print("TESTCASE SUCCESS");': - lines.pop() - lines[-1] = lines[-1].replace('\n', '') - file = open(file_paths, 'w') - file.writelines(lines) - file.close() - -print("TOTAL CASE COUNT:%d" % total_case) -print("FAILED CASE COUNT:%d" % failed_case) -# delete temp dir -if os.path.exists(TEMP_PATH): - shutil.rmtree(TEMP_PATH) diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/Ambient_Class_Declarations/Ambient_Class_Declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/Ambient_Class_Declarations/Ambient_Class_Declarations.ts new file mode 100644 index 0000000000..40efacf774 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/Ambient_Class_Declarations/Ambient_Class_Declarations.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + An ambient class declaration declares a class type and a constructor function in the containing declaration space. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +declare class Student { + constructor(sname?: string, sage?: number); + public sname: string; + public sage: number; + cl():number; +} +let s1 :Student ={ + sname:"static", + sage:12, + cl(){ + return 1; + } +} +Assert.equal(s1.sname,"static"); +Assert.equal(s1.sage,"12"); +Assert.equal(s1.cl(),1); +Assert.isFunction(s1.cl); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts new file mode 100644 index 0000000000..60d3b91412 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_function_declarations/ambient_function_declarations.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + an ambient function declaration introduces a function in the containing declaration space. + ambient functions may be overloaded by specifying multiple ambient function declarations with the same name, but it is an error to declare multiple overloads that are considered identical or differ only in their return types. + ambient function declarations cannot specify a function bodies and do not permit default parameter values. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +declare type DF1 = () => void; +declare type DF2 = (a: string, b: string) => string; +declare type DF3 = (a: number, b?: number) => string; +const dFun1: DF1 = () => { Assert.isString("dFun1"); } +const dFun2: DF2 = (a: string, b: string) => { Assert.isString("dFun2"); return a + b; } +const dFun3: DF3 = (a: number, b?: number) => { + let c: any; + if (b != undefined) { + c = a + b; + } else { + c = a; + } + c = c.toString(); + Assert.isString("dFun3"); + return "$" + c; +} +dFun1(); +Assert.equal(dFun2("A", "B"), 'AB'); +Assert.equal(dFun3(10, 20), "$30"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_namespace_declarations/ambient_namespace_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_namespace_declarations/ambient_namespace_declarations.ts new file mode 100644 index 0000000000..ccc60c491c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_namespace_declarations/ambient_namespace_declarations.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + an ambient namespace declaration declares a namespace. + except for ImportAliasDeclarations, AmbientNamespaceElements always declare exported entities regardless of whether they include the optional export modifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +declare namespace AmbientNamespace { + var an1: string; + export var an2: string; + interface ColorInterface { + Red: number; + Green: number; + Blue: number; + } +} +var colorI: AmbientNamespace.ColorInterface = { Red: 0, Green: 1, Blue: 2 }; +Assert.equal(JSON.stringify(colorI), '{"Red":0,"Green":1,"Blue":2}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_variable_declarations/ambient_variable_declarations.ts similarity index 62% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_variable_declarations/ambient_variable_declarations.ts index 0b823f8aeb..d76695a41e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_declarations/ambient_variable_declarations/ambient_variable_declarations.ts @@ -14,8 +14,7 @@ */ /**--- description: > - String literal types are permitted only in that context and nowhere else. - string literals no longer always have the type string. + An ambient variable declaration introduces a variable in the containing declaration space. module: ESNext isCurrent: true ---*/ @@ -23,14 +22,14 @@ import { Assert } from '../../../../../suite/assert.js' -let HELLO: "HELLO" = "HELLO"; -let WORLD: "WORLD" = "WORLD"; +declare type variable1 = number; +declare type variable2 = string; +declare type variable3 = (vab1:number,vab2:string) => string;; -let hello = HELLO.toLowerCase(); -Assert.equal(hello, "hello"); +var vab1:variable1 = 3; +let vab2:variable2 = "www"; +const vab3:variable3 = (vab1,vab2) =>{return vab1+vab2;} -let HELLOWORLD = HELLO + WORLD; -Assert.equal(HELLOWORLD, "HELLOWORLD"); - -let a: "foo" | number = "foo"; -Assert.equal(a, 'foo'); \ No newline at end of file +Assert.equal(typeof vab1,"number"); +Assert.equal(typeof vab2,"string"); +Assert.equal(vab3(vab1,vab2),"3www"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_1.ts similarity index 62% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_1.ts index f88d8baf94..6052602a32 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_1.ts @@ -14,19 +14,20 @@ */ /**--- description: > - If the declaration includes a type annotation, the parameter is of that type. + ambient modules are "open-ended" and ambient module declarations with the same string literal name contribute to a single module. module: ESNext isCurrent: true ---*/ -import { Assert } from '../../../../../../suite/assert.js' +import { Assert } from "../../../../suite/assert.js" -function ff(first: string, second: number) { - return first; +declare module AMD1 { + export var a1: any; + export interface AMD1IF { + a1_1: any; + a1_2: number; + } } -let first = "first"; -let second = 2; -ff(first, second); -Assert.equal(first, "first"); -Assert.equal(second, 2); \ No newline at end of file +var am2: AMD1.AMD1IF = { a1_1: "am2", a1_2: 123 }; +Assert.equal(JSON.stringify(am2), '{"a1_1":"am2","a1_2":123}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts new file mode 100644 index 0000000000..22d8b49755 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/ambients/ambient_module_declarations/ambient_module_declarations_3.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + if an ambient module declaration includes an export assignment, it is an error for any of the declarations within the module to specify an export modifier. + if an ambient module declaration contains no export assignment, entities declared in the module are exported regardless of whether their declarations include the optional export modifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +export declare module m1 { + interface I1 { + a3_1: boolean; + a3_2: number; + } + var AMD2Var1: string; +} +declare module m2 { + export interface I2 { + a3_1: boolean; + a3_2: string; + } + export var AMD2Var1: string; +} +var am3_1: m1.I1 = { a3_1: false, a3_2: 0 }; +var am3_2: m2.I2 = { a3_1: true, a3_2: "T" }; +Assert.equal(JSON.stringify(am3_1), '{"a3_1":false,"a3_2":0}'); +Assert.equal(JSON.stringify(am3_2), '{"a3_1":true,"a3_2":"T"}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_body/class_body.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_body/class_body.ts new file mode 100644 index 0000000000..08b2bd7059 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_body/class_body.ts @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The class body consists of zero or more constructor or member declarations. + Statements are not allowed in the body of a class—they must be placed in the constructor or in members. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Compute { + num1: number; + num2: number; + constructor(num1: number, num2: number) { + this.num1 = num1; + this.num2 = num2; + } + public hypot() { + return Math.sqrt(this.num1 * this.num1 + this.num2 * this.num2); + } + static initial = new Compute(0, 0); +} +let p: Compute = new Compute(10, 20); +Assert.equal(10, p.num1); +Assert.equal(20, p.num2); +Assert.equal(0, Compute.initial.num1); +Assert.equal(0, Compute.initial.num2); +let p2: Compute = new Compute(4, 3) +Assert.equal(5, p2.hypot()) + +class Circle { + radius: number = 1; +} +let c = new Circle(); +Assert.equal(c.radius, 1); +type TypeSummation = { + width?: number; + height?: number; +}; +class summation { + public width: number; + public height: number; + constructor(width: number, height: number); + constructor(ParamObje_: TypeSummation); + constructor(ParamObje_Obj_: any, height_ = 0) { + if (typeof ParamObje_Obj_ === "object") { + const { width, height } = ParamObje_Obj_; + this.width = width; + this.height = height; + } else { + this.width = ParamObje_Obj_; + this.height = height_; + } + } + sunArea(): number { + return this.width * this.height; + } +} +let sun = new summation(4, 5); +Assert.equal(sun.sunArea(), 20); +let obj: TypeSummation = { width: 10, height: 2 }; +let sun2 = new summation(obj); +Assert.equal(sun2.sunArea(), 20); + +class IndexNum { + [key: string]: number | string[]; + constructor(keyList: string[] = [], valueList: string[][] | number[] = []) { + let len = 0; + if ((keyList !== undefined) && (valueList !== undefined)) { + if (keyList.length <= valueList.length) { + len = keyList.length; + } else { + len = valueList.length; + } + for (let i: number = 0; i < len; i++) { + this[keyList[i]] = valueList[i]; + } + } + } +}; +let index = new IndexNum(['A', 'B', 'C'], [0, 1, 2]); +Assert.equal(index['A'], 0); +index['B'] = 5; +Assert.equal(index['B'], 5); +Assert.equal(index.C, 2); +index['D'] = ['D', 'E']; +index.E = 9; +Assert.equal(JSON.stringify(index.D), '["D","E"]'); +Assert.equal(index['E'], 9); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_1.ts new file mode 100644 index 0000000000..8f381f91de --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_1.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A class declaration declares a class type and a constructor function: class BindingIdentifieropt TypeParametersopt ClassHeritage { ClassBody } + module: ESNext + isCurrent: true + ---*/ +import { Assert } from '../../../../suite/assert.js' + +class Rectangle { + constructor(public height: number, public width: number) { }; + get area() { + return this.calcArea() + } + calcArea() { + return this.height * this.width; + } +} +let square = new Rectangle(10, 10); +Assert.equal(100, square.area); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_2.ts new file mode 100644 index 0000000000..eaa0ec471b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_2.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A class declaration declares a class type and a constructor function: class BindingIdentifieropt TypeParametersopt ClassHeritage { ClassBody } + module: ESNext + isCurrent: true + ---*/ +import { Assert } from '../../../../suite/assert.js' + +class MyClass { + constructor(public x: number, public y: number) { + this.x = x; + this.y = y; + } + static initial = new MyClass(0, 0); + static distance(a: MyClass, b: MyClass) { + let dx = a.x - b.x; + let dy = a.y - b.y; + return Math.hypot(dx, dy); + } +} +Assert.equal(0, MyClass.initial.x); +Assert.equal(0, MyClass.initial.y); +let p1 = new MyClass(0, 4); +let p2 = new MyClass(3, 0); +Assert.equal(0, p1.x); +Assert.equal(4, p1.y); +Assert.equal(3, p2.x); +Assert.equal(0, p2.y); +Assert.equal(5, MyClass.distance(p1, p2)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_3.ts new file mode 100644 index 0000000000..ea990b064c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_declarations_3.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A class with type parameters is called a generic class. + module: ESNext + isCurrent: true + ---*/ +import { Assert } from '../../../../suite/assert.js' + +class MyClass { + field: T; + constructor(field: T) { + this.field = field; + } + public getFieldName(): T { + return this.field; + } +} +class Compute { + constructor(public num1: number, public num2: number) { } + public hypot() { + return Math.sqrt(this.num1 * this.num1 + this.num2 * this.num2); + } +} +let mc1: MyClass = new MyClass("a"); +Assert.equal("a", mc1.field); +Assert.equal("a",mc1.getFieldName()); +let mc2: MyClass = new MyClass(1); +Assert.equal(1, mc2.field); +Assert.equal(1,mc2.getFieldName()); +let mc3: MyClass = new MyClass(false); +Assert.equal(false, mc3.field); +Assert.equal(false,mc3.getFieldName()); +let p: Compute = new Compute(8, 6); +let mc4: MyClass = new MyClass(p); +Assert.equal(8, mc4.field.num1); +Assert.equal(6, mc4.field.num2); +Assert.equal(10,mc4.field.hypot()); + +let obj: object = { + x: 1, + y: 2 +} +let mc5: MyClass = new MyClass(obj); +Assert.equal(obj, mc5.field); +let list: Array = [1, 2, 3]; +let mc6: MyClass> = new MyClass>(list); +Assert.equal(list, mc6.field); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts similarity index 47% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts index 4e414adda1..eb1837f98c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_1.ts @@ -14,8 +14,7 @@ */ /**--- description: > - every class and interface has a this-type that represents the actual type of instances of the class or interface within the declaration of the class or interface. The this-type is referenced using the keyword this in a type position. - within instance methods and constructors of a class, the type of the expression this is the this-type of the class. + A class that includes an extends clause is called a derived class, and the class specified in the extends clause is called the base class of the derived class. module: ESNext isCurrent: true ---*/ @@ -23,30 +22,31 @@ import { Assert } from '../../../../../suite/assert.js' -class CA { - name: string = "CA"; - f() { - return this; - } - caName(cname: string) { - this.name = cname; - return "CA:" + this.name; +class Compute { + constructor(public num1: number, public num2: number) { } + public hypot() { + return Math.sqrt(this.num1 * this.num1 + this.num2 * this.num2); } + static initial = new Compute(0, 0); } - -class CB extends CA { - b() { - return this; +class ChildP extends Compute { + constructor(public x: number, public y: number) { + super(x, y); } - cbName(cname: string) { - this.name = cname; - return "CB:" + this.name; + public move() { + this.x += 1; + this.y += 1; } } -let bB: CB = new CB(); -let xB = bB.f().b(); -Assert.equal(bB, xB); -let thisStrB: string = bB.cbName("CB"); -Assert.equal(thisStrB, "CB:CB"); -let thisStrA: string = bB.caName("CA"); -Assert.equal(thisStrA, "CA:CA"); \ No newline at end of file +let pChild: ChildP = new ChildP(10, 20); +Assert.equal(10, pChild.x); +Assert.equal(20, pChild.y); +pChild.move(); +Assert.equal(11, pChild.x); +Assert.equal(21, pChild.y); +Assert.equal(0, ChildP.initial.num1); + +let count:ChildP = new ChildP(4,3); +Assert.equal(4, count.x); +Assert.equal(3, count.y); +Assert.equal(5,count.hypot()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts new file mode 100644 index 0000000000..cb1f816f5e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_2.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the implements clause specifies a set of interfaces for which to validate the class provides an implementation. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Compute { + constructor(public num1: number, public num2: number) { } + public hypot() { + return Math.sqrt(this.num1 * this.num1 + this.num2 * this.num2); + } + static initial = new Compute(0, 0); +} +let p: Compute = new Compute(4, 3); +Assert.equal(4, p.num1); +Assert.equal(3, p.num2); +Assert.equal(5,p.hypot()) + +interface InterP1 { + x: number; + y: number; +} +class P2 implements InterP1 { + x = 1; + y = 1; + setarea(x: number, y: number) { + return x * y; + } +} +let Ip = new P2(); +Assert.equal(1, Ip.x); +Assert.equal(1, Ip.y); +Assert.equal(2,Ip.setarea(1,2)) + +interface InterP2 { + Area(x: number, y: number): number; +} +class Rectangle implements InterP2 { + Area(x: number, y: number): number { + return x * y; + } +} +let rec = new Rectangle(); +Assert.equal(200, rec.Area(10, 20)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts new file mode 100644 index 0000000000..57caf3cfdb --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_3.ts @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The this-type (section 3.6.3) of the declared class must be assignable (section 3.11.4) to the base type reference + and each of the type references listed in the implements clause. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Addx { + constructor(public x: number) { } + public add(): this { + this.x++; + return this; + } +} +class ChildAddx extends Addx { + constructor(public x: number) { + super(x); + } + public move(): this { + this.x++; + return this; + } +} +let childadd: ChildAddx = new ChildAddx(10); +Assert.equal(11, childadd.move().x); +let a: Addx = childadd.move(); +Assert.equal(13, a.add().x); + +interface InterAddx { + x: number; +} +class Addx2 implements InterAddx { + x = 1; + setadd(): this { + this.x++; + return this; + } +} +let b1 = new Addx2(); +Assert.equal(2, b1.setadd().x); +let interb1: InterAddx = b1.setadd(); +Assert.equal(3, interb1.x); + +interface InterP { + Area(x: number, y: number): number; +} +class Rectangle implements InterP { + Area(x: number, y: number): number { + return x * y; + } + setRec(): this { + return this; + } +} +let b2 = new Rectangle(); +Assert.equal(200, b2.Area(10, 20)); +let interb2: InterP = b2.setRec(); +Assert.equal(200, interb2.Area(10, 20)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts new file mode 100644 index 0000000000..4075363ecc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_4.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + as is the case with every object type, type references (section 3.3.1) to the class + will appear to have the members of the global interface type named 'Object' + unless those members are hidden by members with the same name in the class. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Compute { + constructor(public num1: number, public num2: number) { } + public hypot() {return "what are you doing?" } + static initial = new Compute(0, 0); +} +let p = new Compute(1, 2); +let obj = new Object(); +Assert.equal(p.toString(), obj.toString()); +Assert.isString(p.hypot()); +Assert.equal(0,Compute.initial.num1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_5.ts new file mode 100644 index 0000000000..7126a82c87 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_5.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The type parameters of a generic class declaration are in scope in the entire declaration and may be referenced in the ClassHeritage and ClassBody. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class MyClass{ + myArry: T[] = []; + add(num: T): void { + this.myArry.push(num); + } + max(): T { + let mNum = this.myArry[0]; + for (let i = 0; i < this.myArry.length; i++) { + if (mNum < this.myArry[i]) { + mNum = this.myArry[i]; + } + } + return mNum; + } +} +let h_m: MyClass = new MyClass(); +h_m.add(5); +h_m.add(4); +h_m.add(9); +h_m.add(15); +Assert.equal(h_m.max(), 15); +let h_m2: MyClass = new MyClass(); +h_m2.add('b'); +h_m2.add('a'); +h_m2.add('w'); +h_m2.add('f'); +Assert.equal(h_m2.max(), 'w'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_6.ts new file mode 100644 index 0000000000..227a5aaefe --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/class_declarations/class_heritage_specification/class_heritage_specification_6.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The constructor function type created by the class declaration must be assignable to the base class constructor function type + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Person { + name: string; + age: number; + constructor(name: string, age: number) { + this.name = name; + this.age = age; + } +} +class Student extends Person { + constructor(name: string, age: number, public id: string) { + super(name, age); + this.id = id; + } +} +let stu1: Student = new Student("xiao", 18, "001"); +let per1: Person = stu1; +Assert.equal("xiao", per1.name); +Assert.equal(18, per1.age); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/function_type_literals/function_type_literals_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_1.ts similarity index 63% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/function_type_literals/function_type_literals_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_1.ts index 711f57f6cf..3e40064410 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/function_type_literals/function_type_literals_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_1.ts @@ -14,8 +14,7 @@ */ /**--- description: > - Function types with multiple call or construct signatures cannot be written as function type literals - but must instead be written as object type literals. + If a class omits a constructor declaration, an automatic constructor is provided. module: ESNext isCurrent: true ---*/ @@ -23,16 +22,23 @@ import { Assert } from '../../../../../suite/assert.js' -interface I { - (x: string): number; - (x: number): string +class A { + x: number = 1; + y: string = "go"; } -let i: I = Object.assign(function (x: any) { - if (typeof x === 'string') { - return x.toString(); - } else { - return x.toString(); - } -}) -Assert.equal(i('a'), 'a'); -Assert.equal(i(2), 2); \ No newline at end of file +let a = new A(); +Assert.equal(a.x, 1); +Assert.equal(a.y, "go"); +class B { + x: number; + y: string; + constructor(x: number = 1, y: string = "go") { + this.x = x; + this.y = y; + } +} +let b = new B(); +Assert.equal(a.x, 1); +Assert.equal(a.y, "go"); +Assert.equal(b.x, 1); +Assert.equal(b.y, "go"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_2.ts similarity index 45% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_2.ts index 59218da010..1faf83d9b3 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_2.ts @@ -14,8 +14,7 @@ */ /**--- description: > - Constructor types may be written using constructor type literals - or by including construct signatures in object type literals. + In a derived class, the automatic constructor has the same parameter list (and possibly overloads) as the base class constructor. module: ESNext isCurrent: true ---*/ @@ -23,33 +22,38 @@ import { Assert } from '../../../../../suite/assert.js' -class Person { - name: string; - age: number; - constructor(n: string, age: number) { - this.name = n; - this.age = age; +class Point1 { + x: string; + y: string; + constructor(x: string, y: string) { + this.x = x; + this.y = y; } - run(): string { - return "person"; + toString() { + return this.x + " " + this.y; } } -class Student extends Person { - run(): string { - return "student"; +class ColorPoint extends Point1 { + color: string; + constructor(x: string, y: string, color: string) { + super(x, y); + this.color = color; + } + toString() { + return this.color + " " + super.toString(); } } -class Teacher extends Person { - run(): string { - return "teacher"; +let co = new ColorPoint("A", "B", "blue"); +Assert.equal(co.x, "A"); +Assert.equal(co.y, "B"); +Assert.equal(co.color, "blue"); +Assert.equal(co.toString(), "blue A B"); +class ColorPoint2 extends Point1 { + constructor(x: string, y: string) { + super(x, y); } } - -let testClass1: new (name: string, age: number) => Person = Student; -let testObj1: Person = new testClass1("caihua1", 12); -Assert.equal(testObj1.age, 12); -Assert.equal(testObj1.name, "caihua1"); -let testClass2: { new(n: string, a: number): Person } = Teacher; -let testObj2: Person = new testClass2("caihua2", 120); -Assert.equal(testObj2.age, 120); -Assert.equal(testObj2.name, "caihua2"); \ No newline at end of file +let co2 = new ColorPoint2("a", "b"); +Assert.equal(co2.x, "a"); +Assert.equal(co2.y, "b"); +Assert.equal(co2.toString(), "a b"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_3.ts new file mode 100644 index 0000000000..a7a294bd11 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/automatic_constructors/automatic_constructors_3.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a class with no extends clause, the automatic constructor has no parameters + and performs no action other than executing the instance member variable initializers (section 8.4.1), if any. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Foo { + constructor(public x: number = 1, public y: string = "go") { + this.x = x; + this.y = y; + } +} +let foo = new Foo(); +Assert.equal(foo.x, 1); +Assert.equal(foo.y, "go"); +class Foo2 { + x: number; + y: string; + constructor(x: number, y: string) { + this.x = x; + this.y = y; + } +} +let foo2 = new Foo2(2, "go"); +Assert.equal(foo2.x, 2); +Assert.equal(foo2.y, "go"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts similarity index 70% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts index 68ac126824..79d6a94147 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_1.ts @@ -14,7 +14,10 @@ */ /**--- description: > - An object type containing one or more construct signatures is said to be a constructor type. + Constructor declarations that specify a body are called constructor implementations and + constructor declarations without a body are called constructor overloads. + It is possible to specify multiple constructor overloads in a class, + but a class can have at most one constructor implementation. module: ESNext isCurrent: true ---*/ @@ -22,7 +25,7 @@ import { Assert } from '../../../../../suite/assert.js' -class Animal { +class Animal1 { name: string | undefined; age: number | undefined; constructor(); @@ -41,11 +44,13 @@ class Animal { } } } -let tt1 = new Animal(); -let tt2 = new Animal("caihua2", 12); +let tt1 = new Animal1("caihua1",NaN); +Assert.equal(tt1.name,"caihua1"); +Assert.equal(tt1.age, undefined); +let tt2 = new Animal1("caihua2", 12); Assert.equal(tt2.name, "caihua2"); Assert.equal(tt2.age, 12); -let tt3 = new Animal("caihua3"); +let tt3 = new Animal1("caihua3"); Assert.equal(tt3.name, "caihua3"); -let tt4 = new Animal(1230); +let tt4 = new Animal1(1230); Assert.equal(tt4.age, 1230); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_symbol_type/the_symbol_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts similarity index 50% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_symbol_type/the_symbol_type_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts index 8ccc6d6508..2af41b9e05 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_symbol_type/the_symbol_type_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_2.ts @@ -14,10 +14,9 @@ */ /**--- description: > - the Symbol primitive type represents a unique token - that can be used as a property key for an object. - options: - lib: es2015 + A parameter of a ConstructorImplementation may be prefixed with a public, private, or protected modifier. + This is called a parameter property declaration and is shorthand for declaring a property with the same name as the parameter + and initializing it with the value of the parameter. module: ESNext isCurrent: true ---*/ @@ -25,7 +24,25 @@ import { Assert } from '../../../../../suite/assert.js' -let sym: symbol = Symbol(); -let obj1: object = { [sym]: "symbol" }; -type Key = keyof typeof obj1; -Assert.equal(obj1[sym as Key], "symbol"); \ No newline at end of file +class MyClass1 { + constructor(public num1: number, private num2: number = 1) { } + get foo(): number { + return this.num2; + } +} +class MyClass2 { + public num1: number; + protected num2: number; + constructor(num1: number, num2: number) { + this.num1 = num1; + this.num2 = num2; + } + get foo(): number { + return this.num2; + } +} +let p1 = new MyClass1(1, 2); +Assert.equal(p1.num1, 1); +Assert.equal(p1.foo, 2); +let p2 = new MyClass2(3, 4); +Assert.equal(p2.foo, 4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_3.ts similarity index 56% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_3.ts index 27fe913488..8138bbfb04 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_3.ts @@ -14,8 +14,8 @@ */ /**--- description: > - When all constituent types of U have an apparent string index signature, - U has an apparent string index signature of a union type of the respective string index signature types. + The function body of a constructor is permitted to contain return statements. If return statements specify expressions, + those expressions must be of types that are assignable to the this-type of the class. module: ESNext isCurrent: true ---*/ @@ -23,21 +23,22 @@ import { Assert } from '../../../../../suite/assert.js' -interface Array1 { - [index1: string]: string -} -interface Array2 { - [index2: string]: string -} -function test(obj: Array1 | Array2) { - return "right" -} -const stu1 = { - age: "19" +class myClass1 { + num: number; + constructor(num: number) { + this.num = num + return; + } } -const stu2 = { - name: "xiao" +let myTest1 = new myClass1(5); +Assert.equal(myTest1.num, 5); +class myClass2 { + num: number; + constructor(num: number) { + this.num = num + return { num: 10 }; + } } -Assert.equal(test(stu1), "right"); -Assert.equal(test(stu2), "right"); \ No newline at end of file +let myTest2 = new myClass2(5); +Assert.equal(myTest2.num, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_4.ts similarity index 74% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_4.ts index b72720d112..ce311d0f45 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_4.ts @@ -14,8 +14,7 @@ */ /**--- description: > - Type parameter names must be unique. A compile-time error occurs - if two or more type parameters in the same TypeParameterList have the same name. + The type parameters of a generic class are in scope and accessible in a constructor declaration. module: ESNext isCurrent: true ---*/ @@ -23,7 +22,11 @@ import { Assert } from '../../../../../suite/assert.js' -function sum(a: T, b: K): string { - return "a"; +class myClass{ + num: T; + constructor(num: T) { + this.num = num; + } } -Assert.equal(sum(1, 1), "a"); +let myTest = new myClass(10); +Assert.equal(myTest.num, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_5.ts similarity index 61% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_5.ts index 3faad4a7ce..4ee4119aa9 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_5.ts @@ -14,8 +14,8 @@ */ /**--- description: > - S is a subtype of a type T, and T is a supertype of S, - if S has no excess properties with respect to T and S is the Undefined type. + A parameter property declaration may declare an optional parameter, + but the property introduced by such a declaration is always considered a required property. module: ESNext isCurrent: true ---*/ @@ -23,25 +23,14 @@ import { Assert } from '../../../../../suite/assert.js' -interface T { - name: string | undefined - age: number | undefined +class myClass { + constructor(public num1: number, public num2?: number, public num3: number = 10) { + this.num1 = num1; + this.num2 = num2; + this.num3 = num3; + } } -interface S { - name: undefined - age: undefined - hobbies: undefined -} -let t: T = { - name: "T", - age: 20 -}; - -let s: S = { - name: undefined, - age: undefined, - hobbies: undefined -}; - -t = s; -Assert.equal(t, s); \ No newline at end of file +let myTest = new myClass(3); +Assert.equal(myTest.num1, 3); +Assert.equal(myTest.num3, 10); +Assert.equal(myTest.num2, undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_6.ts similarity index 64% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_6.ts index 1e2ef9e1ba..3c0093b044 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/constructor_parameters/constructor_parameters_6.ts @@ -14,7 +14,7 @@ */ /**--- description: > - a call to a generic function may explicitly include a type argument list instead of relying on type inference. + In a class with no constructor declaration, an automatic constructor is provided, as described in section 8.3.3. module: ESNext isCurrent: true ---*/ @@ -22,14 +22,15 @@ import { Assert } from '../../../../../suite/assert.js' -interface GenericIdentityFn { - (arg: T): T; +class myClass { + public a: string = "test"; + public b: number = 1; } -function identity(arg: T): T { - return arg; +class myClass2 { + public c: number = 2; } -let x: number = 1; -let y: GenericIdentityFn = identity; -let z = y(x); -Assert.equal(z, 1); - +let myTest: myClass = new myClass(); +Assert.equal(myTest.a, "test"); +Assert.equal(myTest.b, 1); +let myTest2: myClass2 = new myClass2(); +Assert.equal(myTest2.c, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/super_calls/super_calls.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/super_calls/super_calls.ts new file mode 100644 index 0000000000..c938838f71 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/constructor_declarations/super_calls/super_calls.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Super calls (section 4.9.1) are used to call the constructor of the base class. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class P { + public num1: number; + public num2: number; + constructor(num1: number, num2: number) { + this.num1 = num1; + this.num2 = num2; + } +} +class HueP extends P { + constructor(num1: number, num2: number, public hue: string) { + super(num1, num2); + } +} +let p1 = new HueP(1, 2, "red"); +Assert.equal(p1.num1, 1); +Assert.equal(p1.num2, 2); +Assert.equal(p1.hue, "red"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/decorators/decorators.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/decorators/decorators.ts new file mode 100644 index 0000000000..cf935f6063 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/decorators/decorators.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Class decorator. + module: ESNext + isCurrent: true + experimentalDecorators: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function create(name:string,age:number){ + return function(constructor:T){ + return class extends constructor { + name = name + age = age + } + } +} + +@create("小张",22) +class Man { + name:string + height = 180 + constructor(name:string){ + this.name = name + } +} +let man = new Man("jack"); +Assert.equal(man.height,"180"); +Assert.notEqual(man.name,"jack"); +Assert.equal(man.name,"小张") diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/index_member_declarations/index_member_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/index_member_declarations/index_member_declarations.ts new file mode 100644 index 0000000000..d0584deafc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/index_member_declarations/index_member_declarations.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + All instance property members of a class must satisfy + the constraints implied by the index members of the class as specified in section 3.9.4. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class ind { + name: string; + [index: string]: number | string; + constructor(name: string) { + this.name = name; + } +} +let a = new ind("aa"); +a.name = "pig"; +a.age = 12; +Assert.equal(a.age, 12); +a.add = "qindao"; +Assert.equal(a.add, "qindao"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_1.ts new file mode 100644 index 0000000000..90ac66d160 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_1.ts @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Public property members can be accessed everywhere without restrictions. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Base { + public a: number; + constructor(a: number) { + this.a = a; + } + public add() { + this.a++; + } +} +class Derived extends Base { + public b: number; + constructor(a: number, b: number) { + super(a); + this.b = b; + } + public geta() { + return this.a; + } +} +let derived: Derived = new Derived(1, 2); +let x = derived.a; +Assert.equal(x, 1); +let y = derived.geta(); +Assert.equal(y, 1); +let z: Base = new Base(3); +Assert.equal(z.a, 3); +z.add(); +Assert.equal(z.a, 4); +class MyClass{ + public myArry: T[] = []; + public add(num: T): void { + this.myArry.push(num); + } + public max(): T { + let mNum = this.myArry[0]; + for (let i = 0; i < this.myArry.length; i++) { + if (mNum < this.myArry[i]) { + mNum = this.myArry[i]; + } + } + return mNum; + } +} +let h_m: MyClass = new MyClass(); +h_m.add(5); +h_m.add(4); +h_m.add(9); +h_m.add(15); +Assert.equal(h_m.max(), 15); +let h_m2: MyClass = new MyClass(); +h_m2.add('b'); +h_m2.add('a'); +h_m2.add('w'); +h_m2.add('f'); +Assert.equal(h_m2.max(), 'w'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_2.ts new file mode 100644 index 0000000000..0a8a658283 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_2.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain m copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Private property members can be accessed only within their declaring class. Specifically, + m private member M declared in m class C can be accessed only within the class body of C. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Base { + private x: number = 1; + private y: number = 2; + addx() { + this.x++; + } + get foo() { + return this.x; + } + public addxy(): number { + return this.x + this.y; + } + static fun(m: Base, n: Derived) { + m.x = 1; + n.x = 1; + m.y = 1; + n.y = 1; + } +} +class Derived extends Base { } +let m: Base = new Base(); +m.addx(); +Assert.equal(m.foo, 2); +Assert.equal(m.addxy(), 4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_3.ts similarity index 47% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_3.ts index 1fde37489d..b91989153a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/accessibility/accessibility_3.ts @@ -14,8 +14,8 @@ */ /**--- description: > - A type reference references a named type or type parameter through its name and, in the case of a generic type, supplies a type argument list. - A TypeReference consists of a TypeName that a references a named type or type parameter. A reference to a generic type must be followed by a list of TypeArguments. + Protected property members can be accessed only within their declaring class and classes derived from their declaring class, + and a protected instance property member must be accessed through an instance of the enclosing class or a subclass thereof. module: ESNext isCurrent: true ---*/ @@ -23,18 +23,41 @@ import { Assert } from '../../../../../suite/assert.js' -let obj: { - month: number; - day: number; -} = { - month: 5, - day: 15 +class Base { + protected x: number = 1; + protected y: number = 4; + protected addxy() { + return this.x + this.y; + } + public addx() { + this.x++; + } + public get foo() { + return this.x; + } + static fun(m: Base, b: Derived) { + m.x = 1; + b.x = 1; + m.y = 1; + b.y = 1; + } } -Assert.equal(obj.month, 5); -Assert.equal(obj.day, 15); -function identity1(value: T, message: U): [T, U] { - return [value, message]; +class Derived extends Base { + public get add(): number { + return this.addxy() + } + public get foo() { + return this.x; + } + static fun(b: Derived) { + b.x = 1; + b.y = 1; + } } -let identi = identity1(1, 'string'); -Assert.equal(identi[0], 1); -Assert.equal(identi[1], 'string'); \ No newline at end of file +let m: Base = new Base(); +m.addx(); +Assert.equal(m.foo, 2); +let b: Derived = new Derived(); +b.addx(); +Assert.equal(b.foo, 2); +Assert.equal(b.add, 6); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_1.ts new file mode 100644 index 0000000000..25ab9d6c7f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_1.ts @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Within the constructor and instance member functions of a class, the type of this is the this-type of that class type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Ra { + public x: number; + public y: number; + constructor(x: number, y: number) { + this.x = x; + this.y = y; + } + public addx(): this { + this.x++; + return this + } + public addy(): this { + this.y++; + return this; + } + public add() { + return this.x + this.y; + } +} +class Rb extends Ra { + public z: number; + constructor(x: number, y: number, z: number) { + super(x, y); + this.z = z; + } + public addz(): this { + this.z++; + return this; + } +} +let a: Ra = new Ra(1, 1); +let b: Rb = new Rb(1, 1, 1); +Assert.equal(a.addx().x, 2); +Assert.equal(a.addx().y, 1); +Assert.equal(a.addx().add(), 5); +Assert.equal(a.addy().x, 4); +Assert.equal(a.addy().y, 3); +Assert.equal(a.add(), 7); +Assert.equal(b.addx().x, 2); +Assert.equal(b.addx().y, 1); +Assert.equal(b.addy().x, 3); +Assert.equal(b.addy().y, 3); +Assert.equal(b.addz().z, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_2.ts new file mode 100644 index 0000000000..7686b8c6f2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_2.ts @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + All instance property members of a class must satisfy the constraints implied by the index members of the class . + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Ra { + public h_x: number; + constructor(h_x: number) { + this.h_x = h_x; + } + public h_f() { + this.h_x++; + } + public h_g(): any { + return this.h_x; + } + static h_s: string = "aa"; +} +let aa: Ra = new Ra(1); +Assert.equal(aa.h_x, 1); +aa.h_f(); +Assert.equal(aa.h_x, 2); +class Rb extends Ra { + public h_y: number; + constructor(h_x: number, h_y: number) { + super(h_x); + this.h_y = h_y; + } + public h_g(): boolean { return false; } +} +let bb: Rb = new Rb(1, 2); +Assert.equal(bb.h_x, 1); +Assert.equal(bb.h_y, 2); +bb.h_f(); +Assert.equal(bb.h_x, 2); +Assert.equal(bb.h_g(), false); +interface Rc { + h_x: number; + h_f: () => void; + h_g: () => any; +} +let c: Rc = aa; +Assert.equal(c.h_g(), 2); +interface Rd { + h_x: number; + h_y: number; + h_f: () => void; + h_g: () => boolean; +} +let d: Rd = bb; +Assert.equal(d.h_g(), false); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_3.ts new file mode 100644 index 0000000000..870c54edb0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/class_types/class_types_3.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The class type has a property for each constructor parameter declared with a public, private, or protected modifier. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Ra { + public x: number = 10; + private y: number = 10; + protected z: number = 10; + constructor() { }; + public f() { + this.x++; + return this; + } + public gety(): number { + return this.y; + } + public getz(): number { + return this.z; + } + protected fun(): boolean { + return false; + } + public getfun() { + return this.fun(); + } +} +class Rb extends Ra { + protected z: number = 20; + protected fun(): boolean { + return true; + } +} +let a: Ra = new Ra(); +Assert.equal(a.x, 10); +Assert.equal(a.gety(), 10); +Assert.equal(a.getz(), 10); +Assert.equal(a.getfun(), false); +Assert.equal(a.f().x, 11); +let b: Rb = new Rb(); +Assert.equal(b.x, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_1.ts new file mode 100644 index 0000000000..0eeb7cee80 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_1.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the class contains no constructor declaration and has no base class, + a single construct signature with no parameters, + having the same type parameters as the class (if any) + and returning an instantiation of the class type with those type parameters passed as type arguments. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class A { + a: number = 0; + b: number = 0; + constructor() { } +} +let a = new A(); +Assert.equal(a.a, 0); +Assert.equal(a.b, 0); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_2.ts similarity index 52% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_2.ts index 23960d1795..83f781677c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_2.ts @@ -14,8 +14,10 @@ */ /**--- description: > - A literal type may overload a method by declaring multiple method signatures - with the same name but differing parameter lists. + If the class contains no constructor declaration and has a base class, + a set of construct signatures with the same parameters as those of the base class constructor function type + following substitution of type parameters with the type arguments specified in the base class type reference, + all having the same type parameters as the class. module: ESNext isCurrent: true ---*/ @@ -23,27 +25,21 @@ import { Assert } from '../../../../../suite/assert.js' -class A { - add(x: number, y: number): number; - add(x: number, y: number, z: number): number; - add(x: any, y: any, z?: any): any { - if ( - typeof x == "number" && - typeof y == "number" && - typeof z == "undefined" - ) { - return x + y; - } - if ( - typeof x === "number" && - typeof y === "number" && - typeof z === "number" - ) { - return x + y + z; - } +class A1 { + public numa: number; + constructor(a: number) { + this.numa = a; } } -let a1 = new A(); -Assert.equal(a1.add(1, 2), 3); -let a2 = new A(); -Assert.equal(a2.add(1, 2, 3), 6); +class B1 extends A1 { + public numb: number; + constructor(a: number, b: number) { + super(a); + this.numb = b; + } +} +let a: A1 = new A1(1); +Assert.equal(a.numa, 1); +let b: B1 = new B1(2, 2); +Assert.equal(b.numa, 2); +Assert.equal(b.numb, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_3.ts new file mode 100644 index 0000000000..4d8e22be4b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_3.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the class contains a constructor declaration with no overloads, + a construct signature with the parameter list of the constructor implementation, + having the same type parameters as the class (if any) + and returning an instantiation of the class type with those type parameters passed as type arguments. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class A { + public x: number; + public y: number; + constructor(x: number, y: number) { + this.x = x; + this.y = y; + } +} +let a = new A(1, 2); +Assert.equal(a.x, 1); +Assert.equal(a.y, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_4.ts similarity index 42% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_4.ts index 542289e72a..3ccc9e317d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_4.ts @@ -14,8 +14,9 @@ */ /**--- description: > - Class, interface, type alias, and function declarations may optionally include - lists of type parameters enclosed in < and > brackets. + If the class contains a constructor declaration with overloads, a set of construct signatures + with the parameter lists of the overloads, all having the same type parameters as the class (if any) + and returning an instantiation of the class type with those type parameters passed as type arguments. module: ESNext isCurrent: true ---*/ @@ -23,33 +24,30 @@ import { Assert } from '../../../../../suite/assert.js' -class MinClass { - public list: T[] = []; - add(v: T) { - this.list.push(v); - } - findminNumberValue(): T { - let minNum = this.list[0]; - - for (let i = 0; i < this.list.length; i++) { - if (minNum > this.list[i]) { - minNum = this.list[i]; - } +type TypeSummation = { + width?: number; + height?: number; +}; +class summation { + public width; + public height; + constructor(width: number, height: number); + constructor(ParamObje_: TypeSummation); + constructor(ParamObje_Obj_: any, height_ = 0) { + if (typeof ParamObje_Obj_ === "object") { + const { width, height } = ParamObje_Obj_; + this.width = width; + this.height = height; + } else { + this.width = ParamObje_Obj_; + this.height = height_; } - return minNum; + } + sunArea(): number { + return this.width * this.height; } } - -let minStringValue = new MinClass(); -minStringValue.add("a"); -minStringValue.add("b"); -minStringValue.add("c"); -minStringValue.add("d"); -Assert.equal(minStringValue.findminNumberValue(), "a"); - -let minNumberValue = new MinClass(); -minNumberValue.add(1); -minNumberValue.add(2); -minNumberValue.add(3); -minNumberValue.add(4); -Assert.equal(minNumberValue.findminNumberValue(), 1); +const sun = new summation(4, 5); +Assert.equal(sun.sunArea(), 20); +const obj: TypeSummation = { width: 10, height: 20 }; +Assert.equal(new summation(obj).sunArea(), 200); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/tuple_types/tuple_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts similarity index 65% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/tuple_types/tuple_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts index adf7b4858e..98ad0473e6 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/tuple_types/tuple_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_5.ts @@ -14,8 +14,7 @@ */ /**--- description: > - Tuple types represent JavaScript arrays with individually tracked element types. - A tuple type combines a set of numerically named properties with the members of an array type. + A property for each static member variable declaration in the class body. module: ESNext isCurrent: true ---*/ @@ -23,12 +22,24 @@ import { Assert } from '../../../../../suite/assert.js' -let cc: [number, string, boolean]; -cc = [12, "abcd", true]; -Assert.equal(cc[0], "12"); -Assert.equal(cc[0].toString(), "12"); -Assert.equal(cc[1], "abcd"); -Assert.equal(cc[1].length, 4); -Assert.equal(cc[2], true); -let dd = cc[2] ? 0 : 1; -Assert.equal(dd, 0); \ No newline at end of file +class A1 { + public numa: number; + constructor(a: number) { + this.numa = a; + } + static c: number = 20; +} +class B1 extends A1 { + public numb: number; + constructor(a: number, b: number) { + super(a); + this.numb = b; + } +} +let a: A1 = new A1(10); +Assert.equal(a.numa, 10); +Assert.equal(A1.c, 20); +let b: B1 = new B1(10, 20); +Assert.equal(b.numa, 10); +Assert.equal(b.numb, 20); +Assert.equal(B1.c, 20); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_6.ts new file mode 100644 index 0000000000..d97b249c6e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_6.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A property of a function type for each static member function declaration in the class body. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class A1 { + public numa: number; + constructor(a: number) { + this.numa = a; + } + static c = 10; + static f(): void { + this.c++; + } +} +class B1 extends A1 { + public numb: number; + constructor(a: number, b: number) { + super(a); + this.numb = b; + } + static f() { + this.c++; + return this.c + } +} +Assert.equal(A1.c, 10); +A1.f(); +Assert.equal(A1.c, 11); +Assert.equal(B1.c, 11); +Assert.equal(B1.f(), 12); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/predefined_types/predefined_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_7.ts similarity index 58% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/predefined_types/predefined_types.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_7.ts index fbf293ec2e..8435c66f74 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/predefined_types/predefined_types.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/constructorc_function_types/constructor_function_types_7.ts @@ -14,8 +14,8 @@ */ /**--- description: > - The any, number, boolean, string, symbol and void keywords reference - the Any type and the Number, Boolean, String, Symbol, and Void primitive types respectively. + A property named 'prototype', the type of which is an instantiation of the class type with type Any supplied + as a type argument for each type parameter. module: ESNext isCurrent: true ---*/ @@ -23,23 +23,14 @@ import { Assert } from '../../../../../suite/assert.js' -let x1: number = 5; -Assert.equal(x1.toString(), "5"); - -let x2: boolean = true; -Assert.equal(x2.toString(), "true"); - -let x3: string = 's'; -Assert.equal(x3.toString(), "s"); - -let x4: symbol = Symbol(); -Assert.equal(x4.toString(), "Symbol()"); - -let x5: any; -x5 = 1; -x5 = "aa" -x5 = true; -Assert.equal(x5, true); - -let x6: void = undefined; -Assert.equal(x6, undefined); \ No newline at end of file +class Animal { + public name: string; + constructor(name: string) { + this.name = name; + } +} +Assert.equal(typeof (Animal.prototype), "object"); +let cat = new Animal("Cat") +Assert.equal(Object.getPrototypeOf(cat) === Animal.prototype, true); +Assert.equal(Object.getPrototypeOf(Animal.prototype) === Object.prototype, true); +Assert.equal(Object.getPrototypeOf(Object.prototype) === null, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_18.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_1.ts similarity index 53% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_18.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_1.ts index 119ae5e291..c813e63ef5 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_18.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_1.ts @@ -14,8 +14,8 @@ */ /**--- description: > - when assigning values or passing parameters, - optional properties must either be present and of a compatible type, or not be present at all. + A derived class inherits all members from its base class it doesn't override. + Inheritance means that a derived class implicitly contains all non-overridden members of the base class. module: ESNext isCurrent: true ---*/ @@ -23,11 +23,23 @@ import { Assert } from '../../../../../suite/assert.js' -function func(stu: { num: number; name?: string }) { - return stu +class Shape { + public color: string = "black"; + protected side: number = 10; + constructor() { }; + public switchColor() { + this.color = this.color === "black" ? "white" : "black"; + } } -let f1 = func({ num: 1234 }); -Assert.equal(JSON.stringify(f1), '{"num":1234}') - -let f2 = func({ num: 1234, name: "xiao" }) -Assert.equal(JSON.stringify(f2), '{"num":1234,"name":"xiao"}'); \ No newline at end of file +class Circle extends Shape { + get gside() { + return this.side; + } +} +let circle: Circle = new Circle(); +let a: string = circle.color; +Assert.equal(a, "black"); +circle.switchColor(); +let b: string = circle.color; +Assert.equal(b, "white"); +Assert.equal(10, circle.gside); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_2.ts new file mode 100644 index 0000000000..093a81f893 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_2.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Only public and protected property members can be overridden. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Shape { + public color: string = "black"; + protected side: number = 10; + constructor() { }; + public switchColor() { + this.color = this.color === "black" ? "white" : "black"; + } +} +class Circle extends Shape { + public color: string = "red"; + protected side: number = 11; + get gside() { + return this.side; + } + public switchColor() { + this.color = this.color === "red" ? "white" : "black"; + } +} +let shape: Shape = new Shape(); +Assert.equal(shape.color, "black"); +shape.switchColor(); +Assert.equal(shape.color, "white"); +let circle: Circle = new Circle(); +Assert.equal(circle.color, "red"); +circle.switchColor(); +Assert.equal(circle.color, "white"); +Assert.equal(11, circle.gside); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_3.ts new file mode 100644 index 0000000000..42c1eecee2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_3.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Base class static property members can be overridden by derived class static property members + of any kind as long as the types are compatible. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Shape { + static color: string = "black"; + static switchColor() { + this.color = this.color === "black" ? "white" : "black"; + } +} +class Circle extends Shape { + static color: string = "red"; + static switchColor() { + this.color = this.color === "red" ? "green" : "red"; + } +} +let a = Circle.color; +Assert.equal(a, "red"); +Circle.switchColor(); +let b = Circle.color; +Assert.equal(b, "green"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_4.ts similarity index 56% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_4.ts index a011585986..1b55b81f59 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_4.ts @@ -14,8 +14,7 @@ */ /**--- description: > - Every class and interface has a this-type that represents the actual type of instances of the class or interface within the declaration of the class or interface. The this-type is referenced using the keyword this in a type position. - within instance methods and constructors of a class, the type of the expression this is the this-type of the class. + Base class instance member variables and accessors can be overridden by derived class instance member variables and accessors. module: ESNext isCurrent: true ---*/ @@ -23,21 +22,30 @@ import { Assert } from '../../../../../suite/assert.js' -interface INTERFACE { - say: () => string; -} -let i: INTERFACE = { - say() { - return typeof this; +class MyClass { + num: number = 20; + constructor(num: number) { + this.num = num; + } + get() { + return this.num + } + set(num: number) { + this.num = num; } } -Assert.equal(i.say(), 'object'); -class C { - num: number; +class myClass extends MyClass { constructor(num: number) { + super(num); + this.num = num; + } + get() { + return 10 + } + set(num: number) { this.num = num; - Assert.equal(typeof this, 'object'); } } -let h_c = new C(10); -Assert.equal(h_c.num, 10); \ No newline at end of file +let myTest = new myClass(5); +Assert.equal(myTest.num, 5); +Assert.equal(myTest.get(), 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_5.ts new file mode 100644 index 0000000000..aa473982b5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/inheritance_and_overriding/inheritance_and_overriding_5.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A property member in a derived class is said to override a property member in a base class + when the derived class property member has the same name and kind (instance or static) as the base class property member. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Shape { + public color: string = "black"; + protected name: string = "shape"; + public switchColor() { + this.color = this.color === "black" ? "white" : "black"; + } + protected f(a: Shape, b: Circle) { + a.color = "blue"; + b.color = "blue"; + } + static size: number = 10; +} +class Circle extends Shape { + public color: string = "red"; + protected name: string = "circle"; + public switchColor() { + this.color = this.color === "red" ? "green" : "red"; + } + static size: number = 12; + protected f(a: Shape, b: Circle) { + a.color = "pink"; + b.color = "pink"; + } +} +let shape: Shape = new Shape(); +Assert.equal(shape.color, "black"); +shape.switchColor(); +Assert.equal(shape.color, "white"); +Assert.equal(Shape.size, 10); +let circle = new Circle(); +Assert.equal(circle.color, "red"); +circle.switchColor(); +Assert.equal(circle.color, "green"); +Assert.equal(Circle.size, 12); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_1.ts similarity index 57% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_1.ts index e20b34625c..5683f2888a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_1.ts @@ -14,7 +14,7 @@ */ /**--- description: > - An object type containing one or more construct signatures is said to be a constructor type. + Members are either instance members or static members. module: ESNext isCurrent: true ---*/ @@ -23,24 +23,25 @@ import { Assert } from '../../../../../suite/assert.js' class Person { - name: string; - age: number; - constructor(n: string, age: number) { - this.name = n; + private _name: string; + public age: number; + constructor(name: string, age: number) { + this._name = name; this.age = age; } - run(): string { - return "person"; + public set name(name: string) { + this._name = name; } -} -class Teacher extends Person { - run(): string { - return "teacher"; + public get name() { + return this._name; + } + static language: string = "english"; + static ageAdd() { + return this.language + "aaa"; } } -type constructor = new (name: string, age: number) => T; -let testClass1: constructor = Teacher; -let testObj1: Person = new testClass1("caihua", 20); -Assert.equal(testObj1.age, 20); -Assert.equal(testObj1.name, "caihua"); -Assert.equal(testObj1.run(), "teacher"); \ No newline at end of file +let per: Person = new Person("rain", 22); +Assert.equal(per.name, "rain"); +Assert.equal(per.age, 22); +Assert.equal(Person.language, "english"); +Assert.equal(Person.ageAdd(), "englishaaa"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts similarity index 35% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_6.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts index 40ddf28c78..478ebc4313 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_6.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_2.ts @@ -14,8 +14,9 @@ */ /**--- description: > - When one or more constituent types of I have an apparent string index signature, - I has an apparent string index signature of an intersection type of the respective string index signature types. + Instance members are members of the class type and its associated this-type. Within constructors, + instance member functions, and instance member accessors, + the type of this is the this-type of the class. module: ESNext isCurrent: true ---*/ @@ -23,21 +24,54 @@ import { Assert } from '../../../../../suite/assert.js' -interface Array1 { - [index1: string]: string +class Counter { + private count: number = 0; + constructor(count_: number) { + this.count = count_; + } + public add(): this { + this.count++; + return this; + } + public subtract(): this { + this.count--; + return this; + } + public get Result(): number { + return this.count; + } } -interface Array2 { - [index2: string]: string +let counter = new Counter(1); +counter.add(); +Assert.equal(counter.add(), counter); +Assert.equal(counter.Result, 3); +counter.subtract(); +Assert.equal(counter.subtract(), counter); +Assert.equal(counter.Result, 1); +class Compute { + constructor(public num1: number, public num2: number) { } + public hypot() { + return Math.sqrt(this.num1 * this.num1 + this.num2 * this.num2); + } + static initial = new Compute(0, 0); } - -function test(obj: Array1 & Array2) { - return "right" -} -const stu1 = { - age: "19" -} -const stu2 = { - name: "xiao" +class ChildP extends Compute { + constructor(public x: number, public y: number, public z: number) { + super(x, y); + this.z = z; + } + public move(): this { + this.x += 1; + this.y += 1; + this.z += 1; + return this + } } -Assert.equal(test(stu1), "right"); -Assert.equal(test(stu2), "right"); \ No newline at end of file +let childp: ChildP = new ChildP(1, 2, 3); +childp.move(); +Assert.equal(childp.x, 2); +Assert.equal(childp.y, 3); +Assert.equal(childp.z, 4); +Assert.equal(childp.move(), childp); +let count: ChildP = new ChildP(4,3,1); +Assert.equal(count.hypot(),5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts similarity index 52% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts index ff20e6e436..234ee19637 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/this_types/this_types_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/members/instance_and_static_members/instance_and_static_members_3.ts @@ -14,8 +14,9 @@ */ /**--- description: > - Classes and interfaces support inheritance and therefore the instance represented by this in a method - isn't necessarily an instance of the containing class—it may in fact be an instance of a derived class or interface. + Static members are declared using the static modifier and are members of the constructor function type. + Within static member functions and static member accessors, + the type of this is the constructor function type. module: ESNext isCurrent: true ---*/ @@ -23,31 +24,28 @@ import { Assert } from '../../../../../suite/assert.js' -class CA { - name: string = "CA"; - f() { - return this; +class Person { + static n2: number = 20; + tool(): number { + return 30; } - caName(cname: string) { - this.name = cname; - return "CA:" + this.name; + static tool1(): number { + return this.n2; } -} - -class CB extends CA { - b() { + static tool2() { + this.n2++; return this; } - cbName(cname: string) { - this.name = cname; - return "CB:" + this.name; + static get foo(): number { + return this.n2; } } - -let bB: CB = new CB(); -let xB = bB.f().b(); -Assert.equal(bB, xB); -let thisStrB: string = bB.cbName("CB"); -Assert.equal(thisStrB, "CB:CB"); -let thisStrA: string = bB.caName("CA"); -Assert.equal(thisStrA, "CA:CA"); \ No newline at end of file +let a: number = Person.n2; +Assert.equal(a, 20); +let b: number = Person.tool1(); +Assert.equal(b, 20); +let c: number = Person.foo; +Assert.equal(c, 20); +Assert.equal(Person, Person.tool2()); +let d: Person = new Person(); +Assert.equal(d.tool(),30); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/dynamic_property_declarations/dynamic_property_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/dynamic_property_declarations/dynamic_property_declarations.ts new file mode 100644 index 0000000000..c11af2fa48 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/dynamic_property_declarations/dynamic_property_declarations.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A dynamic property declaration does not introduce a property in the class type or constructor function type. + The property name expression of a dynamic property assignment must be of type Any or the String, Number, or Symbol primitive type. + The name associated with a dynamic property declarations is considered to be a numeric property name if the property name expression is of type Any or the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class computer { + [compute:string]:any + constructor( + public name:string, + public age:number + ){} + sayOne(){return "one"} +} +let uce = new computer("aa",22); +uce.pid = "223"; +uce.id=1; +Assert.equal(uce.name,"aa"); +Assert.equal(typeof uce,"object"); +Assert.equal(uce.id+uce.pid,"1223"); +Assert.equal(uce.sayOne(),"one"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_accessor_declarations/member_accessor_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_accessor_declarations/member_accessor_declarations.ts new file mode 100644 index 0000000000..d4789e76dc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_accessor_declarations/member_accessor_declarations.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A member accessor declaration declares an instance member accessor or a static member accessor. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class A { + private _foo: number = 0; + get foo(): number { + return this._foo; + } + set foo(value: number) { + this._foo = value; + } + private static a: number = 0; + static get aa(): number { + return this.a; + } + static set aa(value: number) { + this.a = value; + } +} +let x = new A(); +Assert.equal(x.foo, 0); +x.foo = 10; +Assert.equal(x.foo, 10); +Assert.equal(A.aa, 0); +A.aa = 20; +Assert.equal(A.aa, 20); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts new file mode 100644 index 0000000000..81ff4b1d7b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_1.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A member function declaration declares an instance member function or a static member function. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class MyClass { + constructor(public x: number, public y: number) { } + public distance(p: MyClass) { + let dx = this.x - p.x; + let dy = this.y - p.y; + return Math.sqrt(dx * dx + dy * dy); + } + static add(p1: MyClass) { + p1.x++; + return p1.x + } +} +let p1: MyClass = new MyClass(2, 2); +let p2: MyClass = new MyClass(1, 1); +Assert.equal(p1.distance(p2), Math.sqrt(2)); +Assert.equal(MyClass.add(p1), 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_2.ts similarity index 67% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_2.ts index eaf2c69edf..913abdd47c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_2.ts @@ -14,7 +14,7 @@ */ /**--- description: > - Array types can be written using the 'Array' notation. + In the body of an instance member function declaration, this is of the this-type (section 3.6.3) of the class. module: ESNext isCurrent: true ---*/ @@ -22,15 +22,14 @@ import { Assert } from '../../../../../suite/assert.js' -let arr: Array = [2, 'a']; -Assert.equal(arr[0], 2); -Assert.equal(arr[1], 'a'); -let x = function () { - return 'x'; +class Circle { + radius: number = 1; + area(): number { + return Math.PI * this.radius * this.radius; + } } -let y = function () { - return 'y'; -} -let fun: Array<() => string> = [x, y]; -Assert.isFunction(fun[0]); -Assert.isFunction(fun[1]); \ No newline at end of file +let c = new Circle(); +Assert.equal(c.radius, 1); +Assert.equal(c.area(), Math.PI); +c.radius = 2; +Assert.equal(c.area(), Math.PI * 4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts similarity index 65% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts index 521985e8d3..b5b27f92c4 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_3.ts @@ -14,8 +14,7 @@ */ /**--- description: > - Index signatures, which define type constraints for properties in the given type. - An object type can have at most one string index signature and one numeric index signature. + In the body of a static member function declaration, the type of this is the constructor function type. module: ESNext isCurrent: true ---*/ @@ -23,10 +22,15 @@ import { Assert } from '../../../../../suite/assert.js' -interface numberIndex { - [index: number]: string +class MyClass { + constructor(public x: number = 3, public y: number = 3) { } + static z: number; + static pro() { + return this.prototype; + } + static returnz() { + this.z; + } } -let numberTest: numberIndex = ['1', '2', '3'] -Assert.equal(numberTest[0], '1'); -Assert.equal(numberTest[1], '2'); -Assert.equal(numberTest[2], '3'); \ No newline at end of file +Assert.equal(MyClass.pro(), "[object Object]"); +Assert.equal(MyClass.returnz(), undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts similarity index 56% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts index d29630a0b1..00b736c2f0 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_4.ts @@ -14,9 +14,7 @@ */ /**--- description: > - Properties in an object type literal or interface declaration may be designated required or optional, - while properties declared in other contexts are always considered required. - Properties that are optional in the target type of an assignment may be omitted from source objects. + A member function can access overridden base class members using a super property access (section 4.9.2). module: ESNext isCurrent: true ---*/ @@ -24,17 +22,24 @@ import { Assert } from '../../../../../suite/assert.js' -interface I { - h_name: string; - h_age: number; - h_height?: number; - h_weight?: number; +class MyClass { + constructor(public x: number, public y: number) { } + public add() { + return this.x + this.y; + } } -let h_s: I = { - h_name: 'xiao', - h_age: 19, - h_height: 180 +class MyClass2 extends MyClass { + constructor(x: number, y: number, public z: number) { + super(x, y); + } + public add() { + return super.add() + this.z; + } } -Assert.equal(h_s.h_name, 'xiao'); -Assert.equal(h_s.h_age, 19); -Assert.equal(h_s.h_height, 180); \ No newline at end of file +let p = new MyClass(1, 2); +Assert.equal(p.x, 1); +Assert.equal(p.y, 2); +Assert.equal(p.add(), 3); +let cp = new MyClass2(1, 2, 3); +Assert.equal(cp.z, 3); +Assert.equal(cp.add(), 6); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts similarity index 64% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts index 098eaa1675..9d52a76633 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_function_declarations/member_function_declarations_5.ts @@ -14,8 +14,7 @@ */ /**--- description: > - S is a subtype of a type T, and T is a supertype of S, - if S has no excess properties with respect to T, and T is the Any type. + In a static member function,a call to 'new this()' may actually invoke a derived class constructor module: ESNext isCurrent: true ---*/ @@ -23,24 +22,18 @@ import { Assert } from '../../../../../suite/assert.js' -interface T { - name: any - age: any +class TP { + constructor(public a: number = 1, public b: number = 1) { } + static createthis() { + return new this(); + } } -interface S { - name: string - age: number - hobbies: string[] +class CP extends TP { + constructor(public a: number = 2, public b = 2) { + super(); + } } -let t: T = { - name: "T", - age: 20 -}; -let s: S = { - name: "S", - age: 19, - hobbies: ["draw", "game"] -}; - -t = s; -Assert.equal(t, s); \ No newline at end of file +let x = TP.createthis(); +let y = CP.createthis(); +Assert.equal(x.a, 1); +Assert.equal(y.a, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts new file mode 100644 index 0000000000..0858958081 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_1.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Initializers in static member variable declarations are executed once when the containing script or module is loaded. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class MyClass { + constructor(public x: number, public y: number) { } + public addc() { + MyClass.c++; + } + static po = new MyClass(0, 0); + static c: number = 10; +} +let a: MyClass = new MyClass(1, 1); +Assert.equal(MyClass.c, 10); +a.addc(); +Assert.equal(MyClass.c, 11); +let b: MyClass = new MyClass(1, 1); +b.addc(); +Assert.equal(MyClass.c, 12); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_2.ts similarity index 43% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_2.ts index 065f411360..f6709f6ede 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_2.ts @@ -14,7 +14,7 @@ */ /**--- description: > - An array type literal is written as an element type followed by an open and close square bracket. + Instance member variable initializers are equivalent to assignments to properties of this in the constructor module: ESNext isCurrent: true ---*/ @@ -22,8 +22,37 @@ import { Assert } from '../../../../../suite/assert.js' -let arr: number[] = [2, 4, 6, 8]; -Assert.equal(arr[0], 2); -Assert.equal(arr[1], 4); -Assert.equal(arr[2], 6); -Assert.equal(arr[3], 8); \ No newline at end of file +class Staff1 { + public name: string; + public place: string; + public work: boolean; + constructor(name: string, place: string, work: boolean) { + this.name = name; + this.place = place; + this.work = work; + } + initializer(name: string, place: string, work: boolean) { + this.name = name; + this.place = place; + this.work = work; + } +} +class Staff2 { + public name: string; + public place: string; + public work: boolean; + constructor(name: string, place: string, work: boolean) { + this.name = name; + this.place = place; + this.work = work; + } +} +let em1 = new Staff1("zhangsan", "shanghai", true); +em1.initializer("wangwu", "hainan", true); +let em2 = new Staff2("lisi", "qingdao", true); +Assert.equal(em1.name, "wangwu"); +Assert.equal(em1.place, "hainan"); +Assert.equal(em1.work, true); +Assert.equal(em2.name, "lisi"); +Assert.equal(em2.place, "qingdao"); +Assert.equal(em2.work, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts similarity index 57% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts index 61a588e895..562151a0f7 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/constructor_types/constructor_types_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_3.ts @@ -14,7 +14,7 @@ */ /**--- description: > - An object type containing one or more construct signatures is said to be a constructor type. + A member variable declaration declares an instance member variable or a static member variable. module: ESNext isCurrent: true ---*/ @@ -22,31 +22,26 @@ import { Assert } from '../../../../../suite/assert.js' -interface Point { - x: number; - y: number; -} -interface PointConstructor { - new(x: number, y: number): Point; -} -class Point2 implements Point { - readonly x: number; - readonly y: number; +class MyClass { + public x: number; + public y: number; constructor(x: number, y: number) { this.x = x; this.y = y; } + static z: number = 3; } -function newPoint( - pointConstructor: PointConstructor, - x: number, - y: number -): Point { - return new pointConstructor(x, y); +class MyClass2 extends MyClass { + constructor(x: number, y: number, public color: string) { + super(x, y); + } + static r: number = 10; } -let point1: Point = new Point2(1, 2); -Assert.equal(point1.x, 1); -Assert.equal(point1.y, 2); -let point: Point = newPoint(Point2, 2, 2); -Assert.equal(point.x, 2); -Assert.equal(point.y, 2); \ No newline at end of file +let p = new MyClass(1, 2); +Assert.equal(p.x, 1); +Assert.equal(p.y, 2); +Assert.equal(MyClass.z, 3); +let cp = new MyClass2(4, 5, "red"); +Assert.equal(cp.x, 4); +Assert.equal(cp.y, 5); +Assert.equal(MyClass2.r, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts new file mode 100644 index 0000000000..04668be36d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/member_variable_declarations/member_variable_declarations_4.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Instance member variable initializers are equivalent to assignments to properties of this in the constructor + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class A { + public x: number = 1; + public y: string = "name"; + public z: boolean = false; + constructor() { } +} +class B { + public x: number = 1; + public y: string = "name"; + public z: boolean + constructor(z: boolean = false) { + this.z = z; + } +} +let a = new A(); +Assert.equal(a.z, false); +let b = new B(); +Assert.equal(b.z, false); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_1.ts new file mode 100644 index 0000000000..f6eacfb220 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_1.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Member declarations with a static modifier are called static member declarations. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Compute { + constructor(public x: number, public y: number) { } + public range(p1: Compute, p2: Compute) { + let dx = p1.x - p2.x; + let dy = p1.y - p2.y; + return Math.sqrt(dx * dx + dy * dy); + } + static getx() { + return this.x; + } + static po = new Compute(0, 0); + static x: number = 10; +} +let p1: Compute = new Compute(2, 2); +let p2: Compute = new Compute(1, 1); +Assert.equal(p1.range(p1, p2), Math.sqrt(2)); +Assert.equal(Compute.getx(), 10); +Assert.equal(p1.range(p1, Compute.po), Math.sqrt(8)); +Assert.equal(Compute.x, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_2.ts similarity index 53% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_2.ts index 1202a176b9..12ffdf3f7d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_2.ts @@ -14,22 +14,33 @@ */ /**--- description: > - A parameter declaration may specify either an identifier or a binding pattern. - The identifiers specified in parameter declarations and binding patterns in a parameter list must be unique within that parameter list. + it is possible to have instance and static property members with the same name. module: ESNext isCurrent: true ---*/ -import { Assert } from '../../../../../../suite/assert.js' +import { Assert } from "../../../../suite/assert.js" -class Animal { - fname: string; - constructor(fname: string) { - this.fname = fname; +class myClass { + public x: number; + public y: number; + constructor(x: number, y: number) { + this.x = x; + this.y = y; + } + public add(): number { + return this.x + this.y; + } + static x: number = 3; + static add(): number { + this.x++; + return this.x; } } -let name1 = "Anny"; -let animal = new Animal(name1); -name1 = "Bob"; -Assert.notEqual(animal.fname, name1); \ No newline at end of file +let myTest = new myClass(1, 2); +Assert.equal(myTest.x, 1); +Assert.equal(myTest.y, 2); +Assert.equal(myTest.add(), 3); +Assert.equal(myClass.x, 3); +Assert.equal(myClass.add(), 4); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_3.ts similarity index 59% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_3.ts index 7fe8901575..e8432500f8 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/classes/property_member_declarations/property_member_declarations_3.ts @@ -14,39 +14,30 @@ */ /**--- description: > - TypeScript has a structural type system, and therefore an instantiation of a generic type - is indistinguishable from an equivalent manually written expansion. + Every class automatically contains a static property member named 'prototype' module: ESNext isCurrent: true ----*/ + ---*/ import { Assert } from '../../../../suite/assert.js' -class C { - x: number; - y: number; +class Compute { + public x: number; + public y: number; constructor(x: number, y: number) { this.x = x; this.y = y; } + static p = new Compute(0, 0); } -interface I { - front: T; - later: U; -} -function test(v: I) { - Assert.equal(v.front, "abc"); - Assert.equal(v.later.x, 1); - Assert.equal(v.later.y, 1); +class ColoredPoint extends Compute { + constructor(x: number, y: number, public color: string) { + super(x, y); + } } -test({ front: "abc", later: { x: 1, y: 1 } }); -let cc: I; -cc = { - front: "abc", - later: { - x: 1, - y: 1, - }, -}; -test(cc); \ No newline at end of file +Assert.equal(ColoredPoint.prototype.color, undefined); +Assert.equal(ColoredPoint.prototype.x, undefined); +Assert.equal(ColoredPoint.prototype.y, undefined); +Assert.equal(Compute.prototype.x, undefined); +Assert.equal(Compute.prototype.y, undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/constant_enum_declarations/constant_enum_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/constant_enum_declarations/constant_enum_declarations.ts new file mode 100644 index 0000000000..4c56963def --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/constant_enum_declarations/constant_enum_declarations.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + in a constant enum declaration, all members must have constant values and it is an error for a member declaration to specify an expression that isn't classified as a constant enum expression. + it is an error to reference a constant enum object in any other context than a property access that selects one of the enum's members. + the only permitted references to the enum object are those that are replaced with an enum member value. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +const enum CED { + None = -1, + False, + True = 1, + DEF = 1024, + Val = DEF / 8, +} +Assert.equal(CED.None, -1); +Assert.equal(CED.False, 0); +Assert.equal(CED.True, 1); +Assert.equal(CED.DEF, 1024); +Assert.equal(CED.Val, 128); +Assert.equal(CED["None"], -1); +Assert.equal(CED["False"], 0); +Assert.equal(CED["True"], 1); +Assert.equal(CED["DEF"], 1024); +Assert.equal(CED["Val"], 128); + +enum CED_COPY { + None = -1, + False, + True = 1, + DEF = 1024, + Val = DEF / 8, +} +Assert.equal(CED_COPY[-1], "None"); +Assert.equal(CED_COPY[0], "False"); +Assert.equal(CED_COPY[1], "True"); +Assert.equal(CED_COPY[1024], "DEF"); +Assert.equal(CED_COPY[128], "Val"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_1.ts new file mode 100644 index 0000000000..3cad444c10 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_1.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + enums are "open-ended" and enum declarations with the same qualified name relative to a common root define a single enum type and contribute to a single enum object. + it isn't possible for one enum declaration to continue the automatic numbering sequence of another, and when an enum type has multiple declarations, only one declaration is permitted to omit a value for the first member. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +enum A { + A1, + A2, +} +enum A { + A3 = 3, + A4, +} +Assert.equal(A.A1, 0); +Assert.equal(A.A2, 1); +Assert.equal(A.A3, 3); +Assert.equal(A.A4, 4); +namespace NSP { + export enum A { + A1, + A2, + } + export enum A { + A3 = 2, + A4, + } +} +Assert.equal(NSP.A.A1, 0); +Assert.equal(NSP.A.A2, 1); +Assert.equal(NSP.A.A3, 2); +Assert.equal(NSP.A.A4, 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_2.ts similarity index 61% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_2.ts index 4da21efaaa..f7efe29be5 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/declaration_merging/declaration_merging_2.ts @@ -14,32 +14,35 @@ */ /**--- description: > - class declarations with only public members introduce named types - that function exactly like those created by interface declarations. + when enum declarations are merged, they must either all specify a const modifier or all specify no const modifier. module: ESNext isCurrent: true ----*/ + ---*/ import { Assert } from '../../../../suite/assert.js' -interface TestInterface { - age: number; +const enum T1 { + Tex0, + Tex1, } -class TestClass { - public age: number; - constructor(age: number) { - this.age = age - } +const enum T1 { + Tex2 = 2, + Tex3, } -function test1(v: TestInterface) { - return v.age; +Assert.equal(T1.Tex0, 0); +Assert.equal(T1.Tex1, 1); +Assert.equal(T1.Tex2, 2); +Assert.equal(T1.Tex3, 3); +enum T2 { + Tex0, + Tex1, } -function test2(v: TestClass) { - return v.age; +enum T2 { + Tex2 = 2, + Tex3, } -let ee = { - age: 18, -}; -Assert.equal(test1(ee), 18); -Assert.equal(test2(ee), 18); \ No newline at end of file +Assert.equal(T2.Tex0, 0); +Assert.equal(T2.Tex1, 1); +Assert.equal(T2.Tex2, 2); +Assert.equal(T2.Tex3, 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_1.ts new file mode 100644 index 0000000000..cca34206d6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_1.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + an EnumDeclaration introduces a named type and a named value in the containing declaration space. + The enum type is a distinct subtype of the Number primitive type. + the enum object is a value of an anonymous object type containing a set of properties, + all of the enum type, corresponding to the values declared for the enum type in the body of the declaration. + The enum object's type furthermore includes a numeric index signature with the signature '[x: number]: string'. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +enum Animal { + cat = 0xff0000, + dog = 0x00ff00, + pig = 0x0000ff, +} +Assert.isString(Animal[0xff0000]); +Assert.equal(Animal[0x00ff00], "dog"); +Assert.isNumber(Animal.pig); +enum TypeABC { + A, + B, + C, +} +var index = TypeABC.A; +Assert.equal(TypeABC.A, 0); +Assert.equal(TypeABC.B, index + 1); +Assert.equal(TypeABC.C, index + 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_2.ts new file mode 100644 index 0000000000..78e6995c4d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_2.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the numeric index signature reflects a "reverse mapping" that is automatically generated in every enum object. + the reverse mapping provides a convenient way to obtain the string representation of an enum value + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +enum Animal { + Cat = 0xff0000, + Dog = 0x00ff00, + Pig = 0x0000ff, +} +var dog = Animal.Dog; +Assert.isNumber(dog); +Assert.isString(Animal[dog]); +Assert.equal("Dog", Animal[dog]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_3.ts new file mode 100644 index 0000000000..481799d7ca --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_declarations/enum_declarations_3.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When an enum declaration includes a const modifier it is said to be a constant enum declaration. + The members of a constant enum declaration must all have constant values that can be computed at compile time. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +const enum H_Date { + Monday = 'Mon', + Tuesday = 'Tues', + Wednesday = 'Wed', + Thursday = 'Thur', + Friday = 'Fri', + Saturday = 'Satur', + Sunday = 'Sun' +} +let h_date1 = H_Date.Monday; +Assert.equal(h_date1, 'Mon'); +let h_date2 = H_Date.Tuesday; +Assert.equal(h_date2, 'Tues'); +let h_date3 = H_Date.Wednesday; +Assert.equal(h_date3, 'Wed'); +let h_date4 = H_Date.Thursday; +Assert.equal(h_date4, 'Thur'); +let h_date5 = H_Date.Friday; +Assert.equal(h_date5, 'Fri'); +let h_date6 = H_Date.Saturday; +Assert.equal(h_date6, 'Satur'); +let h_date7 = H_Date.Sunday; +Assert.equal(h_date7, 'Sun'); +const enum H_Odd { + a = 1, + b = a + 2, + c = a + 4, + d = c + 2, + e = b * b, +} +Assert.equal(H_Odd.a, 1); +Assert.equal(H_Odd.b, 3); +Assert.equal(H_Odd.c, 5); +Assert.equal(H_Odd.d, 7); +Assert.equal(H_Odd.e, 9); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_members/enum_members_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_members/enum_members_1.ts new file mode 100644 index 0000000000..3a272a6a11 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/enums/enum_members/enum_members_1.ts @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + if the member declaration specifies no value, the member is considered a constant enum member. + If the member is the first member in the enum declaration, it is assigned the value zero. + Otherwise, it is assigned the value of the immediately preceding member plus one, and an error occurs if the immediately preceding member is not a constant enum member. + if the member declaration specifies a value that can be classified as a constant enum expression, + the member is considered a constant enum member.otherwise, the member is considered a computed enum member. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function toLength(str: string): number { + return str.length; +} +let k = 999; +enum ABCList { + A, + B, + C = "string".length, + D = 10, + E, + F = ~17, + G = 0x0f << 0x02, + H = 0xff & 0xaa, + I = E | F, + J = toLength(ABCList[11]), + K = k++, + L = k--, + M = 1 + 2, + N = 1 - 2, + O = 1 / 2, + P = 1 % 2, + Q = 1 >> 2, + R = 1 >>> 2, + S = 1 ^ 2, +} +Assert.equal(ABCList.A, 0); +Assert.equal(ABCList.B, 1); +Assert.equal(ABCList.C, 6); +Assert.equal(ABCList.D, 10); +Assert.equal(ABCList.E, 11); +Assert.equal(ABCList.F, -18); +Assert.equal(ABCList.G, 60); +Assert.equal(ABCList.H, 170); +Assert.equal(ABCList.I, -17); +Assert.equal(ABCList.J, 1); +Assert.equal(ABCList.K, 999); +Assert.equal(ABCList.L, 1000); +Assert.equal(ABCList.M, 3); +Assert.equal(ABCList.N, -1); +Assert.equal(ABCList.O, 0.5); +Assert.equal(ABCList.P, 1); +Assert.equal(ABCList.Q, 0); +Assert.equal(ABCList.R, 0); +Assert.equal(ABCList.S, 3); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_1.ts new file mode 100644 index 0000000000..32a416d660 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_1.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.23) + by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, + the element expression is contextually typed by the type of that property. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface MyArray { + 0: number; + 1: string; + length: 2; +} +const myArray: MyArray = [42, "hello"]; +Assert.isNumber(myArray[0]); +Assert.isString(myArray[1]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_2.ts new file mode 100644 index 0000000000..78b09fffd4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_2.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the array literal is contextually typed by a type T with a numeric index signature, + the element expression is contextually typed by the type of the numeric index signature + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let MyArray: { + [key: number]: string; +} = ["aaa", "bbb", "ccc"]; +Assert.isString(MyArray[0]); +Assert.isString(MyArray[1]); +Assert.isString(MyArray[2]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_3.ts new file mode 100644 index 0000000000..270c64722a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_3.ts @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the array literal is empty, the resulting type is an array type with the element type Undefined. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +const emptyArray: any[] = []; +Assert.isUndefined(emptyArray[0]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_4.ts new file mode 100644 index 0000000000..81a90b45b6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_4.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the array literal contains no spread elements and is contextually typed by a tuple-like type (section 3.3.3), + the resulting type is a tuple type constructed from the types of the element expressions + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let myTuple: [string, number] = ["hello", 42]; +Assert.isString(myTuple[0]); +Assert.isNumber(myTuple[1]); +function foo(pair: [string, number]) { + return pair +} +Assert.equal(JSON.stringify(foo(["hello", 42])), '["hello",42]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_5.ts similarity index 65% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_5.ts index 47db9b2c1a..b620932604 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_5.ts @@ -13,9 +13,9 @@ * limitations under the License. */ /**--- - description: > - union types represent values that may have one of several distinct representations. - a value of a union type A | B is a value that is either of type A or type B. Union types are written using union type literals + description: > + If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.21.1), + the resulting type is a tuple type constructed from the types of the element expressions. module: ESNext isCurrent: true ---*/ @@ -23,13 +23,6 @@ import { Assert } from '../../../../suite/assert.js' -var x: number | string; -var y: boolean | string; -x = 2048; -Assert.isNumber(x); -y = false; -Assert.isFalse(y); -x = "NARC"; +let [x, y]: [string, number] = ["hello", 42]; Assert.isString(x); -y = "1"; -Assert.equal(y, "1"); \ No newline at end of file +Assert.isNumber(y); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_6.ts new file mode 100644 index 0000000000..4e51f2a244 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_6.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The resulting type is an array type with an element type that is the union of the types of + the non-spread element expressions and the numeric index signature types of the spread element expressions. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let arr = [1, 2, ...["three", "four"], 5]; +Assert.isNumber(arr[0]); +Assert.isNumber(arr[1]); +Assert.isString(arr[2]); +Assert.isString(arr[3]); +Assert.isNumber(arr[4]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_1.ts new file mode 100644 index 0000000000..d2d837d32c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_1.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Arrow functions are extended from JavaScript to optionally include parameter and return type annotations. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +const addNumbers = (num1: number, num2: number): number => { + return num1 + num2; +}; +const result1 = addNumbers(5, 10); +Assert.equal(result1, 15); +const greet = (name: string) => { + return name; +}; +const result2 = greet("Alice"); +Assert.equal(result2, "Alice"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_2.ts similarity index 48% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_2.ts index 8e0473c29b..d483ad0bc0 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_2.ts @@ -13,8 +13,10 @@ * limitations under the License. */ /**--- - description: > - The Any type is a supertype of all types, and is assignable to and from all types. + description: > + 1.( ... ) => expr is exactly equivalent to ( ... ) => { return expr ; } + 2.id => { ... } id => expr are exactly equivalent to + ( id ) => { ... } ( id ) => expr module: ESNext isCurrent: true ---*/ @@ -22,41 +24,22 @@ import { Assert } from '../../../../suite/assert.js' -let x: any -let y1: number; -x = 1024; -y1 = x; -Assert.equal(y1, 1024) -let y2: string; -x = "AAA"; -y2 = x; -Assert.equal(y2.length, 3); -let y3: boolean; -x = true; -y3 = x; -Assert.equal(y3, true); -let y4: number[]; -x = [1, 2, 3]; -y4 = x; -Assert.equal(y4[0], 1); -let y5: string[]; -x = ["aa", "bb"]; -y5 = x; -Assert.equal(y5[0], "aa"); -let y6: Function; -x = (a: number, b: number) => { return a + b }; -y6 = x; -Assert.equal(y6(1, 2), 3); -let y7: symbol; -x = Symbol("aa"); -y7 = x; -Assert.equal(y7.toString(), "Symbol(aa)"); -let y8: object; -x = { - toString() { - return 123; - } +const myFunctionA = (num: string): string => { + return num; }; -y8 = x; -Assert.isObject(x); -Assert.equal(y8.toString(), 123) \ No newline at end of file +const resultA = myFunctionA("hello,world"); +Assert.equal(resultA, "hello,world"); +const myFunctionB: () => string = () => "hello,world"; +const resultB = myFunctionB(); +Assert.equal(resultB, "hello,world"); +let getTempItem = (id: any) => ({ id: id, name: "Temp" }); +const TempAResult = getTempItem(123); +Assert.equal(TempAResult.id, 123); +let getTempItemB = function (id: any) { + return { + id: id, + name: "Temp", + }; +}; +const TempBResult = getTempItemB(123); +Assert.equal(TempBResult.id, 123); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_3.ts new file mode 100644 index 0000000000..a8aa4b7819 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_3.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When an arrow function with an expression body and no return type annotation is contextually typed + by a function type T and a contextual signature S can be extracted from T, + the expression body is contextually typed by the return type of S. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let myFunction = (h_x: number, h_y: number) => { return h_x + h_y; } +function myFunc(myValue: (x: number, y: number) => number) { + return myValue; +} +Assert.isFunction(myFunc(myFunction)); +function getx(x: number): number { + return x; +} +const a: number = 10; +let x = () => { return getx(a); } +let y = () => getx(a); +Assert.equal(x(), 10); +Assert.equal(y(), 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_4.ts new file mode 100644 index 0000000000..f7e54b5fac --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_4.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A function expression introduces a new dynamically bound this, whereas an arrow function expression preserves the this of its enclosing context. + Arrow function expressions are particularly useful for writing callbacks, which otherwise often have an undefined or unexpected this. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class ToAlert { + information = "Have a good time!"; + F() { + let for_this = this; + for_this.information = "sad boy"; + Assert.equal(for_this.information, "sad boy") + } +}; +let a = new ToAlert(); +a.F(); +a.information = "boy!"; +Assert.isString(a.information); +Assert.equal(a.information, "boy!"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts new file mode 100644 index 0000000000..2dba576210 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + An assignment of the form 'v = expr' requires v to be classified as a reference or as an assignment pattern. + The expr expression is contextually typed by the type of v, and the type of expr must be assignable to the type of v, + or otherwise a compile-time error occurs. The result is a value with the type of expr. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var sum: Function = function (x: number, y: number) { + return x + y +} +let result = sum(5, 10); +Assert.equal(result, 15); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_2.ts new file mode 100644 index 0000000000..6603bcda8e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_2.ts @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A compound assignment of the form 'v ??= expr' where '??=' is one of the compound assignment operators, + is subject to the same requirements, and produces a value of the same type, as the corresponding non-compound operation. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var x: number = 10 +var y: number = 20 +x *= y +Assert.isNumber(x); +Assert.equal(x, 200); +x = 10; +y = 20; +x /= y +Assert.isNumber(x); +Assert.equal(x, 0.5); +x = 10; +y = 20; +x %= y +Assert.isNumber(x); +Assert.equal(x, 10); +x = 10; +y = 20; +x += y +Assert.isNumber(x); +Assert.equal(x, 30); +x = 10; +y = 20; +x -= y +Assert.isNumber(x); +Assert.equal(x, -10); +x = 10; +y = 20; +x <<= y +Assert.isNumber(x); +Assert.equal(x, 10485760); +x = 10; +y = 20; +x >>= y +Assert.isNumber(x); +Assert.equal(x, 0); +x = 10; +y = 20; +x >>>= y +Assert.isNumber(x); +Assert.equal(x, 0); +x = 10; +y = 20; +x &= y +Assert.isNumber(x); +Assert.equal(x, 0); +x = 10; +y = 20; +x ^= y +Assert.isNumber(x); +Assert.equal(x, 30); +x = 10; +y = 20; +x |= y +Assert.isNumber(x); +Assert.equal(x, 30); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/intersection_type_literals/intersection_type_literals.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_3.ts similarity index 74% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/intersection_type_literals/intersection_type_literals.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_3.ts index daec49b722..025a430f02 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/intersection_type_literals/intersection_type_literals.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_3.ts @@ -14,8 +14,7 @@ */ /**--- description: > - An intersection type literal is written as a sequence of types separated by ampersands. - An intersection type literal references an intersection type. + A compound assignment furthermore requires v to be classified as a reference and the type of the non-compound operation to be assignable to the type of v. module: ESNext isCurrent: true ---*/ @@ -23,8 +22,10 @@ import { Assert } from '../../../../../suite/assert.js' -let x: object & { name: string }; -x = { - name: 'intersection' +let obj = { + name: 'xiao', + age: 18 } -Assert.isObject(x); \ No newline at end of file +let v = obj +v.age += v.age +Assert.equal(v.age, 36); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_1.ts similarity index 66% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_1.ts index 2c8c61db45..731c9d1407 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_1.ts @@ -14,7 +14,8 @@ */ /**--- description: > - the declaration of the 'Array' interface includes a property 'length' and a numeric index signature for the element type, along with other members + In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. + An expression of type S is considered assignable to an assignment target V, if V is variable and S is assignable to the type of V. module: ESNext isCurrent: true ---*/ @@ -22,7 +23,7 @@ import { Assert } from '../../../../../suite/assert.js' -let arr: Array = ["A", "B", "C", "D", "E", "F", "G", "H", "I"]; -Assert.equal(arr[0], "A"); -Assert.equal(arr[5], "F"); -Assert.equal(arr.length, 9); \ No newline at end of file +let arr = [1, 2] +let [first, second] = arr +Assert.equal(first, 1) +Assert.equal(second, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_2.ts new file mode 100644 index 0000000000..8555c425b6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_2.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. + An expression of type S is considered assignable to an assignment target V if V is an object assignment pattern and, + for each assignment property P in V, S is the type Any. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +let obj: any = { + a: "foo", + b: 15, + c: "bar" +} +let { a, b, c } = obj; +Assert.equal(a, 'foo') +Assert.equal(b, 15) +Assert.equal(c, 'bar'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_3.ts new file mode 100644 index 0000000000..722f536d89 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_3.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. + An expression of type S is considered assignable to an assignment target V if V is an object assignment pattern and, + for each assignment property P in V, S has an apparent property with the property name specified in P of a type that is assignable to the target given in P. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +let obj = { + a: "foo", + b: 15, + c: "bar" +} +let { a, b } = obj; +Assert.equal(a, 'foo'); +Assert.equal(b, 15); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_4.ts similarity index 54% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_8.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_4.ts index b713d707f5..0d12823371 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_8.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_4.ts @@ -14,9 +14,9 @@ */ /**--- description: > - S is a subtype of a type T, and T is a supertype of S, - if S has no excess properties with respect to T, - and S is an intersection type and at least one constituent type of S is a subtype of T. + In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. + An expression of type S is considered assignable to an assignment target V if V is an object assignment pattern and, + for each assignment property P in V, P specifies a numeric property name and S has a numeric index signature of a type that is assignable to the target given in P. module: ESNext isCurrent: true ---*/ @@ -24,27 +24,19 @@ import { Assert } from '../../../../../suite/assert.js' -interface T { - name: string - age: number -} interface Foo { - name: string - age: number -} -interface Bar { - hobby: string + [key: number]: string + 18: string + 180: string } -type S = Foo & Bar -let t: T = { - name: "T", - age: 18 +let t: Foo = { + 18: 'age', + 180: 'height' } -let s: S = { - name: "S", - age: 20, - hobby: "drawing" +let v = { + 18: 'Age', + 180: 'Height' } - -t = s; -Assert.equal(t, s); \ No newline at end of file +v = t +Assert.equal(v[18], 'age'); +Assert.equal(v[180], 'height'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_10.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_5.ts similarity index 55% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_10.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_5.ts index 9ee1b09a00..bcbbee18d3 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_10.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_5.ts @@ -14,9 +14,9 @@ */ /**--- description: > - S is a subtype of a type T, and T is a supertype of S, - if S has no excess properties with respect to T, - and T is an intersection type and S is a subtype of each constituent type of T. + In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. + An expression of type S is considered assignable to an assignment target V if V is an object assignment pattern and, + for each assignment property P in V,S has a string index signature of a type that is assignable to the target given in P. module: ESNext isCurrent: true ---*/ @@ -24,27 +24,19 @@ import { Assert } from '../../../../../suite/assert.js' -interface S { - name: string - age: number - height: number -} interface Foo { - name: string -} -interface Bar { - age: number + [key: string]: string + name: string + house: string } -type T = Foo & Bar -let s: S = { - name: "T", - age: 18, - height: 180 +let t: Foo = { + name: 'xiao', + house: 'nanjing' } -let t: T = { - name: "S", - age: 20 +let v = { + name: '', + house: '' } - -t = s; -Assert.equal(t, s); \ No newline at end of file +v = t +Assert.equal(v.house, 'nanjing'); +Assert.equal(v.name, 'xiao'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_6.ts new file mode 100644 index 0000000000..10a776d67d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_6.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. + An expression of type S is considered assignable to an assignment target V if V is an array assignment pattern, + for each assignment element E in V, S is the type Any. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +let arr: any = [1, 2] +let [first, second]: [number, number] = arr +Assert.equal(first, 1) +Assert.equal(second, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_7.ts similarity index 53% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_7.ts index 43a1046c08..b7bb0e33ea 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_7.ts @@ -14,7 +14,10 @@ */ /**--- description: > - array literals may be used to create values of array types. + In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. + An expression of type S is considered assignable to an assignment target V if V is an array assignment pattern, + for each assignment element E in V, S is a tuple-like type with a property named N of a type that is assignable to the target given in E, + where N is the numeric index of E in the array assignment pattern. module: ESNext isCurrent: true ---*/ @@ -22,16 +25,8 @@ import { Assert } from '../../../../../suite/assert.js' -let arr6: number[] = [1, 3, 5, 7, 9]; -let arr7: boolean[] = [true, false, true, false, true]; -let arr8: string[] = ["a", "b", "c", "d", "e", "f"]; -let arr9: object[] = [{ 0x00: "0x00" }, { 0x01: "0x01" }]; -arr6[3] = 14; -Assert.equal(arr6[3], 14); -Assert.equal(true, arr7[2]); -Assert.equal(arr8.toString(), "a,b,c,d,e,f"); -arr8.pop(); -Assert.equal(arr8.toString(), "a,b,c,d,e"); -arr8.push("0x02"); -Assert.equal(arr8.toString(), "a,b,c,d,e,0x02"); -Assert.isObject(arr9); \ No newline at end of file +let s: ['0', string, number] = ['0', 'str', 10] +let [x, y, z]: [string, string, number] = s +Assert.equal(x, '0') +Assert.equal(y, 'str') +Assert.equal(z, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_8.ts new file mode 100644 index 0000000000..5fe003b1d5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_8.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. + An expression of type S is considered assignable to an assignment target V if V is an array assignment pattern, + S is the type Any or an array-like type, and, for each assignment element E in V, + S is not a tuple-like type and the numeric index signature type of S is assignable to the target given in E. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface A { + [key: number]: string +} +let a: A = ['a', 'b', 'c'] +let [x, y, z] = [a[0], a[1], a[2]] +Assert.equal(x, 'a') +Assert.equal(y, 'b') +Assert.equal(z, 'c'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts similarity index 50% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts index 9656503fa3..9f13b77ca8 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts @@ -14,8 +14,10 @@ */ /**--- description: > - the variables 'a' and 'b' are of identical types because the two type references to 'C' create types with a private member 'x' that originates in the same declaration, - and because the two private 'x' members have types with identical sets of members once the type arguments 'X' and 'Y' are substituted. + The binary + operator requires both operands to be of the Number primitive type or an enum type, + or at least one of the operands to be of type Any or the String primitive type. + Operands of an enum type are treated as having the primitive type Number. + If one operand is the null or undefined value, it is treated as having the type of the other operand. module: ESNext isCurrent: true ---*/ @@ -23,26 +25,31 @@ import { Assert } from '../../../../../suite/assert.js' -class Teacher { - private x: T; - constructor(t: T) { - this.x = t; - } - +var a: number = 10 +var b: number = 20 +var x = a + b +Assert.equal(x, 30) +enum e1 { + A, + B, + C } - -interface student1 { f(): string; } - -interface student2 { f(): string; } - -class Person implements student1, student2 { - f() { - return "X+Y" - } +enum e2 { + D, + E, + F } - -let a: Teacher = new Teacher(new Person); -let b: Teacher = new Teacher(new Person); -Assert.isObject(a); -Assert.isObject(b); -Assert.equal(typeof a, typeof b) \ No newline at end of file +var c = e1.A +Assert.equal(c, 0) +var d = e2.D +Assert.equal(d, 0) +var y = c + d +Assert.equal(y, 0) +var e: any = true +Assert.isTrue(e) +var f: string = 's' +Assert.equal(f, 's') +var w = a + e +Assert.equal(w, 11) +var v = c + f +Assert.equal(v, '0s'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/union_type_literals/union_type_literals.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts similarity index 57% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/union_type_literals/union_type_literals.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts index dd967d6d15..d563a695ea 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/union_type_literals/union_type_literals.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts @@ -14,8 +14,9 @@ */ /**--- description: > - A union type literal is written as a sequence of types separated by vertical bars. - A union type literal references a union type. + The binary + operator, + If one or both operands are of the String primitive type, the result is of the String primitive type. + Otherwise, the result is of type Any. module: ESNext isCurrent: true ---*/ @@ -23,10 +24,24 @@ import { Assert } from '../../../../../suite/assert.js' -let x: string | number | boolean; -x = 's'; -Assert.isString(x); -x = 5; +var a: any = true +var b: any = 's' +var c: boolean = false +var d: string = 'str' +var e: number = 10 +var f: any = 20 +var w = a + b +Assert.isString(w); +Assert.equal(w, 'trues'); +var v = a + f +Assert.isNumber(v); +Assert.equal(v, 21); +var x = a + c Assert.isNumber(x); -x = true; -Assert.isBoolean(x); \ No newline at end of file +Assert.equal(x, 1); +var y = a + d +Assert.isString(y); +Assert.equal(y, 'truestr'); +var z = a + e +Assert.isNumber(z); +Assert.equal(z, 11); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_type/the_string_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts similarity index 77% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_type/the_string_type_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts index 78d89c6fc2..1584ff3a92 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_type/the_string_type_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts @@ -14,8 +14,8 @@ */ /**--- description: > - The string keyword references the String primitive type and - string literals may be used to write values of the String primitive type. + The binary + operator, + A value of any type can converted to the String primitive type by adding an empty string. module: ESNext isCurrent: true ---*/ @@ -23,6 +23,7 @@ import { Assert } from '../../../../../suite/assert.js' -let str: string; -str = "abcd"; -Assert.equal(str, "abcd"); \ No newline at end of file +function func() { } +let s = func() + "" +Assert.isString(s); +Assert.equal(s, 'undefined'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts new file mode 100644 index 0000000000..773396e33d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The && operator permits the operands to be of any type and produces a result of the same type as the second operand. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = 10 +var b: any = 's' +var c: boolean = false +var d: boolean = true +var e: number = 20 +var f: number = 15 +var g: string = 'a' +var h: string = 'b' +var i: undefined = undefined +var j: undefined = undefined +var k = a && b +Assert.isString(k); +Assert.equal(k, 's'); +var l = c && d +Assert.isFalse(l); +var m = e && f +Assert.isNumber(m); +Assert.equal(m, 15); +var n = g && h +Assert.isString(n); +Assert.equal(n, 'b'); +var o = i && j +Assert.isUndefined(o); +var p = a && c +Assert.isFalse(p); +var q = a && e +Assert.isNumber(q); +Assert.equal(q, 20); +var r = a && g +Assert.isString(r); +Assert.equal(r, 'a'); +var s = a && i +Assert.isUndefined(s); +var t = c && e +Assert.isFalse(t); +var u = c && g +Assert.isFalse(u); +var v = c && i +Assert.isFalse(v); +var w = e && g +Assert.isString(w); +Assert.equal(w, 'a'); +var x = e && i +Assert.isUndefined(x); +var y = g && i +Assert.isUndefined(y); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_congruence_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_congruence_operator.ts new file mode 100644 index 0000000000..7355498027 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_congruence_operator.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '===' operator require one or both of the operand types to be assignable to the other. + The result is always of the Boolean primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = undefined; +var b: boolean = true; +var c: number = 1; +var d: string = 'str'; +var e: number = 1; +Assert.isFalse(a === b); +Assert.isFalse(a === c); +Assert.isFalse(a === d); +Assert.isFalse(b as unknown === c); +Assert.isTrue(c === e); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_equal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_equal_operator.ts new file mode 100644 index 0000000000..95e2a6c463 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_equal_operator.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '==' operator require one or both of the operand types to be assignable to the other. + The result is always of the Boolean primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = undefined; +var b: boolean = true; +var c: number = 1; +var d: string = 'str'; +var e: number = 1; +Assert.isFalse(a == b); +Assert.isFalse(a == c); +Assert.isFalse(a == d); +Assert.isTrue(b as unknown == c); +Assert.isTrue(c == e); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_operator.ts new file mode 100644 index 0000000000..af6b372c83 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_operator.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '>' operator require one or both of the operand types to be assignable to the other. + The result is always of the Boolean primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = undefined; +var b: boolean = true; +var c: number = 10; +var d: string = 'str'; +var e: number = 0; +Assert.isFalse(a > b); +Assert.isFalse(a > c); +Assert.isFalse(a > d); +Assert.isTrue(c > (b as unknown as number)); +Assert.isTrue(c > e); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_or_equal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_or_equal_operator.ts new file mode 100644 index 0000000000..eb07feba43 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_or_equal_operator.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '>=' operator require one or both of the operand types to be assignable to the other. + The result is always of the Boolean primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = undefined; +var b: boolean = true; +var c: number = 1; +var d: string = 'str'; +var e: number = 0; +Assert.isFalse(a >= b); +Assert.isFalse(a >= c); +Assert.isFalse(a >= d); +Assert.isTrue(c >= (b as unknown as number)); +Assert.isTrue(c >= e); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_incongruence_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_incongruence_operator.ts new file mode 100644 index 0000000000..fa381e16a2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_incongruence_operator.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '!==' operator require one or both of the operand types to be assignable to the other. + The result is always of the Boolean primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = undefined; +var b: boolean = true; +var c: number = 1; +var d: string = 'str'; +var e: number = 1; +Assert.isTrue(a !== b); +Assert.isTrue(a !== c); +Assert.isTrue(a !== d); +Assert.isTrue(b as unknown !== c); +Assert.isFalse(c !== e); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_operator.ts new file mode 100644 index 0000000000..83e35d4f0d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_operator.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '<' operator require one or both of the operand types to be assignable to the other. + The result is always of the Boolean primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = undefined; +var b: boolean = true; +var c: number = 1; +var d: string = 'str'; +var e: number = 0; +Assert.isFalse(a < b) +Assert.isFalse(a < c) +Assert.isFalse(a < d); +Assert.isFalse(c < (b as unknown as number)); +Assert.isFalse(c < e); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_or_equal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_or_equal_operator.ts new file mode 100644 index 0000000000..86271a7683 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_or_equal_operator.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '<=' operator require one or both of the operand types to be assignable to the other. + The result is always of the Boolean primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = undefined; +var b: boolean = true; +var c: number = 1; +var d: string = 'str'; +var e: number = 0; +Assert.isFalse(a <= b) +Assert.isFalse(a <= c) +Assert.isFalse(a <= d); +Assert.isTrue(c <= (b as unknown as number)); +Assert.isFalse(c <= e); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/tuple_types/tuple_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_unequal_operator.ts similarity index 65% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/tuple_types/tuple_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_unequal_operator.ts index ecbffe23bc..68ba03331e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/tuple_types/tuple_types_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_unequal_operator.ts @@ -14,8 +14,8 @@ */ /**--- description: > - Array literals may be used to create values of tuple types. - the members of an array type whose element type is the union type of the tuple element types + The '!=' operator require one or both of the operand types to be assignable to the other. + The result is always of the Boolean primitive type. module: ESNext isCurrent: true ---*/ @@ -23,13 +23,13 @@ import { Assert } from '../../../../../suite/assert.js' -let cc: [number, string, boolean]; -cc = [12, "abcd", true]; -let index: number = 0; -let x = cc[index]; -x = 12; -Assert.equal(x, 12); -x = false; -Assert.equal(x, false); -x = "string"; -Assert.equal(x, "string"); \ No newline at end of file +var a: any = undefined; +var b: boolean = true; +var c: number = 1; +var d: string = 'str'; +var e: number = 1; +Assert.isTrue(a != b) +Assert.isTrue(a != c) +Assert.isTrue(a != d); +Assert.isFalse(b as unknown != c); +Assert.isFalse(c != e); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts similarity index 51% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts index 26ac209857..5b201f2b87 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts @@ -14,10 +14,9 @@ */ /**--- description: > - The apparent members of an object type T are the combination of the following: - The declared and/or inherited members of T. - The properties of the global interface type 'Object' that aren't hidden by properties with the same name in T. - If T has one or more call or construct signatures, the properties of the global interface type 'Function' that aren't hidden by properties with the same name in T. + The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, + and the right operand to be of type Any, an object type, or a type parameter type. + The result is always of the Boolean primitive type. module: ESNext isCurrent: true ---*/ @@ -25,19 +24,24 @@ import { Assert } from '../../../../../suite/assert.js' -let obj: Object; -obj = { - toString() { - return '123'; - } +interface A { + num: number } -Assert.notEqual(obj.toString, "123"); - -class Person { - name?: string; - age?: number; - toString(): string { - return "hello" +interface B { + str: string +} +function isString(k: A | B) { + let flag: boolean = false; + if ('num' in k) { + Assert.isTrue('num' in k); + flag = false; + } else if ('str' in k) { + Assert.isTrue('str' in k); + flag = true; } + return flag; } -Assert.notEqual(Person.toString(), "hello"); \ No newline at end of file +let result1 = isString({ num: 20 }); +Assert.isFalse(result1); +let result2 = isString({ str: 'A' }); +Assert.isTrue(result2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_12.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_instanceof_operator/the_instanceof_operator.ts similarity index 43% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_12.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_instanceof_operator/the_instanceof_operator.ts index cb4b90c5a2..2a9e1e5435 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_12.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_instanceof_operator/the_instanceof_operator.ts @@ -14,16 +14,9 @@ */ /**--- description: > - S is a subtype of a type T, and T is a supertype of S, - if S has no excess properties with respect to T, - and S is an object type, an intersection type, an enum type, or the Number, Boolean, or String primitive type, T is an object type, - and for each member M in T, M is a property and S has an apparent property N where, - M and N have the same name, - the type of N is a subtype of that of M, - if M is a required property, N is also a required property, and - M and N are both public, M and N are both private and originate in the same declaration, - M and N are both protected and originate in the same declaration, - or M is protected and N is declared in a class derived from the class in which M is declared. + The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type, + and the right operand to be of type Any or a subtype of the 'Function' interface type. + The result is always of the Boolean primitive type. module: ESNext isCurrent: true ---*/ @@ -31,24 +24,34 @@ import { Assert } from '../../../../../suite/assert.js' -type T = { - name: any - age: number +interface Animal { + species: string } -type S = { +class Felidae implements Animal { + kind: string + species: string + constructor(species: string, kind: string) { + this.species = species + this.kind = kind + } +} +class Canidae implements Animal { + species: string name: string - age: number - height: number + constructor(species: string, name: string) { + this.species = species + this.name = name + } } -let t: T = { - name: "xiao", - age: 19 +const getRandomAnimal = () => { + return Math.random() < 0.5 ? + new Canidae('Canidae', 'Wolf') : + new Felidae('Felidae', 'Tiger') } -let s: S = { - name: "Xi", - age: 20, - height: 180 +let Animal = getRandomAnimal() +if (Animal instanceof Canidae) { + Assert.isTrue(Animal instanceof Canidae) } - -t = s; -Assert.equal(t, s); \ No newline at end of file +if (Animal instanceof Felidae) { + Assert.isTrue(Animal instanceof Felidae); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_and_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_and_operator.ts new file mode 100644 index 0000000000..7f3c671a94 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_and_operator.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '&' operator require its operands to be of type Any, the Number primitive type, or an enum type. + Operands of an enum type are treated as having the primitive type Number. + If one operand is the null or undefined value, it is treated as having the type of the other operand. + The result is always of the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = '10'; +var b: any = true; +var c: number = 9; +var x = a & b; +var y = a & c; +var bb = b & b; +var cc = c & c; +Assert.isNumber(x); +Assert.equal(x, 0); +Assert.isNumber(y); +Assert.equal(y, 8); +Assert.isNumber(bb); +Assert.equal(bb, 1); +Assert.isNumber(cc); +Assert.equal(cc, 9); +enum e { + A, + B, + C +} +var d = e.C; +var z = a & d; +Assert.isNumber(z); +Assert.equal(z, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_division_method_operator.ts similarity index 54% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_division_method_operator.ts index 36aed13d2c..1e8304437c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_division_method_operator.ts @@ -14,8 +14,10 @@ */ /**--- description: > - The process of substituting type arguments for type parameters in a generic type - or generic signature is known as instantiating the generic type or signature. + The '/' operator require its operands to be of type Any, the Number primitive type, or an enum type. + Operands of an enum type are treated as having the primitive type Number. + If one operand is the null or undefined value, it is treated as having the type of the other operand. + The result is always of the Number primitive type. module: ESNext isCurrent: true ---*/ @@ -23,9 +25,23 @@ import { Assert } from '../../../../../suite/assert.js' -function fun(h_x: T): T { - return h_x; -} -let x = fun(10); +var a: any = '10'; +var b: any = true; +var c: number = 20; +var x = b / a; +var y = a / c; Assert.isNumber(x); -Assert.equal(x, 10); \ No newline at end of file +Assert.equal(x, 0.1); +Assert.isNumber(y); +Assert.equal(y, 0.5); +Assert.isNumber(c / 2); +Assert.equal(c / 2, 10); +enum e { + A, + B, + C +} +var d = e.C; +var z = a / d; +Assert.isNumber(z); +Assert.equal(z, 5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_left_shift_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_left_shift_operator.ts new file mode 100644 index 0000000000..93c3f48936 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_left_shift_operator.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '<<' operator require its operands to be of type Any, the Number primitive type, or an enum type. + Operands of an enum type are treated as having the primitive type Number. + If one operand is the null or undefined value, it is treated as having the type of the other operand. + The result is always of the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = '10'; +var b: any = true; +var c: number = 20; +var x = a << b; +var y = c << a; +Assert.isNumber(x); +Assert.equal(x, 20); +Assert.isNumber(y); +Assert.equal(y, 20480); +Assert.isNumber(c << 2); +Assert.equal(c << 2, 80); +enum e { + A, + B, + C +} +var d = e.C; +var z = a << d; +Assert.isNumber(z); +Assert.equal(z, 40); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_multiplication_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_multiplication_operator.ts new file mode 100644 index 0000000000..592d9bc61a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_multiplication_operator.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '*' operator require its operands to be of type Any, the Number primitive type, or an enum type. + Operands of an enum type are treated as having the primitive type Number. + If one operand is the null or undefined value, it is treated as having the type of the other operand. + The result is always of the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = '10'; +var b: any = false; +var c: number = 20; +var x = a * b; +var y = a * c; +Assert.isNumber(x); +Assert.equal(x, 0); +Assert.isNumber(y); +Assert.equal(y, 200); +Assert.isNumber(c * 2); +Assert.equal(c * 2, 40); +enum e { + A, + B, + C +} +var d = e.C; +var z = a * d; +Assert.isNumber(z); +Assert.equal(z, 20); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_or_operator.ts similarity index 51% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_or_operator.ts index 9dacbcde77..7da1b71d72 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_or_operator.ts @@ -14,21 +14,38 @@ */ /**--- description: > - S is assignable to a type T, and T is assignable from S, - if S has no excess properties with respect to T, and S or T is an enum type and the other is the primitive type Number. + The '|' operator require its operands to be of type Any, the Number primitive type, or an enum type. + Operands of an enum type are treated as having the primitive type Number. + If one operand is the null or undefined value, it is treated as having the type of the other operand. + The result is always of the Number primitive type. module: ESNext isCurrent: true ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../../suite/assert.js' -enum T { +var a: any = '10'; +var b: any = true; +var c: number = 9; +var x = a | b; +var y = a | c; +var bb = b | b; +var cc = c | c; +Assert.isNumber(x); +Assert.equal(x, 11); +Assert.isNumber(y); +Assert.equal(y, 11); +Assert.isNumber(bb); +Assert.equal(bb, 1); +Assert.isNumber(cc); +Assert.equal(cc, 9); +enum e { A, B, C } -let S: number = 5 -let t: T -t = S -Assert.equal(t, S); \ No newline at end of file +var d = e.C; +var z = a | d; +Assert.isNumber(z); +Assert.equal(z, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_remainder_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_remainder_operator.ts new file mode 100644 index 0000000000..64034d3d7e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_remainder_operator.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '%' operator require its operands to be of type Any, the Number primitive type, or an enum type. + Operands of an enum type are treated as having the primitive type Number. + If one operand is the null or undefined value, it is treated as having the type of the other operand. + The result is always of the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = '11'; +var b: any = true; +var c: number = 5; +var x = a % b; +var y = a % c; +Assert.isNumber(x); +Assert.equal(x, 0); +Assert.isNumber(y); +Assert.equal(y, 1); +Assert.isNumber(28 % c); +Assert.equal(28 % c, 3); +enum e { + A, + B, + C +} +var d = e.C; +var z = a % d; +Assert.isNumber(z); +Assert.equal(z, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_right_shift_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_right_shift_operator.ts new file mode 100644 index 0000000000..c5dba842a4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_right_shift_operator.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '>>' operator require its operands to be of type Any, the Number primitive type, or an enum type. + Operands of an enum type are treated as having the primitive type Number. + If one operand is the null or undefined value, it is treated as having the type of the other operand. + The result is always of the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = '10'; +var b: any = true; +var c: number = 20; +var x = a >> b; +var y = a >> c; +Assert.isNumber(x); +Assert.equal(x, 5); +Assert.isNumber(y); +Assert.equal(y, 0); +Assert.isNumber(c >> 4); +Assert.equal(c >> 4, 1); +enum e { + A, + B, + C +} +var d = e.C; +var z = a >> d; +Assert.isNumber(z); +Assert.equal(z, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_subtraction_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_subtraction_operator.ts new file mode 100644 index 0000000000..ac23d291e3 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_subtraction_operator.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '-' operator require its operands to be of type Any, the Number primitive type, or an enum type. + Operands of an enum type are treated as having the primitive type Number. + If one operand is the null or undefined value, it is treated as having the type of the other operand. + The result is always of the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = '10'; +var b: any = true; +var c: number = 20; +var x = a - b; +var y = a - c; +Assert.isNumber(x); +Assert.equal(x, 9); +Assert.isNumber(y); +Assert.equal(y, -10); +Assert.isNumber(c - 9); +Assert.equal(c - 9, 11); +enum e { + A, + B, + C +} +var d = e.A; +var z = a - d; +Assert.isNumber(z); +Assert.equal(z, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_unsigned_shift_to_the_right.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_unsigned_shift_to_the_right.ts new file mode 100644 index 0000000000..1710c25a47 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_unsigned_shift_to_the_right.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '>>>' operator require its operands to be of type Any, the Number primitive type, or an enum type. + Operands of an enum type are treated as having the primitive type Number. + If one operand is the null or undefined value, it is treated as having the type of the other operand. + The result is always of the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = '10'; +var b: any = true; +var c: number = 20; +var x = a >>> b; +var y = a >>> c; +Assert.isNumber(x); +Assert.equal(x, 5); +Assert.isNumber(y); +Assert.equal(y, 0); +Assert.isNumber(c >>> 4); +Assert.equal(c >>> 4, 1); +enum e { + A, + B, + C +} +var d = e.C; +var z = a >>> d; +Assert.isNumber(z); +Assert.equal(z, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_xor_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_xor_operator.ts new file mode 100644 index 0000000000..64c0333b88 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_xor_operator.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The '^' operator require its operands to be of type Any, the Number primitive type, or an enum type. + Operands of an enum type are treated as having the primitive type Number. + If one operand is the null or undefined value, it is treated as having the type of the other operand. + The result is always of the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var a: any = '10'; +var b: any = true; +var c: number = 20; +var x = a ^ b; +var y = a ^ c; +Assert.isNumber(x); +Assert.equal(x, 11); +Assert.isNumber(y); +Assert.equal(y, 30); +Assert.isNumber(c ^ 4); +Assert.equal(c ^ 4, 16); +enum e { + A, + B, + C +} +var d = e.C; +var z = a ^ d; +Assert.isNumber(z); +Assert.equal(z, 8); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/tuple_type_literals/tuple_type_literals.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts similarity index 39% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/tuple_type_literals/tuple_type_literals.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts index 5eba9508bd..3bfc017ab7 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/tuple_type_literals/tuple_type_literals.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts @@ -14,8 +14,8 @@ */ /**--- description: > - A tuple type literal is written as a sequence of element types, separated by commas and enclosed in square brackets. - A tuple type literal references a tuple type. + The || operator permits the operands to be of any type. + The type of the result is the union type of the two operand types. module: ESNext isCurrent: true ---*/ @@ -23,7 +23,55 @@ import { Assert } from '../../../../../suite/assert.js' -let arr: [number, string, boolean] = [3, 'a', true] -Assert.isNumber(arr[0]); -Assert.isString(arr[1]); -Assert.isBoolean(arr[2]); \ No newline at end of file +var a: any = 10; +var b: any = 's'; +var c: boolean = false; +var d: boolean = true; +var e: number = 20; +var f: number = 15; +var g: string = 'a'; +var h: string = 'b'; +var i: undefined = undefined; +var j: undefined = undefined; +var k = a || b; +Assert.isNumber(k); +Assert.equal(k, 10); +var l = c || d; +Assert.isTrue(l); +var m = e || f; +Assert.isNumber(m); +Assert.equal(m, 20); +var n = g || h; +Assert.isString(n); +Assert.equal(n, 'a'); +var o = i || j; +Assert.isUndefined(o); +var p = a || c; +Assert.isNumber(p); +Assert.equal(p, 10); +var q = a || e; +Assert.isNumber(q); +Assert.equal(q, 10); +var r = a || g; +Assert.isNumber(r); +Assert.equal(r, 10); +var s = a || i; +Assert.isNumber(s); +Assert.equal(s, 10); +var t = c || e; +Assert.isNumber(t); +Assert.equal(t, 20); +var u = c || g; +Assert.isString(u); +Assert.equal(u, 'a'); +var v = c || i; +Assert.isUndefined(v); +var w = e || g; +Assert.isNumber(w); +Assert.equal(w, 20); +var x = e || i; +Assert.isNumber(x); +Assert.equal(x, 20); +var y = g || i; +Assert.isString(y); +Assert.equal(y, 'a'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_2.ts new file mode 100644 index 0000000000..ab473317f6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_2.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the || expression is contextually typed, the operands are contextually typed by the same type. + Otherwise, the left operand is not contextually typed and the right operand is contextually typed by the type of the left operand. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +var sum = function (x: number, y: number) { + return x + y +} +var average = function (a: number, b: number) { + return (a + b) / 2 +} +var rela1 = sum || average; +var rela2 = average || sum; +let a = rela1(1, 2); +let b = rela2(1, 2); +Assert.isFunction(rela1); +Assert.isFunction(rela2); +Assert.equal(rela1, sum); +Assert.equal(rela2, average); +Assert.equal(a, 3); +Assert.equal(b, 1.5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/class_expressions/class_expressions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/class_expressions/class_expressions_1.ts new file mode 100644 index 0000000000..83c9081bee --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/class_expressions/class_expressions_1.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Just as with class declarations, class expressions would create a constructor function that can be used to construct instances. + Like class declarations, you may also declare property members and index members, as well as use the constructor parameters. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var Square = class { + acreage: number; + + constructor(public h_length: number, public h_width: number) { + this.acreage = this.h_length * this.h_width; + } +}; +var square = new Square(5, 10); +Assert.equal(square.acreage, 50); +let Ref = class Reflmpl { + public readonly _v = true; + constructor(private _rawValue: number, public _shaw = false) { + this._rawValue = _rawValue; + this._shaw = this._shaw; + } + get value() { + return this._rawValue; + } + set value(newVal) { + this._rawValue = newVal; + } + get shaw() { + return this._shaw; + } + set shaw(newShaw) { + this._shaw = newShaw; + } +} +let ref = new Ref(10, true); +Assert.equal(ref.value, 10); +Assert.equal(ref._shaw, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts new file mode 100644 index 0000000000..0868288f8f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a variable, parameter, binding property, binding element, or member declaration, + an initializer expression is contextually typed by the type given in the declaration's type annotation. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let a: number +a = 10 +Assert.isNumber(a) +function fun(x: string) { + let y = x + 'ing' + return y +} +Assert.isString(fun('str')) +interface Obj { + name: string + age: number +} +let obj: Obj = { + name: 'xiao', + age: 18 +} +Assert.isString(obj.name) +Assert.isNumber(obj.age); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_10.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_10.ts new file mode 100644 index 0000000000..c9649d460a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_10.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a contextually typed array literal expression containing no spread elements, an element expression at index N is contextually typed by + the type of the property with the numeric name N in the contextual type, if any, or otherwise + the numeric index type of the contextual type, if any. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let arr: { + [key: number]: string +} = { + 1: 'a', + 2: 'b', + 3: 'c', + 4: 'd' +} +Assert.isString(arr[1]) +Assert.isString(arr[2]) +Assert.isString(arr[3]) +Assert.isString(arr[4]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/widend_types/widend_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_11.ts similarity index 67% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/widend_types/widend_types_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_11.ts index b1b02996d9..46c0bdd684 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/widend_types/widend_types_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_11.ts @@ -14,7 +14,8 @@ */ /**--- description: > - The widened form of a type is the type in which all occurrences of the Null and Undefined types have been replaced with the type any. + In a contextually typed array literal expression containing one or more spread elements, + an element expression at index N is contextually typed by the numeric index type of the contextual type, if any. module: ESNext isCurrent: true ---*/ @@ -22,11 +23,8 @@ import { Assert } from '../../../../suite/assert.js' -var nu = null -Assert.equal(typeof nu, 'object') -var un = undefined -Assert.isUndefined(un) -var obj = { x: 0, y: null } -Assert.equal(typeof obj, 'object') -var arr = [null, undefined] -Assert.equal(typeof arr, 'object'); \ No newline at end of file +let first = [1, 2] +let second = [3, 4] +let bothPlus = [0, ...first, ...second, 5] +Assert.isNumber(bothPlus[2]) +Assert.isNumber(bothPlus[4]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts new file mode 100644 index 0000000000..5c60fa1c14 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a contextually typed parenthesized expression, the contained expression is contextually typed by the same type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var a: number = 10 +var b: number = 5 +var c = (a + b) * (a - b) +Assert.isNumber(c) +interface Foo { + num: number + str: string +} +const x: Foo[] = [{ num: 18, str: 'hello' }, { num: 20, str: 'world' }] +Assert.isNumber(x[0].num) +Assert.isNumber(x[1].num) +Assert.isString(x[0].str) +Assert.isString(x[1].str); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_13.ts similarity index 70% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_6.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_13.ts index 171bc00ed4..b7a6cd652f 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_6.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_13.ts @@ -14,8 +14,7 @@ */ /**--- description: > - type guards may be used to narrow a union type to a more specific type. - in particular, type guards are useful for narrowing union type values to a non-union type values. + In a type assertion, the expression is contextually typed by the indicated type. module: ESNext isCurrent: true ---*/ @@ -23,8 +22,12 @@ import { Assert } from '../../../../suite/assert.js' -let x: string | number; -x = 37; -x = "hello"; -let h_n = typeof x === "string" ? x.length : x; -Assert.isNumber(h_n); \ No newline at end of file +interface Person { + name: string + age: number +} +let student = {} as Person +student.name = 'xiao' +student.age = 18 +Assert.isNumber(student.age) +Assert.isString(student.name); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts new file mode 100644 index 0000000000..76c8be1985 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a || operator expression, if the expression is contextually typed, the operands are contextually typed by the same type. + Otherwise, the right expression is contextually typed by the type of the left expression. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var sum = function (x: number, y: number) { + return x + y +} +var average1 = function (a: number, b: number) { + return (a + b) / 2 +} +var rela1 = sum || average1 +Assert.equal(typeof rela1, 'function') +var average2: number = 10 +var rela2 = average2 || sum +Assert.equal(typeof rela2, 'number'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_15.ts similarity index 68% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_15.ts index 9cb462699e..d7a649f139 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_15.ts @@ -14,20 +14,16 @@ */ /**--- description: > - Two types are considered identical when they are the same type parameter. + In a contextually typed conditional operator expression, the operands are contextually typed by the same type. module: ESNext isCurrent: true ---*/ -import { Assert } from '../../../../../suite/assert.js' +import { Assert } from '../../../../suite/assert.js' -type T = string; -type U = string; -function func(arg: T) { - return arg; +function processValue(value: number | (() => number)) { + var x = typeof value !== "number" ? value() : value + Assert.isNumber(x) } - -let a = func('a'); -let b = func('b'); -Assert.equal(typeof a, typeof b); \ No newline at end of file +processValue(5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_16.ts similarity index 71% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_16.ts index 09108a4f63..940f31181e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_16.ts @@ -14,15 +14,18 @@ */ /**--- description: > - An array type literal references an array type with the given element type. + In an assignment expression, the right hand expression is contextually typed by the type of the left hand expression. module: ESNext isCurrent: true ---*/ -import { Assert } from '../../../../../suite/assert.js' +import { Assert } from '../../../../suite/assert.js' -let arr: (string | number | boolean)[] = ['s', 5, true]; -Assert.equal(arr[0], 's'); -Assert.equal(arr[1], 5); -Assert.equal(arr[2], true); \ No newline at end of file +interface A { + (a: number): void +} +const fn: A = function (a) { + Assert.isNumber(a) +} +fn(5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/specifying_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_2.ts similarity index 66% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/specifying_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_2.ts index 861a9cc8cf..d24a9bad0e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/specifying_types_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_2.ts @@ -14,7 +14,8 @@ */ /**--- description: > - Parentheses are required around union, intersection, function, or constructor types when they are used as array element types + In a variable, parameter, binding property, binding element, or member declaration, + an initializer expression is contextually typed by for a parameter, the type provided by a contextual signature. module: ESNext isCurrent: true ---*/ @@ -22,10 +23,8 @@ import { Assert } from '../../../../suite/assert.js' -let arr: (string | number)[] = ['10', 5]; -Assert.equal(typeof arr, 'object'); -let m_fun = function func(x: number) { - return x; +var f: (s: string) => string = function (x) { + Assert.isString(x) + return x.toLowerCase() } -let fun: ((h_x: string) => string) | ((h_x: number) => number) = m_fun; -Assert.equal(typeof fun, 'function'); \ No newline at end of file +f('str'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_3.ts new file mode 100644 index 0000000000..b94a14a8f5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_3.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a variable, parameter, binding property, binding element, or member declaration, + an initializer expression is contextually typed by the type implied by the binding pattern in the declaration. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function f({ a = true, b = "hello", c = 1 }) { + Assert.isBoolean(a) + Assert.isString(b) + Assert.isNumber(c) +} +f({ a: false }); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts new file mode 100644 index 0000000000..d15947b430 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In the body of a function declaration, function expression, arrow function, method declaration, + or get accessor declaration that has a return type annotation, + return expressions are contextually typed by the type given in the return type annotation. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function add(x: number, y: number): number { + return x + y +} +let sum = add(10, 20) +Assert.isNumber(sum) +type Fun = (a: number, b: number) => number +function fun(fn: Fun, x: number, y: number) { + return fn(x, y) +} +function minus(a: number, b: number) { + return a - b +} +function mul(a: number, b: number) { + return a * b +} +let m = fun(minus, 15, 7) +let n = fun(mul, 3, 6) +Assert.isNumber(m) +Assert.isNumber(n); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_5.ts new file mode 100644 index 0000000000..dadabf1676 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_5.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In the body of a function expression or arrow function that has no return type annotation, + if the function expression or arrow function is contextually typed by a function type with exactly one call signature, + and if that call signature is non-generic, return expressions are contextually typed by the return type of that call signature. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +type Fun = { + description: string + (someThing: number): boolean +} +function fun1(fn: Fun) { + return fn.description + fn(100) +} +function fun2(num: number) { + Assert.equal(num, 100) + return false +} +fun2.description = 'hello' +Assert.equal(fun1(fun2), 'hellofalse'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_6.ts new file mode 100644 index 0000000000..3d70a3597e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_6.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In the body of a constructor declaration, return expressions are contextually typed by the containing class type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Person { + name: string + age: number + constructor(name: string, age: number) { + this.name = name + this.age = age + } +} +const p = new Person("xiao", 18) +Assert.isString(p.name) +Assert.isNumber(p.age); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts new file mode 100644 index 0000000000..f910a94072 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In the body of a get accessor with no return type annotation, + if a matching set accessor exists and that set accessor has a parameter type annotation, + return expressions are contextually typed by the type given in the set accessor's parameter type annotation. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class C { + private _str = '' + private _arr: string[] = [] + get func() { + return this._str + } + set func(value: string) { + this._str= value + } + get f() { + return this._arr + } + set f(value: string[]) { + this._arr = value + } +} +const c = new C() +c.func= 'TS' +Assert.isString(c.func) +c.f = ['develop', 'test'] +c.f.push('ship') +Assert.equal(c.f, 'develop,test,ship'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts new file mode 100644 index 0000000000..2036c81219 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a typed function call, argument expressions are contextually typed by their corresponding parameter types. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +const obj: Record = { + boo: false, + arr: ['a', 'b', 'c'] +} +const para = (str: string): [T, Function] => { + const result1: T = obj[str]; + const result2: Function = (value: T) => { + obj[str] = value; + return obj[str]; + } + return [result1, result2]; +} +const [boo, mem2] = para('boo'); +const [arr, mem4] = para('arr'); +Assert.isBoolean(boo); +Assert.equal(arr, 'a,b,c'); +let x = mem2(true); +let y = mem4(false); +Assert.isTrue(x); +Assert.isFalse(y); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_9.ts similarity index 59% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_9.ts index 6d52692591..e6fc7d38b7 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_9.ts @@ -14,8 +14,10 @@ */ /**--- description: > - A type alias serves as an alias for the type specified in the type alias declaration. - A type alias declaration can introduce a name for any kind of type. + In a contextually typed object literal, each property value expression is contextually typed by + the type of the property with a matching name in the contextual type, if any, or otherwise + for a numerically named property, the numeric index type of the contextual type, if any, or otherwise + the string index type of the contextual type, if any. module: ESNext isCurrent: true ---*/ @@ -23,18 +25,15 @@ import { Assert } from '../../../../suite/assert.js' -type MyString = string; -let x: MyString = 'x'; -Assert.isString(x); - -type MyUnionType = number | string | boolean; -let y: MyUnionType = 10; -Assert.isNumber(y); -y = '10'; -Assert.isString(y); -y = true; -Assert.isBoolean(y); - -type MyInterType = object & { name: string }; -let z: MyInterType = { name: 'xiao' }; -Assert.equal(typeof z, 'object'); \ No newline at end of file +interface Person { + (a: number): void +} +interface B { + fn: Person +} +const obj: B = { + fn: function (a) { + Assert.isNumber(a) + } +} +obj.fn(10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts similarity index 61% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts index 39e9d6a0b4..f93221902a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts @@ -14,9 +14,7 @@ */ /**--- description: > - In certain contexts, - inferences for a given set of type parameters are made from a type S, in which those type parameters do not occur, - to another type T, in which those type parameters do occur. + The inclusion of type arguments in the Arguments production gives rise to certain ambiguities in the grammar for expressions. module: ESNext isCurrent: true ---*/ @@ -24,17 +22,20 @@ import { Assert } from '../../../../../suite/assert.js' -interface I1 { - (a: number): void +var h_g: number = 5 +var h_A: number = 3 +var h_B: number = 6 +function f(a: any, b?: any) { + return a } -interface I2 { - (cb: I1): void +Assert.isFalse(f(h_g < h_A, h_B > 7)) +Assert.isFalse(f(h_g < h_A, h_B > +(7))) +type A1 = number +type B1 = number +function g1(a: T) { + return a; } -const fn: I2 = function (cb) { - Assert.isFunction(cb); +function f1(a: any, b?: any) { + return a } - -fn(function (a) { - Assert.isNumber(a); - a = a + 1; -}); +Assert.equal(f1(g1(7)), 7); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts new file mode 100644 index 0000000000..ae09cd482e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The compile-time processing of a typed function call consists, + a list of candidate signatures is constructed from the call signatures in the function type in declaration order. + A generic signature is a candidate in a function call with type arguments when the signature has the same number of type parameters + as were supplied in the type argument list, the type arguments satisfy their constraints, + and once the type arguments are substituted for their associated type parameters, + the signature is applicable with respect to the argument list of the function call. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +function fun(x: Array, y: Array): Array +function fun(x: Array, y: Array, z: Array): Array +function fun(x: Array, y: Array, z?: V): Array { + return x +} +let arr1: Array = [1, 2, 3]; +let arr2: Array = ['a', 'b']; +let arr3: Array = [true, false]; +let a = fun(arr1, arr2); +Assert.equal(a, arr1); +let b = fun(arr1, arr2, arr3); +Assert.equal(b, arr1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts new file mode 100644 index 0000000000..a5d9d10954 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A non-generic signature is a candidate when + the function call has no type arguments, and + the signature is applicable with respect to the argument list of the function call. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +function add(): number; +function add(x: number): number; +function add(x: number, y: number): number; +function add(x?: number, y?: number): number { + let sum: number = 0; + if (x) { + sum += x; + } + if (y) { + sum += y; + } + return sum; +} +Assert.equal(add(), 0); +Assert.equal(add(1), 1); +Assert.equal(add(1, 1), 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts similarity index 60% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts index aa1e6dce8b..a27a866d9e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts @@ -14,7 +14,8 @@ */ /**--- description: > - Two members are considered identical when they are public properties with identical names, optionality, and types. + Given a type parameter T and set of candidate types, the actual inferred type argument is determined, + if the set of candidate argument types is empty, the inferred type argument for T is T's constraint. module: ESNext isCurrent: true ---*/ @@ -22,24 +23,15 @@ import { Assert } from '../../../../../suite/assert.js' -interface M{ - str: string; - mem?: number; +type t = number | string; +function select(h_x: T, h_y: T): T { + return h_x < h_y ? h_x : h_y; } -interface M{ - str: string; - mem?: number; - boo: boolean; +var a = select(10, 20); +Assert.isNumber(a); +type HELLO = "HELLO"; +function getx(x: HELLO): string { + return x; } -let a: M = { - str: 'a', - mem: 5, - boo: true -} -let b: M = { - str: 'a', - mem: 5, - boo: false -} -Assert.equal(typeof a.str, typeof b.str); -Assert.equal(typeof a.mem, typeof b.mem); \ No newline at end of file +const x = "HELLO"; +Assert.equal(getx(x), "HELLO"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts similarity index 53% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts index 441d6416dd..fb9d601be9 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts @@ -14,8 +14,11 @@ */ /**--- description: > - A type reference to a generic type is required to specify exactly one type argument for each type parameter - of the referenced generic type, and each type argument must be assignable to the constraint of the corresponding type parameter. + Given a type parameter T and set of candidate types, the actual inferred type argument is determined, + if at least one of the candidate types is a supertype of all of the other candidate types, + let C denote the widened form of the first such candidate type. + If C satisfies T's constraint, the inferred type argument for T is C. + Otherwise, the inferred type argument for T is T's constraint. module: ESNext isCurrent: true ---*/ @@ -23,29 +26,14 @@ import { Assert } from '../../../../../suite/assert.js' -interface I1 { - a: string; +type t = number | null | undefined +function select(h_x: T, h_y: T): T { + return h_x ? h_x : h_y; } -interface I2 extends I1 { - b: string; +var y = select(10, undefined) +if (typeof y === 'number') { + Assert.isNumber(y); } -interface I3 extends I2 { - c: string; -} -interface I4 { - x: T; - y: U; -} - -let z: I4 = { - x: { a: 'a' }, - y: { - a: 'a', - b: 'b', - c: 'c' - } -} -Assert.equal(z.x.a, 'a'); -Assert.equal(z.y.a, 'a'); -Assert.equal(z.y.b, 'b'); -Assert.equal(z.y.c, 'c'); \ No newline at end of file +else { + Assert.isUndefined(y); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/function_types/function_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts similarity index 62% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/function_types/function_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts index 30c20b90ce..a133fc3c7c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/function_types/function_types_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts @@ -14,8 +14,8 @@ */ /**--- description: > - an object type containing one or more call signatures is said to be a function type. - function types may be written using function type literals or by including call signatures in object type literals. + When a function expression is inferentially typed and a type assigned to a parameter in that expression references type parameters for which inferences are being made, + the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them. module: ESNext isCurrent: true ---*/ @@ -23,11 +23,10 @@ import { Assert } from '../../../../../suite/assert.js' -function add(x: number, y: number): number { - return x + y; +function func(arg1: T, arg2:T) { + return [arg1, arg2]; } -let a: number = add(1, 2); -Assert.equal(a, 3); -let add2 = function (x: number, y: number): number { return x + y; }; -let b: number = add2(3, 4); -Assert.equal(b, 7); \ No newline at end of file +let a = func(3, 5); +let b = func('a', 'b'); +Assert.equal(a, '3,5'); +Assert.equal(b, 'a,b'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts similarity index 54% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_6.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts index e545055f5e..173b602bbb 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_6.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts @@ -14,10 +14,10 @@ */ /**--- description: > - Two call or construct signatures are considered identical - when they have the same number of type parameters with identical type parameter constraints and, - after substituting type Any for the type parameters introduced by the signatures, - identical number of parameters with identical kind and types, and identical return types. + If e is an expression of a function type that contains exactly one generic call signature and no other members, + and T is a function type with exactly one non-generic call signature and no other members, + then any inferences made for type parameters referenced by the parameters of T's call signature are fixed, + and e's type is changed to a function type with e's call signature instantiated in the context of T's call signature. module: ESNext isCurrent: true ---*/ @@ -25,14 +25,11 @@ import { Assert } from '../../../../../suite/assert.js' -interface M{ - (arg: T): T; -} -interface M{ - (arg: T): T; -} -function func(arg: T): T{ +type T = (arg: number) => number; +let f = (arg: T): T => { return arg }; +let para: T = function func(arg: number) { return arg; } -let a: M = func('a'); -Assert.isString(a); \ No newline at end of file +let result = f(para(20)); +Assert.equal(result, 20); +Assert.isFunction(f); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_1.ts new file mode 100644 index 0000000000..36ee6593be --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_1.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If T is a union type, let U be the set of element types in T that have call signatures. + If each type in U has exactly one call signature and that call signature is non-generic, and if all of the signatures are identical ignoring return types, + then S is a signature with the same parameters and a union of the return types. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +type MyUnionType = ((x: number) => string) | ((x: number) => number); +function myFunction(fn: MyUnionType, arg: number) { + return fn(arg); +} +const fn1 = (x: number): string => `Hello,${x}`; +const fn2 = (x: number): number => x * 2; +const result1 = myFunction(fn1, 123); +const result2 = myFunction(fn2, 456); +Assert.equal(result1, "Hello,123"); +Assert.equal(result2, 912); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_2.ts new file mode 100644 index 0000000000..b7dd95ab05 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_2.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If T is a function type with exactly one call signature, + and if that call signature is non-generic, S is that signature. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +type MyFunctionType = (x: number, y: number) => number; +function myFunction(fn: MyFunctionType) { + return fn(2, 3); +} +const add: MyFunctionType = function (x: number, y: number) { + return x + y; +}; +const result = myFunction(add); +Assert.equal(result, 5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_3.ts similarity index 65% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_3.ts index 351ed8fb63..efdd1e8157 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_3.ts @@ -13,9 +13,8 @@ * limitations under the License. */ /**--- - description: > - A type alias may optionally have type parameters - that serve as placeholders for actual types to be provided when the type alias is referenced in type references. + description: > + Otherwise, no contextual signature can be extracted from T. module: ESNext isCurrent: true ---*/ @@ -24,14 +23,16 @@ import { Assert } from '../../../../suite/assert.js' type MyType = { - h_name: string; - h_age: number; - h_height?: number; - h_weight?: number + fn: (a: number, b: string) => boolean; +}; +function myFunction(obj: MyType) { + const { fn } = obj; + const result = fn(123, "hello"); + Assert.isTrue(result); } -var h_ty: MyType = { - h_name: 'xiao', - h_age: 18, - h_height: 180 +let h_x: MyType = { + fn: function func() { + return true; + } } -Assert.equal(h_ty.h_height, 180); \ No newline at end of file +myFunction(h_x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_4.ts new file mode 100644 index 0000000000..79dc9f26e7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_4.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The type of a function expression is an object type containing a single call signature with parameter + and return types inferred from the function expression's signature and body. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +type Greeting = 'Hello, world'; +let x: Greeting = 'Hello, world'; +function f(x: Greeting): string { + return x; +} +Assert.equal(f(x), "Hello, world"); +function f2(x: T): T { + return x; +} +let a = f2(10); +Assert.equal(a, 10); +let b = f2("hello"); +Assert.equal(b, "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/class.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/class.ts new file mode 100644 index 0000000000..8341313a6e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/class.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: For a class, the constructor type associated with the constructor function object. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Car { + engine: string; + agelimit: number; + constructor(engine: string, agelimit: number) { + this.engine = engine; + this.agelimit = agelimit; + } +} +let car = new Car("Benchi", 2); +Assert.equal(car.agelimit, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/enum.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/enum.ts new file mode 100644 index 0000000000..49f197edf1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/enum.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: For an enum, the object type associated with the enum object. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +enum Direction { + up = 1, + down, + Left, + right, +} +const direction: Direction = Direction.up; +Assert.isNumber(direction); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/function.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/function.ts new file mode 100644 index 0000000000..d1513c3bf3 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/function.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: For a function, the function type associated with the function object. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function myFunction(x: number): number { + return x * 2; +} +Assert.isFunction(myFunction); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/name_space.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/name_space.ts new file mode 100644 index 0000000000..dedd915898 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/name_space.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When an expression is an IdentifierReference, the expression refers to the most nested namespace, class, enum, function, variable, + or parameter with that name whose scope (section 2.4) includes the location of the reference. + The type of such an expression is the type associated with the referenced entity: + For a namespace, the object type associated with the namespace instance + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +namespace MyNamespace { + export interface Person { + name: string; + age: number; + } + export function greet(person: Person) { + Assert.equal(person.name, "John"); + Assert.equal(person.age, 30); + } +} +const person: MyNamespace.Person = { + name: "John", + age: 30, +}; +MyNamespace.greet(person); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/parameter.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/parameter.ts new file mode 100644 index 0000000000..050218eaba --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/parameter.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + For a parameter, the type of the parameter. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class paramMethod { + person: string; + age: number; + constructor(person: string, age: number) { + this.person = person; + this.age = age; + Assert.isString(person); + Assert.isNumber(age); + } +} +let newparam = new paramMethod("xiaoli", 18); +Assert.equal(newparam.age, 18); +Assert.equal(newparam.person, "xiaoli"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/variable.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/variable.ts new file mode 100644 index 0000000000..b95d6d191a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/variable.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + For a variable, the type of the variable. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let uname: string = "Runoob"; +let score1: number = 50; +Assert.isString(uname); +Assert.isNumber(score1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/boolean.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/boolean.ts new file mode 100644 index 0000000000..cfd5252d24 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/boolean.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The type of the literals true and false is the Boolean primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +Assert.equal(typeof false, "boolean"); +Assert.equal(typeof true, "boolean"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/null.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/null.ts new file mode 100644 index 0000000000..f014d23c13 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/null.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The type of the null literal is the Null primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +Assert.isTrue(typeof null === "object"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/number.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/number.ts new file mode 100644 index 0000000000..070870d0f5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/number.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The type of numeric literals is the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +Assert.equal(typeof 1, "number"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/widend_types/widend_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/regexp.ts similarity index 79% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/widend_types/widend_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/regexp.ts index b93a60ebd7..bb9d378516 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/widend_types/widend_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/regexp.ts @@ -14,8 +14,7 @@ */ /**--- description: > - In several situations TypeScript infers types from context, - alleviating the need for the programmer to explicitly specify types that appear obvious. + The type of regular expression literals is the global interface type 'RegExp'. module: ESNext isCurrent: true ---*/ @@ -23,5 +22,4 @@ import { Assert } from '../../../../suite/assert.js' -var str = "xiao" -Assert.isString(str); \ No newline at end of file +Assert.isTrue(/hello world/ instanceof RegExp); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/string.ts similarity index 74% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/string.ts index c4f7d5a5ef..3a97e72e58 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/string.ts @@ -14,14 +14,13 @@ */ /**--- description: > - the Boolean primitive type behaves as an object - type with the same properties as the global interface type 'Boolean'. + The type of string literals is the String primitive type. module: ESNext isCurrent: true ---*/ -import { Assert } from '../../../../../suite/assert.js' +import { Assert } from '../../../../suite/assert.js' -let a = true; -Assert.equal(a.valueOf(), true); +Assert.isString("Hello world"); +Assert.isString("kitty"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_1.ts new file mode 100644 index 0000000000..e23968a8c9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_1.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the object literal is contextually typed and the contextual type contains a property with a matching name, + the property assignment is contextually typed by the type of that property. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let obj1: { + str: string; + num: number; + bool: boolean; +} = { + str: 'string', + num: 5, + bool: true +} +Assert.isString(obj1.str); +Assert.isNumber(obj1.num); +Assert.isBoolean(obj1.bool); + +interface I{ + num: number; + str: string; +} +let obj2 = {} as I; +obj2.num = 10; +obj2.str = 'string'; +Assert.isNumber(obj2.num); +Assert.isString(obj2.str); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_2.ts new file mode 100644 index 0000000000..94500c72a7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_2.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + if the object literal is contextually typed, + if the contextual type contains a numeric index signature, + and if the property assignment specifies a numeric property name, + the property assignment is contextually typed by the type of the numeric index signature. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let obj1: { + 1: string; + [key: number]: string; +} = { + 1: 'string', + 2: 'number', + 3: 'boolean' +} +Assert.isString(obj1[2]); +Assert.isString(obj1[3]); + +interface I{ + 1: string; + [key: number]: string; +} +let obj2 = {} as I; +obj2 = { + 1: 'string', + 2: 'number', + 3: 'boolean' +} +Assert.isString(obj2[2]); +Assert.isString(obj2[3]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_3.ts new file mode 100644 index 0000000000..0d7ec34ce5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_3.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the object literal is contextually typed and the contextual type contains a string index signature, + the property assignment is contextually typed by the type of the string index signature. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let obj1: { + 'str': string; + [key: string]: string; +} = { + 'str': 'string', + 'num': 'number', + 'bool': 'boolean' +} +Assert.isString(obj1['num']); +Assert.isString(obj1['bool']); + +interface I{ + 'str': string; + [key: string]: string; +} +let obj2 = {} as I; +obj2 = { + 'str': 'string', + 'num': 'number', + 'bool': 'boolean' +} +Assert.isString(obj2['num']); +Assert.isString(obj2['bool']); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_4.ts new file mode 100644 index 0000000000..6cc575365a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_4.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The property assignment is processed without a contextual type + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface Iperson { + name: String; + age: Number; + gender?: string; + sayName(): void; +} +const P: Iperson = { + name: "Tom", + age: 21, + gender: "male", + sayName() { + return this.name; + }, +}; +Assert.equal(P.gender, "male"); +P.gender = "female"; +Assert.equal(P.gender, "female"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_5.ts similarity index 51% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_5.ts index d8e97e6992..3613783b55 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_5.ts @@ -14,42 +14,33 @@ */ /**--- description: > - Classes, enums, and type aliases are named types that are introduced through class declarations, - interface declarations, enum declarations, and type alias declarations. + A get accessor declaration is processed in the same manner as an ordinary function declaration (section 6.1) with no parameters. + A set accessor declaration is processed in the same manner as an ordinary function declaration with a single parameter and a Void return type. + When both a get and set accessor is declared for a property: + If both accessors include type annotations, the specified types must be identical. module: ESNext isCurrent: true ----*/ + ---*/ import { Assert } from '../../../../suite/assert.js' -class Test { +interface Obj { + id: number; name: string; - constructor(name: string) { - this.name = name; - } -} -let tt = new Test("caihua"); -Assert.equal(tt.name, "caihua"); -interface A { - a: string; + get gid(): number; + set sid(id: number); } -function f(obj: A) { - obj.a = obj.a + "bb"; -} -let obj: A = { a: "aa" }; -f(obj); -Assert.equal(obj.a, "aabb"); -enum Color { - Red, - Green, - Blue, +let obj1: Obj = { + id: 1, + name: "obj1", + get gid() { + return this.id + }, + set sid(id: number) { + this.id = id; + } } -let a: Color.Red = Color.Red; -Assert.equal(a, Color.Red); -type pp = number | string; -let b: pp; -b = 10; -Assert.equal(b, 10); -b = "hello"; -Assert.equal(b, "hello"); \ No newline at end of file +Assert.equal(obj1.id, 1); +obj1.sid = 2; +Assert.equal(obj1.gid, 2); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_6.ts new file mode 100644 index 0000000000..3fb79b27f7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_6.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If a get accessor is declared for a property, + the return type of the get accessor becomes the type of the property. + If only a set accessor is declared for a property, + the parameter type of the set accessor becomes the type of the property. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class C{ + private mem; + constructor(mem: string) { + this.mem = mem; + } + get Mem(): string { + return this.mem; + } + set Mem(mem: string) { + this.mem = mem; + } +} +let c = new C('a'); +Assert.isString(c.Mem); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_7.ts new file mode 100644 index 0000000000..f364ccedab --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_7.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When an object literal is contextually typed by a type that includes a string/numeric index signature, + the resulting type of the object literal includes a string/numeric index signature with the union type + of the types of the properties declared in the object literal, or the Undefined type if the object literal is empty. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface I1{ + 1: string; + [key: string]: string; +} +let obj1: I1 = { + 1: 'number', + 'str': 'string' +} +Assert.isString(obj1[1]); +Assert.isString(obj1['str']); +let obj2: I1 = { + 1: 'number' +} +Assert.isString(obj2[1]); +Assert.isUndefined(obj2['str']); + +interface I2{ + 'string': string; + [key: number]: string; +} +let obj3: I2 = { + 'string': 'number', + 1: 'string' +} +Assert.isString(obj3['string']); +Assert.isString(obj3[1]); +let obj4: I2 = { + 'string': 'number' +} +Assert.isString(obj4['string']); +Assert.isUndefined(obj4[1]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_8.ts new file mode 100644 index 0000000000..663bb91de2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_8.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A shorthand property assignment. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface I1 { + 1: 1; + 2: number; + f1: () => number; + f2(): number; +} +let obj1: I1 = { + 1: 1, + 2: 1, + f1() { + return 2; + }, + f2() { + return 2; + }, +} +Assert.equal(obj1[1], 1); +Assert.equal(obj1[2], 1); +Assert.equal(obj1.f1(), 2); +Assert.equal(obj1.f2(), 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_9.ts new file mode 100644 index 0000000000..ea26e43b68 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_9.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If the PropertyName of a property assignment is a computed property name. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +const x1: "x1" = "x1"; +const x2: "x2" = "x2"; +const x3 = Symbol("x3"); +interface Obj { + [x1](): string; + [x2]: string; + [x3]: string; +} +let obj1: Obj = { + x1() { + return "xx1"; + }, + x2: 'xx2', + [x3]: 'xx3' +}; +let obj2 = { + [x2]: 1 +}; +let obj3: { + [x2]: string +} = { + x2: 'xxx2' +}; +Assert.equal(obj1[x1](), "xx1"); +Assert.equal(obj1[x2], "xx2"); +Assert.equal(obj2[x2], 1); +Assert.equal(obj3[x2], "xxx2"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/parentheses/parentheses.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/parentheses/parentheses.ts new file mode 100644 index 0000000000..b6975c3fb7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/parentheses/parentheses.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A parenthesized expression has the same type and classification as the contained expression itself. + Specifically, if the contained expression is classified as a reference, so is the parenthesized expression. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let addparent = function (n1: number, n2: number): number { + return n1 + n2; +}; +let addnoparent = (n1: number, n2: number): number => n1 + n2; +let isCorrect = addparent(11, 22) === addnoparent(11, 22); +Assert.isTrue(isCorrect); +let foo: string = "hello"; +let bar: string = foo; +Assert.isString(foo); +Assert.isString(bar); +const obj = { value: "world" }; +function printValue(value: string) { + Assert.equal(value, "world"); + Assert.isString(value); +} +printValue(obj.value); + +let str1 = (37 * 12) + ((37 * 9) + ''); +Assert.equal(str1, "444333"); +Assert.isString(str1); + +let t: boolean = true; +let f: boolean = false; +let bool: boolean = t || ((f || t) && (false && t)); +Assert.isTrue(bool); + diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_access_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_access_2.ts new file mode 100644 index 0000000000..fc245d3fd9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_access_2.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If name denotes an accessible apparent property (section 3.11.1) in the widened type (section 3.12) of object, + the property access is of the type of that property. Public members are always accessible, + but private and protected members of a class have restricted accessibility, as described in 8.2.2. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var sites = { + site1: "Runoob", + site2: "Google", + sayHello: function () { }, +}; +sites.sayHello = function () { + return "hello " + sites.site1; +}; +Assert.isString(sites.sayHello()); +class Person { + name: string; + age: string; + constructor(name: any, age: any) { + this.name = name; + this.age = age; + } + greet() { } +} +const person1 = new Person("Alice", 30); +const person2 = { name: "Bob", age: 35 }; +person1["greet"](); +Assert.equal(person1.name, "Alice"); +Assert.equal(person2.name, "Bob"); +Assert.equal(person1.age, 30); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_1.ts new file mode 100644 index 0000000000..167baf148f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_1.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If object is of type Any, any name is permitted and the property access is of type Any. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let myVariable: any = { name: "John", age: 30 }; +Assert.isString(myVariable.name); +myVariable.name = 42; +Assert.isNumber(myVariable.name); + +Assert.isNumber(myVariable.age); +myVariable.age = "Hello World"; +Assert.isString(myVariable.age); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_type_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_type_6.ts new file mode 100644 index 0000000000..87e41c23ce --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_type_6.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If index is of type Any, the String or Number primitive type, + or an enum type, the property access is of type Any. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface MyObject { + [key: string]: number; +} +const obj: MyObject = { + prop1: 1, + prop2: 2, + prop3: 3, +}; +const value2 = obj[0]; +Assert.equal(value2, undefined); +enum MyEnum { + Prop1 = "prop1", + Prop2 = "prop2", + Prop3 = "prop3", +} +const value3 = obj[MyEnum.Prop3]; +Assert.equal(value3, 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_apprent_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_apprent_5.ts new file mode 100644 index 0000000000..0cfac703a8 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_apprent_5.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If object has an apparent string index signature and index is of type Any, + the String or Number primitive type, or an enum type, the property access is of the type of that index signature. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface ExampleObject { + [key: string]: string; +} +const myObject: ExampleObject = { + foo: "bar", + baz: "qux", +}; +const myIndex: any = "foo"; +const myValue = myObject[myIndex]; +Assert.isString(myValue); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_index_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_index_4.ts new file mode 100644 index 0000000000..8a09d000a1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_index_4.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If object has an apparent numeric index signature and index is of type Any, + the Number primitive type, or an enum type, the property access is of the type of that index signature + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface MyObj { + [index: number]: string; +} +const obj: MyObj = { + 0: "foo", + 1: "bar", + 2: "baz", +}; +Assert.equal(obj[0], "foo"); +Assert.equal(obj[1], "bar"); +Assert.equal(obj[2], "baz"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_string_number_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_string_number_3.ts new file mode 100644 index 0000000000..9e4293dba4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_string_number_3.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If index is a string literal or a numeric literal and object has an apparent property with the name given by that literal, + the property access is of the type of that property. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +const sites = { + siteName: "Runoob", + site2: 999, + sayHello: function () { }, +}; +Assert.isString(sites["siteName"]); +Assert.isNumber(sites["site2"]); +Assert.isFunction(sites["sayHello"]); +interface Person { + name: string; + age: number; + city: string; +} +const person: Person = { + name: "Alice", + age: 30, + city: "New York", +}; +Assert.equal(person["name"], "Alice"); +Assert.equal(person["city"], "New York"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_1.ts new file mode 100644 index 0000000000..5dcfd232d9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_1.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Properties are strongly typed when accessed using bracket notation with the literal representation of their name. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var myType = { + h_str: 'string', + h_bool: true +}; +var h_s = myType['h_str']; +Assert.isString(h_s); +var h_b = myType['h_bool']; +Assert.isBoolean(h_b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_2.ts new file mode 100644 index 0000000000..3b624b2cdc --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_2.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Tuple types assign numeric names to each of their elements and elements are therefore strongly typed + when accessed using bracket notation with a numeric literal. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var myArry: [number, string, boolean] = [10, 'string', true]; +var h_n = myArry[0]; +Assert.isNumber(h_n); +var h_s = myArry[1]; +Assert.isString(h_s); +var h_b = myArry[2]; +Assert.isBoolean(h_b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/template_literals/template_literals.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/template_literals/template_literals.ts new file mode 100644 index 0000000000..beaa1deeae --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/template_literals/template_literals.ts @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Template literals are literals delimited with backtick (`) characters, allowing for multi-line strings, string interpolation with embedded expressions, and special constructs called tagged templates. + Template literals are sometimes informally called template strings, because they are used most commonly for string interpolation (to create strings by doing substitution of placeholders). + However, a tagged template literal may not result in a string; it can be used with a custom tag function to perform whatever operations you want on the different parts of the template literal. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../../suite/assert.js"; + +function hiStr(str: string | TemplateStringsArray) { + return 'hi ' + str; +} +let hi = hiStr`TypeScript`; +Assert.equal(hi, 'hi TypeScript'); + +let bool1 = `\`` == "\`"; +Assert.isTrue(bool1); + +let bool2 = `\${37*3}` == '${37*3}'; +Assert.isTrue(bool2); + +let bool3 = `${bool1}` == 'true'; +Assert.isTrue(bool3); + +let str1 = hiStr`Type +Script`; +Assert.equal(str1, `hi Type +Script`); +Assert.equal(str1, 'hi Type\nScript'); + +function funF(str: string | TemplateStringsArray) { + let str2 = `${str}\n${str}`; + function funFF(str1: string | TemplateStringsArray, ...strs: string[] | TemplateStringsArray[]) { + let s = `${str2}\n${str1}`; + for (let i = 0; i < strs.length; i++) { + s = s + `\n` + strs[i]; + } + return s; + } + return funFF; +} +let s1 = funF`A``B`; +Assert.equal(s1, `A +A +B`); +let s2 = funF`A``B` + `C`; +Assert.equal(s2, `A +A +BC`); +let s3 = funF`A`(`B`, `C`); +Assert.equal(s3, `A +A +B +C`); + +function sRaw(str: TemplateStringsArray) { + return str.raw[0]; +} +let s4 = sRaw`ABC\nDEF`; +Assert.equal(s4, 'ABC\\nDEF'); + +let s5 = String.raw`AB\n${s4}`; +Assert.equal(s5, 'AB\\nABC\\nDEF'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_comma_operator/the_comma_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_comma_operator/the_comma_operator.ts new file mode 100644 index 0000000000..80cc709cfd --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_comma_operator/the_comma_operator.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The comma operator permits the operands to be of any type and produces a result that is of the same type as the second operand. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let x: number = 20; +let y: boolean = true; +let z: string = 'a'; +function add(arg1: number, arg2: number) { + return arg1 + arg2; +} +let com1 = (x++, y); +let com2 = (x++, z = z + 'b'); +let com3 = (x++, add(3, 5)); +Assert.isBoolean(com1); +Assert.equal(com1, true); +Assert.isString(com2); +Assert.equal(com2, 'ab'); +Assert.isNumber(com3); +Assert.equal(com3, 8); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts new file mode 100644 index 0000000000..01e70a8364 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a conditional expression of the form 'test ? expr1 : expr2', the test expression may be of any type. + The type of the result is the union type of the types of expr1 and expr2. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var x: number = 10 +var y: string = '5' +var z = Math.random() < 0.5 ? x + y : y && x +if (typeof z === 'number') { + z++ + Assert.equal(z, 11); +} +else { + Assert.equal(z, '105'); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_2.ts similarity index 56% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_2.ts index d02ee66334..d722c0719d 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_2.ts @@ -14,10 +14,8 @@ */ /**--- description: > - in places where a type is not explicitly provided - and TypeScript cannot infer one, the Any type is assumed. - options: - lib: es2015 + If the conditional expression is contextually typed, expr1 and expr2 are contextually typed by the same type. + Otherwise, expr1 and expr2 are not contextually typed. module: ESNext isCurrent: true ---*/ @@ -25,26 +23,17 @@ import { Assert } from '../../../../suite/assert.js' -let a; -a = 25.25; -Assert.isNumber(a); -a = "narc"; -Assert.isString(a); -a = function add(a: any, b: any) { - return a + b; -}; -Assert.isFunction(a); -a = false; -Assert.isBoolean(a); -a = Symbol(); -Assert.isSymbol(a); -a = { 1408: "Movie" }; -Assert.equal(JSON.stringify(a), '{"1408":"Movie"}'); -a = null; -let flag = false; -if (a === null) { - flag = true; +let sum = function (x: number, y: number) { + return x + y; } -Assert.isTrue(flag); -a = undefined; -Assert.isUndefined(a); \ No newline at end of file +let average = function (a: number, b: number) { + return (a + b) / 2; +} +let flag = 0; +let rela1: number = flag < 0.5 ? sum(5, 7) : average(6, 9); +Assert.isNumber(rela1); +Assert.equal(rela1, 12); +flag = 1; +let rela2: number = flag < 0.5 ? sum(5, 7) : average(6, 9); +Assert.isNumber(rela2); +Assert.equal(rela2, 7.5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_1.ts new file mode 100644 index 0000000000..6579559ced --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_1.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If C is of type Any, any argument list is permitted and the result of the operation is of type Any. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let C: any; +C = function (this: any, x: number, y: number) { + this.sum = x + y; +}; +let myObject = new C(2, 3); +Assert.equal(myObject.sum, 5); +myObject = 5; +Assert.isNumber(myObject); +myObject = 'a'; +Assert.isString(myObject); +myObject = true; +Assert.isBoolean(myObject); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_2.ts new file mode 100644 index 0000000000..42c673b0a3 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_2.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If C has one or more apparent construct signatures (section 3.11.1), the expression is processed in the same manner as a function call, + but using the construct signatures as the initial set of candidate signatures for overload resolution. + The result type of the function call becomes the result type of the operation. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Person { + constructor(public name: string, public age: number) { } +} +interface Animal { + speak(): void; +} +class Dog implements Animal { + speak() { + return "Woof!"; + } +} +const p = new Person("Alice", 30); +const d = new Dog(); +Assert.isString(p.name); +Assert.equal(d.speak(), "Woof!"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_3.ts new file mode 100644 index 0000000000..7ee5e319d5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_3.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If C has no apparent construct signatures but one or more apparent call signatures, the expression is processed as a function call. + A compile-time error occurs if the result of the function call is not Void. The type of the result of the operation is Any. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Person { + sayHello() { + return "Hello,world"; + } +} +let person: Person = new Person(); +Assert.equal(person.sayHello(), "Hello,world"); +let person2: any = new Person(); +person2.sayHello(); +Assert.equal(person2.sayHello(), "Hello,world"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_4.ts similarity index 59% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_4.ts index b50a04cf1e..966c697a6a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/named_types/named_types_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_4.ts @@ -14,28 +14,36 @@ */ /**--- description: > - Generic types are "templates" from which multiple actual types can be created by writing type references - that supply type arguments to substitute in place of the generic type's type parameters + new C + new C ( ... ) + new C < ... > ( ... ) module: ESNext isCurrent: true ----*/ + ---*/ import { Assert } from '../../../../suite/assert.js' -interface Person { +class C { + x: number = 1; +} +let c = new C; +Assert.equal(c.x, 1); +class Person { name: string; age: number; - getName(name: string): string; + constructor(name: string, age: number) { + this.name = name; + this.age = age; + } +} +const john = new Person("john", 30); +Assert.isString(john.name, "john"); +class Box { + contents: T; + constructor(value: T) { + this.contents = value; + } } -type Optional = { [P in keyof T]: T[P] }; -let cc: Optional = { - age: 18, - name: "caihua", - getName(name: string) { - return name; - }, -}; -Assert.equal(cc.age, 18); -Assert.equal(cc.name, "caihua"); -Assert.equal(cc.getName("caihua"), "caihua"); \ No newline at end of file +const myBox = new Box("hello"); +Assert.equal(myBox.contents, "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/arguments.ts similarity index 68% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/arguments.ts index 2f37788501..9658263480 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/arguments.ts @@ -13,8 +13,8 @@ * limitations under the License. */ /**--- - description: > - Specialized signatures permit string literals to be used as types in parameter type annotations. + description: > + Type arguments cannot be explicitly specified in a super call. module: ESNext isCurrent: true ---*/ @@ -22,14 +22,16 @@ import { Assert } from '../../../../../suite/assert.js' -interface Test { - v: "hello"; +class SuperClass { + value: T; + constructor(value: T) { + this.value = value; + } } -function test(dd: Test) { - Assert.equal(dd.v.length, 5); - return dd; +class SubClass extends SuperClass { + constructor(value: T) { + super(value); + } } -let cc: Test = { - v: "hello", -}; -Assert.equal(test(cc).v, "hello"); \ No newline at end of file +const sub = new SubClass("hello"); +Assert.equal(sub.value, "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts similarity index 60% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts index 6a809181c5..3243840b97 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts @@ -14,8 +14,8 @@ */ /**--- description: > - the type contains only optional properties, without the excess property check, - any object literal would be assignable to the variable. + If the base class is a generic class, + the type arguments used to process a super call are always those specified in the extends clause that references the base class. module: ESNext isCurrent: true ---*/ @@ -23,22 +23,18 @@ import { Assert } from '../../../../../suite/assert.js' -interface I { - a?: number - b?: boolean - c?: string +class BaseClass { + constructor(public value: T) { } } -let x: I = { - a: 12, - b: true, - c: "ccc" +class SubClass extends BaseClass { + constructor(value: T) { + super(value); + } } -Assert.equal(x.a, 12); -Assert.equal(x.b, true); -Assert.equal(x.c, "ccc"); -let y: I = { - a: 11, - b: false +class StringSubClass extends SubClass { + constructor() { + super("hello"); + } } -Assert.equal(y.a, 11); -Assert.equal(y.b, false); +const sub = new StringSubClass(); +Assert.equal(sub.value, "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/super_calls.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/super_calls.ts new file mode 100644 index 0000000000..b64f05916a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/super_calls.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The super keyword can be used in expressions to reference base class properties and the base class constructor. + Super calls consist of the keyword super followed by an argument list enclosed in parentheses. Super calls are only permitted in constructors of derived classes. + A super call invokes the constructor of the base class on the instance referenced by this. + A super call is processed as a function call (section 4.15) using the construct signatures of the base class constructor function type + as the initial set of candidate signatures for overload resolution. + The type of a super call expression is Void. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +class Animal { + private name: string; + constructor(name: any) { + this.name = name; + } + speak() { + return `${this.name} makes a noise`; + } +} +class Dog extends Animal { + private breed: string; + constructor(name: any, breed: any) { + super(name); + this.breed = breed; + } + extendsSpeak() { + super.speak(); + Assert.isString(super.speak(), "Fodo makes a noise"); + return `${this.breed}`; + } +} +const d = new Dog("Fido", "Golden Retriever"); +d.extendsSpeak(); +Assert.isString(d.extendsSpeak(), "Golden Retriever"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/super_property_access_1.ts similarity index 42% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/super_property_access_1.ts index 3ef706cd20..5dce4ac822 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/members/members_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/super_property_access_1.ts @@ -14,10 +14,8 @@ */ /**--- description: > - Properties in a class declaration may be designated public, private, or protected, - while properties declared in other contexts are always considered public. - Private members are only accessible within their declaring class. - Protected members are only accessible within their declaring class and classes derived from it. + In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance, + a super property access is permitted and must specify a public instance member function of the base class. module: ESNext isCurrent: true ---*/ @@ -25,29 +23,37 @@ import { Assert } from '../../../../../suite/assert.js' -class C { - public h_pub: string; - private h_pri: string; - protected h_pro: string; - constructor(h_pub: string, h_pri: string, h_pro: string) { - this.h_pub = h_pub; - this.h_pri = h_pri; - this.h_pro = h_pro; +class Animal { + public age: number = 10; + constructor() { } + public makeSound(): string { + return "the animal makes"; } - set(h_pri: string) { - this.h_pri = h_pri; + static weight: number = 0; +} +class Dog extends Animal { + + constructor() { + super(); + this.age = 20; + } + public makeSound(): string { + super.makeSound(); + Assert.equal(super.makeSound(), "the animal makes"); + return "the dog barks"; + } + public Animalweight(): number { + return Animal.weight; } - get() { - return this.h_pri; + get _age(): number { + return this.age } - output() { - return this.h_pro; + set _age(age: number) { + this.age = age; } } -let x = new C('Public', 'Private', 'Protected'); -Assert.equal(x.h_pub, 'Public'); -Assert.equal(x.get(), 'Private'); -Assert.equal(x.output(), 'Protected'); -class Child extends C { } -let y = new Child('public', 'private', 'protected'); -Assert.equal(y.output(), 'protected'); \ No newline at end of file +let myDog = new Dog(); +myDog.makeSound(); +Assert.equal(myDog.makeSound(), "the dog barks"); +Assert.equal(myDog.age, 20); +Assert.equal(myDog.Animalweight(), 0); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/function_type_literals/function_type_literals_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/super_property_access_2.ts similarity index 58% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/function_type_literals/function_type_literals_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/super_property_access_2.ts index 6f4840816b..d7c0f1dc7a 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/function_type_literals/function_type_literals_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/super_property_access_2.ts @@ -14,7 +14,8 @@ */ /**--- description: > - A function type literal specifies the type parameters, regular parameters, and return type of a call signature. + In a static member function or static member accessor where this references the constructor function object of a derived class, + a super property access is permitted and must specify a public static member function of the base class. module: ESNext isCurrent: true ---*/ @@ -22,19 +23,17 @@ import { Assert } from '../../../../../suite/assert.js' -let fun1: (x: number, y: number) => number = - function (x: number, y: number): number { return x + y; }; -Assert.equal(fun1(1, 2), 3); -let fun2: Function = (x: number, y: number): boolean => { - return x > y ? true : false; -} -Assert.equal(fun2(1, 2), false); -interface Func { - fun(x: string): string; +class Base { + static greet() { + return "hello world"; + } } -let fun3: Func = { - fun(x: string): string { - return x; +class Derived extends Base { + static greet() { + super.greet(); + Assert.equal(super.greet(), "hello world"); + return "hola,mundo"; } } -Assert.equal(fun3.fun("aa"), "aa"); \ No newline at end of file +Derived.greet(); +Assert.equal(Derived.greet(), "hola,mundo"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_1.ts new file mode 100644 index 0000000000..c1c78b95c9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_1.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a constructor, instance member function, instance member accessor, + or instance member variable initializer, this is of the this-type (section 3.6.3) of the containing class. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class C { + public mem: string; + private num: number; + constructor(mem: string, num: number) { + this.mem = mem; + this.num = num; + Assert.isObject(this); + } + func() { + return this; + } + get getNum() { + Assert.isObject(this); + return this.num; + } + set setNum(num: number) { + this.num = num; + } +} +let c: C = new C('a', 10); +c.getNum; +c.setNum = 11; +Assert.isObject(c.func()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_2.ts new file mode 100644 index 0000000000..af043bd290 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_2.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a static member function or static member accessor, the type of this is the constructor function type of the containing class. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class C{ + static mem: string = 'a'; + static get getMem() { + Assert.isFunction(this); + return this.mem; + } + static set setMem(mem: string) { + this.mem = mem; + } + static func() { + return this; + } +} +C.getMem; +Assert.isFunction(C.func()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_3.ts new file mode 100644 index 0000000000..f603816488 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_3.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a function declaration or a function expression, this is of type Any. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface Str { + id: number; +} +interface Obj { + name: string; + getName(this: Obj): string; +} +interface Obj2 { + name: string; + getName(this: Str): number; +} +let obj: Obj = { + name: "obj", + getName() { + return this.name; + }, +} +let obj2: Obj2 & Str = { + name: "obj2", + id: 1, + getName() { + return this.id; + } +} +Assert.equal(obj.getName(), "obj"); +Assert.equal(obj2.getName(), 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_4.ts new file mode 100644 index 0000000000..18409de810 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_4.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The type of this in an expression depends on the location in which the reference takes place:In the global namespace, this is of type Any. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +let obj = { + a: 1024, + ADD(a: number) { + return this.a + a; + }, + getType() { + return typeof this; + }, + getThis() { + return this; + } +} +Assert.equal(obj.ADD(1), 1025); +Assert.equal(obj.getType(), 'object'); +let obj2 = obj.getThis(); +Assert.equal(JSON.stringify(obj2), '{"a":1024}'); + +const t1 = this; +Assert.isUndefined(t1); + +const t2 = globalThis; +Assert.equal(t2.JSON.stringify(obj.getThis()), JSON.stringify(obj2.getThis())); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_1.ts new file mode 100644 index 0000000000..17020e1b08 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_1.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Type assertions check for assignment compatibility in both directions. + Thus, type assertions allow type conversions that might be correct, but aren't known to be correct. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class P{ } +class C extends P { } +function func(str: string): P { + if (str === "string") { + return new C(); + } + return C; +} +let c = func("string"); +Assert.equal(JSON.stringify(c), '{}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_2.ts new file mode 100644 index 0000000000..e0a3eac692 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_2.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + type assertions are not checked at run-time and it is up to the programmer to guard against errors, + for example using the instanceof operator + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Foo { + foo: number; + cname: string; + constructor(foo: number = 123, cname: string = 'Foo') { + this.foo = foo; + this.cname = cname; + } +} +class Bar extends Foo { + bar: number; + cname: string; + constructor(bar: number = 1024, cname: string = 'Bar') { + super(); + this.bar = bar; + this.cname = cname; + } +} +function toFoo(): Foo { + return new Bar(); +} +let foo: Foo = toFoo(); +let bar: Bar = toFoo(); +function toBar(arg: Foo | Bar): Bar | string { + let bar: Bar; + if (arg instanceof Bar) { + bar = arg; + return bar; + } + return "Can not"; +} +let foo1 = toBar(new Foo()); +let foo2 = toBar(foo); +let bar1 = toBar(bar); +Assert.equal(foo1, 'Can not'); +Assert.equal(JSON.stringify(foo2), '{"foo":123,"cname":"Bar","bar":1024}'); +Assert.equal(JSON.stringify(foo2), JSON.stringify(bar1)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_3.ts new file mode 100644 index 0000000000..076898c01c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_3.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In a type assertion expression of the form < T > e, e is contextually typed by T and the resulting type of* e* is required to be assignable to T, + or T is required to be assignable to the widened form of the resulting type of e, or otherwise a compile-time error occurs. The type of the result is T. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function getLength(something: string | number): number { + if ((something).length) { + return (something).length + } else { + return something.toString().length + } +} +Assert.equal(getLength('length'), 6); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_1.ts new file mode 100644 index 0000000000..08b585694d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_1.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Type guards are particular expression patterns involving the 'typeof' and 'instanceof' operators + that cause the types of variables or parameters to be narrowed to more specific types. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function fun(x: boolean | number | string) { + if (typeof x === 'string') { + Assert.isString(x); + } + if (typeof x === 'boolean') { + x = true; + Assert.isTrue(x); + } + if (typeof x === 'number') { + Assert.isNumber(x); + } +} +fun('string'); +fun(10); +fun(false); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_10.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_10.ts new file mode 100644 index 0000000000..c96d649482 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_10.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type guard of the form !expr, + when true, narrows the type of x by expr when false, + or when false, narrows the type of x by expr when true. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function func(x: string | number) { + if (!(typeof x === "string")) { + Assert.isNumber(x); + return x + 1; + } + else { + Assert.isString(x); + return x.length; + } +} +let a = func(10); +Assert.equal(a, 11); +let b = func('s'); +Assert.equal(b, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_11.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_11.ts new file mode 100644 index 0000000000..9fcd82bbf2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_11.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type guard of the form expr1 && expr2, + when true, narrows the type of x by expr1 when true and then by expr2 when true, or + when false, narrows the type of x to T1 | T2, where T1 is the type of x narrowed by expr1 when false, + and T2 is the type of x narrowed by expr1 when true and then by expr2 when false. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function func(x: string | number | undefined) { + if (typeof x === "string" && typeof x === "number") { + return undefined; + } + else { + return x; + } +} +let a = func(10); +Assert.isNumber(a); +let b = func('s'); +Assert.isString(b); +let c = func(undefined); +Assert.isUndefined(c); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_12.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_12.ts new file mode 100644 index 0000000000..23569fbadb --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_12.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type guard of the form expr1 || expr2, + when true, narrows the type of x to T1 | T2, where T1 is the type of x narrowed by expr1 when true, + and T2 is the type of x narrowed by expr1 when false and then by expr2 when true, or + when false, narrows the type of x by expr1 when false and then by expr2 when false. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function func(x: string | number | undefined) { + if (typeof x === "string" || typeof x === "number") { + return x; + } + else { + return undefined; + } +} +let a = func(10); +Assert.isNumber(a); +let b = func('s'); +Assert.isString(b); +let c = func(undefined); +Assert.isUndefined(c); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_13.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_13.ts new file mode 100644 index 0000000000..17c6536000 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_13.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type guard of any other form has no effect on the type of x. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Person { + name: string + age: number + public constructor(name: string, age: number) { + this.name = name + this.age = age + } +} +class Animal { + height: number + weight: number + public constructor(height: number, weight: number) { + this.height = height + this.weight = weight + } +} +function func(arg: Person | Animal) { + if ('age' in arg) { + Assert.isString(arg.name) + } + if ('height' in arg) { + Assert.isNumber(arg.height) + } +} +let p = new Person('x', 18); +func(p); +let a = new Animal(200, 180); +func(a); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_2.ts similarity index 61% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_2.ts index c5c1a672f8..8b8027f7cd 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_2.ts @@ -14,10 +14,9 @@ */ /**--- description: > - The Any type is a supertype of all types, - and is assignable to and from all types. - options: - lib: es2015 + In the false branch statement of an 'if' statement, + the type of a variable or parameter is narrowed by a type guard in the 'if' condition when false, + provided no part of the 'if' statement contains assignments to the variable or parameter. module: ESNext isCurrent: true ---*/ @@ -25,20 +24,14 @@ import { Assert } from '../../../../suite/assert.js' -let x: any; -x = 12; -Assert.equal(x, 12); -x = "abc"; -Assert.equal(x, "abc"); -x = true; -Assert.equal(x, true); -x = [1, 2, 3]; -Assert.equal(x[0], 1); -x = ["aa", "bb"]; -Assert.equal(x[0], "aa"); -x = (a: number, b: number) => { return a + b }; -Assert.isFunction(x); -x = Symbol("aa"); -Assert.isSymbol(x); -x = { a: 1, b: 1 }; -Assert.isObject(x); \ No newline at end of file +function h_func(h_x: number | string) { + if (!(typeof h_x === 'string')) { + Assert.isNumber(h_x); + return h_x; + } + else { + return h_x.length + } +} +let a = h_func(10); +Assert.equal(a, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_3.ts new file mode 100644 index 0000000000..d092aec559 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_3.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In the true expression of a conditional expression, + the type of a variable or parameter is narrowed by a type guard in the condition when true, + provided no part of the conditional expression contains assignments to the variable or parameter. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function func(arg: string | (() => string)) { + let x = typeof arg == "string" ? arg : arg(); + return x; +} +let result = func("abc"); +Assert.isString(result); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_4.ts new file mode 100644 index 0000000000..1497787e83 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_4.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In the false expression of a conditional expression, + the type of a variable or parameter is narrowed by a type guard in the condition when false, + provided no part of the conditional expression contains assignments to the variable or parameter. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function func(arg: string | (() => string)) { + var x = typeof arg !== "string" ? arg() : arg; + return x; +} +let result = func("abc"); +Assert.isString(result); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_5.ts new file mode 100644 index 0000000000..8eaf5a06cf --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_5.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In the right operand of a && operation, + the type of a variable or parameter is narrowed by a type guard in the left operand when true, + provided neither operand contains assignments to the variable or parameter. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function fun(obj: any) { + typeof obj === "number" && obj + Assert.isNumber(obj) +} +fun(12); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_6.ts similarity index 40% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_6.ts index 77f7b25a76..0040c18beb 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/the_any_type/any_type_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_6.ts @@ -14,8 +14,11 @@ */ /**--- description: > - properties of any name can be accessed through an Any value - and Any values can be called as functions or constructors with any argument list. + A type guard of the form 'x instanceof C', where x is not of type Any, + C is of a subtype of the global type 'Function', and C has a property named 'prototype', + when true, narrows the type of x to the type of the 'prototype' property in C provided it is a subtype of the type of x, + or, if the type of x is a union type, removes from the type of x all constituent types that aren't subtypes of the type of the 'prototype' property in C, + or when false, has no effect on the type of x. module: ESNext isCurrent: true ---*/ @@ -23,48 +26,31 @@ import { Assert } from '../../../../suite/assert.js' -let x: any -let fun: any; -fun = (x: any) => x; -Assert.equal(fun(5), 5); -x = 1024; -x.toString(); -Assert.isString(x.toString()); -x = "AAA"; -x.length; -Assert.equal(x.length, 3); -Assert.equal(fun(x), "AAA"); -x = true; -Assert.equal(x, true); -Assert.equal(fun(x), true); -x = [1, 2, 3]; -Assert.equal(x[0], 1); -Assert.equal(fun(x), "1,2,3"); -x = ["aa", "bb"]; -Assert.equal(x[0], "aa"); -Assert.equal(fun(x), "aa,bb"); -x = (a: number, b: number) => { return a + b }; -Assert.isFunction(x); -Assert.isFunction(fun(x)); -x = Symbol("aa"); -Assert.isSymbol(x); -Assert.isSymbol(fun(x)); -x = { a: 1, b: 1 }; -Assert.isObject(x); -Assert.isObject(fun(x)); -class C { - public a: any; - public b: any; - constructor(a: any, b: any) { - this.a = a; - this.b = b; +class Person { + height: number + age: number + public constructor(height: number, age: number) { + this.height = height + this.age = age } } -let c1 = new C(1, "1"); -Assert.isNumber(c1.a); -let c2 = new C("aa", "bb"); -Assert.isString(c2.a); -let c3 = new C(true, true); -Assert.isBoolean(c3.a); -let c4 = new C({}, {}); -Assert.isObject(c4.a); \ No newline at end of file +class Animal { + height: number + weight: number + public constructor(height: number, weight: number) { + this.height = height + this.weight = weight + } +} +function func(arg: Person | Animal) { + if (arg instanceof Person) { + return arg.age = 18 + } + if (arg instanceof Animal) { + return arg.weight = 300 + } +} +var p = new Person(150, 18) +Assert.equal(func(p), 18) +var a = new Animal(200, 180) +Assert.equal(func(a), 300); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_7.ts new file mode 100644 index 0000000000..7d3ef1a40d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_7.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type guard of the form typeof x === s, where s is a string literal with the value 'string', 'number', or 'boolean', + when true, narrows the type of x to the given primitive type provided it is a subtype of the type of x, + or, if the type of x is a union type, removes from the type of x all constituent types that aren't subtypes of the given primitive type, + or when false, removes the primitive type from the type of x. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function func(x: string | number) { + if (typeof x === "string") { + Assert.isString(x); + return x.length; + } + else { + Assert.isNumber(x); + return x + 1; + } +} +let a = func(10); +Assert.equal(a, 11); +let b = func('s'); +Assert.equal(b, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_8.ts new file mode 100644 index 0000000000..53c3fab073 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_8.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type guard of the form typeof x === s, where s is a string literal with any value but 'string', 'number', or 'boolean', + when true, if x is a union type, removes from the type of x all constituent types that are subtypes of the string, number, or boolean primitive type, + or when false, has no effect on the type of x. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function f1(x: string | number | undefined) { + if (typeof x === "undefined") { + return undefined + } + else { + return x + } +} +var a = f1(10) +Assert.isNumber(a) +var b = f1('s') +Assert.isString(b) +var c = f1(undefined) +Assert.isUndefined(c) +function f2(x: string | number | boolean) { + if (typeof x === "undefined") { + return undefined + } + else { + return x + } +} +var a1 = f2(10) +Assert.isNumber(a1) +var b1 = f2('s') +Assert.isString(b1) +var c1 = f2(true) +Assert.isBoolean(c1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_9.ts new file mode 100644 index 0000000000..c026b9e2f7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_9.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A type guard of the form typeof x !== s, where s is a string literal, + when true, narrows the type of x by typeof x === s when false, + or when false, narrows the type of x by typeof x === s when true. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function func(x: string | number) { + if (typeof x !== "string") { + Assert.isNumber(x); + return x + 1; + } + else { + Assert.isString(x); + return x.length; + } +} +let a = func(10); +Assert.equal(a, 11); +let b = func('s'); +Assert.equal(b, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_!_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_!_operator.ts new file mode 100644 index 0000000000..a897e3afac --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_!_operator.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The ! operator permits its operand to be of any type and produces a result of the Boolean primitive type. + Two unary ! operators in sequence can conveniently be used to convert a value of any type to the Boolean primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var num1: number = 20 +var num2: number = 90 +var res = !((num1 > 50) && (num2 > 80)) +Assert.isTrue(res) +function func(): any { +} +var b = !!func() +Assert.isFalse(b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_++_and_--_operators.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_++_and_--_operators.ts new file mode 100644 index 0000000000..a3a4b162f0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_++_and_--_operators.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The ++ and -- operators in prefix or postfix form, require their operand to be of type Any, the Number primitive type, or an enum type, + and classified as a reference. They produce a result of the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var a: any = '10'; +a++; +a--; +--a; +++a; +Assert.isNumber(a); +Assert.equal(a, 10); +enum e { + A, + B, + C, + D +} +let b = e.A +b++; +b--; +++b; +--b; +Assert.isNumber(b); +Assert.equal(b, 0); +var c: number = 10; +c++; +++c; +--c; +c--; +Assert.isNumber(c); +Assert.equal(c, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_+_and_~_operators.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_+_and_~_operators.ts new file mode 100644 index 0000000000..d33f144c3c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_+_and_~_operators.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The +, -, and ~ operators permit their operand to be of any type and produce a result of the Number primitive type. + The unary + operator can conveniently be used to convert a value of any type to the Number primitive type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var a: any = 'a' +a = a + 1 +a = a - 1 +a = ~a +Assert.isNumber(a); +Assert.equal(a, -1); +function func() { } +var n = +func(); +Assert.isTrue(Number.isNaN(n)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_delete_operator.ts similarity index 67% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_delete_operator.ts index 40620e944a..159678417b 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_delete_operator.ts @@ -14,22 +14,22 @@ */ /**--- description: > - S is assignable to a type T, and T is assignable from S, - if S has no excess properties with respect to T, and S and T are identical types. + The 'delete' operator takes an operand of any type and produces a result of the Boolean primitive type. module: ESNext isCurrent: true ---*/ -import {Assert} from '../../../../../suite/assert.js' +import { Assert } from '../../../../suite/assert.js' -interface T { - name: string +interface Foo { + prop1?: string + prop2?: boolean + prop3?: number } -interface S { - name: string +let obj: Foo = { + prop1: 'value', + prop2: true, + prop3: 20 } -let t: T; -let s: S = { name: 'xiao' } -t = s -Assert.equal(t, s); \ No newline at end of file +Assert.isBoolean(delete obj.prop1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_typeof_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_typeof_operator.ts new file mode 100644 index 0000000000..06eb874eda --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_typeof_operator.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The 'typeof' operator takes an operand of any type and produces a value of the String primitive type. In positions where a type is expected, 'typeof' can also be used in a type query to produce the type of an expression. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let aa = 1 +let bb = typeof aa +Assert.equal(bb, 'number') +let cc: typeof aa = 2 +Assert.equal(cc, 2) \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_void_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_void_operator.ts new file mode 100644 index 0000000000..501fb22f61 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_void_operator.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The 'void' operator takes an operand of any type and produces the value 'undefined'. The type of the result is the Undefined type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let num: any = 10 +num = 'string' +let un = void num +Assert.isUndefined(un); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_1.ts similarity index 36% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_1.ts index d87814f638..e5fa6f675c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_1.ts @@ -14,8 +14,11 @@ */ /**--- description: > - a union type U is assignable to a type T if each type in U is assignable to T. - a type T is assignable to a union type U if T is assignable to any type in U. + An Async Function is a JavaScript Function, Parameterized Arrow Function, Method that has been prefixed with the async modifier. + An Async Function must provide a return type annotation that points to a compatible Promise type. + Return type inference can only be used if there is a globally defined, compatible Promise type. + options: + lib:es2015 module: ESNext isCurrent: true ---*/ @@ -23,32 +26,42 @@ import { Assert } from '../../../../suite/assert.js' -type numType = { num: number }; -type strType = { str: string }; -type boolType = { bool: boolean }; -type objType = { obj: Object }; -let x: any; -let y: numType | strType | boolType | objType | undefined; -let z: numType = { num: 0xCA }; -x = z; -Assert.equal(JSON.stringify(x), '{"num":202}'); -let a: strType = { str: "QWER" }; -x = a; -Assert.equal(JSON.stringify(x), '{"str":"QWER"}'); -let b: boolType = { bool: false }; -x = b; -Assert.equal(JSON.stringify(x), '{"bool":false}'); -let c: objType = { obj: { 0: "ZERO" } }; -x = c; -Assert.equal(JSON.stringify(x), '{"obj":{"0":"ZERO"}}'); -y = { num: 0xCA, str: "ABC", bool: false, obj: c }; -x = y; -Assert.equal(JSON.stringify(x), '{"num":202,"str":"ABC","bool":false,"obj":{"obj":{"0":"ZERO"}}}'); -y = z; -Assert.equal(JSON.stringify(y), '{"num":202}'); -y = a; -Assert.equal(JSON.stringify(y), '{"str":"QWER"}'); -y = b; -Assert.equal(JSON.stringify(y), '{"bool":false}'); -y = c; -Assert.equal(JSON.stringify(y), '{"obj":{"0":"ZERO"}}'); \ No newline at end of file +let pp: Promise = Promise.resolve(1); +async function fetchTest1(): Promise { + return await pp; +} +fetchTest1().then((params) => { + Assert.equal(params, 1); +}); +async function fetchTest1NoReturnType() { + return await pp; +} +fetchTest1NoReturnType().then((params) => { + Assert.equal(params, 1); +}); +const fetchTest2 = async (): Promise => { + return await pp; +}; +fetchTest2().then((params) => { + Assert.equal(params, 1); +}); +const fetchTest2NoReturnType = async () => { + return await pp; +}; +fetchTest2NoReturnType().then((params) => { + Assert.equal(params, 1); +}); +class Person { + async fetchTest3(): Promise { + return await pp; + } + async fetchTest3NoReturnType() { + return await pp; + } +} +new Person().fetchTest3().then((params) => { + Assert.equal(params, 1); +}); +new Person().fetchTest3NoReturnType().then((params) => { + Assert.equal(params, 1); +}); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_2.ts new file mode 100644 index 0000000000..1ddc1ac347 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_2.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Async Generator Functions + options: + lib:es2018 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +async function* ag() { + let i = 0; + let c = 0; + yield* [0, 0, 0, 0]; + while (true) { + yield c++; + i++; + if (i > 20) { + break; + } + } +} +function newArray() { + let arr: number[] = [0, 0, 0, 0]; + let i = 0; + let c = 0; + while (true) { + arr[i + 4] = c; + c++; + i++; + if (i > 20) { + break; + } + } + return arr; +} +let arr = ag(); +async function showAsyncGenerator(arr: AsyncGenerator) { + let i = 0; + for await (let x of arr) { + Assert.equal(x as number, arr2[i++]); + } +} +let arr2 = newArray(); +showAsyncGenerator(arr); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_3.ts new file mode 100644 index 0000000000..2d547a96f0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_3.ts @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Async Iterators Functions + options: + lib:es2018 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function createAsyncInterator(arr: any[]): AsyncIterator { + let index = 0; + let len = arr.length; + return { + async next() { + return new Promise((resolve, reject) => { + if (index < len) { + resolve({ value: arr[index++], done: false }); + } else { + resolve({ value: undefined, done: true }); + } + }); + }, + }; +} +export function newArray(len: number, step: number = 1) { + if (len <= 0) { return [] }; + let arr: any[] = []; + let x: number = 0; + for (let i: number = 0; i < len; i++) { + arr[i] = x + step; + } + return arr; +} +let arr = newArray(15); +async function exp(arr: any[]) { + let asy = createAsyncInterator(arr); + let i = 0; + let fg; + while (true) { + if (fg == true) { + break; + } + await asy.next().then((v) => { + if (v.done == true) { + fg = true; + } + Assert.equal(v.value, arr[i++]); + return; + }); + } +} +exp(arr); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_4.ts new file mode 100644 index 0000000000..d6a9232379 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/asynchronous_functions/asynchronous_functions_4.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Async Iterators Functions + options: + lib:es2018 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import { newArray } from './asynchronous_functions_3.js'; + +async function asc(arr: any[]) { + let i = 0; + for await (let x of arr) { + Assert.equal(x, arr[i]); + i++ + } +} +let arr = newArray(15, 5); +asc(arr); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_1.ts new file mode 100644 index 0000000000..d3a47bc49d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_1.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + a destructuring parameter declaration introduces zero or more named locals + and initializes them with values extracted from properties or elements of the object or array passed as an argument for the parameter. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Person { + m_name: string; + m_age: number; + constructor(name: string, age: number) { + this.m_name = name; + this.m_age = age; + } +} +let tt: Person = new Person("caihua", 12); +function showInfo({ m_name, m_age }: Person) { + Assert.isString(m_name); + Assert.equal(m_name, tt.m_name); + Assert.isNumber(m_age); + Assert.equal(m_age, tt.m_age); +} +showInfo(tt); +let tt1: Person = new Person("caihua1", 121); +let tt2: Person = new Person("caihua2", 122); +let person_array: Person[] = [tt1, tt2]; +function showArrayInfo(v_array: Array) { + let [tt1, tt2] = v_array; + Assert.equal(tt1.m_name, v_array[0].m_name); + Assert.equal(tt1.m_age, v_array[0].m_age); + Assert.equal(tt2.m_name, v_array[1].m_name); + Assert.equal(tt2.m_age, v_array[1].m_age); +} +showArrayInfo(person_array); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_2.ts new file mode 100644 index 0000000000..ab5bf3ddd4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_2.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the type T associated with a destructuring parameter declaration is determined as follows + If the declaration includes a type annotation, T is that type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Person { + m_name: string; + m_age: number; + constructor(name: string, age: number) { + this.m_name = name; + this.m_age = age; + } +} +let tt: Person = new Person("caihua", 12); +function showInfo(v: Person) { + let { m_name, m_age }: { m_name: string; m_age: number } = v; + Assert.isString(m_name); + Assert.equal(m_name, "caihua"); + Assert.isNumber(m_age); + Assert.equal(m_age, 12); +} +showInfo(tt); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_3.ts new file mode 100644 index 0000000000..3c3293c70b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_3.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the type T associated with a destructuring parameter declaration is determined as follows + If the declaration occurs in a function expression for which a contextual signature is available, + T is the type obtained from the contextual signature. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Person { + m_name: string; + m_age: number; + constructor(name: string, age: number) { + this.m_name = name; + this.m_age = age; + } +} +let tt: Person = new Person("caihua", 12); +const showInfo: (v: Person) => void = function (v) { + let { m_name, m_age } = v; + Assert.isString(m_name); + Assert.equal(m_name, "caihua"); + Assert.isNumber(m_age); + Assert.equal(m_age, 12); +}; +showInfo(tt); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts new file mode 100644 index 0000000000..2f9cefa6e8 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_4.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the type T associated with a destructuring parameter declaration is determined as follows + if the declaration includes an initializer expression, T is the widened form of the type of the initializer expression. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +type testStr = "caihua"; +type testStrNum = 12; +class Person { + m_name: testStr | undefined; + m_age: testStrNum | undefined; + constructor(); + constructor(name?: testStr, age?: testStrNum) { + if (name && typeof name === "string") { + this.m_name = name; + } else { + this.m_name = undefined; + } + if (age && typeof age === "number") { + this.m_age = age; + } else { + this.m_age = undefined; + } + } +} +let tt: Person = new Person(); +function showInfo(v: Person) { + let { + m_name = "caihua", + m_age = 12, + }: { m_name: testStr | undefined; m_age: testStrNum | undefined } = v; + Assert.equal(typeof m_name === "string", true); + Assert.equal(typeof m_age === "number", true); +} +showInfo(tt); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_5.ts similarity index 61% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_5.ts index f2c050785d..cc30604e7e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_5.ts @@ -14,8 +14,8 @@ */ /**--- description: > - a union type encompasses an ordered set of constituent types. - while it is generally true that A | B is equivalent to B | A, the order of the constituent types may matter when determining the call and construct signatures of the union type. + the type T associated with a destructuring parameter declaration is determined as follows + if the declaration specifies a binding pattern, T is the implied type of that binding pattern module: ESNext isCurrent: true ---*/ @@ -23,13 +23,18 @@ import { Assert } from '../../../../suite/assert.js' -let x: number | string; -let y: string | number; -x = 1408; -y = 1408; -Assert.equal(x, y); -Assert.equal(typeof x, typeof y); -x = "Shift"; -y = "Shift"; -Assert.equal(x, y); -Assert.equal(typeof x, typeof y); \ No newline at end of file +type cc = { + name: string; + age: number; + isJob: boolean; +}; +function showInfo({ age, name, isJob }: cc) { + Assert.isNumber(age); + Assert.isBoolean(isJob); + Assert.isString(name); +} +showInfo({ + name: "caihua", + age: 90, + isJob: true, +}); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_6.ts similarity index 50% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_6.ts index ee4efbffa2..9e5149f23e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_6.ts @@ -14,25 +14,32 @@ */ /**--- description: > - A signature's parameter list consists of zero or more required parameters, followed by zero or more optional parameters, - finally followed by an optional rest parameter. + Destructuring parameter declarations do not permit type annotations on the individual binding patterns, + as such annotations would conflict with the already established meaning of colons in object literals. + Type annotations must instead be written on the top-level parameter declaration. module: ESNext isCurrent: true ---*/ -import { Assert } from '../../../../../../suite/assert.js' +import { Assert } from '../../../../suite/assert.js' -function fun1(firstParameter: string, lastParameter?: string) { - if (lastParameter) return firstParameter + " " + lastParameter; - else return firstParameter; +interface information { + title?: string; + place?: [number, number]; + brave?: boolean; } -let result1 = fun1("Bob"); -let result3 = fun1("Bob", "Adams"); -Assert.equal(result1, "Bob"); -Assert.equal(result3, "Bob Adams"); -function fun2(firstParameter: string, ...restParameter: string[]) { - return firstParameter + " " + restParameter.join(" "); +function infor({ title, place, brave }: information) { + if (title) { + Assert.equal(typeof title == "string", true); + } + if (place) { + Assert.equal(Array.isArray(place), true); + } + if (brave) { + Assert.equal(typeof brave === "boolean", true); + } } -let employeeName = fun2("Joseph", "Samuel", "Lucas", "MacKinzie"); -Assert.equal(employeeName, "Joseph Samuel Lucas MacKinzie"); \ No newline at end of file +infor({ title: "title" }); +infor({ brave: false }); +infor({ place: [0, 1] }); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts new file mode 100644 index 0000000000..779bec1a95 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/destructuring_parameter_declarations/destructuring_parameter_declarations_7.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the type T associated with a destructuring parameter declaration is determined as follows + if the parameter is a rest parameter, T is any[]. + Otherwise,T is any + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function test(...v: any[]) { + Assert.isString(v[0]); + Assert.isNumber(v[1]); + Assert.isBoolean(v[2]); +} +test("caihua", 90, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_1.ts new file mode 100644 index 0000000000..4ea5a16f19 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_1.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Function declarations are extended to permit the function body to be omitted in overload declarations. + a function can have at most one implementation. + When a function has both overloads and an implementation, the overloads must precede the implementation + and all of the declarations must be consecutive with no intervening grammatical elements. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function add(a: number, b: number): number; +function add(a: string, b: number): string; +function add(a: string, b: string): string; +function add(arg1: string | number, arg2: string | number) { + if (typeof arg1 === "number" && typeof arg2 === "number") { + return arg1 + arg2; + } + + if (typeof arg1 === "string" || typeof arg2 === "string") { + return `${arg1}${arg2}`; + } +} +Assert.equal(add(0, 1), 1); +Assert.equal(add("0", 1), "01"); +Assert.equal(add("0", "1"), "01"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_2.ts new file mode 100644 index 0000000000..686fa6ef76 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_declarations/function_declarations_2.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + All declarations for the same function must specify the same set of modifiers (the same combination of declare, export, and default) + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +export function add1(a: string, b: string): string; +export function add1(a: number, b: number): number; +export function add1(a: string, b: number): string; +export function add1(arg1: string | number, arg2: string | number) { + if (typeof arg1 === "number" && typeof arg2 === "number") { + return arg1 + arg2; + } + if (typeof arg1 === "string" || typeof arg2 === "string") { + return `${arg1}${arg2}`; + } +} +Assert.equal(add1(0, 1), 1); +Assert.equal(add1("0", 1), "01"); +Assert.equal(add1("0", "1"), "01"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_1.ts new file mode 100644 index 0000000000..cc139d21f1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_1.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + If there are no return statements with expressions in f's function body, the inferred return type is Void. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function func(h_x: number) { + Assert.isNumber(h_x); +} +type voidTest = ReturnType; +let tt1: void = undefined; +let tt2: voidTest = undefined; +Assert.equal(tt1, tt2); +Assert.equal(tt1 === tt2, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_2.ts new file mode 100644 index 0000000000..3180469b8e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_2.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + if f is a contextually typed function expression + the inferred return type is the union type of the types of the return statement expressions in the function body, + ignoring return statements with no expressions. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function f(x: number) { + switch (x) { + case 0: + return "hello"; + case 1: + return 1; + default: + return true; + } +} +type testType = ReturnType; +type ttStr = testType & string; +let tt1: ttStr = "hello"; +Assert.isString(tt1); +type ttBoo = testType & boolean; +let tt2: ttBoo = true; +Assert.isBoolean(tt2); +type ttNum = testType & number; +let tt3: ttNum = 1; +Assert.isNumber(tt3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_3.ts new file mode 100644 index 0000000000..bbe98cd076 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_3.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the inferred return type is the first of the types of the return statement expressions in the function body + that is a supertype of each of the others, ignoring return statements with no expressions. + A compile-time error occurs if no return statement expression has a type that is a supertype of each of the others. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function foo(x: string | number, y: string | boolean) { + if (typeof x === "string") { + return x.toUpperCase(); + } else if (typeof x === "number") { + return x.toString(); + } else if (typeof y === "string") { + return y.toUpperCase(); + } else { + return y; + } +} +type cc = ReturnType; +let dd: cc = "string"; +Assert.isString(dd); +dd = true; +Assert.isBoolean(dd); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_4.ts new file mode 100644 index 0000000000..15c7e92fda --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_4.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + In the signature of a function implementation, a parameter can be marked optional by following it with an initializer. + When a parameter declaration includes both a type annotation and an initializer, the initializer expression is contextually typed by the stated type + and must be assignable to the stated type, or otherwise a compile-time error occurs. + When a parameter declaration has no type annotation but includes an initializer, + the type of the parameter is the widened form (section 3.12) of the type of the initializer expression + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class Test { + a: number; + constructor(a: number) { this.a = a; } +} +function f(x: number, y: Test = { a: 1 }, z = "hello") { + Assert.isString(z); + return { + x, + yy: y, + z: z, + }; +} +Assert.equal(f(0).yy.a, 1); +Assert.equal(f(0).z, "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_5.ts new file mode 100644 index 0000000000..1427e462ac --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_implementations/function_implementations_5.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Initializer expressions are evaluated in the scope of the function body but are not permitted to reference local variables + and are only permitted to access parameters that are declared to the left of the parameter they initialize, + unless the parameter reference occurs in a nested function expression. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let a = 3; +function f(n1: number = a, n2 = n1 * 2, n3 = n1 + 2) { + let b = 12; + function g(xx = b) { + return xx; + } + let c = g(); + return { n1, n2, n3, g: c }; +} +Assert.equal(f().n1, 3); +Assert.equal(f().n2, 6); +Assert.equal(f().n3, 5); +Assert.equal(f().g, 12); +Assert.equal(f(1).n1, 1); +Assert.equal(f(1).n2, 2); +Assert.equal(f(1).n3, 3); +Assert.equal(f(1).g, 12); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_overloads/function_overloads_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_overloads/function_overloads_1.ts new file mode 100644 index 0000000000..734b89651c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/function_overloads/function_overloads_1.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The parameter list of a function overload cannot specify default values for parameters. + In other words, an overload may use only the ? form when specifying optional parameters. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function add(): number; +function add(x: number): number; +function add(x: number, y: number): number; +function add(x?: number, y?: number): number { + let sum: number = 0; + if (x) { + sum += x; + } + if (y) { + sum += y; + } + return sum; +} +Assert.equal(add(), 0); +Assert.equal(add(1), 1); +Assert.equal(add(1, 1), 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_1.ts new file mode 100644 index 0000000000..4601785d81 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_1.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Generator Functions + options: + lib: es2015 + target: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function* generator(): IterableIterator { + yield 0; + yield 1; + yield 2; +} +const iterator = generator(); +let cc = iterator.next(); +Assert.equal(cc.value, 0); +Assert.equal(cc.done, false); +cc = iterator.next(); +Assert.equal(cc.value, 1); +Assert.equal(cc.done, false); +cc = iterator.next(); +Assert.equal(cc.value, 2); +Assert.equal(cc.done, false); +cc = iterator.next(); +Assert.equal(cc.value, undefined); +Assert.equal(cc.done, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_2.ts new file mode 100644 index 0000000000..237d92a46d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generator_functions/generator_functions_2.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Generator Functions + options: + lib: es2015 + target: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function* g1(n: number, step: number = 1): Generator { + let i: number = 0, c: number = 0; + while (true) { + yield i += step; + c++; + if (c >= n) { + break; + } + } +} +function getGeneratorArray(gen: Generator, step: number = 1): any[] { + let c: number = 0; + let arr: any[] = []; + let i: number = 0; + while (true) { + let next = gen.next(); + if (next.done == true) { + break; + } + arr[i] = next.value; + i++; + Assert.equal(next.value, c += step); + } + return arr; +} +let genS1 = g1(10); +let arr: number[] = getGeneratorArray(genS1); +Assert.equal(JSON.stringify(arr), '[1,2,3,4,5,6,7,8,9,10]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/Intersection_Types/intersection_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_1.ts similarity index 61% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/Intersection_Types/intersection_types_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_1.ts index 27fc57353d..5a4a3a7ae1 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/Intersection_Types/intersection_types_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_1.ts @@ -14,7 +14,8 @@ */ /**--- description: > - The union and intersection type operators can be applied to type parameters. + Type parameters declared in the signature of a function implementation are + in scope in the signature and body of that function implementation. module: ESNext isCurrent: true ---*/ @@ -22,20 +23,14 @@ import { Assert } from '../../../../suite/assert.js' -function getSmallPet(name: string | number) { - return name; +type XY = { x: number; y: number }; +function f1(arg: T): T { + return arg; } -let pet = getSmallPet("fishbird"); -Assert.equal(pet, "fishbird"); -interface Person1 { name: string } -interface People1 { sex: string } -type PersonMan = Person1 & People1 -function getPerson(person: PersonMan) { - return person.name; +Assert.equal(f1(0), 0); +Assert.equal(f1("hello"), "hello"); +Assert.equal(f1(true), true); +function f2(arg: T): T { + return arg; } -let man: PersonMan = { - name: "join", - sex: "man" -} -let getpersonname = getPerson(man); -Assert.equal(getpersonname, "join"); \ No newline at end of file +Assert.equal(JSON.stringify(f2<{ x: number, y: number, z: number }>({ x: 0, y: 0, z: 0 })), '{"x":0,"y":0,"z":0}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_2.ts new file mode 100644 index 0000000000..4fb699c4f7 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/generic_functions/generic_functions_2.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The type arguments of a call to a generic function may be explicitly specified in a call operation + or may, when possible, be inferred from the types of the regular arguments in the call. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function identity(arg: T): T { + return arg; +} +Assert.equal(identity(0), 0); +Assert.equal(identity(0), 0); +Assert.equal(identity("hello"), "hello"); +Assert.equal(identity("hello"), "hello"); +Assert.equal(identity(true), true); +Assert.equal(identity(true), true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/named_type_reference/named_type_reference.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/type_guard_functions/type_guard_functions_1.ts similarity index 36% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/named_type_reference/named_type_reference.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/type_guard_functions/type_guard_functions_1.ts index 62bd85f61f..538450c5fb 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/named_type_reference/named_type_reference.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/functions/type_guard_functions/type_guard_functions_1.ts @@ -13,53 +13,54 @@ * limitations under the License. */ /**--- - description: > - Type references to class and interface types are classified as C1ect types. - Type references to generic class and interface types include type arguments that are substituted for the type parameters of the class - or interface to produce an actual C1ect type. + description: TypeScript compiler narrows the type of a variable within a type guard. module: ESNext isCurrent: true ---*/ -import { Assert } from '../../../../../suite/assert.js' +import { Assert } from '../../../../suite/assert.js' -class C1 { - num1: number; - num2: number; - constructor(num1: number, num2: number) { - this.num1 = num1; - this.num2 = num2; - } - add(x: number, y: number): void { - let sum: number = x + y; - Assert.equal(sum, 10); +class Student { + name: string; + age: number; + constructor(name: string, age: number) { + this.name = name; + this.age = age; } } -let o: C1 = new C1(4, 6); -o.add(3, 7); - -interface I { +class Teacher { name: string; age: number; - greet: () => string + job: string; + constructor(name: string, age: number, job: string) { + this.name = name; + this.age = age; + this.job = job; + } } -let i: I = { - name: 'xiao', - age: 18, - greet() { return "hello"; } +function isTeacher(obj: Student | Teacher): obj is Teacher { + return "job" in obj; } -Assert.equal(i.name, "xiao"); -Assert.equal(i.age, 18); -Assert.equal(i.greet(), "hello"); -class C2 { - x: T; - constructor(x: T) { - this.x = x; +function printInfo(obj: Student | Teacher) { + if ( + isTeacher(obj) && + typeof obj.age === "number" && + obj instanceof Teacher + ) { + Assert.equal(obj.name, "caihuaTeacher"); + Assert.equal(obj.age, 20); + Assert.equal(obj.job, "teacher"); + return "teacher"; + } else { + Assert.equal(obj.name, "caihuaStudent"); + Assert.equal(obj.age, 20); + return "student"; } - getx() { - return this.x; - }; } -let c2 = new C2(1); -Assert.equal(c2.getx(), 1) \ No newline at end of file +let tt: Teacher = new Teacher("caihuaTeacher", 20, "teacher"); +let ss: Student = new Student("caihuaStudent", 20); +Assert.equal(printInfo(tt), "teacher"); +Assert.notEqual(printInfo(tt), "student"); +Assert.equal(printInfo(ss), "student"); +Assert.notEqual(printInfo(ss), "teacher"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/Intersection_Types/Intersection_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/classes/classes.ts similarity index 34% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/Intersection_Types/Intersection_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/classes/classes.ts index 14ce4b4a98..f72709bc48 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/Intersection_Types/Intersection_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/classes/classes.ts @@ -14,9 +14,8 @@ */ /**--- description: > - Intersection types represent values that simultaneously have multiple types. - A value of an intersection type A & B is a value that is both of type A and type B. - Intersection types are written using intersection type literals. + this appendix contains a summary of the grammar found in the main document. + typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. module: ESNext isCurrent: true ---*/ @@ -24,63 +23,42 @@ import { Assert } from '../../../../suite/assert.js' -interface A1 { - num1: number; +interface PointInterface { + x: number; + y: number; + z: number; + getPointArray(): number[]; } -interface B1 { - str1: string; +class Point implements PointInterface { + x: number = 0; + y: number = 0; + z: number = 0; + getPointArray() { + return [this.x, this.y, this.z]; + } + constructor(x: number, y: number, z: number) { + this.x = x; + this.y = y; + this.z = z; + } } -let x: A1 & B1 = { num1: 1, str1: "b" }; -Assert.equal(x.num1, 1); -Assert.equal(x.str1, "b"); -enum Color { - Red1 = 1, - Green1, - Blue1, +class ColorC extends Point { + static Red: number = 0; + static Green: number = 0; + static Blue: number = 0; + static getColorArray(): number[] { + return [this.Red, this.Green, this.Blue] + } + toJSON() { + return JSON.stringify(ColorC.getColorArray()); + } + constructor(Red: number, Green: number, Blue: number, x: number = 0, y: number = 0, z: number = 0) { + super(x, y, z); + ColorC.Red = Red; + ColorC.Green = Green; + ColorC.Blue = Blue; + } } -interface A2 { - num2: [string, number]; -} -interface B2 { - str2: Color; -} -let x2: A2 & B2 = { num2: ["a2", 1], str2: Color.Red1 }; -Assert.equal(x2.num2[0], "a2"); -Assert.equal(x2.str2, 1); -interface A3 { - num3: number[]; -} -interface B3 { - str3: boolean; -} -let x3: A3 & B3 = { num3: [1, 2, 3], str3: true }; -Assert.equal(x3.str3, true); -interface A4 { - num4: number; -} -interface B4 { - str4: string; -} -interface C4 { - cm: any; -} -let x4: A4 & B4 & C4 = { num4: 1, str4: "b4", cm: 3 }; -Assert.equal(x4.num4, 1); -Assert.equal(x4.str4, "b4"); -Assert.equal(x4.cm, 3); -interface XX { - obj: A1; -} -interface YY { - obj: B1; -} -let x5: XX & YY = { obj: x }; -Assert.equal(x5.obj.num1, 1); -interface A5 { - x: number; -} -interface B5 { - x: number; -} -let x6: A5 & B5 = { x: 1 }; -Assert.equal(x6.x, 1); \ No newline at end of file +let colorPoint = new ColorC(255, 0, 0, 1, 1, 1); +Assert.equal(JSON.stringify(colorPoint.getPointArray()), "[1,1,1]"); +Assert.equal(colorPoint.toJSON(), "[255,0,0]"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/enums/enums.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/enums/enums.ts new file mode 100644 index 0000000000..18f047adf9 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/enums/enums.ts @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + this appendix contains a summary of the grammar found in the main document. + typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +const enum CED { + None = -1, + False, + True = 1, + DEF = 1024, + Ver = "1.0.1", +} +Assert.equal(CED.None, -1); +Assert.equal(CED.False, 0); +Assert.equal(CED.True, 1); +Assert.equal(CED.DEF, 1024); +Assert.equal(CED["None"], -1); +Assert.equal(CED["False"], 0); +Assert.equal(CED["True"], 1); +Assert.equal(CED["DEF"], 1024); +Assert.equal(CED.Ver, "1.0.1"); + +function toLength(str: string): number { + return str.length; +} + +enum ABCList { + A, + B, + C = "string".length, + D = 10, + E, + F = ~17, + G = 0x0f << 0x02, + H = 0xff & 0xaa, + I = E | F, + J = toLength(ABCList[11]), +} +Assert.equal(ABCList.A, 0); +Assert.equal(ABCList.B, 1); +Assert.equal(ABCList.C, 6); +Assert.equal(ABCList.D, 10); +Assert.equal(ABCList.E, 11); +Assert.equal(ABCList.F, -18); +Assert.equal(ABCList.G, 60); +Assert.equal(ABCList.H, 170); +Assert.equal(ABCList.I, -17); +Assert.equal(ABCList.J, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/expressions/expressions.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/expressions/expressions.ts new file mode 100644 index 0000000000..09327519a0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/expressions/expressions.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + this appendix contains a summary of the grammar found in the main document. + typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class EXP { + cname: string; + private _ver: number = -1; + addName(ad: string) { + this.cname = this.cname + " " + ad; + return this.cname; + } + get ver() { + return this._ver; + } + set ver(v: number) { + this._ver = v; + } + constructor(cname: string) { + this.cname = cname; + } +} +let exp = new EXP("EXP"); +exp.addName("Class"); +Assert.equal(exp.cname, "EXP Class"); + +exp.ver = 1; +Assert.equal(exp.ver, 1); + +function Ax2(a: number) { + return a * 2; +} +Assert.equal(Ax2(2), 4); + +let fun1: (a: number, b: number) => number = (a: number, b: number) => { + return a + b; +} +Assert.equal(fun1(1, 2), 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/functions/functions.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/functions/functions.ts new file mode 100644 index 0000000000..031c95ec63 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/functions/functions.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + this appendix contains a summary of the grammar found in the main document. + typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function addXYZ(x: number, y: number, z: number): number { + return x + y + z; +} +Assert.equal(addXYZ(1, 2, 3), 6); + +function addXY(x: number, y: number): number; +function addXY(x: number, y: number): number { + return x + y; +} +Assert.equal(addXY(1, 2), 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/interfaces/interfaces.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/interfaces/interfaces.ts new file mode 100644 index 0000000000..34eebfd537 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/interfaces/interfaces.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + this appendix contains a summary of the grammar found in the main document. + typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface X { + x: number; +} +interface Y { + y: number; +} +interface Z { + z: number; +} +interface PointXYZ extends X, Y, Z { + toJSON(): string; +} +let pa: PointXYZ = { + x: 3, + y: 4, + z: 5, + toJSON() { + let pArr = [this.x, this.y, this.z]; + return JSON.stringify(pArr); + }, +} +Assert.equal(pa.toJSON(), "[3,4,5]"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/namespaces/namespaces.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/namespaces/namespaces.ts new file mode 100644 index 0000000000..f272a45cb4 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/namespaces/namespaces.ts @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + this appendix contains a summary of the grammar found in the main document. + typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +namespace ExampleG { + var namespace_name = "Example"; + export function exampleName(str: string): string { + return str + " " + namespace_name; + } + class Point { + x: number = 0; + y: number = 0; + } + interface PointXYZ { + x: number; + y: number; + z: number; + } + type StrNumBool = string | number | boolean; + export enum Color { + RED = 0xFF0000, + GREEN = 0x00FF00, + BLUE = 0x0000FF, + }; + namespace SubNamespace { } + declare var __TEST__: boolean; + export import EE = ExportExampleG; +} +namespace ExportExampleG { + export var namespace_name = "ExportExampleG"; + export function exampleEName(str: string): string { + return str + " " + namespace_name; + } + export class Point { + x: number = 0; + y: number = 0; + } + export interface PointXYZ { + x: number; + y: number; + z: number; + } + export type StrNumBool = string | number | boolean; + export enum Color { + RED = 0xFF0000, + GREEN = 0x00FF00, + BLUE = 0x0000FF, + } + export namespace SubNamespace { } + export declare var __TEST__: boolean; + export import E = ExampleG; +} +Assert.equal(ExampleG.exampleName("G"), "G Example"); +Assert.equal(ExampleG.Color.RED, 0xFF0000); +Assert.equal(ExportExampleG.exampleEName("G"), "G ExportExampleG"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/specialized_signatures/specialized_signatures_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/scripts_and_modules.ts similarity index 32% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/specialized_signatures/specialized_signatures_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/scripts_and_modules.ts index 28ae71c53d..f719c24c2e 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/specialized_signatures/specialized_signatures_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/scripts_and_modules.ts @@ -14,41 +14,50 @@ */ /**--- description: > - Specialized signatures are used to express patterns where specific string values for some parameters - cause the types of other parameters or the function result to become further specialized. + this appendix contains a summary of the grammar found in the main document. + typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. module: ESNext isCurrent: true ---*/ -import { Assert } from '../../../../../../suite/assert.js' - -interface specialType { - Tfun(x: "hello"): "hello"; - Tfun(x: "world"): "world"; - Tfun(x: string): string; -} -class getType implements specialType { - Tfun(x: any): any { - let xx: "hello" = "hello"; - let xx2: "world" = "world"; - if (x === xx) { - return x; - } else if (x === xx2) { - return x; - } else if (typeof x === "string") { - return "isstring"; - } - } -} -let x1 = new getType(); -let xx1: "hello" = "hello"; -let y1: "hello" = x1.Tfun(xx1); -Assert.equal(xx1, y1); -let x2 = new getType(); -let xx2: "world" = "world"; -let y2 = x2.Tfun(xx2); -Assert.equal(xx2, y2); -let x3 = new getType(); -let y3 = x3.Tfun("helloworld"); -Assert.equal(y3, "isstring"); \ No newline at end of file +import * as sf1 from "./source_file_1.js"; +import checkGenerator from "./source_file_2.js"; +import arr1 from "./source_file_3.js"; +import PointXY from "./source_file_4.js"; +import { Assert } from "../../../../suite/assert.js"; + +Assert.equal(sf1.num, 1408); + +Assert.equal(sf1.show(), "show"); + +let a3: Generator = sf1.arr3(9); +checkGenerator(a3, 3); + +let green = new sf1.Color(0, 255, 0); +Assert.equal(JSON.stringify(green.ColorData), '[0,255,0]'); + +let p: sf1.Point = { x: 0, y: 0 }; +Assert.equal(p.x, 0); +Assert.equal(p.y, 0); + +let arrstrnum: sf1.ArrStrNum; +arrstrnum = ["a", "b", "c", "d", "e"]; +Assert.equal(JSON.stringify(arrstrnum), '["a","b","c","d","e"]'); +arrstrnum = [1, 2, 3, 4, 5]; +Assert.equal(JSON.stringify(arrstrnum), '[1,2,3,4,5]'); +arrstrnum = ["a", 2, "c"]; +Assert.equal(JSON.stringify(arrstrnum), '["a",2,"c"]'); +arrstrnum = "arrstrnum"; +Assert.isString(arrstrnum); +arrstrnum = 0; +Assert.isNumber(arrstrnum); + +Assert.equal(sf1.XXXX.x, 1024); +Assert.equal(sf1.XXXX.showXXXX(), "showXXXX"); + +let a1 = arr1(9); +checkGenerator(a1, 1); + +let p1 = new PointXY(10, 10); +Assert.equal(JSON.stringify(p1.point), '[10,10]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_1.ts similarity index 36% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_1.ts index 7d8838deab..a19235627c 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_references/type_references_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_1.ts @@ -12,47 +12,50 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/**--- - description: > - A type argument is simply a Type and may itself be a type reference to a generic type. - A type reference to a generic type G designates a type wherein all occurrences of G's type parameters have been replaced - with the actual type arguments supplied in the type reference. - module: ESNext - isCurrent: true - ---*/ -import { Assert } from '../../../../../suite/assert.js' - -interface I1 { - a: string; +export let num: number = 1408; +export function show() { return "show"; }; +export function* arr3(n: number): Generator { + let i = 0; + let c = 0; + if (n > 0) { + while (true) { + yield i += 3; + if (c >= n) { + break; + } else { + c++; + } + } + } } -interface I2 extends I1 { - b: string; +export class Color { + Red: number; + Green: number; + Blue: number; + ColorData: [number, number, number] = [0, 0, 0]; + getColor(): [number, number, number] { + this.ColorData = [this.Red, this.Green, this.Blue]; + return this.ColorData; + } + constructor(red: number, green: number, blue: number) { + this.Red = red; + this.Green = green; + this.Blue = blue; + this.getColor(); + } } -interface I3 extends I2 { - c: string; +export interface Point { + x: number; + y: number; } -interface I4 { - x: T; - y: U; +export type ArrStrNum = string[] | number[] | (string | number)[] | string | number; +export enum ABC { + A, B, C, D, E, } -let z: I4, I3> = { - x: { - x: { a: 'a' }, - y: { - a: 'a', - b: 'b' - } - }, - y: { - a: 'a', - b: 'b', - c: 'c' - } +export namespace XXXX { + export let x: number = 1024; + export function showXXXX() { return "showXXXX"; }; } -Assert.equal(z.x.x.a, 'a'); -Assert.equal(z.x.y.b, 'b'); -Assert.equal(z.y.a, 'a'); -Assert.equal(z.y.b, 'b'); -Assert.equal(z.y.c, 'c'); \ No newline at end of file +export declare let dnum: number; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_2.ts new file mode 100644 index 0000000000..624f3d3f5a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_2.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +import { Assert } from "../../../../suite/assert.js"; +export default function checkGenerator(gen: Generator, step: number) { + let c = 0; + while (true) { + let next = gen.next(); + if (next.done == true) { + break; + } + Assert.equal(next.value, c += step); + } +} \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_3.ts new file mode 100644 index 0000000000..bc333e40b1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_3.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export default function* arr1(n: number): Generator { + let i = 0; + let c = 0; + if (n > 0) { + while (true) { + yield i += 1; + if (c >= n) { + break; + } else { + c++; + } + } + } +} \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_4.ts new file mode 100644 index 0000000000..67fbe4f588 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/scripts_and_modules/source_file_4.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export default class PointXY { + x: number; y: number; + point: [number, number] = [0, 0]; + getPoint(): [number, number] { + this.point = [this.x, this.y]; + return this.point; + } + constructor(x: number, y: number) { + this.x = x; + this.y = y; + this.getPoint(); + } +} \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/statements/statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/statements/statements.ts new file mode 100644 index 0000000000..239165c974 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/statements/statements.ts @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + this appendix contains a summary of the grammar found in the main document. + typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface Skill { + SkillName: string; + Damage: number; + Data: string; +} +let aoe: Skill = { SkillName: "AoE", Damage: 495, Data: "AreaFire" }; +Assert.equal(aoe.SkillName, "AoE"); +Assert.equal(aoe.Damage, 495); +Assert.equal(aoe.Data, "AreaFire"); + +type NumStr = number | string; +let ns: NumStr; +ns = 1024; +Assert.isNumber(ns); +ns = "A"; +Assert.isString(ns); + +enum Color { + Red = 0xFF0000, + Green = 0x00FF00, + Bule = 0x0000FF, +} +Assert.equal(Color.Green, 0x00FF00); + +let aaa; +aaa = true; +Assert.isBoolean(aaa); +aaa = 1408; +Assert.isNumber(aaa); +let abc: string; +abc = "ABC"; +Assert.isString(abc); + +type TF = -1 | 0 | 1; +let tf0: TF = 0; +let tf1: TF = 1; +let tf2: TF = -1; +Assert.equal(tf0, 0); +Assert.equal(tf1, 1); +Assert.equal(tf2, -1); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/types/types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/types/types.ts new file mode 100644 index 0000000000..a7f8823b07 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/grammar/types/types.ts @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + this appendix contains a summary of the grammar found in the main document. + typescript grammar is a superset of the grammar defined in the ECMAScript 2015 Language Specification (specifically, the ECMA-262 Standard, 6th Edition) + and this appendix lists only productions that are new or modified from the ECMAScript grammar. + options: + target: es2015 + lib: es2015 + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let num: number = 1024; +let str: string = "string"; +let bool: boolean = false; +let big: bigint = 1n; +let sym: symbol = Symbol(); +let obj: object = {}; +let fun: Function = () => { return "Function"; } +let udf: undefined = undefined; +Assert.isNumber(num); +Assert.isString(str); +Assert.isBoolean(bool); +Assert.equal(typeof big, "bigint"); +Assert.isSymbol(sym); +Assert.equal(typeof obj, "object"); +Assert.isFunction(fun); +Assert.isUndefined(udf); + +type Ver = { ver: string }; +interface Data extends Ver { + data: number; +} +let v: Data = { data: 1024, ver: "1.0.1" }; +Assert.equal(v.data, 1024); +Assert.equal(v.ver, "1.0.1"); + +function addNumbers(...num: number[]): number { + let n: number = 0; + for (let i: number = 0; i < num.length; i++) { + n += num[i]; + } + return n; +} +Assert.equal(addNumbers(5, 5, 5, 5, 5), 25); + +interface StrIndex { + [key: string]: number; +} +let si: StrIndex = { C: 3, D: 4 }; +si['A'] = 1; +si.B = 2; +Assert.equal(si.A, 1); +Assert.equal(si['B'], 2); +Assert.equal(si.C, 3); +Assert.equal(si['D'], 4); +Assert.equal(JSON.stringify(si), '{"C":3,"D":4,"A":1,"B":2}'); + +interface NumIndex { + [key: number]: string; +} +let ni: NumIndex = { 1: 'A' }; +ni[3] = 'C'; +Assert.equal(ni[1], 'A'); +Assert.equal(ni[3], 'C'); +Assert.equal(JSON.stringify(ni), '{"1":"A","3":"C"}'); + +class AB{ + a: T | undefined; + b: U | undefined; + public c: string = ""; + private d: string = ""; + protected e: string = ""; + setD(val: string) { + this.d = val; + } + setE(val: string) { + this.e = val; + } + show() { + return JSON.stringify({ d: this.d, e: this.e }); + } + constructor(a?: T, b?: U) { + this.a = a; + this.b = b; + } +} +let ab = new AB(123, "ABC"); +Assert.equal(ab.a, 123); +Assert.equal(ab.b, "ABC"); + +let ab2 = new AB(1024); +Assert.equal(ab2.a, 1024); +Assert.isUndefined(ab2.b); + +ab.c = "1024"; +Assert.equal(ab.c, "1024"); + +ab.setD("D"); +ab.setE("E"); +Assert.equal(ab.show(), "{\"d\":\"D\",\"e\":\"E\"}"); + +type ONS = { n1?: number | string, n2?: number | string }; +let ons: ONS = { n1: 0, n2: "ABC" }; +Assert.equal(ons.n1, 0); +Assert.equal(ons.n2, "ABC"); + + +type NumStrBool = number | string | boolean; +type NumObjBool = number | object | boolean; +type NumBool = NumObjBool & NumStrBool; +let nb: NumBool = 1; +Assert.isNumber(nb); +nb = true; +Assert.isBoolean(nb); + +type StrFun = (a: string, b: string) => string; +let strFun: StrFun = (a: string, b: string) => { return a + b; } +Assert.equal(strFun("AB", "CD"), "ABCD"); + +let a: any; +let vo: void; + +let arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; +Assert.equal(arr[0], 0); + +type type0 = "A" | "B" | "C" | "D"; +let t0: type0 = "A"; +Assert.equal(t0, "A"); + +type NumStrArray = number[] | string[] | (number | string)[]; +let nsa1: NumStrArray = [1, 3, 5]; +let ar1 = [1, 3, 5] +let nsa2: NumStrArray = ["A", "B", "C"]; +let ar2 = ["A", "B", "C"]; +let nsa3: NumStrArray = ["A", 1, "B", 2, "C", 3]; +let ar3 = ["A", 1, "B", 2, "C", 3]; +Assert.equal(JSON.stringify(nsa1), JSON.stringify(ar1)); +Assert.equal(JSON.stringify(nsa2), JSON.stringify(ar2)); +Assert.equal(JSON.stringify(nsa3), JSON.stringify(ar3)); + +type ABC = [number, string, boolean]; +let abc: ABC = [1, "A", true]; +let abc2 = [1, "A", true]; +Assert.equal(JSON.stringify(abc), JSON.stringify(abc2)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_1.ts new file mode 100644 index 0000000000..fa6621e1ed --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_1.ts @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + An interface declaration declares an interface type. + An InterfaceDeclaration introduces a named type (section 3.7) in the containing declaration space. + The BindingIdentifier of an interface declaration may not be one of the predefined type names (section 3.8.1). + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +{ + interface Worker { + x: number; + + work(): string; + + getS(): { rate: number,velocity: number; }; + } + + interface Tool { + y: number; + + tool(): string; + + getS(): { rate: number, velocity: number;}; + } + + interface Runer extends Tool,Worker{ + z:string, + + getS(): { rate: number, velocity: number,play:string}; + + run():string; + + tool(): string; + } + + let result1: { rate: number,velocity: number; } = { + rate: 1, + velocity:123, + }; + let result2: { velocity: number,rate: number,} = { + velocity: 1, + rate:999, + }; + let ToRun: {velocity: number, rate: number, play: string} = { + velocity: 1314, + rate:999, + play:"一万年", + } + + let point: Worker = { + x: 1, + getS(): {rate: number, velocity: number} { + return result2 + }, + work(): string { + return "work"; + } + }; + let pointer: Tool = { + y: 1, + getS(): {rate: number, velocity: number} { + return result1 + }, + tool(): string { + return "tool"; + }, + }; + let run:Runer = { + x: ++point.x, + y: --pointer.y, + z:"with z", + getS(): { rate: number; velocity: number; play: string } { + return ToRun; + }, + work(): string { + return "let it work"; + }, + run():string { + return "let it run"; + }, + tool(): string { + return "He is the tool of work"; + } + } + + Assert.equal(run.x,2); + Assert.equal(run.y,0); + Assert.equal(run.z,"with z"); + Assert.equal(run.getS(),ToRun); + Assert.equal(run.run()+","+run.work()+","+run.tool(),"let it run,let it work,He is the tool of work"); + Assert.equal(point.x, 2); + Assert.equal(pointer.y, 0); + Assert.equal(point.getS(), result2); + Assert.equal(pointer.getS(), result1); + Assert.equal(pointer.tool(), "tool"); + Assert.equal(point.work(), "work"); +}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_2.ts new file mode 100644 index 0000000000..4040342f7f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_2.ts @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + An interface can inherit from zero or more base types which are specified in the InterfaceExtendsClause. + The base types must be type references to class or interface types. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +{ + interface Worker { + x: number; + + work(): void; + + getS(): { velocity: number; }; + } + + interface Tool { + y: number; + + tool(): void; + + getS(): { rate: number; }; + } + + interface WorkerTool extends Worker, Tool { + z: string; + + getS(): { velocity: number; rate: number; }; + } + + let result: { velocity: number; rate: number; } = { + velocity: 1, + rate: 1 + }; + + let point: WorkerTool = { + x: 1 , + y: 1, + z: "zzz", + getS(): { velocity: number; rate: number; } { + return result + }, + tool(): string { + return "tool"; + }, + work(): string { + return "work"; + } + }; + + Assert.equal(point.x, 1); + Assert.equal(point.y, 1); + Assert.equal(point.z, "zzz"); + Assert.equal(point.getS(), result); + Assert.equal(point.tool(), "tool"); + Assert.equal(point.work(), "work"); +}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_3.ts new file mode 100644 index 0000000000..def71989e3 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/1_interface_declarations/interface_declarations_3.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Since function and constructor types are just object types containing call and construct signatures, interfaces can + be used to declare named function and constructor types + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +{ + interface Example1 { + (h_a: string, h_b: string): number; + } + + let sc: Example1 = (h_a: string, h_b: string): number => { return h_a.charCodeAt(0) + h_b.charCodeAt(0); }; + Assert.equal(sc('a', 'b'), 195); +}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_1.ts new file mode 100644 index 0000000000..d1a8386819 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_1.ts @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When a generic interface has multiple declarations, all declarations must have identical type parameter lists, + i.e. identical type parameter names with identical constraints in identical order. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +{ + interface Ds { + createE1(a: T): number; + } + + interface Ds { + createE2(a: T): number; + + createE3(a: T): number; + } + + let name: Ds = { + createE1(a: string): number { + return 0 + }, + createE2(a: boolean): number { + return 0 + }, + createE3(a: number): number { + return 0 + } + }; + let src :Ds = { + createE1(a: number): number { + return 1 + }, + createE2(a: number | string): number { + return 2; + }, + createE3(a: number | string): number { + return 3; + }, + } + + class Get { + static getName(name: Ds): Ds { + return name; + }; + static getSrc(src :Ds){ + return src; + } + } + + Assert.equal(Get.getSrc(src).createE1(1),1); + Assert.equal(Get.getSrc(src).createE2(""),2); + Assert.equal(Get.getName(src).createE3("233"), 3); + Assert.equal(Get.getName(name).createE1(''), 0); + Assert.equal(Get.getName(name).createE3(0), 0); + Assert.equal(Get.getName(name).createE2(true), 0); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_2.ts new file mode 100644 index 0000000000..90d5543f22 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/2_declaration_merging/declaration_merging_2.ts @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + multiple declarations is equivalent to the following single declaration. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +{ + interface D1 { + createE1(a: string): number; + } + + interface D1 { + createE2(a: boolean): number; + + createE3(a: number): number; + } + + interface DAssert { + createE4(a: string): number; + + createE5(a: boolean): number; + + createE6(a: number): number; + } + + let name: D1 & DAssert = { + createE1(a: string): number { + return 0 + }, + createE2(a: boolean): number { + return 0 + }, + createE3(a: number): number { + return 0 + }, + createE4(a: string): number { + return 0 + }, + createE5(a: boolean): number { + return 0 + }, + createE6(a: number): number { + return 0 + } + }; + + class Class { + static getName(name: D1 & DAssert): D1 & DAssert { + return name; + } + } + + Assert.equal(Class.getName(name).createE1(''), 0); + Assert.equal(Class.getName(name).createE3(0), 0); + Assert.equal(Class.getName(name).createE2(true), 0); + Assert.equal(Class.getName(name).createE4(''), 0); + Assert.equal(Class.getName(name).createE5(true), 0); + Assert.equal(Class.getName(name).createE6(0), 0); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_1.ts new file mode 100644 index 0000000000..12887890b3 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_1.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + When an interface type extends a class type it inherits the members of the class but not their implementations. + It is as if the interface had declared all of the members of the class without providing an implementation. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +{ + class h_C { + private state: any = 0; + point: number | unknown = 0; + } + + interface h_SC extends h_C { + choose(): number; + } + + class h_B extends h_C implements h_SC { + choose(): number { + return 0 + } + } + + Assert.equal(new h_B().point,0); + Assert.equal(typeof new h_B().point,"number"); + Assert.isTrue(new h_B().hasOwnProperty('point')); + Assert.isTrue(new h_B().hasOwnProperty('state')); + +}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_2.ts new file mode 100644 index 0000000000..584bb73ebe --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/3_interfaces_extending_classes/interfaces_extending_classes_2.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Interfaces inherit even the private and protected members of a base class. + When a class containing private or protected members is the base type of an interface type, + that interface type can only be implemented by that class or a descendant class. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +class h_C { + private h_pri: string; + constructor(h_pri: string) { + this.h_pri = h_pri; + } + get() { + return this.h_pri; + } + set() { + this.h_pri = this.h_pri; + } +} +interface h_I extends h_C { + choose(): string; +} +class h_c extends h_C implements h_I { + choose(): string { + return 'choose'; + } +} +let h_CC = new h_C('private'); +Assert.equal(h_CC.get(), 'private'); +let h_cc = new h_c('PRIVATE'); +Assert.equal(h_cc.get(), 'PRIVATE'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/4_dynamic_type_checks/dynamic_type_checks_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/4_dynamic_type_checks/dynamic_type_checks_1.ts new file mode 100644 index 0000000000..58eccbd620 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/interfaces/4_dynamic_type_checks/dynamic_type_checks_1.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + TypeScript does not provide a direct mechanism for dynamically testing whether an object implements a particular + interface. Instead, TypeScript code can use the JavaScript technique of checking whether an appropriate set of members + are present on the object + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + + +interface WorkerTool { + shift(): void; + + rock(): void; + + getS(): void; +} + +function asWorkerTool(o: any): WorkerTool { + return o && o.shift && o.rock && o.getS ? o : null; +} + +let point: WorkerTool = { + getS(): void { + }, + rock(): void { + }, + shift(): void { + } +}; + +Assert.equal(asWorkerTool(point), point); +Assert.equal(typeof asWorkerTool(point),"object") \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_1.ts new file mode 100644 index 0000000000..1b184061c8 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_1.ts @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +namespace outside { + var native = 1; + export var h_a = native; + export namespace interior { + export var h_x = 10; + } + export interface OA { + OA: string; + } +}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_2.ts new file mode 100644 index 0000000000..249f43f4be --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_2.ts @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +namespace outside { + var native = 2; + export var h_b = native; + export namespace interior { + export var h_y = 20; + } + export interface OB { + OB: number; + } +}; diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_3.ts new file mode 100644 index 0000000000..40f5e04746 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_1_3.ts @@ -0,0 +1,30 @@ +/// +/// +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + namespaces are "open-ended" and namespace declarations with the same qualified name relative to a common root (as defined in section 2.3) contribute to a single namespace. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var o1: outside.OA = { OA: "OA" }; +var o2: outside.OB = { OB: 1024 }; +Assert.isString(o1.OA); +Assert.isNumber(o2.OB); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_2.ts new file mode 100644 index 0000000000..d75e35c37e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/declaration_merging/declaration_merging_2.ts @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + declaration merging also extends to namespace declarations with the same qualified name relative to a common root as a function, class, or enum declaration. + when merging a non-ambient function or class declaration and a non-ambient namespace declaration, the function or class declaration must be located prior to the namespace declaration in the same source file. + this ensures that the shared object instance is created as a function object. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface Point { + x: number; + y: number; +} +function Point(x: number, y: number): Point { + return { x: x, y: y }; +} +namespace Point { + export var origin = Point(0, 0); + export function equals(p1: Point, p2: Point) { + return p1.x == p2.x && p1.y == p2.y; + } +} +var p1 = Point(0, 0); +var p2 = Point.origin; +var b = Point.equals(p1, p2); +Assert.equal(p1.x, 0); +Assert.equal(p1.y, 0); +Assert.equal(p2.x, 0); +Assert.equal(p2.y, 0); +Assert.equal(b, true); + +enum Color { + Red = 0xFF0000, + Green = 0x00FF00, + Blue = 0x0000FF, +} +namespace Color { + export interface Color { + Red: number; + Green: number; + Blue: number; + } +} +Assert.equal(Color.Red, 0xFF0000); +var color: Color.Color = { Red: 255, Green: 255, Blue: 255 }; +Assert.equal(color.Green, 255); + +class PointXYZ { + public x: number; + public y: number; + public z: number; + constructor(x: number = 0, y: number = 0, z: number = 0) { + this.x = x; + this.y = y; + this.z = z; + } + toString() { + return "( " + this.x + " , " + this.y + " , " + this.z + " )"; + } +} +namespace PointXYZ { + export var xyz = new PointXYZ(1, 1, 1); + export interface PointXYZ { + x: number; + y: number; + z: number; + } +} +var xyz1 = new PointXYZ(1, 3, 5); +var xyz2: PointXYZ.PointXYZ = { x: 2, y: 3, z: 4 }; +var xyz3 = PointXYZ.xyz; +Assert.equal(xyz1.toString(), "( 1 , 3 , 5 )"); +Assert.equal(xyz2.x, 2); +Assert.equal(xyz3.toString(), "( 1 , 1 , 1 )"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_1.ts new file mode 100644 index 0000000000..8f240e609d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_1.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + an export declaration declares an externally accessible namespace member. An export declaration is simply a regular declaration prefixed with the keyword export. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +namespace ED1 { + export interface Weapon { WName: string, Damage: number } + export var def = 1024; +} +var weapon1: ED1.Weapon = { WName: "40mmAT", Damage: 40 }; +var def1 = ED1.def; +Assert.equal(weapon1.WName, "40mmAT"); +Assert.equal(weapon1.Damage, 40); +Assert.equal(def1, 1024); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_2.ts new file mode 100644 index 0000000000..1ad82d5e7d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_2.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the members of a namespace's export declaration space constitute the namespace's export member set. + a namespace's instance type is an object type with a property for each member in the namespace's export member set that denotes a value. + module: ESNext + isCurrent: true + ---*/ + +import { Assert } from '../../../../suite/assert.js' + + +namespace ED2 { + export var def = 1024; + interface Weapon { WName: string, Damage: number } + export var weapon1: Weapon = { WName: "Lightting", Damage: 200 } + export var tf = "False"; +} +var ed2 = ED2; +var ed2_1 = ed2.def; +var ed2_2 = ed2.weapon1; +var ed2_3 = ed2.tf; +Assert.equal(typeof ed2, "object"); +Assert.isNumber(ed2_1); +Assert.equal(typeof ed2_2, "object"); +Assert.isString(ed2_3); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_3.ts new file mode 100644 index 0000000000..bea69bcc1b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/export_declarations/export_declarations_3.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + an exported member depends on a (possibly empty) set of named types. Those named types must be at least as accessible as the exported member, or otherwise an error occurs. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface WeaponDamage { DamageType: string, Damage: number } +namespace ED3 { + export interface WeaponData { WName: string, ROT: number, Range: number } + export interface Weapon { WeaponDamage: WeaponDamage, WeaponData: WeaponData } + export function getWeapon(Weapon: Weapon) { + return "WeaponName = " + Weapon.WeaponData.WName + "\n" + "DamageType = " + Weapon.WeaponDamage.DamageType + "\n" + "Damage = " + Weapon.WeaponDamage.Damage + "\n" + "ROT = " + Weapon.WeaponData.ROT + "\n" + "Range = " + Weapon.WeaponData.Range; + } +} +var weapon_damage: WeaponDamage = { DamageType: "EXPLODE", Damage: 1024 }; +var weapon_data: ED3.WeaponData = { WName: "AntiTankMissiles", ROT: 75, Range: 16 }; +var weapon: ED3.Weapon = { WeaponData: weapon_data, WeaponDamage: weapon_damage }; +var weaponStr = ED3.getWeapon(weapon); +Assert.isString(weaponStr); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/import_alias_declarations/import_alias_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/import_alias_declarations/import_alias_declarations_1.ts new file mode 100644 index 0000000000..41e5d6172e --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/import_alias_declarations/import_alias_declarations_1.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + import alias declarations are used to create local aliases for entities in other namespaces. + an EntityName consisting of a single identifier is resolved as a NamespaceName and is thus required to reference a namespace. The resulting local alias references the given namespace and is itself classified as a namespace. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +namespace hB { + interface hA { hn: number } + export import hY = hA; + import hZ = hA.hX; + export var vb: hZ = { hs: "v" }; +} +namespace hA { + export interface hX { hs: string } + export import va = hB.vb; +} +var v1: hB.hY.hX = hB.vb; +var v2 = hA.va; +let iadFlag: boolean = false; +if (v1 == v2) { + iadFlag = true; +} +Assert.isTrue(iadFlag); + diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/import_alias_declarations/import_alias_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/import_alias_declarations/import_alias_declarations_3.ts new file mode 100644 index 0000000000..dc177e8eaa --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/import_alias_declarations/import_alias_declarations_3.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + when an import statement includes an export modifier, all meanings of the local alias are exported. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../../suite/assert.js"; + +namespace IAD1 { + export var lv: number = 5; + export interface GGI { + UIName: string; + Cost: number; + } +} +namespace IAD2 { + import I1 = IAD1; + import I2 = IAD1.GGI; + export var i2 = I1.lv * 2; + export interface GI extends I2 { + Strength: number; + } +} +var i1 = IAD2.i2; +var gi: IAD2.GI = { UIName: "GI", Cost: 200, Strength: 100 }; +Assert.equal(i1, 10); +Assert.equal(gi.UIName, "GI"); +Assert.equal(gi.Cost, 200); +Assert.equal(gi.Strength, 100); + +namespace IAD3 { + export var i = 0; + interface U { + times: number; + } + var u1: U = { times: 5 }; + export function ux5() { + return u1.times * 5; + } +} +export namespace IAD4 { + export import I3 = IAD3; +} +Assert.equal(IAD4.I3.i, 0); +Assert.equal(IAD4.I3.ux5(), 25); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_body/namespace_body.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_body/namespace_body.ts new file mode 100644 index 0000000000..34ad1291b8 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_body/namespace_body.ts @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + the body of a namespace corresponds to a function that is executed once to initialize the namespace instance. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +namespace Example { + var namespace_name = "Example"; + export function exampleName(str: string): string { + return str + " " + namespace_name; + } + class Point { + x: number = 0; + y: number = 0; + } + interface PointXYZ { + x: number; + y: number; + z: number; + } + type StrNumBool = string | number | boolean; + export enum Color { + RED = 0xFF0000, + GREEN = 0x00FF00, + BLUE = 0x0000FF, + } + namespace SubNamespace { } + declare var __TEST__: boolean; + import EE = ExportExample; +} +namespace ExportExample { + export var namespace_name = "ExportExample"; + export function exampleEName(str: string): string { + return str + " " + namespace_name; + } + export class Point { + x: number = 0; + y: number = 0; + } + export interface PointXYZ { + x: number; + y: number; + z: number; + } + export type StrNumBool = string | number | boolean; + export enum Color { + RED = 0xFF0000, + GREEN = 0x00FF00, + BLUE = 0x0000FF, + } + export namespace SubNamespace { } + export declare var __TEST__: boolean; + export import E = Example; +} +Assert.equal(Example.exampleName("G"), "G Example"); +Assert.equal(Example.Color.RED, 0xFF0000); +Assert.equal(ExportExample.exampleEName("G"), "G ExportExample"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/specifying_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_1.ts similarity index 56% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/specifying_types_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_1.ts index 32e6a20d1f..47588be5e2 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/specifying_types_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_1.ts @@ -14,8 +14,8 @@ */ /**--- description: > - Types are specified either by referencing their keyword or name, or by writing object type literals, - array type literals, tuple type literals, function type literals, constructor type literals, or type queries. + namespaces are declared using the namespace keyword, + but for backward compatibility of earlier versions of TypeScript a module keyword can also be used. module: ESNext isCurrent: true ---*/ @@ -23,22 +23,22 @@ import { Assert } from '../../../../suite/assert.js' -let num: number = 5; -Assert.isNumber(num); - -let obj = { - name: 'xiao', - age: 18 +namespace A { + export interface TA { + TName: string; + Ver: number; + } } -Assert.equal(typeof obj, 'object'); - -let arr = [10, 5, 7, 20]; -Assert.equal(typeof arr, 'object'); - -let arr2 = ['str', 5, true]; -Assert.equal(typeof arr2, 'object'); +var varA: A.TA = { TName: "TA", Ver: 1.5 } +Assert.equal(varA.TName, "TA"); +Assert.equal(varA.Ver, 1.5); -let fun = (h_x: number, h_y: number) => { - return h_x + h_y +module B { + export interface TB { + SkillName: string; + Damage: number; + } } -Assert.equal(typeof fun, 'function'); \ No newline at end of file +var varB: B.TB = { SkillName: "OverKill", Damage: 1024 }; +Assert.equal(varB.SkillName, "OverKill"); +Assert.equal(varB.Damage, 1024); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_2.ts similarity index 39% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_2.ts index 1a66085107..eef814ca13 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_2.ts @@ -14,8 +14,8 @@ */ /**--- description: > - a union type U is a subtype of a type T if each type in U is a subtype of T. - a type T is a subtype of a union type U if T is a subtype of any type in U. + namespaces are either instantiated or non-instantiated. A non-instantiated namespace is a namespace containing only interface types, type aliases, and other non-instantiated namespace. + an instantiated namespace is a namespace that doesn't meet this definition. In intuitive terms, an instantiated namespace is one for which a namespace instance is created, whereas a non-instantiated namespace is one for which no code is generated. module: ESNext isCurrent: true ---*/ @@ -23,41 +23,30 @@ import { Assert } from '../../../../suite/assert.js' -class ClassT { - size: number = 0; - description: string = ''; -} -class ClassU1 extends ClassT { - alive: boolean = false; -} -class ClassU2 extends ClassT { - weight: number = 0; -} -interface InterfaceU1 { - speak(): string; -} -interface InterfaceU2 { - eat(): string; -} -class ClassT2 implements InterfaceU1, InterfaceU2 { - food: string = ''; - language: string = ''; - speak() { - return this.language; - } - eat() { - return this.food; - } - constructor(food: string, language: string) { - this.food = food; - this.language = language; +namespace NonInstantiated { + export interface A { + TName: string; + Ver: number; + } + export type TF = boolean | number; + export namespace NI { + export interface B { + SkillName: string; + Damage: number; } + export type StrNum = string | number; + } +} +var ni1: NonInstantiated.A = { TName: "Non", Ver: 1.0 }; +var ni2: NonInstantiated.NI.StrNum = "ni2"; +Assert.equal(ni1.Ver, 1.0); +Assert.equal(ni2, "ni2"); + +namespace Instantiated { + export function returnName() { + return "Instantiated"; + } + export var nsname: string = "Instantiated"; } -let u1: ClassU1 | ClassU2 = { size: 7, description: "A", alive: false }; -let t1: ClassT; -t1 = u1; -Assert.equal(JSON.stringify(t1), '{"size":7,"description":"A","alive":false}'); -let u2: InterfaceU1 | InterfaceU2; -let t2: ClassT2 = new ClassT2("rice", "Chinese"); -u2 = t2; -Assert.equal(JSON.stringify(u2), '{"food":"rice","language":"Chinese"}'); \ No newline at end of file +Assert.equal(Instantiated.returnName(), "Instantiated"); +Assert.equal(Instantiated.nsname, "Instantiated"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_3.ts new file mode 100644 index 0000000000..ba7781ad29 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_3.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + when a namespace identifier is referenced as a NamespaceName it denotes a container of namespace and type names, and when a namespace identifier is referenced as a PrimaryExpression it denotes the singleton namespace instance. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' + +namespace A { + export interface TypeA { + AName: string; + Lv: number; + UID: number; + } + export var player: TypeA = { AName: "Player", Lv: 5, UID: 0x0000A0F0 }; + export var playerRandom: TypeA = { AName: "playerRandom", Lv: getRandomNumber(99), UID: getRandomNumber(0xFFFFFFFF) }; + function getRandomNumber(x: number): number { + return Math.floor(Math.random() * x); + } +} +var playerA = A.player; +var playerB = A.playerRandom; +var an = A; +var playerC: A.TypeA = { AName: "PlayerC", Lv: 95, UID: 6250 }; +var playerD = an.player; +Assert.equal(playerA.AName, "Player"); +Assert.equal(playerA.Lv, 5); +Assert.equal(playerA.UID, 41200); +Assert.equal(playerB.AName, "playerRandom"); +Assert.isNumber(playerB.Lv); +Assert.isNumber(playerB.UID); +Assert.equal(playerC.AName, "PlayerC"); +Assert.equal(playerC.Lv, 95); +Assert.equal(playerC.UID, 6250); +Assert.equal(playerD.AName, "Player"); +Assert.equal(playerD.Lv, 5); +Assert.equal(playerD.UID, 41200); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_4.ts similarity index 54% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_4.ts index d9e10e8b06..c2c09e42be 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_aliases/type_aliases_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/namespaces/namespace_declarations/namespace_declarations_4.ts @@ -14,8 +14,7 @@ */ /**--- description: > - Type aliases are referenced using type references. - Type references to generic type aliases produce instantiations of the aliased type with the given type arguments. + a namespace declaration that specifies an IdentifierPath with more than one identifier is equivalent to a series of nested single-identifier namespace declarations where all but the outermost are automatically exported. module: ESNext isCurrent: true ---*/ @@ -23,24 +22,15 @@ import { Assert } from '../../../../suite/assert.js' -interface I { - h_x: T; - h_y: U; +namespace h_A.h_B.h_C { + export var h_x = "This is equivalent to the code below."; } -interface I2 { - h_y: T; - h_b: U; +Assert.equal(h_A.h_B.h_C.h_x, "This is equivalent to the code below."); +namespace h_A { + export namespace h_B { + export namespace h_C { + export var h_x = "This is equivalent to the code above."; + } + } } -type MyType = I | I2 -var mytest: MyType = { - h_x: 10, - h_y: 'y', - h_b: true -} -Assert.isString(mytest.h_y); - -type KeyOf = keyof T & keyof U; -let key1: KeyOf = 'toString'; -let key2: KeyOf = 'valueOf'; -Assert.equal(key1, 'toString'); -Assert.equal(key2, 'valueOf'); +Assert.equal(h_A.h_B.h_C.h_x, "This is equivalent to the code above."); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_00.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_00.ts new file mode 100644 index 0000000000..4c22da7bc1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_00.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +type Color = [number, number, number]; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_files_dependencies.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_files_dependencies.ts new file mode 100644 index 0000000000..257831a87f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/1_source_files_dependencies/source_files_dependencies.ts @@ -0,0 +1,28 @@ +/// +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The TypeScript compiler automatically determines a source file's dependencies and includes those dependencies in the program being compiled. + Any files included as dependencies in turn have their references analyzed in a transitive manner until all dependencies have been determined. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from "../../../../../suite/assert.js"; + +let red: Color = [255, 0, 0]; +Assert.equal(JSON.stringify(red), '[255,0,0]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_1.ts new file mode 100644 index 0000000000..9f6fb69cad --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_1.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export function message():string { + return 'string'; +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_10.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_10.ts new file mode 100644 index 0000000000..fafe386049 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_10.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export interface Point { x: number; y: number }; + +export function point(x: number, y: number): Point { + return { x, y }; +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_2.ts new file mode 100644 index 0000000000..512c7b88a0 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_2.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export let h_x: number = 0; +export let h_y: number = 1; +export let h_z: number = 2; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_3.ts new file mode 100644 index 0000000000..1f005b1ecb --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_3.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +let x:number = 0; +export default x; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_4.ts new file mode 100644 index 0000000000..15a51b3ab1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_4.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export default function message():string { + return 'string'; +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_5.ts new file mode 100644 index 0000000000..7bb278e263 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_5.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +function message():string { + return 'string'; +} + +export default message; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_6.ts new file mode 100644 index 0000000000..0ad23bd163 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_6.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +function message():string { + return 'string'; +} + +export { message as default }; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_7.ts new file mode 100644 index 0000000000..fab5d937f6 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_7.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +function message():string { + return 'string'; +} + +interface message { + x: number; + y: number; +} + + +export default message; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_8.ts new file mode 100644 index 0000000000..5f1327d564 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_8.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export default 'hello'; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_9.ts new file mode 100644 index 0000000000..899278f98f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/1_programs_and_source_files/source_9.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +class Point { + public x: number; + public y: number; + constructor(a: number, b: number) { + this.x = a; + this.y = b; + } +} +export default Point; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/2_modules/modules_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/2_modules/modules_1.ts new file mode 100644 index 0000000000..03406a4a93 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/2_modules/modules_1.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + An interface declaration declares an interface type. + An InterfaceDeclaration introduces a named type (section 3.7) in the containing declaration space. + The BindingIdentifier of an interface declaration may not be one of the predefined type names (section 3.8.1). + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import { message } from '../1_programs_and_source_files/source_1.js'; + +Assert.equal(message(), 'string'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_type/the_string_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_1.ts similarity index 67% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_type/the_string_type_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_1.ts index d74dc821f0..482d3537e4 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_type/the_string_type_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_1.ts @@ -14,14 +14,15 @@ */ /**--- description: > - The String primitive type corresponds to the similarly named JavaScript primitive type - and represents sequences of characters stored as Unicode UTF-16 code units. + Import declarations are used to import entities from other modules and provide bindings for them in the current module. module: ESNext isCurrent: true ---*/ -import { Assert } from '../../../../../suite/assert.js' +import { Assert } from '../../../../suite/assert.js' +import * as h_m from '../1_programs_and_source_files/source_2.js'; -let str: string = "\u4f60\u597d"; -Assert.equal(str, "你好"); \ No newline at end of file +Assert.equal(h_m.h_x, 0); +Assert.equal(h_m.h_y, 1); +Assert.equal(h_m.h_z, 2); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_2.ts new file mode 100644 index 0000000000..2fe3642b6b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_2.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + imports the module with the given name and creates a local binding for the module itself. The local binding is + classified as a value (representing the module instance) and a namespace (representing a container of types and + namespaces). + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import { h_x, h_y, h_z } from '../1_programs_and_source_files/source_2.js'; + +Assert.equal(h_x, 0); +Assert.equal(h_y, 1); +Assert.equal(h_z, 2); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_3.ts new file mode 100644 index 0000000000..b444779c3c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_3.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + imports a given module and creates local bindings for a specified list of exported members of the module. The specified + names must each reference an entity in the export member set (11.3.4.4) of the given module. The local bindings have t + he same names and classifications as the entities they represent unless as clauses are used to that specify different + local names. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import { h_x as a, h_y as b, h_z as c } from '../1_programs_and_source_files/source_2.js'; + +Assert.equal(a, 0); +Assert.equal(b, 1); +Assert.equal(c, 2); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_4.ts new file mode 100644 index 0000000000..11c402ebe2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/3_import_declarations/import_declarations_4.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + imports a given module and creates local bindings for a specified list of exported members of the module. The specified + names must each reference an entity in the export member set (11.3.4.4) of the given module. The local bindings have t + he same names and classifications as the entities they represent unless as clauses are used to that specify different + local names. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import x from '../1_programs_and_source_files/source_3.js'; +import { default as a } from '../1_programs_and_source_files/source_3.js'; + +Assert.equal(x, 0); +Assert.equal(a, 0); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/4_import_require_declarations/import_require_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/4_import_require_declarations/import_require_declarations_1.ts new file mode 100644 index 0000000000..574384e19f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/4_import_require_declarations/import_require_declarations_1.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Import require declarations exist for backward compatibility with earlier versions of TypeScript. + An import require declaration of the form + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import * as m from "../1_programs_and_source_files/source_2.js" + +Assert.equal(m.h_x, 0); +Assert.equal(m.h_y, 1); +Assert.equal(m.h_z, 2); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_1.ts new file mode 100644 index 0000000000..4cf7bf66f1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_1.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Export default declarations provide short-hand syntax for exporting an entity named default. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import message from '../1_programs_and_source_files/source_4.js'; + +Assert.equal(message(), 'string'); + diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_2.ts new file mode 100644 index 0000000000..88e2c6d8c2 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_2.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Export default declarations provide short-hand syntax for exporting an entity named default. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import message from '../1_programs_and_source_files/source_5.js'; + +Assert.equal(message(), 'string'); + diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_3.ts new file mode 100644 index 0000000000..fc93b8382d --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_3.ts @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Export default declarations provide short-hand syntax for exporting an entity named default. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import message from '../1_programs_and_source_files/source_6.js'; + +Assert.equal(message(), 'string'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_4.ts new file mode 100644 index 0000000000..aaa19b5480 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_4.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Export default declarations provide short-hand syntax for exporting an entity named default. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import message from '../1_programs_and_source_files/source_7.js'; + +Assert.equal(message(), 'string'); + diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_5.ts new file mode 100644 index 0000000000..c214a7f21f --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/5_export_declarations/export_declarations_5.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Export default declarations provide short-hand syntax for exporting an entity named default. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import message from '../1_programs_and_source_files/source_8.js'; + +Assert.equal(message, 'hello'); + diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/6_export_assignments/export_assignments_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/6_export_assignments/export_assignments_1.ts new file mode 100644 index 0000000000..c7b3dee269 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/6_export_assignments/export_assignments_1.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + Export assignments exist for backward compatibility with earlier versions of TypeScript. An export assignment + designates a module member as the entity to be exported in place of the module itself. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import Pt from '../1_programs_and_source_files/source_9.js'; + +let point = new Pt(10, 20); +Assert.equal(point.x, 10); +Assert.equal(point.y, 20); + diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_1.ts new file mode 100644 index 0000000000..c386db17ba --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_1.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A variable declaration and 'require' call is emitted for a particular imported module only if the imported module, or + a local alias that references the imported module, is referenced as a PrimaryExpression somewhere in the body of the + importing module. If an imported module is referenced only as a NamespaceName or TypeQueryExpression,nothing is emitted. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import * as g from '../1_programs_and_source_files/source_10.js'; + +let p = g.point(10, 20); +Assert.equal(p.x, 10); +Assert.equal(p.y, 20); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_2.ts new file mode 100644 index 0000000000..c6efd439a1 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/scripts_and_modules/7_commonJS_modules/commonJS_modules_2.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + A variable declaration and 'require' call is emitted for a particular imported module only if the imported module, or + a local alias that references the imported module, is referenced as a PrimaryExpression somewhere in the body of the + importing module. If an imported module is referenced only as a NamespaceName or TypeQueryExpression,nothing is emitted. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../suite/assert.js' +import * as g from '../1_programs_and_source_files/source_10.js'; + +let p: g.Point = { x: 10, y: 20 }; +Assert.equal(p.x, 10); +Assert.equal(p.y, 20); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_1.ts new file mode 100644 index 0000000000..9c29f77149 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_1.ts @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Expressions controlling 'if' statements can be of any type (and not just type Boolean). + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let a = true; + +if (a) { + a = false; +} + +Assert.isFalse(a); + +let b = "string b"; +if (b) { + b = "string b 2"; +} +Assert.equal("string b 2", b); + +let c = 1; +if (c) { + c = 2 +} +Assert.equal(2, c); + +var myObject = { + d: 4 +} +if (myObject) { + myObject.d = 5; +} +Assert.equal(5, myObject.d); + +let myObject2 = 1; +if (myObject2 == 2) { + myObject2 = 3; +} +Assert.equal(1, myObject2); + +let und: undefined; +let flag = false; +if (und) { + flag = true; +} else { + flag = false; +} +Assert.isFalse(flag); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_2.ts new file mode 100644 index 0000000000..b81710a25c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_2.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Expressions controlling 'Do' statements can be of any type (and not just type Boolean). + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +var num = 1; +do { + if (num % 5 == 0) { + + break; + } + num++; +} while (num); +Assert.equal(5, num); + +do { + num++; +} while (num < 100); + +Assert.equal(100, num); + + +var myObject = { + d: 1, +} +do { + if (myObject.d % 5 == 0) { + + break; + } + myObject.d++; +} while (myObject); +Assert.equal(5, myObject.d); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_3.ts similarity index 65% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_5.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_3.ts index 7452d54fd8..aa04e3ee81 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_5.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/If_do_and_while_Statements/if_do_and_while_Statements_3.ts @@ -13,24 +13,21 @@ * limitations under the License. */ /**--- - description: > - S is a subtype of a type T, and T is a supertype of S, - if S has no excess properties with respect to T, and S is an enum type and T is the primitive type Number. + description: Expressions controlling 'while' statements can be of any type (and not just type Boolean). module: ESNext isCurrent: true - ---*/ +---*/ -import { Assert } from '../../../../../suite/assert.js' +import { Assert } from '../../../../suite/assert.js' -var T: number = 4; -enum S { - Mon = 1, - Tue, - Wde, - Thur, - Fri +let arr: number[] = []; +let i = 0; +while (true) { + arr[i] = i * 2; + i++; + if (i >= 10) { + break; + } } - -T = S.Mon; -Assert.equal(T, S.Mon); \ No newline at end of file +Assert.equal(JSON.stringify(arr), '[0,2,4,6,8,10,12,14,16,18]'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_1.ts new file mode 100644 index 0000000000..2139e475db --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_1.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Blocks are extended to include, local interface + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +interface BlocksInterface { + name: string; +} +class MyBlocks implements BlocksInterface { + name: string; + + constructor(name: string) { + this.name = name; + } + + public getName() { + return this.name; + } + +} +var myBlocks = new MyBlocks("Open Harmony"); + +Assert.equal("Open Harmony", myBlocks.getName()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_2.ts new file mode 100644 index 0000000000..3f5e8ed75b --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_2.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Blocks are extended to include, type alias + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +type Parent = { + name: string; +}; + +type Child = Parent & { + age: number +}; + + +const child: Child = { name: "name", age: 10 }; + +Assert.equal("name", child.name) +Assert.equal(10, child.age); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_3.ts new file mode 100644 index 0000000000..803c7cab14 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_3.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Blocks are extended to include, enum + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +enum Direction { + Forward, + Back, + Left, + Right, +} + +class Car { + name!: string; + direction!: Direction; +} + +const car = new Car(); +car.name = "myCar"; +car.direction = Direction.Forward; + +Assert.equal("myCar", car.name) +Assert.equal(Direction.Forward, car.direction); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_4.ts new file mode 100644 index 0000000000..a884aa1e6c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/blocks/blocks_4.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Blocks {} + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +{ + var block1: number | undefined = 1024; + let block2: string | undefined = "NARC"; + Assert.equal(block1, 1024); + Assert.equal(block2, "NARC"); +} +{ + var block1: number | undefined; + let block2: string | undefined; + Assert.equal(block1, 1024); + Assert.isUndefined(block2); +} \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/break_statements/break_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/break_statements/break_statements.ts new file mode 100644 index 0000000000..e9b559590c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/break_statements/break_statements.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: A 'break' statement is required to be nested, directly or indirectly (but not crossing function boundaries), within an iteration ('do', 'while', 'for', or 'for-in') or 'switch' statement. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let num: number = 0; +let count: number = 0; +do { + num++; + if (num >= 5) { + break; + } +} while (num < 10); +Assert.equal(5, num); + + +num = 0; +for (num = 0; num <= 20; num++) { + if (num >= 5) { + break; + } +} +Assert.equal(5, num); + +let arr = [0, 1, 2, 3, 4, 5]; +for (let index in arr) { + if (arr[index] >= 2) { + break; + } + count++; +} +Assert.equal(2, count); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/continue_statements/continue_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/continue_statements/continue_statements.ts new file mode 100644 index 0000000000..95dc3b4011 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/continue_statements/continue_statements.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: A 'continue' statement is required to be nested, directly or indirectly (but not crossing function boundaries), within an iteration ('do', 'while', 'for', or 'for-in') statement. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let num: number = 0; +let count: number = 0; +do { + num++; + if (num % 2 == 0) { + continue; + } + count++; +} while (num < 10); +Assert.equal(5, count); + + +num = 0; +count = 0; +for (num = 0; num <= 20; num++) { + if (num % 2 == 0) { + continue; + } + count++; +} +Assert.equal(10, count); + +count = 0; +let arr = [0, 1, 2, 3, 4, 5]; +for (let index in arr) { + if (arr[index] % 2 == 0) { + continue; + } + count++; +} +Assert.equal(3, count); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_in_statements/for_in_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_in_statements/for_in_statements.ts new file mode 100644 index 0000000000..45124ed810 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_in_statements/for_in_statements.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: test for (v in expr) statement + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let arr = [4, 5, 6]; + +let i = 0; +for (let index in arr) { + i++; +} +Assert.equal(3, i); + +const person = { + name: "opharmony", + role: "tools", + age: 3, +}; + +i = 0; +for (const key in person) { + i++; +} +Assert.equal(3, i); + +interface ABC { + a: number + b: string +} + +const x: ABC = { + a: 1, + b: '2' +} + +i = 0; +for (let key in x) { + i++; +} +Assert.equal(2, i); + +i = 0; +for (var key in x) { + i++; +} +Assert.equal(2, i); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_of_statements/for_of_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_of_statements/for_of_statements.ts new file mode 100644 index 0000000000..774a0bd61a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_of_statements/for_of_statements.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: test for (v of expr) statement + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let count = 0; +for (let word of ["one", "two", "three"]) { + count++; +} +Assert.equal(3, count); + +count = 0; +let s = [0, 1, 2, 3, 4]; +for (let value of s) { + count++; +} +Assert.equal(5, count); + +count = 0; +let blogName: string = "openHarmony"; +for (let character of blogName) { + count++; +} +Assert.equal(11, count); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_statements/for_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_statements/for_statements.ts new file mode 100644 index 0000000000..288bf5c529 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/for_statements/for_statements.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Variable declarations in 'for' statements are extended in the same manner as variable declarations in variable statements + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let result = 0; +for (let i: number = 0; i < 10; i++) { + result++; +} +Assert.equal(10, result); + +let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]; +for (let i: number = 0; i < arr.length; i++) arr[i] = 0; +Assert.equal(JSON.stringify(arr), '[0,0,0,0,0,0,0,0,0]'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/let_and_const_declarations/let_and_const_declarations.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/let_and_const_declarations/let_and_const_declarations.ts new file mode 100644 index 0000000000..82a9d8a39a --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/let_and_const_declarations/let_and_const_declarations.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: Let and Const Declarations + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +let a = 1; +Assert.equal(1, a); + +a = 2; +Assert.equal(2, a); + +const num = 9; +Assert.equal(9, num); + +const myname = 'openharmony'; +Assert.equal('openharmony', myname); + +const myBoolean = true; +Assert.isTrue(myBoolean); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/tuple_types/tuple_types_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/return_statements/return_statements.ts similarity index 64% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/tuple_types/tuple_types_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/return_statements/return_statements.ts index 333748d2aa..015db368af 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/tuple_types/tuple_types_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/return_statements/return_statements.ts @@ -13,20 +13,26 @@ * limitations under the License. */ /**--- - description: > - Named tuple types can be created by declaring interfaces that derive from Array - and introduce numerically named properties + description: Return Statements module: ESNext isCurrent: true ---*/ -import { Assert } from '../../../../../suite/assert.js' +import { Assert } from '../../../../suite/assert.js' -interface tt extends Array { - 0: K; - 1: V; +function h_f(): (h_x: string) => number { + return h_s => h_s.length; } -let x: tt = [10, "ten"]; -Assert.equal(x[0], 10); -Assert.equal(x[1], "ten"); \ No newline at end of file + +Assert.equal(11, h_f()("openharmony")); + +function testReruen() { + for (let i = 0; i < 10; i++) { + + if (i == 5) { + return i; + } + } +} +Assert.equal(5, testReruen()); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/switch_statements/switch_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/switch_statements/switch_statements.ts new file mode 100644 index 0000000000..5cd194a4b5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/switch_statements/switch_statements.ts @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from (section 3.11.4) the type of the 'switch' expression + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function testSwitch(inputVar: number) { + let outputVar: string; + switch (inputVar) { + case 1: + outputVar = 'a'; + break; + case 2: + outputVar = 'b'; + break; + case 3: + outputVar = 'c'; + break; + case 4: + outputVar = 'd'; + break; + default: + outputVar = 'e'; + break; + } + return outputVar; +} + +Assert.equal("a", testSwitch(1)); +Assert.equal("b", testSwitch(2)); +Assert.equal("c", testSwitch(3)); +Assert.equal("d", testSwitch(4)); +Assert.equal("e", testSwitch(5)); + +function testSwitchExpression(x: number, y: number) { + let outputVar: string; + switch (x + y) { + case 0: + outputVar = 'a'; + break; + case 5: + outputVar = 'b'; + break; + case 10: + outputVar = 'c'; + break; + + default: + outputVar = 'd'; + } + return outputVar; +} + +Assert.equal("a", testSwitchExpression(-1, 1)); +Assert.equal("b", testSwitchExpression(1, 4)); +Assert.equal("c", testSwitchExpression(5, 5)); +Assert.equal("d", testSwitchExpression(8, 10)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/throw_statements/throw_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/throw_statements/throw_statements.ts new file mode 100644 index 0000000000..8af0522974 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/throw_statements/throw_statements.ts @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The expression specified in a 'throw' statement can be of any type. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +function testThrow(inputVar: number) { + let outputVar: string; + if (inputVar == 1) { + throw 100; + } + + if (inputVar == 2) { + throw 'a'; + } + + if (inputVar == 3) { + throw true; + } + + if (inputVar == 4) { + throw new Error('Something bad happened'); + } +} + +try { + testThrow(1); +} catch (error) { + Assert.equal(100, error); +} + +try { + testThrow(2); +} catch (error) { + Assert.equal('a', error); +} + +try { + testThrow(3); +} catch (error) { + Assert.isTrue(error); +} + +try { + testThrow(4); +} catch (error: any) { + Assert.equal('Something bad happened', error.message); +} + +try { + testThrow(4); +} catch (error) { + Assert.isTrue(error instanceof Error); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/try_statements/try_statements.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/try_statements/try_statements.ts new file mode 100644 index 0000000000..7b1e992e7c --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/try_statements/try_statements.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: The variable introduced by a 'catch' clause of a 'try' statement is always of type Any. It is not possible to include a type annotation in a 'catch' clause. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../suite/assert.js' + +try { + new Array(100000000000000000000); +} +catch (err) { + Assert.isTrue(err instanceof RangeError); +} + +try { + let a: any; + let b = a.name; +} +catch (err) { + Assert.isTrue(err instanceof TypeError); +} + +try { + decodeURI('%'); +} +catch (err) { + Assert.isTrue(err instanceof URIError); +}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_1.ts similarity index 48% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_3.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_1.ts index 1ac5683c06..8eae01c6f4 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_3.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_1.ts @@ -14,33 +14,51 @@ */ /**--- description: > - Class, interface, type alias, and function declarations may optionally include - lists of type parameters enclosed in < and > brackets. + The type T of a variable introduced by a simple variable declaration is determined as follows: + If the declaration includes a type annotation, T is that type. + Otherwise, if the declaration includes an initializer expression, T is the widened form (section 3.12) of the type of the initializer expression. + Otherwise, T is the Any type. module: ESNext isCurrent: true - ---*/ +---*/ import { Assert } from '../../../../../suite/assert.js' -class Person { - name: string; - age: number; - job: string; - constructor(name: string, age: number, job: string) { - this.name = name; - this.age = age; - this.job = job; - } +var h_a; + +var h_b: number; + +var h_c = 30; + +var h_d = { x: 40, y: "hello" }; + +var h_e: any = "test"; +h_a = 1; +Assert.equal(1, h_a); + +h_a = '111'; +Assert.equal('111', h_a); + +h_b = 20; +Assert.equal(20, h_b); + +Assert.equal(30, h_c); + +Assert.equal(40, h_d.x); +Assert.equal("hello", h_d.y); + +var h_x = 50; +Assert.equal(50, h_x); +var h_x: number; +Assert.equal(50, h_x); +if (h_x == 50) { + var h_x = 100; + Assert.equal(100, h_x); + + h_x = 200; + + Assert.equal(200, h_x); } -type optionallyTest = { - [P in keyof T]?: T[P]; -}; -let x: optionallyTest = {}; -x = { name: "dog" }; -Assert.isUndefined(x.job); -Assert.isUndefined(x.age); -x = { name: "dog", age: 18 }; -Assert.isUndefined(x.job); -x = { name: "dog", age: 18, job: "teacher" }; \ No newline at end of file +Assert.equal(200, h_x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_2.ts new file mode 100644 index 0000000000..a9501014d5 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_2.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The type T of a variable introduced by a simple variable declaration is determined as follows: + If the declaration includes a type annotation, T is that type. + Otherwise, if the declaration includes an initializer expression, T is the widened form (section 3.12) of the type of the initializer expression. + Otherwise, T is the Any type. + module: ESNext + isCurrent: true + ---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface Point { h_x: number; h_y: number; } + +var h_a = { h_x: 0, h_y: 1 }; +var h_b: Point = { h_x: 10, h_y: 11 }; +var h_c = { h_x: 100, h_y: 111 }; +var h_d: { h_x: number; h_y: number; } = { h_x: 1000, h_y: 1001 }; +var h_e = <{ h_x: number; h_y: number; }>{ h_x: 10000, h_y: 10001 }; + +Assert.equal(0, h_a.h_x); +Assert.equal(1, h_a.h_y); + +Assert.equal(10, h_b.h_x); +Assert.equal(11, h_b.h_y); + +Assert.equal(100, h_c.h_x); +Assert.equal(111, h_c.h_y); + +Assert.equal(1000, h_d.h_x); +Assert.equal(1001, h_d.h_y); + +Assert.equal(10000, h_e.h_x); +Assert.equal(10001, h_e.h_y); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_3.ts similarity index 75% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_2.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_3.ts index 89495faeb2..7ca8929aa8 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_2.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/1_simple_variable_declarations/simple_variable_declarations_3.ts @@ -14,7 +14,8 @@ */ /**--- description: > - the only possible values for the Void type are null and undefined. + Multiple declarations for the same variable name in the same declaration space are permitted, + provided that each declaration associates the same type with the variable. module: ESNext isCurrent: true ---*/ @@ -22,10 +23,6 @@ import { Assert } from '../../../../../suite/assert.js' -let v: void; -Assert.equal(v, undefined); -let v2: void = undefined; -Assert.equal(v2, undefined); -let u: undefined = undefined; -v = u; -Assert.equal(v, undefined); \ No newline at end of file +var h_a: number = 10; +var h_a: number = 20; +Assert.equal(h_a, 20); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_1.ts similarity index 56% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_4.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_1.ts index 45fb780724..1d676f3b08 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_4.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_1.ts @@ -13,35 +13,29 @@ * limitations under the License. */ /**--- - description: > - S is a subtype of a type T, and T is a supertype of S, - if S has no excess properties with respect to T, and S is the Null type and T is not the Undefined type. + description: A destructuring variable declaration introduces zero or more named variables and initializes them with values extracted from properties of an object module: ESNext isCurrent: true - ---*/ +---*/ import { Assert } from '../../../../../suite/assert.js' -interface T { - name: any - age: any +var object_name = { + key1: "value1", + key2: "value2", + key3: ["content1", "content2"], + key4: true, + key5: undefined } -interface S { - name: null - age: null - hobbies: null -} -let t: T = { - name: "T", - age: 20 -}; -let s: S = { - name: null, - age: null, - hobbies: null -}; +var { key1, key2: y, key3, key4: z = false, key5: k = true } = object_name; + +Assert.equal("value1", key1); +Assert.equal("value2", y); +Assert.equal("content1", key3[0]); +Assert.equal("content2", key3[1]); +Assert.isTrue(z); +Assert.isTrue(k); + -t = s; -Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_2.ts new file mode 100644 index 0000000000..79e1b11698 --- /dev/null +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_2.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**--- + description: > + The type T associated with a destructuring variable declaration is determined as follows: + If the declaration includes a type annotation, T is that type. + Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. + Otherwise, T is the Any type. + module: ESNext + isCurrent: true +---*/ + + +import { Assert } from '../../../../../suite/assert.js' + +interface IPerson { + myname: string, + myage: number, +} + +var customer: IPerson = { + myname: "Tom", + myage: 10, +} +let { myname, myage } = customer; + +Assert.isString(myname); +Assert.isNumber(myage) + + +let o = { + a: "foo", + b: 12, + c: "bar" +}; +let { a: newName1 } = o; +Assert.isString(newName1); +var ohArray: number[] = [10, 20, 30]; + +var [x, y, z = 10, k = 10] = ohArray; +Assert.equal(10, x); +Assert.equal(20, y); +Assert.equal(30, z); +Assert.equal(10, k); + diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/constructor_type_literals/constructor_type_literals.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_3.ts similarity index 37% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/constructor_type_literals/constructor_type_literals.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_3.ts index a7841149ff..ec75bc8e66 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/constructor_type_literals/constructor_type_literals.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/2_destructuring_variable_declarations/destructuring_variable_declarations_3.ts @@ -14,65 +14,39 @@ */ /**--- description: > - A constructor type literal specifies the type parameters, regular parameters, and return type of a construct signature. + The type T associated with a binding property is determined as follows: + Let S be the type associated with the immediately containing destructuring variable declaration, binding property, or binding element. + If S is the Any type: + If the binding property specifies an initializer expression, T is the type of that initializer expression. + Otherwise, T is the Any type. + Let P be the property name specified in the binding property. + If S has an apparent property with the name P, T is the type of that property. + Otherwise, if S has a numeric index signature and P is a numerical name, T is the type of the numeric index signature. + Otherwise, if S has a string index signature, T is the type of the string index signature. + Otherwise, no type is associated with the binding property and an error occurs. module: ESNext isCurrent: true - ---*/ +---*/ import { Assert } from '../../../../../suite/assert.js' -interface I1 { - x: number; - y: number; +var object_name = { + key1: "value1", + key2: "value2", + key3: ["content1", "content2"], + key4: true, + key5: undefined } -interface Constructor { - new(x: number, y: number): I1; -} -class I2 implements I1 { - readonly x: number; - readonly y: number; - constructor(x: number, y: number) { - this.x = x; - this.y = y; - } -} -function fun1( - cons: Constructor, - x: number, - y: number -): I1 { - return new cons(x, y); -} -let x1: I1 = fun1(I2, 2, 2) -Assert.equal(x1.x, 2); -Assert.equal(x1.y, 2); +var ohArray: number[] = [10, 20, 30]; -interface F1 { - x: T; - y: U; -} -interface ConstructorF { - new(x: T, y: U): F1; -} -class F2 implements F1 { - readonly x: T; - readonly y: U; +var { key1, key3: [y, z = 10, k = 10] = ohArray, key5: [a, b] = ohArray } = object_name; - constructor(x: T, y: U) { - this.x = x; - this.y = y; - } -} -function fun2( - cons: ConstructorF, - x: T, - y: U -): F1 { - return new cons(x, y); -} -let f1: F1 = fun2(F2, 1, true); -Assert.equal(f1.x, 1); -Assert.equal(f1.y, true); \ No newline at end of file +Assert.equal("value1", key1); +Assert.equal("content1", y); +Assert.equal("content2", z); +Assert.equal(10, k); +Assert.equal(10, a); +Assert.equal(20, b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/3_implied_type/implied_type.ts similarity index 44% rename from es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_1.ts rename to es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/3_implied_type/implied_type.ts index 7250fab342..13157d9199 100644 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_1.ts +++ b/es2panda/test/ts_extra_tests/test_ts_cases/spec/statements/variable_statements/3_implied_type/implied_type.ts @@ -13,45 +13,44 @@ * limitations under the License. */ /**--- - description: > - The Boolean primitive type corresponds to the similarly - named JavaScript primitive type and represents logical values that are either true or false. + description: A variable, parameter, binding property, or binding element declaration that specifies a binding pattern has an implied type which is determined module: ESNext isCurrent: true - ---*/ +---*/ import { Assert } from '../../../../../suite/assert.js' -function test1(): number { - return 0; +var object_name = { + key1: "value1" } -function test2(): number { - return 1; -} -function test3(): number { - return 1; -} -function test4(i: number): number { - return i; -} -let a: boolean = true; -Assert.equal(a, true); -let b: boolean = false; -Assert.equal(b, false); -let c: number = a ? 0 : 1; -Assert.equal(c, 0); -c = b ? 0 : 1; -Assert.equal(c, 1); -if (a) { - Assert.equal(test1(), 0); -} else { - Assert.equal(test2(), 1); + +function f({ aa = {}, b = "hello", c = 3, d = object_name }) { + Assert.equal("object", typeof (aa)); + Assert.equal("string", typeof (b)); + Assert.equal("number", typeof (c)); + Assert.equal("object", typeof (d)); } -while (a) { - Assert.equal(test3(), 1); - break; + +var objectFun = { + a: [1, 2], + b: "2", + c: 3, + d: object_name +}; +f(objectFun); + +var [a1, b1, c1, d1] = [1, "hello", true, object_name]; + +Assert.equal("number", typeof (a1)); +Assert.equal("string", typeof (b1)); +Assert.equal("boolean", typeof (c1)); +Assert.equal("object", typeof (d1)); + +function testRest(...restElements: any[]): any { + Assert.isTrue(restElements.length > 0); + return restElements[0]; } -for (let i = 0; a && i < 5; i++) { - Assert.equal(test4(i), i); -}; \ No newline at end of file + +Assert.isString(testRest("str", "str2")); +Assert.isNumber(testRest(1, 2)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_1.ts deleted file mode 100644 index b950b0e7b3..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/array_types/array_types_1.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - array types represent JavaScript arrays with a common element type. - array types are named type references created from the generic interface type 'Array' in the global namespace with the array element type as a type argument. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let arr1: Array = ["ABC", "DEF", "GHI"]; -let arr2: Array = [1, 3, 5, 7, 9]; -let arr3: Array = [true, false]; -let arr4: Array = [Object, { 0xff: "0xFF" }]; -Assert.equal(arr1[0], "ABC"); -Assert.equal(arr2[0], 1); -Assert.equal(arr3[0], true); -Assert.equal(arr4[0], Object); -let objArray: object[] = []; -arr1.forEach(function (element, index, arr) { - objArray[index] = { index: index, element: element, arr: arr }; -}); -Assert.equal(arr2.toString(), "1,3,5,7,9"); -Assert.equal(arr3.length, 2); -Assert.equal(arr2.pop(), 9); -Assert.equal(arr2.toString(), "1,3,5,7"); -arr3[0] = false; -Assert.equal(arr3[0], false); -interface ArrayNumber { - [x: number]: number; -} -let arr5: ArrayNumber = arr2; -Assert.equal(arr5[0], 1); -Assert.equal(arr5[1], 3); -class ArrayString { - [x: number]: string; -} -let arr6: ArrayString = arr1; -Assert.equal(arr6[0], "ABC"); -Assert.equal(arr6[1], "DEF"); -type ArrayType = { - [x: number]: number; -} -let arr7: ArrayType = [1, 2, 3]; -Assert.equal(arr7[0], 1); -Assert.equal(arr7[1], 2); -let arr8: Object[]; -arr8 = [ - 111, - true, - "aaa" -]; -Assert.equal(arr8[0], 111); -Assert.equal(arr8[1], true); -Assert.equal(arr8[2], "aaa"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/function_types/function_types_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/function_types/function_types_1.ts deleted file mode 100644 index 6c2b213317..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/object_types/function_types/function_types_1.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - an object type containing one or more call signatures is said to be a function type. - function types may be written using function type literals or by including call signatures in object type literals. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let fun1: (num1: number, num2: number) => number = ( - num1: number, - num2: number -) => { - return num1 + num2; -}; -Assert.equal(fun1(3, 5), 8); -let fun2: { (num1: number, num2: number, num3: number): number } = ( - num1: number, - num2: number, - num3: number -) => { - return num1 + num2 + num3; -}; -Assert.equal(fun2(1, 3, 5), 9); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_2.ts deleted file mode 100644 index bac6e838d6..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_boolean_type/the_boolean_type_2.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The boolean keyword references the Boolean primitive - type and the true and false literals reference the two Boolean truth values. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let a: boolean = true; -Assert.isBoolean(a); -Assert.equal(a, true); -a = false; -Assert.isBoolean(a); -Assert.equal(a, false); - -let b: boolean = 2 > 1; -Assert.isBoolean(b); -Assert.equal(b, true); -b = !b; -Assert.isBoolean(b); -Assert.equal(b, false); - -let c: boolean = 2 > 1 && 7 < 8; -Assert.isBoolean(c); -Assert.equal(c, true); -c = 2 < 1 && 7 < 8; -Assert.isBoolean(c); -Assert.equal(c, false); - -c = 2 > 1 || 7 < 8; -Assert.isBoolean(c); -Assert.equal(c, true); -c = 2 < 1 || 7 > 8; -Assert.isBoolean(c); -Assert.equal(c, false); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_enum_type/the_enum_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_enum_type/the_enum_type_1.ts deleted file mode 100644 index bdac5a3c60..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_enum_type/the_enum_type_1.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: Enum types are distinct user defined subtypes of the Number primitive type and vice versa - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -enum Color { - Red, - Green, - Blue, - Black, -} -let cc: Color = Color.Blue; -Assert.equal(cc, 2); -let ee: Color = Color.Blue; -let dd: number = cc; -Assert.equal(dd, Color.Blue); -dd = 15; -ee = dd; -Assert.equal(ee, 15); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_null_type/the_null_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_null_type/the_null_type_1.ts deleted file mode 100644 index 11de69e57b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_null_type/the_null_type_1.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The Null type corresponds to the similarly named JavaScript primitive type and is the type of the null literal. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let n: null = null; -let flag = false; -if (n == null) { - flag = true; -} -Assert.equal(flag, true); -let x1: any = null; -Assert.equal(x1, null); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_1.ts deleted file mode 100644 index 7581d7f67e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_1.ts +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Test "Number primitive type corresponds to the similarly named JavaScript primitive type - and represents double-precision 64-bit format IEEE 754 floating point values." - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let x1: number; -let x2: number; -let x3: number; -x1 = 0.1; -x2 = 0.2; -x3 = 0.3; -Assert.notEqual(x1 + x2, 0.3); -x2 = 0.7; -Assert.notEqual(x1 + x2, 0.8); -x1 = 0.2; -x2 = 0.4; -Assert.notEqual(x1 + x2, 0.6); -x1 = 1.5; -x2 = 1.2; -Assert.notEqual(x1 - x2, 0.3); -x1 = 0.3; -x2 = 0.2; -Assert.notEqual(x1 - x2, 0.1); -x1 = 19.9; -x2 = 100; -Assert.notEqual(x1 * x2, 1990); -x1 = 0.8; -x2 = 3; -Assert.notEqual(x1 * x2, 2.4); -x1 = 35.41; -x2 = 100; -Assert.notEqual(x1 * x2, 3541); -x1 = 0.3; -x2 = 0.1; -Assert.notEqual(x1 / x2, 3); -x1 = 0.69; -x2 = 10; -Assert.notEqual(x1 / x2, 0.069); -Assert.equal((1.335).toFixed(2), 1.33); -Assert.equal((1.3335).toFixed(3), 1.333); -Assert.equal((1.33335).toFixed(4), 1.3334); -Assert.equal((1.333335).toFixed(5), 1.33333); -Assert.equal((1.3333335).toFixed(6), 1.333333); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_2.ts deleted file mode 100644 index 7db2d38356..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_2.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The number keyword references the Number primitive type and numeric literals may be used to write values of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - - -let n1: number = 1; -Assert.isNumber(n1); -Assert.equal(n1, 1); -n1 = 2; -Assert.isNumber(n1); -Assert.equal(n1, 2); -let n2: number = 1.51; -Assert.isNumber(n2); -Assert.equal(n2, 1.51); -n2 = 3.53; -Assert.isNumber(n2); -Assert.equal(n2, 3.53); -let n3: number = 0b1011; -Assert.isNumber(n3); -Assert.equal(n3, 0b1011); -n3 = 0b1111; -Assert.isNumber(n3); -Assert.equal(n3, 0b1111); -let n4: number = 0o17; -Assert.isNumber(n4); -Assert.equal(n4, 0o17); -n4 = 0o24; -Assert.isNumber(n4); -Assert.equal(n4, 0o24); -let n5: number = 0xf00d; -Assert.isNumber(n5); -Assert.equal(n5, 0xf00d); -n5 = 0xf01c; -Assert.isNumber(n5); -Assert.equal(n5, 0xf01c); -let n6: 1 | 2 = 1; -let n7: number; -n7 = n6; -Assert.equal(n7, 1); -n6 = 2; -n7 = n6; -Assert.equal(n7, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_3.ts deleted file mode 100644 index a4bfd74f7a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_number_type/the_number_type_3.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: the Number primitive type behaves as an object type with the same properties as the global interface type 'Number'. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let h_z = 123.456; -let s = h_z.toFixed(2); -Assert.equal(s, 123.46); -let a = h_z.toString(); -Assert.equal(a, "123.456"); -let b = h_z.toExponential(); -Assert.equal(b, "1.23456e+2"); -b = h_z.toExponential(2); -Assert.equal(b, "1.23e+2"); -let c = h_z.toPrecision(); -Assert.equal(c, "123.456"); -c = h_z.toPrecision(3); -Assert.equal(c, "123"); -let d = h_z.valueOf(); -Assert.equal(d, 123.456); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_1.ts deleted file mode 100644 index 96d9da95e0..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_literal_type/the_string_literal_type_1.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - All string literal types are subtypes of the String primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let cc: "hello" = "hello"; -Assert.isString(cc); -let dd: string = cc; -Assert.equal(dd, "hello"); -let ee: "" = ""; -Assert.isString(ee); -let ff: string = ee; -Assert.equal(ff, ""); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_type/the_string_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_type/the_string_type_3.ts deleted file mode 100644 index dd0e5f903e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_string_type/the_string_type_3.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the String primitive type behaves as an object type - with the same properties as the global interface type 'String'. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let str: string = "string"; -Assert.equal(str.charAt(1), "t"); -Assert.equal(str.charCodeAt(2), 114); -Assert.equal(str.toString(), 'string'); -Assert.equal(str.concat("new"), "stringnew"); -str = "cbaabcda"; -Assert.equal(str.indexOf("a"), 2); -Assert.equal(str.indexOf("a", 4), 7); -Assert.equal(str.lastIndexOf("b"), 4); -Assert.equal(str.lastIndexOf("b", 2), 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_symbol_type/the_symbol_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_symbol_type/the_symbol_type_2.ts deleted file mode 100644 index fd46477d62..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_symbol_type/the_symbol_type_2.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The symbol keyword references the Symbol primitive type. - Symbol values are obtained using the global object 'Symbol' which has a number of methods and properties and can be invoked as a function. - options: - lib: es2019 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let sym: symbol = Symbol("NARC"); -let sym2: symbol = Symbol("TypeScript"); -Assert.equal(sym.description, "NARC"); -let s1: string = sym2.toString(); -let s2: symbol = sym.valueOf(); -Assert.equal(s1, "Symbol(TypeScript)"); -let flag1: boolean = false; -if (sym != sym2) { - flag1 = true; -} -Assert.isTrue(flag1); -let flag2: boolean = false; -if (sym == s2) { - flag2 = true; -} -Assert.isTrue(flag2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_symbol_type/the_symbol_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_symbol_type/the_symbol_type_3.ts deleted file mode 100644 index 24b14a5b4b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_symbol_type/the_symbol_type_3.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The Symbol primitive type behaves as an object type with the same properties as the global interface type 'Symbol'. - options: - lib: es2015 - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let x: symbol = Symbol(); -let y: any = {}; -y[x] = "primitive type"; -Assert.equal(y[x], "primitive type"); -y[Symbol.toStringTag] = "project"; -Assert.equal(y[Symbol.toStringTag], "project"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_undefined_type/the_undefined_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_undefined_type/the_undefined_type_1.ts deleted file mode 100644 index b3b814bdc1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_undefined_type/the_undefined_type_1.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The Undefined type corresponds to the similarly named JavaScript primitive type and is the type of the undefined literal. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let u: undefined = undefined; -Assert.equal(u, undefined); -interface I2 { - s: number; -} -interface I { - a: number; - b?: string; - c?: number; - d?: object; - e?: string | number; - f?: I2; - g?: string & number; -} -let x: I = { a: 1 }; -Assert.isUndefined(x.b); -Assert.isUndefined(x.c); -Assert.isUndefined(x.d); -Assert.isUndefined(x.e); -Assert.isUndefined(x.f); -Assert.isUndefined(x.g); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_1.ts deleted file mode 100644 index 2cf13d6f14..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_1.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the Void type, referenced by the void keyword, - represents the absence of a value and is used as the return type of functions with no return value. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let v: void = undefined; -function noReturn(): void { } -Assert.equal(v, undefined); -Assert.equal(noReturn(), undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_3.ts deleted file mode 100644 index 4e90b5298b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/primitive_types/the_void_type/the_void_type_3.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the Void type is a subtype of the any type and a supertype of the null and undefined types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let v: void; -let u: undefined = undefined; -let a: any; -a = v; -Assert.equal(a, undefined); -v = u; -Assert.equal(v, undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_4.ts deleted file mode 100644 index 6c64838374..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_4.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - if the declaration specifies a binding pattern, - the parameter type is the implied type of that binding pattern. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -const x: number = 3; -function fun(a: number, c = 1, b = x) { - return a + c + b; -} -let y = 1; -Assert.equal(y, 1); -let z = fun(y); -Assert.equal(z, 5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_5.ts deleted file mode 100644 index e3f047c52a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_5.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - if the parameter is a rest parameter, the parameter type is any[]. - A type annotation for a rest parameter must denote an array type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -function restFun(first: any, ...restname: any[]) { - return first + " " + restname.join(" "); -} -let restname1 = restFun("aa", "bb", "cc"); -Assert.equal(restname1, "aa bb cc"); -let restname2 = restFun(1, 2, 3, 4); -Assert.equal(restname2, "1 2 3 4"); -let restname3 = restFun(true, false, true); -Assert.equal(restname3, "true false true"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_6.ts deleted file mode 100644 index f83717453c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/parameter_list/parameter_list_6.ts +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A parameter is permitted to include a public, private, - or protected modifier only if it occurs in the parameter list of a ConstructorImplementation (section 8.3.1) - and only if it doesn't specify a BindingPattern. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -class Person { - public name: string; - private age: number; - protected sex: string; - constructor(name: string, age: number, sex: string) { - this.name = name; - this.age = age; - this.sex = sex; - } - get _age() { - return this.age; - } - set _age(value) { - if (value >= 0) { - this.age = value; - } - } -} -class Child extends Person { - f() { - if (this.sex === "man") { - this.sex = "male"; - } else { - this.sex = "female"; - } - } -} -let a = new Child("wangwu", 15, "man"); -a.name = "lisi"; -a._age = 19; -Assert.equal(a.name, "lisi"); -Assert.equal(a._age, 19); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/return_type/return_type_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/return_type/return_type_1.ts deleted file mode 100644 index d3949692a8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/return_type/return_type_1.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - a call signature's return type annotation specifies the type of the value computed and returned by a call operation. - A void return type annotation is used to indicate that a function has no return value. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -function returnNum(a: number, b: number): number { - return a + b; -} -let aa = returnNum(1, 2); -Assert.equal(aa, 3); -function returnString(name: string): string { - return name + " b!"; -} -let bb = returnString("rush"); -Assert.equal(bb, "rush b!"); -function returnBoolean(a: number, b: number): Boolean { - return a > b ? true : false; -} -let cc = returnBoolean(1, 2); -Assert.equal(cc, false); -function returnUndefine(a: undefined): undefined { - return a; -} -let ad: undefined; -let dd = returnUndefine(ad); -Assert.equal(dd, undefined); -function returnVoid(a: number): void { } -let ee = returnVoid(1); -Assert.equal(ee, null); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/return_type/return_type_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/return_type/return_type_2.ts deleted file mode 100644 index f3068cbb81..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/return_type/return_type_2.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - When a call signature with no return type annotation occurs in a context without a function body, - the return type is assumed to be the Any type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -let add: { (x: number, y: number): any }; -type anyT = ReturnType; -let x: anyT; -x = 1; -Assert.equal(x, 1); -x = "any"; -Assert.equal(x, "any"); -x = true; -Assert.equal(x, true); -x = undefined; -Assert.equal(x, undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/return_type/return_type_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/return_type/return_type_3.ts deleted file mode 100644 index 51369f871a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/return_type/return_type_3.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - When a call signature with no return type annotation occurs in a context that has a function body , - he return type is inferred from the function body. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -let add = function (x: number, y: number) { - return x + y; -}; -type Tadd = ReturnType; -let x: Tadd = 1; -Assert.equal(typeof x, "number"); -let sum = function (x: string, y: string) { - return x + y; -}; -type Tsum = ReturnType; -let y: Tsum = "hello"; -Assert.equal(typeof y, "string"); -let booltp = function (x: boolean) { - return true; -}; -let z = booltp(false); -Assert.equal(z, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_1.ts deleted file mode 100644 index acb546ff93..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_1.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Type parameters in call signatures provide a mechanism for expressing the relationships of parameter and return types in call operations. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -function identity(x: T): T { - return x; -} -let x: number = 1; -Assert.equal(x, identity(x)); -function identity2(x: T, y: U): T { - return x; -} -Assert.equal(x, identity2(x, 1)); -function identity3(obj: T, key: K) { - return obj[key]; -} -let y = { h_a: 1, h_b: 2, h_c: 3, h_d: 4 }; -identity3(y, "h_a"); -function identity4(arg: T[]): T[] { - return arg; -} -let arg: number[] = [1, 2, 3]; -Assert.equal(arg, identity4(arg)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_2.ts deleted file mode 100644 index c1e98499b3..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/call_signatures/type_parameters/type_parameters_2.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Type arguments for call signature type parameters may be explicitly specified in a call operation or may, - when possible, be inferred from the types of the regular arguments in the call. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../../suite/assert.js' - -function identity(x: T): T { - return x; -} -let x: number = 3; -Assert.equal(identity(x), 3); -let y = "string"; -Assert.equal(identity(y), "string"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/construct_signatures/construct_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/construct_signatures/construct_signatures.ts deleted file mode 100644 index c6c51a3567..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/construct_signatures/construct_signatures.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: A type may overload new operations by defining multiple construct signatures with different parameter lists. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Animal { - name: string | undefined; - age: number | undefined; - constructor(); - constructor(name: string); - constructor(age: number); - constructor(nameorage?: string | number, age?: number) { - if (typeof nameorage == "number") { - this.age = nameorage; - } - if (typeof nameorage == "string") { - this.name = nameorage; - } - if (age) { - this.age = age; - } - } -} -type AnimalConstructor = { - new(name: string, age: number): Animal; - new(name: string): Animal; - new(age: number): Animal; - new(): Animal; -}; -let AnimalConstructor: AnimalConstructor = Animal; -let tt1 = new AnimalConstructor(); -Assert.equal(tt1.age, undefined); -Assert.equal(tt1.name, undefined); -let tt2 = new AnimalConstructor("caihua2", 12); -Assert.equal(tt2.name, "caihua2"); -Assert.equal(tt2.age, 12); -let tt3 = new AnimalConstructor("caihua3"); -Assert.equal(tt3.name, "caihua3"); -Assert.equal(tt3.age, undefined); -let tt4 = new AnimalConstructor(1230); -Assert.equal(tt4.age, 1230); -Assert.equal(tt4.name, undefined); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/index_signatures/index_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/index_signatures/index_signatures.ts deleted file mode 100644 index 20bdba48b2..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/index_signatures/index_signatures.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - string index signatures, specified using index type string, define type constraints for all properties and numeric index signatures in the containing type. - numeric index signatures, specified using index type number, define type constraints for all numerically named properties in the containing type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let x: { [key: string]: number } = { a: 97, A: 65 }; -x["b"] = 98; -Assert.equal(x["a"], 97); -Assert.equal(x["A"], 65); -let y: { [key: number]: boolean } = { 0: false, 1: true }; -y[-1] = true; -Assert.isBoolean(y[0]); -Assert.equal(y[-1], true); -interface StringKey { - [key: string]: string; -} -let z: StringKey = { "1": "0x01", "2": "0x02", 3: "0x03", "4": "0x04" }; -Assert.equal(z["1"], "0x01"); -Assert.equal(z["2"], "0x02"); -interface NumberKey { - [key: number]: string; -} -let u: NumberKey = { 1: "0x01", 2: "0x02", "3": "0x03", 4: "0x04" }; -Assert.equal(u[1], "0x01"); -Assert.equal(u[2], "0x02"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_1.ts deleted file mode 100644 index 81644f8a3d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/method_signatures/method_signatures_1.ts +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the PropertyName is followed by a question mark, the property is optional. - Only object type literals and interfaces can declare optional properties. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface point { - point(x: number, y: number, z?: number): number; -} -class P implements point { - point(x: number, y: number, z?: number | undefined): number { - if (z) return x + y + z; - return x + y; - } -} -let p1 = new P(); -let x: number = 1; -let y: number = 2; -let z: number = 3; -let sum = p1.point(x, y, z); -Assert.equal(sum, 6); -sum = p1.point(x, y); -Assert.equal(sum, 3); - -let point2: { x: number; y: number; z?: number }; -point2 = { x: 1, y: 2, z: 3 }; -let pp1 = point2; -Assert.equal(pp1.x, 1); -Assert.equal(pp1.y, 2); -point2 = { x: 0, y: 0, z: 0 }; -let pp2 = point2; -Assert.equal(pp2.x, 0); -Assert.equal(pp2.y, 0); -Assert.equal(pp2.z, 0); - -class B { - add(x: T, y: number): string; - add(x: string, y: U): string; - add(x: T, y: U): string; - add(x: T, y: U): string { - return x.toString() + y.toString(); - } -} -let b1 = new B(); -Assert.equal(b1.add(1, 2), '12'); -Assert.equal(b1.add("A", 2), 'A2'); -Assert.equal(b1.add("B", 3), 'B3'); -Assert.equal(b1.add(true, false), 'truefalse'); -b1.add = (x: string, y: U) => { return typeof x + typeof y; }; -Assert.equal(b1.add("B", 3), 'stringnumber'); - -class C { - add1?(x: number): string; - add2?(x: number, y: boolean): number | boolean; -} -let c1 = new C(); -c1.add1 = (x: number): string => { return (x * x).toString() } -Assert.equal(c1.add1(5), '25'); - -let c2 = new C(); -c2.add2 = (x: number, y: boolean) => { - if (y == true) { - return x; - } else { - return y; - } -} -Assert.equal(c2.add2(5, true), 5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/property_signatures/property_signatures.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/property_signatures/property_signatures.ts deleted file mode 100644 index 626a7d8444..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_members/property_signatures/property_signatures.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the PropertyName of a property signature must be unique within its containing type, and must denote a well-known symbol if it is a computed property name. - if the property name is followed by a question mark, the property is optional. Otherwise, the property is required. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let fname: { fristName: string, middleName?: string, lastName: string; } = { fristName: "NARC", lastName: "TypeScript" }; -let f2name: { fristName: string, middleName?: string, lastName: string; } = { - fristName: "Isaac", - middleName: "F", - lastName: "Newton", -}; -function fullName(name: { fristName: string, middleName?: string, lastName: string; }): string { - if (name.middleName != undefined) { - return name.fristName + " " + name.middleName + " " + name.lastName; - } else { - return name.fristName + " " + name.lastName; - } -} -let fn1: string = fullName(fname); -Assert.equal(fn1, "NARC TypeScript"); -let fn2: string = fullName(f2name); -Assert.equal(fn2, "Isaac F Newton"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_3.ts deleted file mode 100644 index e02654d7c8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/array_type_literals/array_type_literals_3.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - When union, intersection, function, or constructor types are used as array element types they must be enclosed in parentheses. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let test: string | number[]; -test = 'string'; -Assert.equal(test, 'string'); -test = [3, 5]; -Assert.equal(test[0], 3); -Assert.equal(test[1], 5); -let test2: (string | number)[]; -test2 = [2, 'a']; -Assert.equal(test2[0], 2); -Assert.equal(test2[1], 'a'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/object_type_literals/object_type_literals.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/object_type_literals/object_type_literals.ts deleted file mode 100644 index 4c5de86e4b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/object_type_literals/object_type_literals.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - An object type literal defines an object type by specifying the set of members that are statically considered to be present in instances of the type. - Object type literals can be given names using interface declarations but are otherwise anonymous. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let obj: { - num: number; - str: string; - boo: boolean; - fun: Function; -} = { - num: 5, - str: 'str', - boo: true, - fun(): number { - return 123; - } -} -Assert.equal(obj.num, 5); -Assert.equal(obj.str, 'str'); -Assert.equal(obj.boo, true); -Assert.equal(obj.fun(), 123); -interface I { - name: string, - age: number, - readonly id: number -} -let i: I = { - name: 'xiao', - age: 18, - id: 111 -} -Assert.equal(i.name, 'xiao'); -Assert.equal(i.age, 18); -Assert.equal(i.id, 111); -interface I2 { - name: string, - [oname: string]: string; -} -let i2: I2 = { - name: "join", - gender: "male" -}; -Assert.equal(i2.name, "join"); -Assert.equal(i2.gender, "male"); -class Myclass { - x: number = 1; - y: string = "aa"; - constructor() { } - fun(): number { - return 11; - } -} -let obj2: Myclass = new Myclass() -Assert.equal(obj2.fun(), 11); -Assert.equal(obj2.x, 1); -Assert.equal(obj2.y, "aa"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/this_type_references/this_type_references_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/this_type_references/this_type_references_1.ts deleted file mode 100644 index 83357c7630..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/this_type_references/this_type_references_1.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The meaning of a ThisType depends on the closest enclosing FunctionDeclaration, FunctionExpression, PropertyDefinition, ClassElement, - or TypeMember, known as the root declaration of the ThisType. - When the root declaration is an instance member or constructor of a class, the ThisType references the this-type of that class. - When the root declaration is a member of an interface type, the ThisType references the this-type of that interface. Otherwise, the ThisType is an error. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class myClass { - x: number; - y: number; - xy() { - return this.x * this.y; - } - m?: this; - constructor(x: number, y: number) { - this.x = x; - this.y = y; - } -} -let mc = new myClass(2, 5); -let mc0 = new myClass(1, 2); -mc.m = mc0; -Assert.equal(mc.m.x, 1); -Assert.equal(mc.m.xy(), 2); - -type PType = { A: T, B: T }; -interface Point { - x: number; - y: number; - PAdd?(a: this, b: this): this; - PObj?(a: this, b: this): PType; -} -let p1: Point = { x: 1, y: 2 }; -let p2: Point = { x: 2, y: 1 }; -let pa: Point = { - x: 0, - y: 0, - PAdd(a: Point, b: Point): Point { - let p: Point = { x: a.x + b.x, y: a.y + b.y }; - return p; - }, - PObj(a: Point, b: Point): PType { - let p: PType = { A: a, B: b }; - return p; - } -} -let p3: Point = pa.PAdd!(p1, p2); -let po: PType = pa.PObj!(p1, p2); -Assert.equal(JSON.stringify(p3), '{"x":3,"y":3}'); -Assert.equal(JSON.stringify(po), '{"A":{"x":1,"y":2},"B":{"x":2,"y":1}}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_queries/type_queries_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_queries/type_queries_1.ts deleted file mode 100644 index b2d3b21886..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/specifying_types/type_queries/type_queries_1.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A type query obtains the type of an expression.A type query consists of the keyword typeof followed by an expression. - Type queries are useful for capturing anonymous types that are generated by letious constructs - such as object literals, function declarations, and namespace declarations. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let a1: { x: number, y: string }; -let a2: typeof a1; -a2 = { - x: 10, - y: 'y' -} -Assert.equal(typeof a2, 'object'); - -function b1(x: number, y: number): number { return x + y; } -let b2: typeof b1; -b2 = (x: number, y: number): number => { return x - y; } -Assert.equal(typeof b2, 'function'); - -namespace CC { - export type C = keyof number & string; -} -let c1: CC.C; -let c2: typeof c1 = 'toExponential'; -c2 = 'toString'; -c1 = c2; -Assert.equal(c1, c2); - -let c3: CC.C; -let c4: typeof c3[] = ['toExponential', 'toFixed', 'toLocaleString', 'toPrecision', 'toString', 'valueOf']; -Assert.equal(JSON.stringify(c4), '["toExponential","toFixed","toLocaleString","toPrecision","toString","valueOf"]'); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_1.ts deleted file mode 100644 index d0ef6684e4..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_1.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A type reference to a generic type must include - a list of type arguments enclosed in angle brackets and separated by commas. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -function identity1(value: T, message: U): [T, U] { - return [value, message]; -} -let identi = identity1(1, 2); -Assert.equal(identi[0], 1); -Assert.equal(identi[1], 2); - diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_3.ts deleted file mode 100644 index 933672c069..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_argument_lists/type_argument_lists_3.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A type argument list is required to specify exactly one type argument for each corresponding type parameter, - and each type argument for a constrained type parameter is required to satisfy the constraint of that type parameter. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -function getname(name: T, number: Y): T { - return name; -} -interface Lengthwise { - length: number; -} -interface Search { - (name: T, number: Y): T; -} -let fn: Search = getname; -let aa: Lengthwise = { length: 11 }; -let a = fn("wan", aa); -Assert.equal(a, "wan"); -let fn2: Search = getname; -let bb: Lengthwise = { length: 33 }; -let b = fn2(22, bb); -Assert.equal(b, 22); -let fn3: Search = getname; -let cc: Lengthwise = { length: 44 }; -let c = fn3(true, cc); -Assert.equal(c, true); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_2.ts deleted file mode 100644 index 2f82c9044b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_2.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Class, interface, type alias, and function declarations may optionally include - lists of type parameters enclosed in < and > brackets. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface OutputValue { - (arg: T): T; -} -let x: OutputValue = function (arg: T): T { - return arg; -}; -Assert.equal(x("abc"), "abc"); - diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_4.ts deleted file mode 100644 index bb7eaf98f3..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_4.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Class, interface, type alias, and function declarations may optionally include - lists of type parameters enclosed in < and > brackets. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -function returnAnyTypeValue(a: T): T { - return a; -} -Assert.equal(returnAnyTypeValue(1), 1); -Assert.equal(returnAnyTypeValue("char"), "char"); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_6.ts deleted file mode 100644 index 5dee8cfec5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_parameters/type_parameter_lists/type_parameter_lists_6.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A type parameter may have an associated type parameter constraint that establishes an upper bound for type arguments. - Type parameters may be referenced in type parameter constraints within the same type parameter list, - including even constraint declarations that occur to the left of the type parameter. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -type Dog = { - m_name: string; - m_age: number; - m_job: string; -}; -type PickProperty = { [P in K]: T[P] }; -type test = PickProperty; -let cc: test = { - m_age: 20, - m_name: "wangwang", -}; -Assert.isNumber(cc.m_age); -Assert.isString(cc.m_name); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_1.ts deleted file mode 100644 index 8057eac966..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_1.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Two types are considered identical when they are both the Any type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -type T = any; -type U = any; - -type IsEqual = - (() => T1 extends TT ? 1 : 2) extends - (() => T2 extends UU ? 1 : 2) - ? true - : false - -let a1: T = 10; -let b1: U = 10; -Assert.equal(typeof a1, typeof b1); -let a2: T = 10; -let b2: U = 10; -Assert.equal(typeof a2, typeof b2); - -let isEqual: IsEqual = true; -Assert.isTrue(isEqual); - -let a3: T = 'a3'; -let b3: U = 1024; -a3 = b3; -Assert.equal(a3, b3); -a3 = 'A3'; -b3 = false; -b3 = a3; -Assert.equal(b3, a3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_2.ts deleted file mode 100644 index 0aae0021bc..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_2.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Two types are considered identical when they are the same primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -type T = number; -type U = number; - -type IsEqual = - (() => T1 extends TT ? 1 : 2) extends - (() => T2 extends UU ? 1 : 2) - ? true - : false - -let a: T = 5; -let b: U = 10; -Assert.equal(typeof a, typeof b); - -let isEqual1: IsEqual = true; -let isEqual2: IsEqual = true; -Assert.equal(isEqual1, isEqual2); -Assert.isTrue(isEqual1); - -let a1: T = 1024; -let b1: U = 999; -a1 = b1; -Assert.equal(a1, b1); -a1 = 37; -b1 = 111; -b1 = a1; -Assert.equal(b1, a1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_4.ts deleted file mode 100644 index 4c40674016..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/Type_and_Member_Identity/Type_and_Member_Identity_4.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Two types are considered identical when they are union types with identical sets of constituent types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -type T = number | string | boolean; -type U = number | string | boolean; - -type IsEqual = - (() => T1 extends TT ? 1 : 2) extends - (() => T2 extends UU ? 1 : 2) - ? true - : false - -let a1: T = 10; -let a2: U = 5; -Assert.equal(typeof a1, typeof a2); -let b1: T = '10'; -let b2: U = '5'; -Assert.equal(typeof b1, typeof b2); -let c1: T = true; -let c2: U = false; -Assert.equal(typeof c1, typeof c2); - -let isEqual: IsEqual = true; -Assert.isTrue(isEqual); - -let d1: T = true; -let d2: U = 555; -d1 = d2; -Assert.equal(d1, d2); -d1 = 'd1'; -d2 = false; -d2 = d1; -Assert.equal(d2, d1); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_1.ts deleted file mode 100644 index d3280708cc..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_1.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The apparent members of the primitive type Number and all enum types are the apparent members of the global interface type 'Number'. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -let num: Number = 1; -enum Color { - red, - black, - green -} -let c: Color.black = Color.black; -num.toString(); -c.toString(); -Assert.equal(num.valueOf(), c.valueOf()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_2.ts deleted file mode 100644 index 4a84a2174f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_2.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The apparent members of the primitive type Boolean are the apparent members of the global interface type 'Boolean'. - The apparent members of the primitive type String and all string literal types are the apparent members of the global interface type 'String' - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -let bool: Boolean = true; -Assert.isBoolean(bool.valueOf()) - -let str1: String = "string"; -type color = "RED" | "BLUE" | "BALCK" -let str2: color = "BLUE"; -str1.toString; -str2.toString; -Assert.equal(typeof str1.valueOf(), typeof str2.valueOf()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_5.ts deleted file mode 100644 index aa43b61234..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_5.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - When all constituent types of U have an apparent numeric index signature, - U has an apparent numeric index signature of a union type of the respective numeric index signature types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface Array1 { - [index1: string]: number -} -interface Array2 { - [index2: string]: number -} - -function test(obj: Array1 | Array2) { - return "right" -} -const stu1 = { - age: 19 -} -const stu2 = { - number: 10001 -} -Assert.equal(test(stu1), "right"); -Assert.equal(test(stu2), "right"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_7.ts deleted file mode 100644 index 45bed47d2b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_7.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - When one or more constituent types of I have an apparent numeric index signature, - I has an apparent numeric index signature of an intersection type of the respective numeric index signature types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface Array1 { - [index1: string]: number -} -interface Array2 { - [index2: string]: number -} - -function test(obj: Array1 & Array2) { - return "right" -} -const stu1 = { - age: 19 -} -const stu2 = { - number: 10001 -} -Assert.equal(test(stu1), "right"); -Assert.equal(test(stu2), "right"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_8.ts deleted file mode 100644 index 49cbe222a5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/apparent_members/apparent_members_8.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - a type's apparent members make it a subtype of the 'Object' or 'Function' interface - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let obj: Object = { num1: 10, num2: 20 }; -Assert.equal(JSON.stringify(obj), '{"num1":10,"num2":20}') - -let fun: Function = (num: number) => num * num; -Assert.isUndefined(JSON.stringify(fun)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_10.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_10.ts deleted file mode 100644 index 11ac500ff8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_10.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - S is assignable to a type T, and T is assignable from S, - if S has no excess properties with respect to T, and T is an intersection type and S is assignable to each constituent type of T. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -interface Foo { - name: string -} -interface Bar { - age: number -} -interface S { - name: string - age: number -} -type T = Foo & Bar -let t: T -let s: S = { - name: 'xiao', - age: 18 -} -t = s -Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_11.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_11.ts deleted file mode 100644 index 02f551bf69..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_11.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - S is assignable to a type T, and T is assignable from S, - if S has no excess properties with respect to T, and S is a type parameter and the constraint of S is assignable to T. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -interface event { - data: T -} -type T = event -type S = event -let t: T -let s: S = { data: 10 } -t = s -Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_12.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_12.ts deleted file mode 100644 index f26c7fdb3d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_12.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - S is assignable to a type T, and T is assignable from S, - if S has no excess properties with respect to T, - and S is an object type, an intersection type, an enum type, or the Number, Boolean, or String primitive type, T is an object type, and for each member M in T, - and M is a property and S has an apparent property N where - M and N have the same name, - the type of N is assignable to that of M, - if M is a required property, N is also a required property, and - M and N are both public, M and N are both private and originate in the same declaration, - M and N are both protected and originate in the same declaration, - or M is protected and N is declared in a class derived from the class in which M is declared. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -type T = { - name: any - age: number -} -type S = { - name: string - age: number -} -let t: T -let s: S = { - name: "Xi", - age: 20, -} -t = s -Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_13.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_13.ts deleted file mode 100644 index a058d9e4af..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_13.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - S is assignable to a type T, and T is assignable from S, - if S has no excess properties with respect to T, - and S is an object type, an intersection type, an enum type, or the Number, Boolean, or String primitive type, T is an object type, and for each member M in T, - and M is a non-specialized call or construct signature and S has an apparent call or construct signature N where, - when M and N are instantiated using type Any as the type argument for all type parameters declared by M and N (if any), - the signatures are of the same kind (call or construct), - M has a rest parameter or the number of non-optional parameters in N is less than or equal to the total number of parameters in M, - for parameter positions that are present in both signatures, each parameter type in N is assignable to or from the corresponding parameter type in M, - and the result type of M is Void, or the result type of N is assignable to that of M. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface T { - (x: any, y: any): void -} -interface S { - (x: number): void -} -let t: T = (x, y): void => { - return; -} -let s: S = (x): void => { - return; -} -t = s -Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_14.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_14.ts deleted file mode 100644 index 4500361cbc..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_14.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - S is assignable to a type T, and T is assignable from S, - if S has no excess properties with respect to T, - and S is an object type, an intersection type, an enum type, or the Number, Boolean, or String primitive type, T is an object type, and for each member M in T, - and M is an optional property and S has no apparent property of the same name as M. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -interface T { - name?: string - age?: number -} -interface S { - name?: string - age?: number -} -let t: T -let s: S = { name: 'xiao' } -t = s -Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_15.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_15.ts deleted file mode 100644 index 024a7d9b7b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_15.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - S is assignable to a type T, and T is assignable from S, - if S has no excess properties with respect to T, - and S is an object type, an intersection type, an enum type, or the Number, Boolean, or String primitive type, T is an object type, and for each member M in T, - and M is a string index signature of type U, - and U is the Any type or S has an apparent string index signature of a type that is assignable to U. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -interface U { - anything: string -} -interface T { - [key: string]: U -} -interface S { - [keyname: string]: U -} -let t: T = {} -let s: S = {} -s['obj'] = { anything: "thing" } -t = s -Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_16.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_16.ts deleted file mode 100644 index 179e0efd85..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_16.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - S is assignable to a type T, and T is assignable from S, - if S has no excess properties with respect to T, - and S is an object type, an intersection type, an enum type, or the Number, Boolean, or String primitive type, T is an object type, and for each member M in T, - and M is a numeric index signature of type U, - and U is the Any type or S has an apparent string or numeric index signature of a type that is assignable to U. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -interface U { - anything: string -} -interface T { - [key: number]: U -} -interface S { - [keyname: number]: U -} -let t: T = {} -let s: S = {} -s[10] = { anything: "thing" } -t = s -Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_17.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_17.ts deleted file mode 100644 index b7a36cfa23..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_17.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The assignment compatibility and subtyping rules differ only in that, - an object type without a particular property is assignable to an object type in which that property is optional. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -interface T { - name?: string - age?: number -} -interface S { -} -let t: T -let s: S = {} -t = s -Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_2.ts deleted file mode 100644 index f7d9366ad6..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_2.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - S is assignable to a type T, and T is assignable from S, - if S has no excess properties with respect to T, and S or T is the Any type. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -interface T { - name: string -} -let t: T -const S: any = 'str' -t = S -Assert.equal(t, S); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_3.ts deleted file mode 100644 index 5b3ef6c5e9..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_3.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - S is assignable to a type T, and T is assignable from S, - if S has no excess properties with respect to T, and S is the Undefined type. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -interface T { - name: undefined -} -interface S { - name: undefined -} -let t: T -let s: S = { name: undefined } -t = s -Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_4.ts deleted file mode 100644 index 8b11adc97e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_4.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - S is assignable to a type T, and T is assignable from S, - if S has no excess properties with respect to T, and S is the Null type and T is not the Undefined type. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -let T: any; -const S: null = null; -T = S; -Assert.equal(T, S); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_6.ts deleted file mode 100644 index 3ccdf7dc27..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_6.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - S is assignable to a type T, and T is assignable from S, - if S has no excess properties with respect to T, and S is a string literal type and T is the primitive type String. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let T: string = "T"; -type S = "s" | "str" | "string"; -let s: S = "str" -T = s -Assert.equal(T, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_7.ts deleted file mode 100644 index 1c93752d9f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_7.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - S is assignable to a type T, and T is assignable from S, - if S has no excess properties with respect to T, and S is a union type and each constituent type of S is assignable to T. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -interface T { - name: string - age: number - hobby: string -} -interface Foo { - name: string - age: number -} -interface Bar { - hobby: string -} -type S = Foo & Bar -let t: T; -let s: S = { - name: "S", - age: 20, - hobby: "drawing" -} -t = s -Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_8.ts deleted file mode 100644 index 8d5a56d4d0..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_8.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - S is assignable to a type T, and T is assignable from S, - if S has no excess properties with respect to T, and T is an intersection type and S is assignable to each constituent type of T. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -interface T { - name: string - age: number -} -interface Foo { - name: string - age: number -} -interface Bar { - hobby: string -} -type S = Foo & Bar -let t: T; -let s: S = { - name: "S", - age: 20, - hobby: "drawing" -} -t = s -Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_9.ts deleted file mode 100644 index bfc0b3f541..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/assignment_compatibility/assignment_compatibility_9.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - S is assignable to a type T, and T is assignable from S, - if S has no excess properties with respect to T, and T is a union type and S is assignable to at least one constituent type of T. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -interface Foo { - name: string -} -interface Bar { - age: number -} -interface S { - age: number -} -type T = Foo | Bar -let t: T -let s: S = { - age: 18 -} -t = s -Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/contextual_signature_instantiation/contextual_signature_instantiation.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/contextual_signature_instantiation/contextual_signature_instantiation.ts deleted file mode 100644 index 88f45984e2..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/contextual_signature_instantiation/contextual_signature_instantiation.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - During type argument inference in a function call, - it is in certain circumstances necessary to instantiate a generic call signature of an argument expression in the context of a non-generic call signature of a parameter such that further inferences can be made. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -function fun(x: S[], y: T[], combine: (x: S) => (y: T) => U): U[] { - let len = Math.max(x.length, y.length); - let result: U[] = []; - for (let i = 0; i < len; i++) result.push(combine(x[i])(y[i])); - return result; -} - -let names = ["Peter", "Paul", "Mary"]; -let ages = [7, 9, 12]; -let pairs = fun(names, ages, s => n => ({ name: s, age: n })); -Assert.equal(JSON.stringify(pairs), '[{"name":"Peter","age":7},{"name":"Paul","age":9},{"name":"Mary","age":12}]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_2.ts deleted file mode 100644 index 1d2b4cdcc4..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/excess_properties/excess_properties_2.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not c this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In cases where excess properties are expected, an index signature can be added to the target type as an indicator of intent. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface I { - a: string; - b?: boolean; - [str: string]: any; -} - -let x: I = { - a: "aaa", - b: true, - c: "ccc", - d: "ddd" -}; -Assert.equal(JSON.stringify(x), '{"a":"aaa","b":true,"c":"ccc","d":"ddd"}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/recursive_types/recursive_types.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/recursive_types/recursive_types.ts deleted file mode 100644 index ab23d074cf..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/recursive_types/recursive_types.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - when comparing types S and T for a given relationship, - the relationship in question is assumed to be true for every directly or indirectly nested occurrence of the same S and the same T - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface iA { - next: iA; -} -interface iB { - next: iC; -} -interface iC { - next: iD; -} -interface iD { - next: iB; -} -type IsEqual = - (() => T1 extends T ? 1 : 2) extends - (() => T2 extends U ? 1 : 2) - ? true - : false -var t1: IsEqual = true; -Assert.isTrue(t1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_1.ts deleted file mode 100644 index 10ca7b99b9..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_1.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - S is a subtype of a type T, and T is a supertype of S, - if S has no excess properties with respect to T, S and T are identical types. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -interface T { - name: string - age: number -} -interface S { - name: string - age: number - hobbies: string[] -} -let t: T = { - name: "T", - age: 20 -}; -let s: S = { - name: "S", - age: 19, - hobbies: ["draw", "game"] -}; - -t = s -Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_11.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_11.ts deleted file mode 100644 index 51fb1ee827..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_11.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - S is a subtype of a type T, and T is a supertype of S, - if S has no excess properties with respect to T, - and S is a type parameter and the constraint of S is a subtype of T. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -let test = (obj: T, key: S): any => { - return obj[key]; -} -let obj = { - a: 'a', - b: 'b' -} -let res = test(obj, "a"); -Assert.equal(res, 'a'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_13.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_13.ts deleted file mode 100644 index 665f1fb45e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_13.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - S is a subtype of a type T, and T is a supertype of S, - if S has no excess properties with respect to T, - and M is a non-specialized call or construct signature and S has an apparent call or construct signature N where, - when M and N are instantiated using type Any as the type argument for all type parameters declared by M and N (if any), - and for each member M in T, M is a property and S has an apparent property N where, - the signatures are of the same kind (call or construct), - M has a rest parameter or the number of non-optional parameters in N is less than or equal to the total number of parameters in M, - for parameter positions that are present in both signatures, each parameter type in N is a subtype or supertype of the corresponding parameter type in M, - and the result type of M is Void, or the result type of N is a subtype of that of M. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface T { - (x: any, y: any): void -} -interface S { - (x: number): void -} -let t: T = (x, y): void => { - return; -} -let s: S = (x): void => { - return; -} - -t = s; -Assert.equal(t, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_6.ts deleted file mode 100644 index 03ee7dd0d9..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_6.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - S is a subtype of a type T, and T is a supertype of S, - if S has no excess properties with respect to T, - and S is a string literal type and T is the primitive type String. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var T: string = "T"; -type S = "s" | "str" | "string"; -let s: S = "str" - -T = s; -Assert.equal(T, s); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_7.ts deleted file mode 100644 index 8562babf4a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_7.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - S is a subtype of a type T, and T is a supertype of S, - if S has no excess properties with respect to T, - and S is a union type and each constituent type of S is a subtype of T. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let T: any = true; -let S: number | string = 18; - -T = S; -Assert.equal(T, 18); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_9.ts deleted file mode 100644 index f775365370..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/subtypes_and_supertypes/subtypes_and_supertypes_9.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - S is a subtype of a type T, and T is a supertype of S, - if S has no excess properties with respect to T, - and T is a union type and S is a subtype of at least one constituent type of T. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let T: number | string = "18"; -let S: number = 20; - -T = S; -Assert.equal(T, S); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_2.ts deleted file mode 100644 index a07b9b18a6..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_2.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - if S and T are references to the same generic type, - inferences are made from each type argument in S to each corresponding type argument in T. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -function map(a: T[], f: (x: T) => U): U[] { - var result: U[] = []; - for (var i = 0; i < a.length; i++) result.push(f(a[i])); - return result; -} - -var names = ["Peter", "Paul", "Mary"]; - -var lengths = map(names, s => s.length); -Assert.equal(typeof lengths, 'object'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_3.ts deleted file mode 100644 index 819c983fbf..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_3.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - if S and T are tuple types with the same number of elements, - inferences are made from each element type in S to each corresponding element type in T. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - - -let T = [1, 'a', true] -Assert.equal(typeof T, 'object') - -let S = [[1, 2, 3], 2, 'b'] -Assert.equal(typeof S, 'object'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_4.ts deleted file mode 100644 index 0e0a4d5b7b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_4.ts +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - if T is a union or intersection type: - First, inferences are made from S to each constituent type in T - that isn't simply one of the type parameters for which inferences are being made. - If the first step produced no inferences then - if T is a union type and exactly one constituent type in T is simply a type parameter for which inferences are being made, - inferences are made from S to that type parameter. - Otherwise, if S is a union or intersection type, inferences are made from each constituent type in S to T. - module: ESNext - isCurrent: true - ---*/ - -import { Assert } from '../../../../../suite/assert.js' - - -type Maybe = T | void -function isDefined(x: Maybe): x is T { - return x! == undefined && x !== null; -} -function isUndefined(x: Maybe): x is void { - return x === undefined || x === null; -} -function getOrElse(x: Maybe, defaultValue: T): T { - return isDefined(x) ? x : defaultValue; -} -function test1(x: Maybe) { - let x1 = getOrElse(x, "Undefined"); - Assert.isString(x1) - let x2 = isDefined(x) ? x : "undefined"; - Assert.isString(x2) - let x3 = isUndefined(x) ? "Undefined" : x; - Assert.isString(x3) -} -test1('t1') -function test2(x: Maybe) { - let x1 = getOrElse(x, - 1); - Assert.isNumber(x1) - let x2 = isDefined(x) ? x : -1; - Assert.isNumber(x2) - let x3 = isUndefined(x) ? -1 : x; - Assert.isNumber(x3) -} -test2(5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_5.ts deleted file mode 100644 index 2f5580fb5c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_5.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - if S and T are object types, then for each member M in T, - If M is a property and S contains a property N with the same name as M, - inferences are made from the type of N to the type of M. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -interface T { - name: any -} -interface S { - name: string -} -var t: T -var s: S = { name: "xxx" } -t = s - -Assert.isString(t.name); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_6.ts deleted file mode 100644 index 0f02f24664..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_6.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - if S and T are object types, then for each member M in T, - if M is a string index signature and S contains a string index signature N, - inferences are made from the type of N to the type of M. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface S { - [value: string]: string -} -let s: S = { - 'name': 'xiao' -} -Assert.equal(typeof s, 'object'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_7.ts deleted file mode 100644 index 535f582d80..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/type_relationships/type_inference/type_inference_7.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - if S and T are object types, then for each member M in T, - if M is a numeric index signature and S contains a numeric index signature N, - inferences are made from the type of N to the type of M. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../../suite/assert.js' - -interface T { - [key: number]: string -} -let S: { [value: number]: T } = {} -Assert.equal(typeof S, 'object'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_5.ts deleted file mode 100644 index 7b128e80e9..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_5.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - the || and conditional operators may produce values of union types, and array literals may produce array values that have union types as their element types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let x: A1 = 1408 || "NARC"; -let y: string | number; -x = 1500; -y = x <= 1408 ? "NARC" : 1024; -Assert.equal(y, 1024); -x = 100; -y = x <= 1408 ? "NARC" : 1024; -Assert.equal(y, "NARC"); -type A1 = string | number | object; -type B1 = number | boolean | string; -let z: A1 & B1; -z = 125; -Assert.isNumber(z); -z = "Fn"; -Assert.isString(z); -let a: Array | Array; -a = [0, true, -1, false]; -Assert.equal(JSON.stringify(a), '[0,true,-1,false]'); -a = [true, "True", false, "False"]; -Assert.equal(JSON.stringify(a), '[true,"True",false,"False"]'); -let b: number[] | boolean[]; -b = [2, 4, 6]; -Assert.equal(JSON.stringify(b), '[2,4,6]'); -b = [true, false]; -Assert.equal(JSON.stringify(b), '[true,false]'); -let c: (number | string)[] | (boolean | Object)[]; -c = [1, 3, 5, "AND", "OR"]; -Assert.equal(JSON.stringify(c), '[1,3,5,"AND","OR"]'); -c = [true, false, { 0x00: "0x00" }, { 0xFA: "0xFA" }]; -Assert.equal(JSON.stringify(c), '[true,false,{"0":"0x00"},{"250":"0xFA"}]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_7.ts deleted file mode 100644 index 885163cdc9..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/union_types/union_types_7.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - for purposes of property access and function calls, the apparent members of a union type are those that are present in every one of its constituent types, - with types that are unions of the respective apparent members in the constituent types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -type numType = { num: number }; -type strType = { str: string }; -type boolType = { bool: boolean }; -type objType = { obj: Object }; -type NS = numType | strType; -type OB = objType | boolType; -var nsv: NS = { num: 1024, str: "NS" }; -var obv: OB = { bool: true, obj: { 0xFF: "0xFF" } }; -var nsobv_1: NS | OB = { num: 1024, obj: { 0xFF: "0xFF" } } -var nsobv_2: NS | OB = { bool: false, str: "nsobv_2" }; -var nsobv_3: NS | OB = { num: 114, bool: false, str: "nsobv_3", obj: { 0xAF: "0xAF" } } -Assert.equal(typeof nsv, "object"); -Assert.equal(typeof obv, "object"); -Assert.equal(typeof nsobv_1, "object"); -Assert.equal(typeof nsobv_2, "object"); -Assert.equal(typeof nsobv_3, "object"); -interface T1 { - x: number, - y: string, - z: boolean -} -interface T2 { - x: string, - y: string, - z: string -} -let t1: T1 | T2 = { x: 1, y: "yy", z: true }; -Assert.equal(t1.x, 1); -Assert.equal(t1.y, "yy"); -Assert.equal(t1.z, true); -let t2: T1 | T2 = { x: "aa", y: "bb", z: "cc" }; -Assert.equal(t2.x, "aa"); -Assert.equal(t2.y, "bb"); -Assert.equal(t2.z, "cc"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/widend_types/widend_types_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/widend_types/widend_types_2.ts deleted file mode 100644 index efa9109865..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/types/widend_types/widend_types_2.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - When inferring the type of a variable, property or function result from an expression, - the widened form of the source type is used as the inferred type of the target. - module: ESNext - isCurrent: true - ---*/ - - -import {Assert} from '../../../../suite/assert.js' - -var x = 10 -var y = 'a' -var z = x + y -Assert.isString(z); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/tool/test_helper.py b/es2panda/test/ts_extra_tests/tool/test_helper.py deleted file mode 100644 index ef411a4357..0000000000 --- a/es2panda/test/ts_extra_tests/tool/test_helper.py +++ /dev/null @@ -1,106 +0,0 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import re -import os - - -def read_declaration(path): - start_pattern = re.compile(r'^\/\*\*\-*') - end_pattern = re.compile(r'^\s*\-+\*\/') - context = "" - with open(path, 'r', encoding='utf-8', errors='ignore') as f: - declaration_begin = False - while True: - line = f.readline() - if not line: - break - if start_pattern.match(line): - declaration_begin = True - continue - if end_pattern.match(line): - declaration_begin = False - break - if declaration_begin: - context += line - return context - - -# LIMIT_VERSION = 4.2 - - -def get_path_file(dir_path, all_file_path=None, is_root=False, limit_version=None): - rf = 'test_ts_cases' - if all_file_path is None: - all_file_path = [] - file_or_dir = os.listdir(dir_path) - file_or_dir_results = [] - if dir_path.endswith("test_ts_cases") or dir_path.endswith("test_ts_cases/"): - is_root = True - else: - is_root = False - if is_root: - root_folder = os.path.basename(dir_path) - if root_folder == rf: - # file_or_dir like: ['2.0', '2.1', '2.2', ... '4.9', 'spec'] - for f_item in file_or_dir: - if limit_version is None: - file_or_dir_results = file_or_dir - break - else: - limit_version = float(limit_version) - try: - f_num = float(f_item) - if f_num <= limit_version: - file_or_dir_results.append(f_item) - except Exception as e: - print(e) - continue - if not limit_version is None: - file_or_dir_results.append('spec') - - else: - file_or_dir_results = file_or_dir - for file_dir in file_or_dir_results: - file_or_dir_path = os.path.join(dir_path, file_dir) - if '\\' in file_or_dir_path: - file_or_dir_path = file_or_dir_path.replace('\\', '/') - - if os.path.isdir(file_or_dir_path): - get_path_file(file_or_dir_path, all_file_path, False, None) - else: - all_file_path.append(file_or_dir_path) - - return all_file_path - - -def get_disable_list(file_path): - disable_list = [] - with open(file_path, 'r', encoding='utf-8', errors='ignore') as f: - while True: - line = f.readline() - if not line: - break - disable_list.append(os.path.abspath(line.strip())) - return disable_list - - -def is_disable_case(file_path, disable_list): - if disable_list is None: - return False - if file_path in disable_list: - return True - for disable_path in disable_list: - if disable_path in file_path: - return True diff --git a/es2panda/test/ts_extra_tests/tool/testcfg.py b/es2panda/test/ts_extra_tests/tool/testcfg.py deleted file mode 100644 index 0bf1e8d654..0000000000 --- a/es2panda/test/ts_extra_tests/tool/testcfg.py +++ /dev/null @@ -1,274 +0,0 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import os -import re -import yaml -import platform -import subprocess -from tool.test_helper import read_declaration - -STRICT_OFF = ['--strict', 'false'] -STRICT_ON = ['--strict', 'true'] -MODULE = ['--module'] -Decorator = ['--experimentalDecorators'] -strictNullChecks = ['--strictNullChecks'] - - -def get_error_message(strs, filename): - if len(re.findall(filename + r':(\d+)', strs)) > 0: - line_number = re.findall(filename + r':(\d+)', strs) - else: - line_number = 0 - err_message = strs - return err_message, line_number - - -class TestCase: - temp_path = "" - ld_library_path = "" - js_runtime_path = "" - es2abc = "" - tsc = "" - - def __init__(self, path): - self.path = path - self.target_js_path = "" - try: - data = yaml.load(read_declaration(path), yaml.SafeLoader) - except: - data = {} - self.declaration = data - self.fail = False - self.is_test_case = False if data is None else True - self.detail_result = "" - self.err_line = 0 - self.abc_file_path = "" - self.abc_file_path_temp = "" - - def execute(self, ark_runtime=False): - if not self.is_test_case: - return - if ark_runtime: - with open(self.path, 'a') as file_added: - file_added.write('\rprint("TESTCASE SUCCESS");') - self.__test_es2abc() - if os.path.exists(self.abc_file_path): - os.remove(self.abc_file_path) - else: - self.__tsc_test() - - def is_negative(self): - if 'error' in self.declaration: - return True - return False - - def is_current(self): - if 'isCurrent' in self.declaration: - return True - return False - - def experimental_decorators(self): - if 'experimentalDecorators' in self.declaration: - return True - return False - - def null_checks(self): - if 'strictNullChecks' in self.declaration: - return True - return False - - def is_set_module(self): - if 'module' in self.declaration: - return True - return False - - def check_declaration(self): - if self.declaration == {}: - self.detail_result = "parse test case declaration failed, maybe bad format." - return False - if 'error' in self.declaration: - if self.declaration['error'] is None or 'code' not in self.declaration['error'] and 'type' not in \ - self.declaration['error']: - self.detail_result = "neither error code nor error type are defined in negative case." - return False - return True - - def __error_code(self): - if 'code' in self.declaration['error']: - return self.declaration['error']['code'] - return None - - def __error_type(self): - if 'type' in self.declaration['error']: - return self.declaration['error']['type'] - return None - - def __get_tsc_cmd(self): - if platform.system().lower() == 'windows': - cmd = ['cmd', '/c', 'tsc', '--target', 'es2020'] - else: - cmd = [TestCase.tsc, '--target', 'es2020'] - if self.__is_strict(): - cmd.extend(STRICT_ON) - else: - cmd.extend(STRICT_OFF) - if self.is_set_module(): - cmd.extend(MODULE) - cmd.append('es2020') - if self.experimental_decorators(): - cmd.extend(Decorator) - cmd.append('true') - if self.null_checks(): - cmd.extend(strictNullChecks) - cmd.append('false') - if self.is_current(): - cmd.append(self.path) - cmd.append('--outDir') - cmd.append(TestCase.temp_path) - self.target_js_path = TestCase.temp_path + self.__get_js_basename() - return cmd - - def __get_node_cmd(self): - cmd = ['node'] - if self.is_current(): - cmd.append(self.target_js_path) - else: - cmd.append(TestCase.temp_path + self.__get_js_basename()) - return cmd - - # get es2abc --merge-abc - def __get_es2abc_cmd(self, file_path): - abc_file_path = ("%s.abc" % (os.path.splitext(file_path)[0])) - self.abc_file_path_temp = abc_file_path - cmd = [TestCase.es2abc + 'es2abc'] - cmd.extend(['--module', '--output', abc_file_path, file_path]) - return cmd - - # create abc files - def create_abc(self, filename): - process = subprocess.Popen(self.__get_es2abc_cmd(filename), stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - out, err = process.communicate() - return_code = process.returncode - if return_code != 0: - err_msg, line = get_error_message( - out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore"), filename) - self.detail_result = err_msg - self.err_line = line - self.fail = True - return - if "TESTCASE SUCCESS" not in out.decode("utf-8", errors="ignore"): - self.detail_result = "check stdout failed!" - self.fail = True - return - - # get es2abc file commands - def _get_ark_js_cmd(self): - os.environ.setdefault("LD_LIBRARY_PATH", TestCase.ld_library_path) - run_abc_cmd = [os.path.join(TestCase.js_runtime_path, 'ark_js_vm'), self.abc_file_path_temp] - return run_abc_cmd - pass - - def __get_js_basename(self): - sp = '/' - return "test_ts_cases" + sp + self.path.split(sp + "test_ts_cases" + sp)[1].replace('.ts', '.js') - - def __is_strict(self): - if 'strict' in self.declaration: - return bool(self.declaration['strict']) - return True - - def __tsc_test(self): - process = subprocess.Popen(self.__get_tsc_cmd(), stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - out, err = process.communicate() - return_code = process.returncode - if self.is_negative(): - if return_code == 0: - self.fail = True - self.detail_result = "No error found in negative case." - return - if self.__error_code() in out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore"): - return - self.fail = True - self.detail_result = "Error code not as expected." - return - # positive case - if return_code != 0: - self.detail_result = out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore") - self.fail = True - return - if self.is_current(): - with open(self.target_js_path, 'a') as fileAdded: - fileAdded.write('console.log("TESTCASE SUCCESS");') - # run node command - process = subprocess.Popen(self.__get_node_cmd(), stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - out, err = process.communicate() - return_code = process.returncode - if self.is_current(): - if os.path.exists(self.target_js_path): - os.remove(self.target_js_path) - if return_code != 0: - err_msg, line = get_error_message( - out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore"), self.__get_js_basename()) - self.detail_result = err_msg - self.err_line = line - self.fail = True - return - # check std out - if "TESTCASE SUCCESS" not in out.decode("utf-8", errors="ignore"): - self.detail_result = "check stdout failed!" - self.fail = True - return - - def __test_es2abc(self): - # compiler to abc - process = subprocess.Popen(self.__get_es2abc_cmd(self.path), stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - out, err = process.communicate() - return_code = process.returncode - if self.is_negative(): - if return_code == 0: - self.fail = True - return - if self.__error_type() in out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore"): - return - self.fail = True - self.detail_result = "Error type not as expected." - return - # positive case - if return_code != 0: - self.detail_result = out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore") - self.fail = True - return - # execute ark_js_vm - process = subprocess.Popen(self._get_ark_js_cmd(), stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - out, err = process.communicate() - return_code = process.returncode - if return_code != 0: - err_msg, line = get_error_message( - out.decode("utf-8", errors="ignore") + err.decode("utf-8", errors="ignore"), - os.path.basename(self.abc_file_path)) - self.detail_result = err_msg - self.err_line = line - self.fail = True - return - # check std out - if "TESTCASE SUCCESS" not in out.decode("utf-8", errors="ignore"): - self.detail_result = "check stdout failed!" - self.fail = True - return -- Gitee From 9bc07c73c46739a87e7d5458dc3debe6de794fd8 Mon Sep 17 00:00:00 2001 From: tanglizhen Date: Thu, 20 Jul 2023 13:47:03 +0800 Subject: [PATCH 17/18] Ts test cases --others Signed-off-by: tanglizhen --- .../array_literals/array_literal_1.ts | 34 -------- .../array_literals/array_literal_2.ts | 31 ------- .../array_literals/array_literal_3.ts | 26 ------ .../array_literals/array_literal_4.ts | 32 -------- .../array_literals/array_literal_5.ts | 28 ------- .../array_literals/array_literal_6.ts | 31 ------- .../arrow_function/arrow_function_1.ts | 34 -------- .../arrow_function/arrow_function_2.ts | 45 ----------- .../arrow_function/arrow_function_3.ts | 39 --------- .../arrow_function/arrow_function_4.ts | 38 --------- .../assignment_operator_1.ts | 31 ------- .../assignment_operator_2.ts | 80 ------------------- .../assignment_operator_3.ts | 31 ------- .../destructing_assignment_1.ts | 29 ------- .../destructing_assignment_2.ts | 35 -------- .../destructing_assignment_3.ts | 34 -------- .../destructing_assignment_4.ts | 42 ---------- .../destructing_assignment_5.ts | 42 ---------- .../destructing_assignment_6.ts | 30 ------- .../destructing_assignment_7.ts | 32 -------- .../destructing_assignment_8.ts | 35 -------- .../the_add_operator/the_add_operator_1.ts | 55 ------------- .../the_add_operator/the_add_operator_2.ts | 47 ----------- .../the_add_operator/the_add_operator_3.ts | 29 ------- .../the_and_operator/the_and_operator.ts | 70 ---------------- .../the_greater/the_congruence_operator.ts | 35 -------- .../the_greater/the_equal_operator.ts | 35 -------- .../the_greater/the_greater_operator.ts | 35 -------- .../the_greater_or_equal_operator.ts | 35 -------- .../the_greater/the_incongruence_operator.ts | 35 -------- .../the_greater/the_less_operator.ts | 35 -------- .../the_greater/the_less_or_equal_operator.ts | 35 -------- .../the_greater/the_unequal_operator.ts | 35 -------- .../the_in_operator/the_in_operator.ts | 47 ----------- .../the_instanceof_operator.ts | 57 ------------- .../the_mul/the_and_operator.ts | 51 ------------ .../the_mul/the_division_method_operator.ts | 47 ----------- .../the_mul/the_left_shift_operator.ts | 47 ----------- .../the_mul/the_multiplication_operator.ts | 47 ----------- .../the_mul/the_or_operator.ts | 51 ------------ .../the_mul/the_remainder_operator.ts | 47 ----------- .../the_mul/the_right_shift_operator.ts | 47 ----------- .../the_mul/the_subtraction_operator.ts | 47 ----------- .../the_unsigned_shift_to_the_right.ts | 47 ----------- .../the_mul/the_xor_operator.ts | 47 ----------- .../the_or_operator/the_or_operator_1.ts | 77 ------------------ .../the_or_operator/the_or_operator_2.ts | 41 ---------- .../class_expressions/class_expressions_1.ts | 56 ------------- .../contextually_typed_expressions_1.ts | 43 ---------- .../contextually_typed_expressions_10.ts | 38 --------- .../contextually_typed_expressions_11.ts | 30 ------- .../contextually_typed_expressions_12.ts | 37 --------- .../contextually_typed_expressions_13.ts | 33 -------- .../contextually_typed_expressions_14.ts | 36 --------- .../contextually_typed_expressions_15.ts | 29 ------- .../contextually_typed_expressions_16.ts | 31 ------- .../contextually_typed_expressions_2.ts | 30 ------- .../contextually_typed_expressions_3.ts | 31 ------- .../contextually_typed_expressions_4.ts | 45 ----------- .../contextually_typed_expressions_5.ts | 39 --------- .../contextually_typed_expressions_6.ts | 35 -------- .../contextually_typed_expressions_7.ts | 48 ----------- .../contextually_typed_expressions_8.ts | 44 ---------- .../contextually_typed_expressions_9.ts | 39 --------- .../grammar_ambiguities.ts | 41 ---------- .../overload_resolution_1.ts | 41 ---------- .../overload_resolution_2.ts | 42 ---------- .../type_argument_inference_1.ts | 37 --------- .../type_argument_inference_2.ts | 39 --------- .../type_argument_inference_3.ts | 32 -------- .../type_argument_inference_4.ts | 35 -------- .../function_expressions_1.ts | 36 --------- .../function_expressions_2.ts | 34 -------- .../function_expressions_3.ts | 38 --------- .../function_expressions_4.ts | 38 --------- .../spec/expressions/identifiers/class.ts | 33 -------- .../spec/expressions/identifiers/enum.ts | 31 ------- .../spec/expressions/identifiers/function.ts | 27 ------- .../expressions/identifiers/name_space.ts | 42 ---------- .../spec/expressions/identifiers/parameter.ts | 37 --------- .../spec/expressions/identifiers/variable.ts | 28 ------- .../spec/expressions/literals/boolean.ts | 25 ------ .../spec/expressions/literals/null.ts | 25 ------ .../spec/expressions/literals/number.ts | 25 ------ .../spec/expressions/literals/regexp.ts | 25 ------ .../spec/expressions/literals/string.ts | 26 ------ .../object_literal/object_literal_1.ts | 47 ----------- .../object_literal/object_literal_2.ts | 50 ------------ .../object_literal/object_literal_3.ts | 48 ----------- .../object_literal/object_literal_4.ts | 41 ---------- .../object_literal/object_literal_5.ts | 46 ----------- .../object_literal/object_literal_6.ts | 41 ---------- .../object_literal/object_literal_7.ts | 57 ------------- .../object_literal/object_literal_8.ts | 44 ---------- .../object_literal/object_literal_9.ts | 51 ------------ .../expressions/parentheses/parentheses.ts | 51 ------------ .../property_access/object_access_2.ts | 50 ------------ .../property_access/object_any_1.ts | 32 -------- .../property_access/object_any_type_6.ts | 42 ---------- .../property_access/object_apprent_5.ts | 35 -------- .../property_access/object_index_4.ts | 36 --------- .../property_access/object_string_number_3.ts | 45 ----------- .../property_access/property_access_1.ts | 32 -------- .../property_access/property_access_2.ts | 32 -------- .../template_literals/template_literals.ts | 80 ------------------- .../the_comma_operator/the_comma_operator.ts | 39 --------- .../the_conditional_operator_1.ts | 35 -------- .../the_conditional_operator_2.ts | 39 --------- .../the_new_operator/new_operator_1.ts | 36 --------- .../the_new_operator/new_operator_2.ts | 41 ---------- .../the_new_operator/new_operator_3.ts | 35 -------- .../the_new_operator/new_operator_4.ts | 49 ------------ .../super_calls/arguments.ts | 37 --------- .../super_calls/gengric_extends.ts | 40 ---------- .../super_calls/super_calls.ts | 53 ------------ .../super_property_access_1.ts | 59 -------------- .../super_property_access_2.ts | 39 --------- .../this_key_word/this_key_word_1.ts | 48 ----------- .../this_key_word/this_key_word_2.ts | 39 --------- .../this_key_word/this_key_word_3.ts | 50 ------------ .../this_key_word/this_key_word_4.ts | 45 ----------- .../type_assertion/type_assertion_1.ts | 35 -------- .../type_assertion/type_assertion_2.ts | 61 -------------- .../type_assertion/type_assertion_3.ts | 33 -------- .../expressions/type_guards/type_guards_1.ts | 40 ---------- .../expressions/type_guards/type_guards_10.ts | 40 ---------- .../expressions/type_guards/type_guards_11.ts | 41 ---------- .../expressions/type_guards/type_guards_12.ts | 41 ---------- .../expressions/type_guards/type_guards_13.ts | 52 ------------ .../expressions/type_guards/type_guards_2.ts | 37 --------- .../expressions/type_guards/type_guards_3.ts | 32 -------- .../expressions/type_guards/type_guards_4.ts | 32 -------- .../expressions/type_guards/type_guards_5.ts | 31 ------- .../expressions/type_guards/type_guards_6.ts | 56 ------------- .../expressions/type_guards/type_guards_7.ts | 41 ---------- .../expressions/type_guards/type_guards_8.ts | 54 ------------- .../expressions/type_guards/type_guards_9.ts | 40 ---------- .../unary_operators/the_!_operator.ts | 33 -------- .../the_++_and_--_operators.ts | 52 ------------ .../unary_operators/the_+_and_~_operators.ts | 34 -------- .../unary_operators/the_delete_operator.ts | 35 -------- .../unary_operators/the_typeof_operator.ts | 29 ------- .../unary_operators/the_void_operator.ts | 28 ------- 143 files changed, 5742 deletions(-) delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_7.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_8.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_congruence_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_equal_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_or_equal_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_incongruence_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_or_equal_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_unequal_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_instanceof_operator/the_instanceof_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_and_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_division_method_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_left_shift_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_multiplication_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_or_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_remainder_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_right_shift_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_subtraction_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_unsigned_shift_to_the_right.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_xor_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/class_expressions/class_expressions_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_10.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_11.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_13.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_15.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_16.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_9.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/class.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/enum.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/function.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/name_space.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/parameter.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/variable.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/boolean.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/null.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/number.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/regexp.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/string.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_7.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_8.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_9.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/parentheses/parentheses.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_access_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_type_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_apprent_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_index_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_string_number_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/template_literals/template_literals.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_comma_operator/the_comma_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/arguments.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/super_calls.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/super_property_access_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/super_property_access_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_1.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_10.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_11.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_12.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_13.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_2.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_3.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_4.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_5.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_6.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_7.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_8.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_9.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_!_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_++_and_--_operators.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_+_and_~_operators.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_delete_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_typeof_operator.ts delete mode 100644 es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_void_operator.ts diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_1.ts deleted file mode 100644 index 32a416d660..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_1.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.23) - by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, - the element expression is contextually typed by the type of that property. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface MyArray { - 0: number; - 1: string; - length: 2; -} -const myArray: MyArray = [42, "hello"]; -Assert.isNumber(myArray[0]); -Assert.isString(myArray[1]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_2.ts deleted file mode 100644 index 78b09fffd4..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_2.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the array literal is contextually typed by a type T with a numeric index signature, - the element expression is contextually typed by the type of the numeric index signature - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let MyArray: { - [key: number]: string; -} = ["aaa", "bbb", "ccc"]; -Assert.isString(MyArray[0]); -Assert.isString(MyArray[1]); -Assert.isString(MyArray[2]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_3.ts deleted file mode 100644 index 270c64722a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_3.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the array literal is empty, the resulting type is an array type with the element type Undefined. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -const emptyArray: any[] = []; -Assert.isUndefined(emptyArray[0]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_4.ts deleted file mode 100644 index 81a90b45b6..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_4.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the array literal contains no spread elements and is contextually typed by a tuple-like type (section 3.3.3), - the resulting type is a tuple type constructed from the types of the element expressions - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let myTuple: [string, number] = ["hello", 42]; -Assert.isString(myTuple[0]); -Assert.isNumber(myTuple[1]); -function foo(pair: [string, number]) { - return pair -} -Assert.equal(JSON.stringify(foo(["hello", 42])), '["hello",42]'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_5.ts deleted file mode 100644 index b620932604..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_5.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.21.1), - the resulting type is a tuple type constructed from the types of the element expressions. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let [x, y]: [string, number] = ["hello", 42]; -Assert.isString(x); -Assert.isNumber(y); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_6.ts deleted file mode 100644 index 4e51f2a244..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/array_literals/array_literal_6.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The resulting type is an array type with an element type that is the union of the types of - the non-spread element expressions and the numeric index signature types of the spread element expressions. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let arr = [1, 2, ...["three", "four"], 5]; -Assert.isNumber(arr[0]); -Assert.isNumber(arr[1]); -Assert.isString(arr[2]); -Assert.isString(arr[3]); -Assert.isNumber(arr[4]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_1.ts deleted file mode 100644 index d2d837d32c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_1.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Arrow functions are extended from JavaScript to optionally include parameter and return type annotations. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -const addNumbers = (num1: number, num2: number): number => { - return num1 + num2; -}; -const result1 = addNumbers(5, 10); -Assert.equal(result1, 15); -const greet = (name: string) => { - return name; -}; -const result2 = greet("Alice"); -Assert.equal(result2, "Alice"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_2.ts deleted file mode 100644 index d483ad0bc0..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_2.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - 1.( ... ) => expr is exactly equivalent to ( ... ) => { return expr ; } - 2.id => { ... } id => expr are exactly equivalent to - ( id ) => { ... } ( id ) => expr - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -const myFunctionA = (num: string): string => { - return num; -}; -const resultA = myFunctionA("hello,world"); -Assert.equal(resultA, "hello,world"); -const myFunctionB: () => string = () => "hello,world"; -const resultB = myFunctionB(); -Assert.equal(resultB, "hello,world"); -let getTempItem = (id: any) => ({ id: id, name: "Temp" }); -const TempAResult = getTempItem(123); -Assert.equal(TempAResult.id, 123); -let getTempItemB = function (id: any) { - return { - id: id, - name: "Temp", - }; -}; -const TempBResult = getTempItemB(123); -Assert.equal(TempBResult.id, 123); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_3.ts deleted file mode 100644 index a8aa4b7819..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_3.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - When an arrow function with an expression body and no return type annotation is contextually typed - by a function type T and a contextual signature S can be extracted from T, - the expression body is contextually typed by the return type of S. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let myFunction = (h_x: number, h_y: number) => { return h_x + h_y; } -function myFunc(myValue: (x: number, y: number) => number) { - return myValue; -} -Assert.isFunction(myFunc(myFunction)); -function getx(x: number): number { - return x; -} -const a: number = 10; -let x = () => { return getx(a); } -let y = () => getx(a); -Assert.equal(x(), 10); -Assert.equal(y(), 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_4.ts deleted file mode 100644 index f7e54b5fac..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/arrow_function/arrow_function_4.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A function expression introduces a new dynamically bound this, whereas an arrow function expression preserves the this of its enclosing context. - Arrow function expressions are particularly useful for writing callbacks, which otherwise often have an undefined or unexpected this. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class ToAlert { - information = "Have a good time!"; - F() { - let for_this = this; - for_this.information = "sad boy"; - Assert.equal(for_this.information, "sad boy") - } -}; -let a = new ToAlert(); -a.F(); -a.information = "boy!"; -Assert.isString(a.information); -Assert.equal(a.information, "boy!"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts deleted file mode 100644 index 2dba576210..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_1.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - An assignment of the form 'v = expr' requires v to be classified as a reference or as an assignment pattern. - The expr expression is contextually typed by the type of v, and the type of expr must be assignable to the type of v, - or otherwise a compile-time error occurs. The result is a value with the type of expr. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var sum: Function = function (x: number, y: number) { - return x + y -} -let result = sum(5, 10); -Assert.equal(result, 15); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_2.ts deleted file mode 100644 index 6603bcda8e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_2.ts +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A compound assignment of the form 'v ??= expr' where '??=' is one of the compound assignment operators, - is subject to the same requirements, and produces a value of the same type, as the corresponding non-compound operation. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var x: number = 10 -var y: number = 20 -x *= y -Assert.isNumber(x); -Assert.equal(x, 200); -x = 10; -y = 20; -x /= y -Assert.isNumber(x); -Assert.equal(x, 0.5); -x = 10; -y = 20; -x %= y -Assert.isNumber(x); -Assert.equal(x, 10); -x = 10; -y = 20; -x += y -Assert.isNumber(x); -Assert.equal(x, 30); -x = 10; -y = 20; -x -= y -Assert.isNumber(x); -Assert.equal(x, -10); -x = 10; -y = 20; -x <<= y -Assert.isNumber(x); -Assert.equal(x, 10485760); -x = 10; -y = 20; -x >>= y -Assert.isNumber(x); -Assert.equal(x, 0); -x = 10; -y = 20; -x >>>= y -Assert.isNumber(x); -Assert.equal(x, 0); -x = 10; -y = 20; -x &= y -Assert.isNumber(x); -Assert.equal(x, 0); -x = 10; -y = 20; -x ^= y -Assert.isNumber(x); -Assert.equal(x, 30); -x = 10; -y = 20; -x |= y -Assert.isNumber(x); -Assert.equal(x, 30); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_3.ts deleted file mode 100644 index 025a430f02..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/assignment_operators/assignment_operator_3.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A compound assignment furthermore requires v to be classified as a reference and the type of the non-compound operation to be assignable to the type of v. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let obj = { - name: 'xiao', - age: 18 -} -let v = obj -v.age += v.age -Assert.equal(v.age, 36); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_1.ts deleted file mode 100644 index 731c9d1407..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_1.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. - An expression of type S is considered assignable to an assignment target V, if V is variable and S is assignable to the type of V. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let arr = [1, 2] -let [first, second] = arr -Assert.equal(first, 1) -Assert.equal(second, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_2.ts deleted file mode 100644 index 8555c425b6..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_2.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. - An expression of type S is considered assignable to an assignment target V if V is an object assignment pattern and, - for each assignment property P in V, S is the type Any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let obj: any = { - a: "foo", - b: 15, - c: "bar" -} -let { a, b, c } = obj; -Assert.equal(a, 'foo') -Assert.equal(b, 15) -Assert.equal(c, 'bar'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_3.ts deleted file mode 100644 index 722f536d89..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_3.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. - An expression of type S is considered assignable to an assignment target V if V is an object assignment pattern and, - for each assignment property P in V, S has an apparent property with the property name specified in P of a type that is assignable to the target given in P. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let obj = { - a: "foo", - b: 15, - c: "bar" -} -let { a, b } = obj; -Assert.equal(a, 'foo'); -Assert.equal(b, 15); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_4.ts deleted file mode 100644 index 0d12823371..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_4.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. - An expression of type S is considered assignable to an assignment target V if V is an object assignment pattern and, - for each assignment property P in V, P specifies a numeric property name and S has a numeric index signature of a type that is assignable to the target given in P. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface Foo { - [key: number]: string - 18: string - 180: string -} -let t: Foo = { - 18: 'age', - 180: 'height' -} -let v = { - 18: 'Age', - 180: 'Height' -} -v = t -Assert.equal(v[18], 'age'); -Assert.equal(v[180], 'height'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_5.ts deleted file mode 100644 index bcbbee18d3..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_5.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. - An expression of type S is considered assignable to an assignment target V if V is an object assignment pattern and, - for each assignment property P in V,S has a string index signature of a type that is assignable to the target given in P. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface Foo { - [key: string]: string - name: string - house: string -} -let t: Foo = { - name: 'xiao', - house: 'nanjing' -} -let v = { - name: '', - house: '' -} -v = t -Assert.equal(v.house, 'nanjing'); -Assert.equal(v.name, 'xiao'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_6.ts deleted file mode 100644 index 10a776d67d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_6.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. - An expression of type S is considered assignable to an assignment target V if V is an array assignment pattern, - for each assignment element E in V, S is the type Any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let arr: any = [1, 2] -let [first, second]: [number, number] = arr -Assert.equal(first, 1) -Assert.equal(second, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_7.ts deleted file mode 100644 index b7bb0e33ea..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_7.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. - An expression of type S is considered assignable to an assignment target V if V is an array assignment pattern, - for each assignment element E in V, S is a tuple-like type with a property named N of a type that is assignable to the target given in E, - where N is the numeric index of E in the array assignment pattern. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -let s: ['0', string, number] = ['0', 'str', 10] -let [x, y, z]: [string, string, number] = s -Assert.equal(x, '0') -Assert.equal(y, 'str') -Assert.equal(z, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_8.ts deleted file mode 100644 index 5fe003b1d5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/assignment_operators/destructing_assignment/destructing_assignment_8.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. - An expression of type S is considered assignable to an assignment target V if V is an array assignment pattern, - S is the type Any or an array-like type, and, for each assignment element E in V, - S is not a tuple-like type and the numeric index signature type of S is assignable to the target given in E. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface A { - [key: number]: string -} -let a: A = ['a', 'b', 'c'] -let [x, y, z] = [a[0], a[1], a[2]] -Assert.equal(x, 'a') -Assert.equal(y, 'b') -Assert.equal(z, 'c'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts deleted file mode 100644 index 9f13b77ca8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_1.ts +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The binary + operator requires both operands to be of the Number primitive type or an enum type, - or at least one of the operands to be of type Any or the String primitive type. - Operands of an enum type are treated as having the primitive type Number. - If one operand is the null or undefined value, it is treated as having the type of the other operand. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: number = 10 -var b: number = 20 -var x = a + b -Assert.equal(x, 30) -enum e1 { - A, - B, - C -} -enum e2 { - D, - E, - F -} -var c = e1.A -Assert.equal(c, 0) -var d = e2.D -Assert.equal(d, 0) -var y = c + d -Assert.equal(y, 0) -var e: any = true -Assert.isTrue(e) -var f: string = 's' -Assert.equal(f, 's') -var w = a + e -Assert.equal(w, 11) -var v = c + f -Assert.equal(v, '0s'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts deleted file mode 100644 index d563a695ea..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_2.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The binary + operator, - If one or both operands are of the String primitive type, the result is of the String primitive type. - Otherwise, the result is of type Any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = true -var b: any = 's' -var c: boolean = false -var d: string = 'str' -var e: number = 10 -var f: any = 20 -var w = a + b -Assert.isString(w); -Assert.equal(w, 'trues'); -var v = a + f -Assert.isNumber(v); -Assert.equal(v, 21); -var x = a + c -Assert.isNumber(x); -Assert.equal(x, 1); -var y = a + d -Assert.isString(y); -Assert.equal(y, 'truestr'); -var z = a + e -Assert.isNumber(z); -Assert.equal(z, 11); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts deleted file mode 100644 index 1584ff3a92..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_add_operator/the_add_operator_3.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The binary + operator, - A value of any type can converted to the String primitive type by adding an empty string. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -function func() { } -let s = func() + "" -Assert.isString(s); -Assert.equal(s, 'undefined'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts deleted file mode 100644 index 773396e33d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_and_operator/the_and_operator.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The && operator permits the operands to be of any type and produces a result of the same type as the second operand. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = 10 -var b: any = 's' -var c: boolean = false -var d: boolean = true -var e: number = 20 -var f: number = 15 -var g: string = 'a' -var h: string = 'b' -var i: undefined = undefined -var j: undefined = undefined -var k = a && b -Assert.isString(k); -Assert.equal(k, 's'); -var l = c && d -Assert.isFalse(l); -var m = e && f -Assert.isNumber(m); -Assert.equal(m, 15); -var n = g && h -Assert.isString(n); -Assert.equal(n, 'b'); -var o = i && j -Assert.isUndefined(o); -var p = a && c -Assert.isFalse(p); -var q = a && e -Assert.isNumber(q); -Assert.equal(q, 20); -var r = a && g -Assert.isString(r); -Assert.equal(r, 'a'); -var s = a && i -Assert.isUndefined(s); -var t = c && e -Assert.isFalse(t); -var u = c && g -Assert.isFalse(u); -var v = c && i -Assert.isFalse(v); -var w = e && g -Assert.isString(w); -Assert.equal(w, 'a'); -var x = e && i -Assert.isUndefined(x); -var y = g && i -Assert.isUndefined(y); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_congruence_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_congruence_operator.ts deleted file mode 100644 index 7355498027..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_congruence_operator.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '===' operator require one or both of the operand types to be assignable to the other. - The result is always of the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = undefined; -var b: boolean = true; -var c: number = 1; -var d: string = 'str'; -var e: number = 1; -Assert.isFalse(a === b); -Assert.isFalse(a === c); -Assert.isFalse(a === d); -Assert.isFalse(b as unknown === c); -Assert.isTrue(c === e); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_equal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_equal_operator.ts deleted file mode 100644 index 95e2a6c463..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_equal_operator.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '==' operator require one or both of the operand types to be assignable to the other. - The result is always of the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = undefined; -var b: boolean = true; -var c: number = 1; -var d: string = 'str'; -var e: number = 1; -Assert.isFalse(a == b); -Assert.isFalse(a == c); -Assert.isFalse(a == d); -Assert.isTrue(b as unknown == c); -Assert.isTrue(c == e); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_operator.ts deleted file mode 100644 index af6b372c83..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_operator.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '>' operator require one or both of the operand types to be assignable to the other. - The result is always of the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = undefined; -var b: boolean = true; -var c: number = 10; -var d: string = 'str'; -var e: number = 0; -Assert.isFalse(a > b); -Assert.isFalse(a > c); -Assert.isFalse(a > d); -Assert.isTrue(c > (b as unknown as number)); -Assert.isTrue(c > e); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_or_equal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_or_equal_operator.ts deleted file mode 100644 index eb07feba43..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_greater_or_equal_operator.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '>=' operator require one or both of the operand types to be assignable to the other. - The result is always of the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = undefined; -var b: boolean = true; -var c: number = 1; -var d: string = 'str'; -var e: number = 0; -Assert.isFalse(a >= b); -Assert.isFalse(a >= c); -Assert.isFalse(a >= d); -Assert.isTrue(c >= (b as unknown as number)); -Assert.isTrue(c >= e); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_incongruence_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_incongruence_operator.ts deleted file mode 100644 index fa381e16a2..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_incongruence_operator.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '!==' operator require one or both of the operand types to be assignable to the other. - The result is always of the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = undefined; -var b: boolean = true; -var c: number = 1; -var d: string = 'str'; -var e: number = 1; -Assert.isTrue(a !== b); -Assert.isTrue(a !== c); -Assert.isTrue(a !== d); -Assert.isTrue(b as unknown !== c); -Assert.isFalse(c !== e); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_operator.ts deleted file mode 100644 index 83e35d4f0d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_operator.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '<' operator require one or both of the operand types to be assignable to the other. - The result is always of the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = undefined; -var b: boolean = true; -var c: number = 1; -var d: string = 'str'; -var e: number = 0; -Assert.isFalse(a < b) -Assert.isFalse(a < c) -Assert.isFalse(a < d); -Assert.isFalse(c < (b as unknown as number)); -Assert.isFalse(c < e); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_or_equal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_or_equal_operator.ts deleted file mode 100644 index 86271a7683..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_less_or_equal_operator.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '<=' operator require one or both of the operand types to be assignable to the other. - The result is always of the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = undefined; -var b: boolean = true; -var c: number = 1; -var d: string = 'str'; -var e: number = 0; -Assert.isFalse(a <= b) -Assert.isFalse(a <= c) -Assert.isFalse(a <= d); -Assert.isTrue(c <= (b as unknown as number)); -Assert.isFalse(c <= e); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_unequal_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_unequal_operator.ts deleted file mode 100644 index 68ba03331e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_greater/the_unequal_operator.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '!=' operator require one or both of the operand types to be assignable to the other. - The result is always of the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = undefined; -var b: boolean = true; -var c: number = 1; -var d: string = 'str'; -var e: number = 1; -Assert.isTrue(a != b) -Assert.isTrue(a != c) -Assert.isTrue(a != d); -Assert.isFalse(b as unknown != c); -Assert.isFalse(c != e); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts deleted file mode 100644 index 5b201f2b87..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_in_operator/the_in_operator.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, - and the right operand to be of type Any, an object type, or a type parameter type. - The result is always of the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface A { - num: number -} -interface B { - str: string -} -function isString(k: A | B) { - let flag: boolean = false; - if ('num' in k) { - Assert.isTrue('num' in k); - flag = false; - } else if ('str' in k) { - Assert.isTrue('str' in k); - flag = true; - } - return flag; -} -let result1 = isString({ num: 20 }); -Assert.isFalse(result1); -let result2 = isString({ str: 'A' }); -Assert.isTrue(result2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_instanceof_operator/the_instanceof_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_instanceof_operator/the_instanceof_operator.ts deleted file mode 100644 index 2a9e1e5435..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_instanceof_operator/the_instanceof_operator.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type, - and the right operand to be of type Any or a subtype of the 'Function' interface type. - The result is always of the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -interface Animal { - species: string -} -class Felidae implements Animal { - kind: string - species: string - constructor(species: string, kind: string) { - this.species = species - this.kind = kind - } -} -class Canidae implements Animal { - species: string - name: string - constructor(species: string, name: string) { - this.species = species - this.name = name - } -} -const getRandomAnimal = () => { - return Math.random() < 0.5 ? - new Canidae('Canidae', 'Wolf') : - new Felidae('Felidae', 'Tiger') -} -let Animal = getRandomAnimal() -if (Animal instanceof Canidae) { - Assert.isTrue(Animal instanceof Canidae) -} -if (Animal instanceof Felidae) { - Assert.isTrue(Animal instanceof Felidae); -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_and_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_and_operator.ts deleted file mode 100644 index 7f3c671a94..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_and_operator.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '&' operator require its operands to be of type Any, the Number primitive type, or an enum type. - Operands of an enum type are treated as having the primitive type Number. - If one operand is the null or undefined value, it is treated as having the type of the other operand. - The result is always of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = '10'; -var b: any = true; -var c: number = 9; -var x = a & b; -var y = a & c; -var bb = b & b; -var cc = c & c; -Assert.isNumber(x); -Assert.equal(x, 0); -Assert.isNumber(y); -Assert.equal(y, 8); -Assert.isNumber(bb); -Assert.equal(bb, 1); -Assert.isNumber(cc); -Assert.equal(cc, 9); -enum e { - A, - B, - C -} -var d = e.C; -var z = a & d; -Assert.isNumber(z); -Assert.equal(z, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_division_method_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_division_method_operator.ts deleted file mode 100644 index 1e8304437c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_division_method_operator.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '/' operator require its operands to be of type Any, the Number primitive type, or an enum type. - Operands of an enum type are treated as having the primitive type Number. - If one operand is the null or undefined value, it is treated as having the type of the other operand. - The result is always of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = '10'; -var b: any = true; -var c: number = 20; -var x = b / a; -var y = a / c; -Assert.isNumber(x); -Assert.equal(x, 0.1); -Assert.isNumber(y); -Assert.equal(y, 0.5); -Assert.isNumber(c / 2); -Assert.equal(c / 2, 10); -enum e { - A, - B, - C -} -var d = e.C; -var z = a / d; -Assert.isNumber(z); -Assert.equal(z, 5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_left_shift_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_left_shift_operator.ts deleted file mode 100644 index 93c3f48936..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_left_shift_operator.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '<<' operator require its operands to be of type Any, the Number primitive type, or an enum type. - Operands of an enum type are treated as having the primitive type Number. - If one operand is the null or undefined value, it is treated as having the type of the other operand. - The result is always of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = '10'; -var b: any = true; -var c: number = 20; -var x = a << b; -var y = c << a; -Assert.isNumber(x); -Assert.equal(x, 20); -Assert.isNumber(y); -Assert.equal(y, 20480); -Assert.isNumber(c << 2); -Assert.equal(c << 2, 80); -enum e { - A, - B, - C -} -var d = e.C; -var z = a << d; -Assert.isNumber(z); -Assert.equal(z, 40); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_multiplication_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_multiplication_operator.ts deleted file mode 100644 index 592d9bc61a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_multiplication_operator.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '*' operator require its operands to be of type Any, the Number primitive type, or an enum type. - Operands of an enum type are treated as having the primitive type Number. - If one operand is the null or undefined value, it is treated as having the type of the other operand. - The result is always of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = '10'; -var b: any = false; -var c: number = 20; -var x = a * b; -var y = a * c; -Assert.isNumber(x); -Assert.equal(x, 0); -Assert.isNumber(y); -Assert.equal(y, 200); -Assert.isNumber(c * 2); -Assert.equal(c * 2, 40); -enum e { - A, - B, - C -} -var d = e.C; -var z = a * d; -Assert.isNumber(z); -Assert.equal(z, 20); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_or_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_or_operator.ts deleted file mode 100644 index 7da1b71d72..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_or_operator.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '|' operator require its operands to be of type Any, the Number primitive type, or an enum type. - Operands of an enum type are treated as having the primitive type Number. - If one operand is the null or undefined value, it is treated as having the type of the other operand. - The result is always of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = '10'; -var b: any = true; -var c: number = 9; -var x = a | b; -var y = a | c; -var bb = b | b; -var cc = c | c; -Assert.isNumber(x); -Assert.equal(x, 11); -Assert.isNumber(y); -Assert.equal(y, 11); -Assert.isNumber(bb); -Assert.equal(bb, 1); -Assert.isNumber(cc); -Assert.equal(cc, 9); -enum e { - A, - B, - C -} -var d = e.C; -var z = a | d; -Assert.isNumber(z); -Assert.equal(z, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_remainder_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_remainder_operator.ts deleted file mode 100644 index 64034d3d7e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_remainder_operator.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '%' operator require its operands to be of type Any, the Number primitive type, or an enum type. - Operands of an enum type are treated as having the primitive type Number. - If one operand is the null or undefined value, it is treated as having the type of the other operand. - The result is always of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = '11'; -var b: any = true; -var c: number = 5; -var x = a % b; -var y = a % c; -Assert.isNumber(x); -Assert.equal(x, 0); -Assert.isNumber(y); -Assert.equal(y, 1); -Assert.isNumber(28 % c); -Assert.equal(28 % c, 3); -enum e { - A, - B, - C -} -var d = e.C; -var z = a % d; -Assert.isNumber(z); -Assert.equal(z, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_right_shift_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_right_shift_operator.ts deleted file mode 100644 index c5dba842a4..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_right_shift_operator.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '>>' operator require its operands to be of type Any, the Number primitive type, or an enum type. - Operands of an enum type are treated as having the primitive type Number. - If one operand is the null or undefined value, it is treated as having the type of the other operand. - The result is always of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = '10'; -var b: any = true; -var c: number = 20; -var x = a >> b; -var y = a >> c; -Assert.isNumber(x); -Assert.equal(x, 5); -Assert.isNumber(y); -Assert.equal(y, 0); -Assert.isNumber(c >> 4); -Assert.equal(c >> 4, 1); -enum e { - A, - B, - C -} -var d = e.C; -var z = a >> d; -Assert.isNumber(z); -Assert.equal(z, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_subtraction_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_subtraction_operator.ts deleted file mode 100644 index ac23d291e3..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_subtraction_operator.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '-' operator require its operands to be of type Any, the Number primitive type, or an enum type. - Operands of an enum type are treated as having the primitive type Number. - If one operand is the null or undefined value, it is treated as having the type of the other operand. - The result is always of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = '10'; -var b: any = true; -var c: number = 20; -var x = a - b; -var y = a - c; -Assert.isNumber(x); -Assert.equal(x, 9); -Assert.isNumber(y); -Assert.equal(y, -10); -Assert.isNumber(c - 9); -Assert.equal(c - 9, 11); -enum e { - A, - B, - C -} -var d = e.A; -var z = a - d; -Assert.isNumber(z); -Assert.equal(z, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_unsigned_shift_to_the_right.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_unsigned_shift_to_the_right.ts deleted file mode 100644 index 1710c25a47..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_unsigned_shift_to_the_right.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '>>>' operator require its operands to be of type Any, the Number primitive type, or an enum type. - Operands of an enum type are treated as having the primitive type Number. - If one operand is the null or undefined value, it is treated as having the type of the other operand. - The result is always of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = '10'; -var b: any = true; -var c: number = 20; -var x = a >>> b; -var y = a >>> c; -Assert.isNumber(x); -Assert.equal(x, 5); -Assert.isNumber(y); -Assert.equal(y, 0); -Assert.isNumber(c >>> 4); -Assert.equal(c >>> 4, 1); -enum e { - A, - B, - C -} -var d = e.C; -var z = a >>> d; -Assert.isNumber(z); -Assert.equal(z, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_xor_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_xor_operator.ts deleted file mode 100644 index 64c0333b88..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_mul/the_xor_operator.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The '^' operator require its operands to be of type Any, the Number primitive type, or an enum type. - Operands of an enum type are treated as having the primitive type Number. - If one operand is the null or undefined value, it is treated as having the type of the other operand. - The result is always of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = '10'; -var b: any = true; -var c: number = 20; -var x = a ^ b; -var y = a ^ c; -Assert.isNumber(x); -Assert.equal(x, 11); -Assert.isNumber(y); -Assert.equal(y, 30); -Assert.isNumber(c ^ 4); -Assert.equal(c ^ 4, 16); -enum e { - A, - B, - C -} -var d = e.C; -var z = a ^ d; -Assert.isNumber(z); -Assert.equal(z, 8); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts deleted file mode 100644 index 3bfc017ab7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_1.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The || operator permits the operands to be of any type. - The type of the result is the union type of the two operand types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var a: any = 10; -var b: any = 's'; -var c: boolean = false; -var d: boolean = true; -var e: number = 20; -var f: number = 15; -var g: string = 'a'; -var h: string = 'b'; -var i: undefined = undefined; -var j: undefined = undefined; -var k = a || b; -Assert.isNumber(k); -Assert.equal(k, 10); -var l = c || d; -Assert.isTrue(l); -var m = e || f; -Assert.isNumber(m); -Assert.equal(m, 20); -var n = g || h; -Assert.isString(n); -Assert.equal(n, 'a'); -var o = i || j; -Assert.isUndefined(o); -var p = a || c; -Assert.isNumber(p); -Assert.equal(p, 10); -var q = a || e; -Assert.isNumber(q); -Assert.equal(q, 10); -var r = a || g; -Assert.isNumber(r); -Assert.equal(r, 10); -var s = a || i; -Assert.isNumber(s); -Assert.equal(s, 10); -var t = c || e; -Assert.isNumber(t); -Assert.equal(t, 20); -var u = c || g; -Assert.isString(u); -Assert.equal(u, 'a'); -var v = c || i; -Assert.isUndefined(v); -var w = e || g; -Assert.isNumber(w); -Assert.equal(w, 20); -var x = e || i; -Assert.isNumber(x); -Assert.equal(x, 20); -var y = g || i; -Assert.isString(y); -Assert.equal(y, 'a'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_2.ts deleted file mode 100644 index ab473317f6..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/binary_operators/the_or_operator/the_or_operator_2.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the || expression is contextually typed, the operands are contextually typed by the same type. - Otherwise, the left operand is not contextually typed and the right operand is contextually typed by the type of the left operand. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var sum = function (x: number, y: number) { - return x + y -} -var average = function (a: number, b: number) { - return (a + b) / 2 -} -var rela1 = sum || average; -var rela2 = average || sum; -let a = rela1(1, 2); -let b = rela2(1, 2); -Assert.isFunction(rela1); -Assert.isFunction(rela2); -Assert.equal(rela1, sum); -Assert.equal(rela2, average); -Assert.equal(a, 3); -Assert.equal(b, 1.5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/class_expressions/class_expressions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/class_expressions/class_expressions_1.ts deleted file mode 100644 index 83c9081bee..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/class_expressions/class_expressions_1.ts +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Just as with class declarations, class expressions would create a constructor function that can be used to construct instances. - Like class declarations, you may also declare property members and index members, as well as use the constructor parameters. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var Square = class { - acreage: number; - - constructor(public h_length: number, public h_width: number) { - this.acreage = this.h_length * this.h_width; - } -}; -var square = new Square(5, 10); -Assert.equal(square.acreage, 50); -let Ref = class Reflmpl { - public readonly _v = true; - constructor(private _rawValue: number, public _shaw = false) { - this._rawValue = _rawValue; - this._shaw = this._shaw; - } - get value() { - return this._rawValue; - } - set value(newVal) { - this._rawValue = newVal; - } - get shaw() { - return this._shaw; - } - set shaw(newShaw) { - this._shaw = newShaw; - } -} -let ref = new Ref(10, true); -Assert.equal(ref.value, 10); -Assert.equal(ref._shaw, true); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts deleted file mode 100644 index 0868288f8f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_1.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a variable, parameter, binding property, binding element, or member declaration, - an initializer expression is contextually typed by the type given in the declaration's type annotation. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let a: number -a = 10 -Assert.isNumber(a) -function fun(x: string) { - let y = x + 'ing' - return y -} -Assert.isString(fun('str')) -interface Obj { - name: string - age: number -} -let obj: Obj = { - name: 'xiao', - age: 18 -} -Assert.isString(obj.name) -Assert.isNumber(obj.age); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_10.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_10.ts deleted file mode 100644 index c9649d460a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_10.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a contextually typed array literal expression containing no spread elements, an element expression at index N is contextually typed by - the type of the property with the numeric name N in the contextual type, if any, or otherwise - the numeric index type of the contextual type, if any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let arr: { - [key: number]: string -} = { - 1: 'a', - 2: 'b', - 3: 'c', - 4: 'd' -} -Assert.isString(arr[1]) -Assert.isString(arr[2]) -Assert.isString(arr[3]) -Assert.isString(arr[4]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_11.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_11.ts deleted file mode 100644 index 46c0bdd684..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_11.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a contextually typed array literal expression containing one or more spread elements, - an element expression at index N is contextually typed by the numeric index type of the contextual type, if any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let first = [1, 2] -let second = [3, 4] -let bothPlus = [0, ...first, ...second, 5] -Assert.isNumber(bothPlus[2]) -Assert.isNumber(bothPlus[4]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts deleted file mode 100644 index 5c60fa1c14..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_12.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a contextually typed parenthesized expression, the contained expression is contextually typed by the same type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var a: number = 10 -var b: number = 5 -var c = (a + b) * (a - b) -Assert.isNumber(c) -interface Foo { - num: number - str: string -} -const x: Foo[] = [{ num: 18, str: 'hello' }, { num: 20, str: 'world' }] -Assert.isNumber(x[0].num) -Assert.isNumber(x[1].num) -Assert.isString(x[0].str) -Assert.isString(x[1].str); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_13.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_13.ts deleted file mode 100644 index b7a6cd652f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_13.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a type assertion, the expression is contextually typed by the indicated type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface Person { - name: string - age: number -} -let student = {} as Person -student.name = 'xiao' -student.age = 18 -Assert.isNumber(student.age) -Assert.isString(student.name); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts deleted file mode 100644 index 76c8be1985..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_14.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a || operator expression, if the expression is contextually typed, the operands are contextually typed by the same type. - Otherwise, the right expression is contextually typed by the type of the left expression. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var sum = function (x: number, y: number) { - return x + y -} -var average1 = function (a: number, b: number) { - return (a + b) / 2 -} -var rela1 = sum || average1 -Assert.equal(typeof rela1, 'function') -var average2: number = 10 -var rela2 = average2 || sum -Assert.equal(typeof rela2, 'number'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_15.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_15.ts deleted file mode 100644 index d7a649f139..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_15.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a contextually typed conditional operator expression, the operands are contextually typed by the same type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function processValue(value: number | (() => number)) { - var x = typeof value !== "number" ? value() : value - Assert.isNumber(x) -} -processValue(5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_16.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_16.ts deleted file mode 100644 index 940f31181e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_16.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In an assignment expression, the right hand expression is contextually typed by the type of the left hand expression. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface A { - (a: number): void -} -const fn: A = function (a) { - Assert.isNumber(a) -} -fn(5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_2.ts deleted file mode 100644 index d24a9bad0e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_2.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a variable, parameter, binding property, binding element, or member declaration, - an initializer expression is contextually typed by for a parameter, the type provided by a contextual signature. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var f: (s: string) => string = function (x) { - Assert.isString(x) - return x.toLowerCase() -} -f('str'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_3.ts deleted file mode 100644 index b94a14a8f5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_3.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a variable, parameter, binding property, binding element, or member declaration, - an initializer expression is contextually typed by the type implied by the binding pattern in the declaration. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function f({ a = true, b = "hello", c = 1 }) { - Assert.isBoolean(a) - Assert.isString(b) - Assert.isNumber(c) -} -f({ a: false }); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts deleted file mode 100644 index d15947b430..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_4.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In the body of a function declaration, function expression, arrow function, method declaration, - or get accessor declaration that has a return type annotation, - return expressions are contextually typed by the type given in the return type annotation. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function add(x: number, y: number): number { - return x + y -} -let sum = add(10, 20) -Assert.isNumber(sum) -type Fun = (a: number, b: number) => number -function fun(fn: Fun, x: number, y: number) { - return fn(x, y) -} -function minus(a: number, b: number) { - return a - b -} -function mul(a: number, b: number) { - return a * b -} -let m = fun(minus, 15, 7) -let n = fun(mul, 3, 6) -Assert.isNumber(m) -Assert.isNumber(n); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_5.ts deleted file mode 100644 index dadabf1676..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_5.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In the body of a function expression or arrow function that has no return type annotation, - if the function expression or arrow function is contextually typed by a function type with exactly one call signature, - and if that call signature is non-generic, return expressions are contextually typed by the return type of that call signature. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -type Fun = { - description: string - (someThing: number): boolean -} -function fun1(fn: Fun) { - return fn.description + fn(100) -} -function fun2(num: number) { - Assert.equal(num, 100) - return false -} -fun2.description = 'hello' -Assert.equal(fun1(fun2), 'hellofalse'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_6.ts deleted file mode 100644 index 3d70a3597e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_6.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In the body of a constructor declaration, return expressions are contextually typed by the containing class type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Person { - name: string - age: number - constructor(name: string, age: number) { - this.name = name - this.age = age - } -} -const p = new Person("xiao", 18) -Assert.isString(p.name) -Assert.isNumber(p.age); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts deleted file mode 100644 index f910a94072..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_7.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In the body of a get accessor with no return type annotation, - if a matching set accessor exists and that set accessor has a parameter type annotation, - return expressions are contextually typed by the type given in the set accessor's parameter type annotation. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class C { - private _str = '' - private _arr: string[] = [] - get func() { - return this._str - } - set func(value: string) { - this._str= value - } - get f() { - return this._arr - } - set f(value: string[]) { - this._arr = value - } -} -const c = new C() -c.func= 'TS' -Assert.isString(c.func) -c.f = ['develop', 'test'] -c.f.push('ship') -Assert.equal(c.f, 'develop,test,ship'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts deleted file mode 100644 index 2036c81219..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_8.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a typed function call, argument expressions are contextually typed by their corresponding parameter types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -const obj: Record = { - boo: false, - arr: ['a', 'b', 'c'] -} -const para = (str: string): [T, Function] => { - const result1: T = obj[str]; - const result2: Function = (value: T) => { - obj[str] = value; - return obj[str]; - } - return [result1, result2]; -} -const [boo, mem2] = para('boo'); -const [arr, mem4] = para('arr'); -Assert.isBoolean(boo); -Assert.equal(arr, 'a,b,c'); -let x = mem2(true); -let y = mem4(false); -Assert.isTrue(x); -Assert.isFalse(y); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_9.ts deleted file mode 100644 index e6fc7d38b7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/contextually_typed_expressions/contextually_typed_expressions_9.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a contextually typed object literal, each property value expression is contextually typed by - the type of the property with a matching name in the contextual type, if any, or otherwise - for a numerically named property, the numeric index type of the contextual type, if any, or otherwise - the string index type of the contextual type, if any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface Person { - (a: number): void -} -interface B { - fn: Person -} -const obj: B = { - fn: function (a) { - Assert.isNumber(a) - } -} -obj.fn(10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts deleted file mode 100644 index f93221902a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/grammar_ambiguities/grammar_ambiguities.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The inclusion of type arguments in the Arguments production gives rise to certain ambiguities in the grammar for expressions. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -var h_g: number = 5 -var h_A: number = 3 -var h_B: number = 6 -function f(a: any, b?: any) { - return a -} -Assert.isFalse(f(h_g < h_A, h_B > 7)) -Assert.isFalse(f(h_g < h_A, h_B > +(7))) -type A1 = number -type B1 = number -function g1(a: T) { - return a; -} -function f1(a: any, b?: any) { - return a -} -Assert.equal(f1(g1(7)), 7); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts deleted file mode 100644 index ae09cd482e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_1.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The compile-time processing of a typed function call consists, - a list of candidate signatures is constructed from the call signatures in the function type in declaration order. - A generic signature is a candidate in a function call with type arguments when the signature has the same number of type parameters - as were supplied in the type argument list, the type arguments satisfy their constraints, - and once the type arguments are substituted for their associated type parameters, - the signature is applicable with respect to the argument list of the function call. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -function fun(x: Array, y: Array): Array -function fun(x: Array, y: Array, z: Array): Array -function fun(x: Array, y: Array, z?: V): Array { - return x -} -let arr1: Array = [1, 2, 3]; -let arr2: Array = ['a', 'b']; -let arr3: Array = [true, false]; -let a = fun(arr1, arr2); -Assert.equal(a, arr1); -let b = fun(arr1, arr2, arr3); -Assert.equal(b, arr1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts deleted file mode 100644 index a5d9d10954..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/overload_resolution/overload_resolution_2.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A non-generic signature is a candidate when - the function call has no type arguments, and - the signature is applicable with respect to the argument list of the function call. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -function add(): number; -function add(x: number): number; -function add(x: number, y: number): number; -function add(x?: number, y?: number): number { - let sum: number = 0; - if (x) { - sum += x; - } - if (y) { - sum += y; - } - return sum; -} -Assert.equal(add(), 0); -Assert.equal(add(1), 1); -Assert.equal(add(1, 1), 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts deleted file mode 100644 index a27a866d9e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_1.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Given a type parameter T and set of candidate types, the actual inferred type argument is determined, - if the set of candidate argument types is empty, the inferred type argument for T is T's constraint. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -type t = number | string; -function select(h_x: T, h_y: T): T { - return h_x < h_y ? h_x : h_y; -} -var a = select(10, 20); -Assert.isNumber(a); -type HELLO = "HELLO"; -function getx(x: HELLO): string { - return x; -} -const x = "HELLO"; -Assert.equal(getx(x), "HELLO"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts deleted file mode 100644 index fb9d601be9..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_2.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Given a type parameter T and set of candidate types, the actual inferred type argument is determined, - if at least one of the candidate types is a supertype of all of the other candidate types, - let C denote the widened form of the first such candidate type. - If C satisfies T's constraint, the inferred type argument for T is C. - Otherwise, the inferred type argument for T is T's constraint. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -type t = number | null | undefined -function select(h_x: T, h_y: T): T { - return h_x ? h_x : h_y; -} -var y = select(10, undefined) -if (typeof y === 'number') { - Assert.isNumber(y); -} -else { - Assert.isUndefined(y); -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts deleted file mode 100644 index a133fc3c7c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_3.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - When a function expression is inferentially typed and a type assigned to a parameter in that expression references type parameters for which inferences are being made, - the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -function func(arg1: T, arg2:T) { - return [arg1, arg2]; -} -let a = func(3, 5); -let b = func('a', 'b'); -Assert.equal(a, '3,5'); -Assert.equal(b, 'a,b'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts deleted file mode 100644 index 173b602bbb..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_calls/type_argument_inference/type_argument_inference_4.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If e is an expression of a function type that contains exactly one generic call signature and no other members, - and T is a function type with exactly one non-generic call signature and no other members, - then any inferences made for type parameters referenced by the parameters of T's call signature are fixed, - and e's type is changed to a function type with e's call signature instantiated in the context of T's call signature. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -type T = (arg: number) => number; -let f = (arg: T): T => { return arg }; -let para: T = function func(arg: number) { - return arg; -} -let result = f(para(20)); -Assert.equal(result, 20); -Assert.isFunction(f); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_1.ts deleted file mode 100644 index 36ee6593be..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_1.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If T is a union type, let U be the set of element types in T that have call signatures. - If each type in U has exactly one call signature and that call signature is non-generic, and if all of the signatures are identical ignoring return types, - then S is a signature with the same parameters and a union of the return types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -type MyUnionType = ((x: number) => string) | ((x: number) => number); -function myFunction(fn: MyUnionType, arg: number) { - return fn(arg); -} -const fn1 = (x: number): string => `Hello,${x}`; -const fn2 = (x: number): number => x * 2; -const result1 = myFunction(fn1, 123); -const result2 = myFunction(fn2, 456); -Assert.equal(result1, "Hello,123"); -Assert.equal(result2, 912); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_2.ts deleted file mode 100644 index b7dd95ab05..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_2.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If T is a function type with exactly one call signature, - and if that call signature is non-generic, S is that signature. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -type MyFunctionType = (x: number, y: number) => number; -function myFunction(fn: MyFunctionType) { - return fn(2, 3); -} -const add: MyFunctionType = function (x: number, y: number) { - return x + y; -}; -const result = myFunction(add); -Assert.equal(result, 5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_3.ts deleted file mode 100644 index efdd1e8157..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_3.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Otherwise, no contextual signature can be extracted from T. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -type MyType = { - fn: (a: number, b: string) => boolean; -}; -function myFunction(obj: MyType) { - const { fn } = obj; - const result = fn(123, "hello"); - Assert.isTrue(result); -} -let h_x: MyType = { - fn: function func() { - return true; - } -} -myFunction(h_x); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_4.ts deleted file mode 100644 index 79dc9f26e7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/function_expression/function_expressions_4.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The type of a function expression is an object type containing a single call signature with parameter - and return types inferred from the function expression's signature and body. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -type Greeting = 'Hello, world'; -let x: Greeting = 'Hello, world'; -function f(x: Greeting): string { - return x; -} -Assert.equal(f(x), "Hello, world"); -function f2(x: T): T { - return x; -} -let a = f2(10); -Assert.equal(a, 10); -let b = f2("hello"); -Assert.equal(b, "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/class.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/class.ts deleted file mode 100644 index 8341313a6e..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/class.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: For a class, the constructor type associated with the constructor function object. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Car { - engine: string; - agelimit: number; - constructor(engine: string, agelimit: number) { - this.engine = engine; - this.agelimit = agelimit; - } -} -let car = new Car("Benchi", 2); -Assert.equal(car.agelimit, 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/enum.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/enum.ts deleted file mode 100644 index 49f197edf1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/enum.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: For an enum, the object type associated with the enum object. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -enum Direction { - up = 1, - down, - Left, - right, -} -const direction: Direction = Direction.up; -Assert.isNumber(direction); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/function.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/function.ts deleted file mode 100644 index d1513c3bf3..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/function.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: For a function, the function type associated with the function object. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function myFunction(x: number): number { - return x * 2; -} -Assert.isFunction(myFunction); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/name_space.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/name_space.ts deleted file mode 100644 index dedd915898..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/name_space.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - When an expression is an IdentifierReference, the expression refers to the most nested namespace, class, enum, function, variable, - or parameter with that name whose scope (section 2.4) includes the location of the reference. - The type of such an expression is the type associated with the referenced entity: - For a namespace, the object type associated with the namespace instance - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -namespace MyNamespace { - export interface Person { - name: string; - age: number; - } - export function greet(person: Person) { - Assert.equal(person.name, "John"); - Assert.equal(person.age, 30); - } -} -const person: MyNamespace.Person = { - name: "John", - age: 30, -}; -MyNamespace.greet(person); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/parameter.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/parameter.ts deleted file mode 100644 index 050218eaba..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/parameter.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - For a parameter, the type of the parameter. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class paramMethod { - person: string; - age: number; - constructor(person: string, age: number) { - this.person = person; - this.age = age; - Assert.isString(person); - Assert.isNumber(age); - } -} -let newparam = new paramMethod("xiaoli", 18); -Assert.equal(newparam.age, 18); -Assert.equal(newparam.person, "xiaoli"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/variable.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/variable.ts deleted file mode 100644 index b95d6d191a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/identifiers/variable.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - For a variable, the type of the variable. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let uname: string = "Runoob"; -let score1: number = 50; -Assert.isString(uname); -Assert.isNumber(score1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/boolean.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/boolean.ts deleted file mode 100644 index cfd5252d24..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/boolean.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: The type of the literals true and false is the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -Assert.equal(typeof false, "boolean"); -Assert.equal(typeof true, "boolean"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/null.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/null.ts deleted file mode 100644 index f014d23c13..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/null.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The type of the null literal is the Null primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -Assert.isTrue(typeof null === "object"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/number.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/number.ts deleted file mode 100644 index 070870d0f5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/number.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The type of numeric literals is the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -Assert.equal(typeof 1, "number"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/regexp.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/regexp.ts deleted file mode 100644 index bb9d378516..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/regexp.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The type of regular expression literals is the global interface type 'RegExp'. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -Assert.isTrue(/hello world/ instanceof RegExp); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/string.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/string.ts deleted file mode 100644 index 3a97e72e58..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/literals/string.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The type of string literals is the String primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -Assert.isString("Hello world"); -Assert.isString("kitty"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_1.ts deleted file mode 100644 index e23968a8c9..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_1.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the object literal is contextually typed and the contextual type contains a property with a matching name, - the property assignment is contextually typed by the type of that property. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let obj1: { - str: string; - num: number; - bool: boolean; -} = { - str: 'string', - num: 5, - bool: true -} -Assert.isString(obj1.str); -Assert.isNumber(obj1.num); -Assert.isBoolean(obj1.bool); - -interface I{ - num: number; - str: string; -} -let obj2 = {} as I; -obj2.num = 10; -obj2.str = 'string'; -Assert.isNumber(obj2.num); -Assert.isString(obj2.str); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_2.ts deleted file mode 100644 index 94500c72a7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_2.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - if the object literal is contextually typed, - if the contextual type contains a numeric index signature, - and if the property assignment specifies a numeric property name, - the property assignment is contextually typed by the type of the numeric index signature. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let obj1: { - 1: string; - [key: number]: string; -} = { - 1: 'string', - 2: 'number', - 3: 'boolean' -} -Assert.isString(obj1[2]); -Assert.isString(obj1[3]); - -interface I{ - 1: string; - [key: number]: string; -} -let obj2 = {} as I; -obj2 = { - 1: 'string', - 2: 'number', - 3: 'boolean' -} -Assert.isString(obj2[2]); -Assert.isString(obj2[3]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_3.ts deleted file mode 100644 index 0d7ec34ce5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_3.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the object literal is contextually typed and the contextual type contains a string index signature, - the property assignment is contextually typed by the type of the string index signature. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let obj1: { - 'str': string; - [key: string]: string; -} = { - 'str': 'string', - 'num': 'number', - 'bool': 'boolean' -} -Assert.isString(obj1['num']); -Assert.isString(obj1['bool']); - -interface I{ - 'str': string; - [key: string]: string; -} -let obj2 = {} as I; -obj2 = { - 'str': 'string', - 'num': 'number', - 'bool': 'boolean' -} -Assert.isString(obj2['num']); -Assert.isString(obj2['bool']); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_4.ts deleted file mode 100644 index 6cc575365a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_4.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The property assignment is processed without a contextual type - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface Iperson { - name: String; - age: Number; - gender?: string; - sayName(): void; -} -const P: Iperson = { - name: "Tom", - age: 21, - gender: "male", - sayName() { - return this.name; - }, -}; -Assert.equal(P.gender, "male"); -P.gender = "female"; -Assert.equal(P.gender, "female"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_5.ts deleted file mode 100644 index 3613783b55..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_5.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A get accessor declaration is processed in the same manner as an ordinary function declaration (section 6.1) with no parameters. - A set accessor declaration is processed in the same manner as an ordinary function declaration with a single parameter and a Void return type. - When both a get and set accessor is declared for a property: - If both accessors include type annotations, the specified types must be identical. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface Obj { - id: number; - name: string; - get gid(): number; - set sid(id: number); -} -let obj1: Obj = { - id: 1, - name: "obj1", - get gid() { - return this.id - }, - set sid(id: number) { - this.id = id; - } -} -Assert.equal(obj1.id, 1); -obj1.sid = 2; -Assert.equal(obj1.gid, 2); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_6.ts deleted file mode 100644 index 3fb79b27f7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_6.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If a get accessor is declared for a property, - the return type of the get accessor becomes the type of the property. - If only a set accessor is declared for a property, - the parameter type of the set accessor becomes the type of the property. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class C{ - private mem; - constructor(mem: string) { - this.mem = mem; - } - get Mem(): string { - return this.mem; - } - set Mem(mem: string) { - this.mem = mem; - } -} -let c = new C('a'); -Assert.isString(c.Mem); diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_7.ts deleted file mode 100644 index f364ccedab..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_7.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - When an object literal is contextually typed by a type that includes a string/numeric index signature, - the resulting type of the object literal includes a string/numeric index signature with the union type - of the types of the properties declared in the object literal, or the Undefined type if the object literal is empty. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface I1{ - 1: string; - [key: string]: string; -} -let obj1: I1 = { - 1: 'number', - 'str': 'string' -} -Assert.isString(obj1[1]); -Assert.isString(obj1['str']); -let obj2: I1 = { - 1: 'number' -} -Assert.isString(obj2[1]); -Assert.isUndefined(obj2['str']); - -interface I2{ - 'string': string; - [key: number]: string; -} -let obj3: I2 = { - 'string': 'number', - 1: 'string' -} -Assert.isString(obj3['string']); -Assert.isString(obj3[1]); -let obj4: I2 = { - 'string': 'number' -} -Assert.isString(obj4['string']); -Assert.isUndefined(obj4[1]); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_8.ts deleted file mode 100644 index 663bb91de2..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_8.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A shorthand property assignment. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface I1 { - 1: 1; - 2: number; - f1: () => number; - f2(): number; -} -let obj1: I1 = { - 1: 1, - 2: 1, - f1() { - return 2; - }, - f2() { - return 2; - }, -} -Assert.equal(obj1[1], 1); -Assert.equal(obj1[2], 1); -Assert.equal(obj1.f1(), 2); -Assert.equal(obj1.f2(), 2); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_9.ts deleted file mode 100644 index ea26e43b68..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/object_literal/object_literal_9.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the PropertyName of a property assignment is a computed property name. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -const x1: "x1" = "x1"; -const x2: "x2" = "x2"; -const x3 = Symbol("x3"); -interface Obj { - [x1](): string; - [x2]: string; - [x3]: string; -} -let obj1: Obj = { - x1() { - return "xx1"; - }, - x2: 'xx2', - [x3]: 'xx3' -}; -let obj2 = { - [x2]: 1 -}; -let obj3: { - [x2]: string -} = { - x2: 'xxx2' -}; -Assert.equal(obj1[x1](), "xx1"); -Assert.equal(obj1[x2], "xx2"); -Assert.equal(obj2[x2], 1); -Assert.equal(obj3[x2], "xxx2"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/parentheses/parentheses.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/parentheses/parentheses.ts deleted file mode 100644 index b6975c3fb7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/parentheses/parentheses.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A parenthesized expression has the same type and classification as the contained expression itself. - Specifically, if the contained expression is classified as a reference, so is the parenthesized expression. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let addparent = function (n1: number, n2: number): number { - return n1 + n2; -}; -let addnoparent = (n1: number, n2: number): number => n1 + n2; -let isCorrect = addparent(11, 22) === addnoparent(11, 22); -Assert.isTrue(isCorrect); -let foo: string = "hello"; -let bar: string = foo; -Assert.isString(foo); -Assert.isString(bar); -const obj = { value: "world" }; -function printValue(value: string) { - Assert.equal(value, "world"); - Assert.isString(value); -} -printValue(obj.value); - -let str1 = (37 * 12) + ((37 * 9) + ''); -Assert.equal(str1, "444333"); -Assert.isString(str1); - -let t: boolean = true; -let f: boolean = false; -let bool: boolean = t || ((f || t) && (false && t)); -Assert.isTrue(bool); - diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_access_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_access_2.ts deleted file mode 100644 index fc245d3fd9..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_access_2.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If name denotes an accessible apparent property (section 3.11.1) in the widened type (section 3.12) of object, - the property access is of the type of that property. Public members are always accessible, - but private and protected members of a class have restricted accessibility, as described in 8.2.2. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var sites = { - site1: "Runoob", - site2: "Google", - sayHello: function () { }, -}; -sites.sayHello = function () { - return "hello " + sites.site1; -}; -Assert.isString(sites.sayHello()); -class Person { - name: string; - age: string; - constructor(name: any, age: any) { - this.name = name; - this.age = age; - } - greet() { } -} -const person1 = new Person("Alice", 30); -const person2 = { name: "Bob", age: 35 }; -person1["greet"](); -Assert.equal(person1.name, "Alice"); -Assert.equal(person2.name, "Bob"); -Assert.equal(person1.age, 30); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_1.ts deleted file mode 100644 index 167baf148f..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_1.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If object is of type Any, any name is permitted and the property access is of type Any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let myVariable: any = { name: "John", age: 30 }; -Assert.isString(myVariable.name); -myVariable.name = 42; -Assert.isNumber(myVariable.name); - -Assert.isNumber(myVariable.age); -myVariable.age = "Hello World"; -Assert.isString(myVariable.age); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_type_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_type_6.ts deleted file mode 100644 index 87e41c23ce..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_any_type_6.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If index is of type Any, the String or Number primitive type, - or an enum type, the property access is of type Any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface MyObject { - [key: string]: number; -} -const obj: MyObject = { - prop1: 1, - prop2: 2, - prop3: 3, -}; -const value2 = obj[0]; -Assert.equal(value2, undefined); -enum MyEnum { - Prop1 = "prop1", - Prop2 = "prop2", - Prop3 = "prop3", -} -const value3 = obj[MyEnum.Prop3]; -Assert.equal(value3, 3); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_apprent_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_apprent_5.ts deleted file mode 100644 index 0cfac703a8..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_apprent_5.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If object has an apparent string index signature and index is of type Any, - the String or Number primitive type, or an enum type, the property access is of the type of that index signature. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface ExampleObject { - [key: string]: string; -} -const myObject: ExampleObject = { - foo: "bar", - baz: "qux", -}; -const myIndex: any = "foo"; -const myValue = myObject[myIndex]; -Assert.isString(myValue); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_index_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_index_4.ts deleted file mode 100644 index 8a09d000a1..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_index_4.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If object has an apparent numeric index signature and index is of type Any, - the Number primitive type, or an enum type, the property access is of the type of that index signature - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface MyObj { - [index: number]: string; -} -const obj: MyObj = { - 0: "foo", - 1: "bar", - 2: "baz", -}; -Assert.equal(obj[0], "foo"); -Assert.equal(obj[1], "bar"); -Assert.equal(obj[2], "baz"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_string_number_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_string_number_3.ts deleted file mode 100644 index 9e4293dba4..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/object_string_number_3.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If index is a string literal or a numeric literal and object has an apparent property with the name given by that literal, - the property access is of the type of that property. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -const sites = { - siteName: "Runoob", - site2: 999, - sayHello: function () { }, -}; -Assert.isString(sites["siteName"]); -Assert.isNumber(sites["site2"]); -Assert.isFunction(sites["sayHello"]); -interface Person { - name: string; - age: number; - city: string; -} -const person: Person = { - name: "Alice", - age: 30, - city: "New York", -}; -Assert.equal(person["name"], "Alice"); -Assert.equal(person["city"], "New York"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_1.ts deleted file mode 100644 index 5dcfd232d9..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_1.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Properties are strongly typed when accessed using bracket notation with the literal representation of their name. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var myType = { - h_str: 'string', - h_bool: true -}; -var h_s = myType['h_str']; -Assert.isString(h_s); -var h_b = myType['h_bool']; -Assert.isBoolean(h_b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_2.ts deleted file mode 100644 index 3b624b2cdc..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/property_access/property_access_2.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Tuple types assign numeric names to each of their elements and elements are therefore strongly typed - when accessed using bracket notation with a numeric literal. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var myArry: [number, string, boolean] = [10, 'string', true]; -var h_n = myArry[0]; -Assert.isNumber(h_n); -var h_s = myArry[1]; -Assert.isString(h_s); -var h_b = myArry[2]; -Assert.isBoolean(h_b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/template_literals/template_literals.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/template_literals/template_literals.ts deleted file mode 100644 index beaa1deeae..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/template_literals/template_literals.ts +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Template literals are literals delimited with backtick (`) characters, allowing for multi-line strings, string interpolation with embedded expressions, and special constructs called tagged templates. - Template literals are sometimes informally called template strings, because they are used most commonly for string interpolation (to create strings by doing substitution of placeholders). - However, a tagged template literal may not result in a string; it can be used with a custom tag function to perform whatever operations you want on the different parts of the template literal. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from "../../../../suite/assert.js"; - -function hiStr(str: string | TemplateStringsArray) { - return 'hi ' + str; -} -let hi = hiStr`TypeScript`; -Assert.equal(hi, 'hi TypeScript'); - -let bool1 = `\`` == "\`"; -Assert.isTrue(bool1); - -let bool2 = `\${37*3}` == '${37*3}'; -Assert.isTrue(bool2); - -let bool3 = `${bool1}` == 'true'; -Assert.isTrue(bool3); - -let str1 = hiStr`Type -Script`; -Assert.equal(str1, `hi Type -Script`); -Assert.equal(str1, 'hi Type\nScript'); - -function funF(str: string | TemplateStringsArray) { - let str2 = `${str}\n${str}`; - function funFF(str1: string | TemplateStringsArray, ...strs: string[] | TemplateStringsArray[]) { - let s = `${str2}\n${str1}`; - for (let i = 0; i < strs.length; i++) { - s = s + `\n` + strs[i]; - } - return s; - } - return funFF; -} -let s1 = funF`A``B`; -Assert.equal(s1, `A -A -B`); -let s2 = funF`A``B` + `C`; -Assert.equal(s2, `A -A -BC`); -let s3 = funF`A`(`B`, `C`); -Assert.equal(s3, `A -A -B -C`); - -function sRaw(str: TemplateStringsArray) { - return str.raw[0]; -} -let s4 = sRaw`ABC\nDEF`; -Assert.equal(s4, 'ABC\\nDEF'); - -let s5 = String.raw`AB\n${s4}`; -Assert.equal(s5, 'AB\\nABC\\nDEF'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_comma_operator/the_comma_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_comma_operator/the_comma_operator.ts deleted file mode 100644 index 80cc709cfd..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_comma_operator/the_comma_operator.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The comma operator permits the operands to be of any type and produces a result that is of the same type as the second operand. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let x: number = 20; -let y: boolean = true; -let z: string = 'a'; -function add(arg1: number, arg2: number) { - return arg1 + arg2; -} -let com1 = (x++, y); -let com2 = (x++, z = z + 'b'); -let com3 = (x++, add(3, 5)); -Assert.isBoolean(com1); -Assert.equal(com1, true); -Assert.isString(com2); -Assert.equal(com2, 'ab'); -Assert.isNumber(com3); -Assert.equal(com3, 8); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts deleted file mode 100644 index 01e70a8364..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_1.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a conditional expression of the form 'test ? expr1 : expr2', the test expression may be of any type. - The type of the result is the union type of the types of expr1 and expr2. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var x: number = 10 -var y: string = '5' -var z = Math.random() < 0.5 ? x + y : y && x -if (typeof z === 'number') { - z++ - Assert.equal(z, 11); -} -else { - Assert.equal(z, '105'); -}; \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_2.ts deleted file mode 100644 index d722c0719d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_conditional_operator/the_conditional_operator_2.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the conditional expression is contextually typed, expr1 and expr2 are contextually typed by the same type. - Otherwise, expr1 and expr2 are not contextually typed. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let sum = function (x: number, y: number) { - return x + y; -} -let average = function (a: number, b: number) { - return (a + b) / 2; -} -let flag = 0; -let rela1: number = flag < 0.5 ? sum(5, 7) : average(6, 9); -Assert.isNumber(rela1); -Assert.equal(rela1, 12); -flag = 1; -let rela2: number = flag < 0.5 ? sum(5, 7) : average(6, 9); -Assert.isNumber(rela2); -Assert.equal(rela2, 7.5); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_1.ts deleted file mode 100644 index 6579559ced..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_1.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If C is of type Any, any argument list is permitted and the result of the operation is of type Any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let C: any; -C = function (this: any, x: number, y: number) { - this.sum = x + y; -}; -let myObject = new C(2, 3); -Assert.equal(myObject.sum, 5); -myObject = 5; -Assert.isNumber(myObject); -myObject = 'a'; -Assert.isString(myObject); -myObject = true; -Assert.isBoolean(myObject); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_2.ts deleted file mode 100644 index 42c673b0a3..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_2.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If C has one or more apparent construct signatures (section 3.11.1), the expression is processed in the same manner as a function call, - but using the construct signatures as the initial set of candidate signatures for overload resolution. - The result type of the function call becomes the result type of the operation. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Person { - constructor(public name: string, public age: number) { } -} -interface Animal { - speak(): void; -} -class Dog implements Animal { - speak() { - return "Woof!"; - } -} -const p = new Person("Alice", 30); -const d = new Dog(); -Assert.isString(p.name); -Assert.equal(d.speak(), "Woof!"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_3.ts deleted file mode 100644 index 7ee5e319d5..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_3.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If C has no apparent construct signatures but one or more apparent call signatures, the expression is processed as a function call. - A compile-time error occurs if the result of the function call is not Void. The type of the result of the operation is Any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Person { - sayHello() { - return "Hello,world"; - } -} -let person: Person = new Person(); -Assert.equal(person.sayHello(), "Hello,world"); -let person2: any = new Person(); -person2.sayHello(); -Assert.equal(person2.sayHello(), "Hello,world"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_4.ts deleted file mode 100644 index 966c697a6a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_new_operator/new_operator_4.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - new C - new C ( ... ) - new C < ... > ( ... ) - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class C { - x: number = 1; -} -let c = new C; -Assert.equal(c.x, 1); -class Person { - name: string; - age: number; - constructor(name: string, age: number) { - this.name = name; - this.age = age; - } -} -const john = new Person("john", 30); -Assert.isString(john.name, "john"); -class Box { - contents: T; - constructor(value: T) { - this.contents = value; - } -} -const myBox = new Box("hello"); -Assert.equal(myBox.contents, "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/arguments.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/arguments.ts deleted file mode 100644 index 9658263480..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/arguments.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Type arguments cannot be explicitly specified in a super call. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class SuperClass { - value: T; - constructor(value: T) { - this.value = value; - } -} -class SubClass extends SuperClass { - constructor(value: T) { - super(value); - } -} -const sub = new SubClass("hello"); -Assert.equal(sub.value, "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts deleted file mode 100644 index 3243840b97..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/gengric_extends.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - If the base class is a generic class, - the type arguments used to process a super call are always those specified in the extends clause that references the base class. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class BaseClass { - constructor(public value: T) { } -} -class SubClass extends BaseClass { - constructor(value: T) { - super(value); - } -} -class StringSubClass extends SubClass { - constructor() { - super("hello"); - } -} -const sub = new StringSubClass(); -Assert.equal(sub.value, "hello"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/super_calls.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/super_calls.ts deleted file mode 100644 index b64f05916a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_calls/super_calls.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The super keyword can be used in expressions to reference base class properties and the base class constructor. - Super calls consist of the keyword super followed by an argument list enclosed in parentheses. Super calls are only permitted in constructors of derived classes. - A super call invokes the constructor of the base class on the instance referenced by this. - A super call is processed as a function call (section 4.15) using the construct signatures of the base class constructor function type - as the initial set of candidate signatures for overload resolution. - The type of a super call expression is Void. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Animal { - private name: string; - constructor(name: any) { - this.name = name; - } - speak() { - return `${this.name} makes a noise`; - } -} -class Dog extends Animal { - private breed: string; - constructor(name: any, breed: any) { - super(name); - this.breed = breed; - } - extendsSpeak() { - super.speak(); - Assert.isString(super.speak(), "Fodo makes a noise"); - return `${this.breed}`; - } -} -const d = new Dog("Fido", "Golden Retriever"); -d.extendsSpeak(); -Assert.isString(d.extendsSpeak(), "Golden Retriever"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/super_property_access_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/super_property_access_1.ts deleted file mode 100644 index 5dce4ac822..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/super_property_access_1.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance, - a super property access is permitted and must specify a public instance member function of the base class. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Animal { - public age: number = 10; - constructor() { } - public makeSound(): string { - return "the animal makes"; - } - static weight: number = 0; -} -class Dog extends Animal { - - constructor() { - super(); - this.age = 20; - } - public makeSound(): string { - super.makeSound(); - Assert.equal(super.makeSound(), "the animal makes"); - return "the dog barks"; - } - public Animalweight(): number { - return Animal.weight; - } - get _age(): number { - return this.age - } - set _age(age: number) { - this.age = age; - } -} -let myDog = new Dog(); -myDog.makeSound(); -Assert.equal(myDog.makeSound(), "the dog barks"); -Assert.equal(myDog.age, 20); -Assert.equal(myDog.Animalweight(), 0); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/super_property_access_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/super_property_access_2.ts deleted file mode 100644 index d7c0f1dc7a..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/the_super_keyword/super_property_access/super_property_access_2.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a static member function or static member accessor where this references the constructor function object of a derived class, - a super property access is permitted and must specify a public static member function of the base class. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../../suite/assert.js' - -class Base { - static greet() { - return "hello world"; - } -} -class Derived extends Base { - static greet() { - super.greet(); - Assert.equal(super.greet(), "hello world"); - return "hola,mundo"; - } -} -Derived.greet(); -Assert.equal(Derived.greet(), "hola,mundo"); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_1.ts deleted file mode 100644 index c1c78b95c9..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_1.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a constructor, instance member function, instance member accessor, - or instance member variable initializer, this is of the this-type (section 3.6.3) of the containing class. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class C { - public mem: string; - private num: number; - constructor(mem: string, num: number) { - this.mem = mem; - this.num = num; - Assert.isObject(this); - } - func() { - return this; - } - get getNum() { - Assert.isObject(this); - return this.num; - } - set setNum(num: number) { - this.num = num; - } -} -let c: C = new C('a', 10); -c.getNum; -c.setNum = 11; -Assert.isObject(c.func()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_2.ts deleted file mode 100644 index af043bd290..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_2.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a static member function or static member accessor, the type of this is the constructor function type of the containing class. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class C{ - static mem: string = 'a'; - static get getMem() { - Assert.isFunction(this); - return this.mem; - } - static set setMem(mem: string) { - this.mem = mem; - } - static func() { - return this; - } -} -C.getMem; -Assert.isFunction(C.func()); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_3.ts deleted file mode 100644 index f603816488..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_3.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a function declaration or a function expression, this is of type Any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface Str { - id: number; -} -interface Obj { - name: string; - getName(this: Obj): string; -} -interface Obj2 { - name: string; - getName(this: Str): number; -} -let obj: Obj = { - name: "obj", - getName() { - return this.name; - }, -} -let obj2: Obj2 & Str = { - name: "obj2", - id: 1, - getName() { - return this.id; - } -} -Assert.equal(obj.getName(), "obj"); -Assert.equal(obj2.getName(), 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_4.ts deleted file mode 100644 index 18409de810..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/this_key_word/this_key_word_4.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The type of this in an expression depends on the location in which the reference takes place:In the global namespace, this is of type Any. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' -let obj = { - a: 1024, - ADD(a: number) { - return this.a + a; - }, - getType() { - return typeof this; - }, - getThis() { - return this; - } -} -Assert.equal(obj.ADD(1), 1025); -Assert.equal(obj.getType(), 'object'); -let obj2 = obj.getThis(); -Assert.equal(JSON.stringify(obj2), '{"a":1024}'); - -const t1 = this; -Assert.isUndefined(t1); - -const t2 = globalThis; -Assert.equal(t2.JSON.stringify(obj.getThis()), JSON.stringify(obj2.getThis())); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_1.ts deleted file mode 100644 index 17020e1b08..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_1.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Type assertions check for assignment compatibility in both directions. - Thus, type assertions allow type conversions that might be correct, but aren't known to be correct. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class P{ } -class C extends P { } -function func(str: string): P { - if (str === "string") { - return new C(); - } - return C; -} -let c = func("string"); -Assert.equal(JSON.stringify(c), '{}'); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_2.ts deleted file mode 100644 index e0a3eac692..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_2.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - type assertions are not checked at run-time and it is up to the programmer to guard against errors, - for example using the instanceof operator - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Foo { - foo: number; - cname: string; - constructor(foo: number = 123, cname: string = 'Foo') { - this.foo = foo; - this.cname = cname; - } -} -class Bar extends Foo { - bar: number; - cname: string; - constructor(bar: number = 1024, cname: string = 'Bar') { - super(); - this.bar = bar; - this.cname = cname; - } -} -function toFoo(): Foo { - return new Bar(); -} -let foo: Foo = toFoo(); -let bar: Bar = toFoo(); -function toBar(arg: Foo | Bar): Bar | string { - let bar: Bar; - if (arg instanceof Bar) { - bar = arg; - return bar; - } - return "Can not"; -} -let foo1 = toBar(new Foo()); -let foo2 = toBar(foo); -let bar1 = toBar(bar); -Assert.equal(foo1, 'Can not'); -Assert.equal(JSON.stringify(foo2), '{"foo":123,"cname":"Bar","bar":1024}'); -Assert.equal(JSON.stringify(foo2), JSON.stringify(bar1)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_3.ts deleted file mode 100644 index 076898c01c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_assertion/type_assertion_3.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In a type assertion expression of the form < T > e, e is contextually typed by T and the resulting type of* e* is required to be assignable to T, - or T is required to be assignable to the widened form of the resulting type of e, or otherwise a compile-time error occurs. The type of the result is T. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function getLength(something: string | number): number { - if ((something).length) { - return (something).length - } else { - return something.toString().length - } -} -Assert.equal(getLength('length'), 6); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_1.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_1.ts deleted file mode 100644 index 08b585694d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_1.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - Type guards are particular expression patterns involving the 'typeof' and 'instanceof' operators - that cause the types of variables or parameters to be narrowed to more specific types. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function fun(x: boolean | number | string) { - if (typeof x === 'string') { - Assert.isString(x); - } - if (typeof x === 'boolean') { - x = true; - Assert.isTrue(x); - } - if (typeof x === 'number') { - Assert.isNumber(x); - } -} -fun('string'); -fun(10); -fun(false); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_10.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_10.ts deleted file mode 100644 index c96d649482..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_10.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A type guard of the form !expr, - when true, narrows the type of x by expr when false, - or when false, narrows the type of x by expr when true. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function func(x: string | number) { - if (!(typeof x === "string")) { - Assert.isNumber(x); - return x + 1; - } - else { - Assert.isString(x); - return x.length; - } -} -let a = func(10); -Assert.equal(a, 11); -let b = func('s'); -Assert.equal(b, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_11.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_11.ts deleted file mode 100644 index 9fcd82bbf2..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_11.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A type guard of the form expr1 && expr2, - when true, narrows the type of x by expr1 when true and then by expr2 when true, or - when false, narrows the type of x to T1 | T2, where T1 is the type of x narrowed by expr1 when false, - and T2 is the type of x narrowed by expr1 when true and then by expr2 when false. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function func(x: string | number | undefined) { - if (typeof x === "string" && typeof x === "number") { - return undefined; - } - else { - return x; - } -} -let a = func(10); -Assert.isNumber(a); -let b = func('s'); -Assert.isString(b); -let c = func(undefined); -Assert.isUndefined(c); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_12.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_12.ts deleted file mode 100644 index 23569fbadb..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_12.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A type guard of the form expr1 || expr2, - when true, narrows the type of x to T1 | T2, where T1 is the type of x narrowed by expr1 when true, - and T2 is the type of x narrowed by expr1 when false and then by expr2 when true, or - when false, narrows the type of x by expr1 when false and then by expr2 when false. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function func(x: string | number | undefined) { - if (typeof x === "string" || typeof x === "number") { - return x; - } - else { - return undefined; - } -} -let a = func(10); -Assert.isNumber(a); -let b = func('s'); -Assert.isString(b); -let c = func(undefined); -Assert.isUndefined(c); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_13.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_13.ts deleted file mode 100644 index 17c6536000..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_13.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A type guard of any other form has no effect on the type of x. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Person { - name: string - age: number - public constructor(name: string, age: number) { - this.name = name - this.age = age - } -} -class Animal { - height: number - weight: number - public constructor(height: number, weight: number) { - this.height = height - this.weight = weight - } -} -function func(arg: Person | Animal) { - if ('age' in arg) { - Assert.isString(arg.name) - } - if ('height' in arg) { - Assert.isNumber(arg.height) - } -} -let p = new Person('x', 18); -func(p); -let a = new Animal(200, 180); -func(a); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_2.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_2.ts deleted file mode 100644 index 8b8027f7cd..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_2.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In the false branch statement of an 'if' statement, - the type of a variable or parameter is narrowed by a type guard in the 'if' condition when false, - provided no part of the 'if' statement contains assignments to the variable or parameter. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function h_func(h_x: number | string) { - if (!(typeof h_x === 'string')) { - Assert.isNumber(h_x); - return h_x; - } - else { - return h_x.length - } -} -let a = h_func(10); -Assert.equal(a, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_3.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_3.ts deleted file mode 100644 index d092aec559..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_3.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In the true expression of a conditional expression, - the type of a variable or parameter is narrowed by a type guard in the condition when true, - provided no part of the conditional expression contains assignments to the variable or parameter. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function func(arg: string | (() => string)) { - let x = typeof arg == "string" ? arg : arg(); - return x; -} -let result = func("abc"); -Assert.isString(result); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_4.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_4.ts deleted file mode 100644 index 1497787e83..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_4.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In the false expression of a conditional expression, - the type of a variable or parameter is narrowed by a type guard in the condition when false, - provided no part of the conditional expression contains assignments to the variable or parameter. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function func(arg: string | (() => string)) { - var x = typeof arg !== "string" ? arg() : arg; - return x; -} -let result = func("abc"); -Assert.isString(result); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_5.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_5.ts deleted file mode 100644 index 8eaf5a06cf..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_5.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - In the right operand of a && operation, - the type of a variable or parameter is narrowed by a type guard in the left operand when true, - provided neither operand contains assignments to the variable or parameter. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function fun(obj: any) { - typeof obj === "number" && obj - Assert.isNumber(obj) -} -fun(12); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_6.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_6.ts deleted file mode 100644 index 0040c18beb..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_6.ts +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A type guard of the form 'x instanceof C', where x is not of type Any, - C is of a subtype of the global type 'Function', and C has a property named 'prototype', - when true, narrows the type of x to the type of the 'prototype' property in C provided it is a subtype of the type of x, - or, if the type of x is a union type, removes from the type of x all constituent types that aren't subtypes of the type of the 'prototype' property in C, - or when false, has no effect on the type of x. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -class Person { - height: number - age: number - public constructor(height: number, age: number) { - this.height = height - this.age = age - } -} -class Animal { - height: number - weight: number - public constructor(height: number, weight: number) { - this.height = height - this.weight = weight - } -} -function func(arg: Person | Animal) { - if (arg instanceof Person) { - return arg.age = 18 - } - if (arg instanceof Animal) { - return arg.weight = 300 - } -} -var p = new Person(150, 18) -Assert.equal(func(p), 18) -var a = new Animal(200, 180) -Assert.equal(func(a), 300); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_7.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_7.ts deleted file mode 100644 index 7d3ef1a40d..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_7.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A type guard of the form typeof x === s, where s is a string literal with the value 'string', 'number', or 'boolean', - when true, narrows the type of x to the given primitive type provided it is a subtype of the type of x, - or, if the type of x is a union type, removes from the type of x all constituent types that aren't subtypes of the given primitive type, - or when false, removes the primitive type from the type of x. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function func(x: string | number) { - if (typeof x === "string") { - Assert.isString(x); - return x.length; - } - else { - Assert.isNumber(x); - return x + 1; - } -} -let a = func(10); -Assert.equal(a, 11); -let b = func('s'); -Assert.equal(b, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_8.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_8.ts deleted file mode 100644 index 53c3fab073..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_8.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A type guard of the form typeof x === s, where s is a string literal with any value but 'string', 'number', or 'boolean', - when true, if x is a union type, removes from the type of x all constituent types that are subtypes of the string, number, or boolean primitive type, - or when false, has no effect on the type of x. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function f1(x: string | number | undefined) { - if (typeof x === "undefined") { - return undefined - } - else { - return x - } -} -var a = f1(10) -Assert.isNumber(a) -var b = f1('s') -Assert.isString(b) -var c = f1(undefined) -Assert.isUndefined(c) -function f2(x: string | number | boolean) { - if (typeof x === "undefined") { - return undefined - } - else { - return x - } -} -var a1 = f2(10) -Assert.isNumber(a1) -var b1 = f2('s') -Assert.isString(b1) -var c1 = f2(true) -Assert.isBoolean(c1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_9.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_9.ts deleted file mode 100644 index c026b9e2f7..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/type_guards/type_guards_9.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - A type guard of the form typeof x !== s, where s is a string literal, - when true, narrows the type of x by typeof x === s when false, - or when false, narrows the type of x by typeof x === s when true. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -function func(x: string | number) { - if (typeof x !== "string") { - Assert.isNumber(x); - return x + 1; - } - else { - Assert.isString(x); - return x.length; - } -} -let a = func(10); -Assert.equal(a, 11); -let b = func('s'); -Assert.equal(b, 1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_!_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_!_operator.ts deleted file mode 100644 index a897e3afac..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_!_operator.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The ! operator permits its operand to be of any type and produces a result of the Boolean primitive type. - Two unary ! operators in sequence can conveniently be used to convert a value of any type to the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var num1: number = 20 -var num2: number = 90 -var res = !((num1 > 50) && (num2 > 80)) -Assert.isTrue(res) -function func(): any { -} -var b = !!func() -Assert.isFalse(b); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_++_and_--_operators.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_++_and_--_operators.ts deleted file mode 100644 index a3a4b162f0..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_++_and_--_operators.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The ++ and -- operators in prefix or postfix form, require their operand to be of type Any, the Number primitive type, or an enum type, - and classified as a reference. They produce a result of the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var a: any = '10'; -a++; -a--; ---a; -++a; -Assert.isNumber(a); -Assert.equal(a, 10); -enum e { - A, - B, - C, - D -} -let b = e.A -b++; -b--; -++b; ---b; -Assert.isNumber(b); -Assert.equal(b, 0); -var c: number = 10; -c++; -++c; ---c; -c--; -Assert.isNumber(c); -Assert.equal(c, 10); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_+_and_~_operators.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_+_and_~_operators.ts deleted file mode 100644 index d33f144c3c..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_+_and_~_operators.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The +, -, and ~ operators permit their operand to be of any type and produce a result of the Number primitive type. - The unary + operator can conveniently be used to convert a value of any type to the Number primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -var a: any = 'a' -a = a + 1 -a = a - 1 -a = ~a -Assert.isNumber(a); -Assert.equal(a, -1); -function func() { } -var n = +func(); -Assert.isTrue(Number.isNaN(n)); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_delete_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_delete_operator.ts deleted file mode 100644 index 159678417b..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_delete_operator.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The 'delete' operator takes an operand of any type and produces a result of the Boolean primitive type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -interface Foo { - prop1?: string - prop2?: boolean - prop3?: number -} -let obj: Foo = { - prop1: 'value', - prop2: true, - prop3: 20 -} -Assert.isBoolean(delete obj.prop1); \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_typeof_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_typeof_operator.ts deleted file mode 100644 index 06eb874eda..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_typeof_operator.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The 'typeof' operator takes an operand of any type and produces a value of the String primitive type. In positions where a type is expected, 'typeof' can also be used in a type query to produce the type of an expression. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let aa = 1 -let bb = typeof aa -Assert.equal(bb, 'number') -let cc: typeof aa = 2 -Assert.equal(cc, 2) \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_void_operator.ts b/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_void_operator.ts deleted file mode 100644 index 501fb22f61..0000000000 --- a/es2panda/test/ts_extra_tests/test_ts_cases/spec/expressions/unary_operators/the_void_operator.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**--- - description: > - The 'void' operator takes an operand of any type and produces the value 'undefined'. The type of the result is the Undefined type. - module: ESNext - isCurrent: true - ---*/ - - -import { Assert } from '../../../../suite/assert.js' - -let num: any = 10 -num = 'string' -let un = void num -Assert.isUndefined(un); \ No newline at end of file -- Gitee From 879020368c1ac4df1c299a480e52c468fd911788 Mon Sep 17 00:00:00 2001 From: tanglizhen Date: Thu, 20 Jul 2023 14:00:52 +0800 Subject: [PATCH 18/18] Ts test cases others Signed-off-by: tanglizhen --- es2panda/test/ts_extra_tests/suite/assert.ts | 68 ------------------- .../ts_extra_tests/suite/assertionError.ts | 24 ------- 2 files changed, 92 deletions(-) delete mode 100644 es2panda/test/ts_extra_tests/suite/assert.ts delete mode 100644 es2panda/test/ts_extra_tests/suite/assertionError.ts diff --git a/es2panda/test/ts_extra_tests/suite/assert.ts b/es2panda/test/ts_extra_tests/suite/assert.ts deleted file mode 100644 index 503047c090..0000000000 --- a/es2panda/test/ts_extra_tests/suite/assert.ts +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -import { AssertionError } from "./assertionError.js" - -export class Assert { - private static defaultMessage(actual: any, expect: any, flag: boolean = true) { - if (flag == true) { - return "expected '" + expect + "' ,but was '" + actual + "'."; - } else { - return "expected not '" + expect + "' ,but was '" + actual + "'."; - } - - } - static equal(actual: any, expect: any, msg?: string) { - if (actual != expect) { - throw new AssertionError(msg ? msg : this.defaultMessage(actual, expect)); - } - } - static notEqual(actual: any, expect: any, msg?: string) { - if (actual == expect) { - throw new AssertionError(msg ? msg : this.defaultMessage(actual, expect, false)); - } - } - static isTrue(actual: any, msg?: string) { - this.equal(actual, true, msg); - } - static isFalse(flag: any, msg?: string) { - this.equal(flag, false, msg); - } - static isNumber(x: any, msg?: string) { - this.equal(typeof x, "number", msg); - } - static isString(s: any, msg?: string) { - this.equal(typeof s, "string", msg); - } - static isBoolean(s: any, msg?: string) { - this.equal(typeof s, "boolean", msg); - } - static isSymbol(actual: any, msg?: string) { - this.equal(typeof actual, "symbol", msg); - } - static isFunction(fun: any, msg?: string) { - this.equal(typeof fun, "function", msg); - } - static notNULL(v: any, msg?: string) { - this.notEqual(v, null, msg); - } - static isUndefined(actual: any, msg?: string) { - this.equal(actual, undefined, msg); - } - static isObject(obj: any, msg?: string) { - this.equal(typeof obj, "object", msg); - } -} \ No newline at end of file diff --git a/es2panda/test/ts_extra_tests/suite/assertionError.ts b/es2panda/test/ts_extra_tests/suite/assertionError.ts deleted file mode 100644 index b1447b867d..0000000000 --- a/es2panda/test/ts_extra_tests/suite/assertionError.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -export class AssertionError extends Error { - protected msg: string | undefined = ""; - - constructor(msg: string | undefined) { - super(); - this.msg = msg; - } -} -- Gitee