Fix coverage with several contract classes; table annotation and file path checks; clean task dir on write
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
This commit is contained in:
231
tasks_gen/eval/G0118/hidden/canteen_hidden.clas.abap
Normal file
231
tasks_gen/eval/G0118/hidden/canteen_hidden.clas.abap
Normal file
@@ -0,0 +1,231 @@
|
||||
CLASS {{p}}canteen_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}if_canteen_plan.
|
||||
|
||||
METHODS setup.
|
||||
|
||||
METHODS assert_quantity
|
||||
IMPORTING iv_expected TYPE {{p}}if_canteen_plan=>ty_quantity
|
||||
iv_actual TYPE {{p}}if_canteen_plan=>ty_quantity.
|
||||
|
||||
METHODS quantity_of
|
||||
IMPORTING it_demand TYPE {{p}}if_canteen_plan=>tt_order
|
||||
iv_ingredient TYPE {{p}}if_canteen_plan=>ty_ingredient
|
||||
RETURNING VALUE(rv_quantity) TYPE {{p}}if_canteen_plan=>ty_quantity.
|
||||
|
||||
METHODS packs_of
|
||||
IMPORTING it_packs TYPE {{p}}if_canteen_plan=>tt_pack
|
||||
iv_ingredient TYPE {{p}}if_canteen_plan=>ty_ingredient
|
||||
RETURNING VALUE(rv_packs) TYPE i.
|
||||
|
||||
METHODS ingredient_list
|
||||
IMPORTING it_demand TYPE {{p}}if_canteen_plan=>tt_order
|
||||
RETURNING VALUE(rv_list) TYPE string.
|
||||
|
||||
METHODS merges_and_sums FOR TESTING.
|
||||
METHODS result_is_sorted FOR TESTING.
|
||||
METHODS ignores_non_positive FOR TESTING.
|
||||
METHODS empty_inputs FOR TESTING.
|
||||
METHODS duplicate_in_one_list FOR TESTING.
|
||||
METHODS packs_round_up FOR TESTING.
|
||||
METHODS packs_skip_unknown FOR TESTING.
|
||||
METHODS packs_sorted FOR TESTING.
|
||||
METHODS missing_lists_unknown FOR TESTING.
|
||||
METHODS missing_none FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}canteen_hidden IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}canteen_planner( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD assert_quantity.
|
||||
cl_abap_unit_assert=>assert_equals( exp = iv_expected act = iv_actual ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD quantity_of.
|
||||
LOOP AT it_demand INTO DATA(ls_demand) WHERE ingredient = iv_ingredient.
|
||||
rv_quantity = rv_quantity + ls_demand-quantity.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD packs_of.
|
||||
LOOP AT it_packs INTO DATA(ls_pack) WHERE ingredient = iv_ingredient.
|
||||
rv_packs = rv_packs + ls_pack-packs.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ingredient_list.
|
||||
LOOP AT it_demand INTO DATA(ls_demand).
|
||||
rv_list = rv_list && ls_demand-ingredient && `|`.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD merges_and_sums.
|
||||
DATA(lt_a) = VALUE {{p}}if_canteen_plan=>tt_order(
|
||||
( ingredient = 'FLOUR' quantity = 5 )
|
||||
( ingredient = 'SUGAR' quantity = 2 ) ).
|
||||
DATA(lt_b) = VALUE {{p}}if_canteen_plan=>tt_order(
|
||||
( ingredient = 'FLOUR' quantity = 3 )
|
||||
( ingredient = 'BUTTER' quantity = 1 ) ).
|
||||
|
||||
DATA(lt_demand) = mo_cut->merge_orders( it_orders_a = lt_a
|
||||
it_orders_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 3 act = lines( lt_demand ) ).
|
||||
assert_quantity( iv_expected = 8
|
||||
iv_actual = quantity_of( it_demand = lt_demand
|
||||
iv_ingredient = 'FLOUR' ) ).
|
||||
assert_quantity( iv_expected = 2
|
||||
iv_actual = quantity_of( it_demand = lt_demand
|
||||
iv_ingredient = 'SUGAR' ) ).
|
||||
assert_quantity( iv_expected = 1
|
||||
iv_actual = quantity_of( it_demand = lt_demand
|
||||
iv_ingredient = 'BUTTER' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD result_is_sorted.
|
||||
DATA(lt_a) = VALUE {{p}}if_canteen_plan=>tt_order(
|
||||
( ingredient = 'SUGAR' quantity = 2 )
|
||||
( ingredient = 'FLOUR' quantity = 1 ) ).
|
||||
DATA(lt_b) = VALUE {{p}}if_canteen_plan=>tt_order(
|
||||
( ingredient = 'BUTTER' quantity = 1 ) ).
|
||||
|
||||
DATA(lt_demand) = mo_cut->merge_orders( it_orders_a = lt_a
|
||||
it_orders_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = `BUTTER|FLOUR|SUGAR|`
|
||||
act = ingredient_list( lt_demand ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ignores_non_positive.
|
||||
DATA(lt_a) = VALUE {{p}}if_canteen_plan=>tt_order(
|
||||
( ingredient = 'FLOUR' quantity = 5 )
|
||||
( ingredient = 'SUGAR' quantity = 0 ) ).
|
||||
DATA(lt_b) = VALUE {{p}}if_canteen_plan=>tt_order(
|
||||
( ingredient = 'BUTTER' quantity = -2 )
|
||||
( ingredient = 'FLOUR' quantity = 1 ) ).
|
||||
|
||||
DATA(lt_demand) = mo_cut->merge_orders( it_orders_a = lt_a
|
||||
it_orders_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = `FLOUR|`
|
||||
act = ingredient_list( lt_demand ) ).
|
||||
assert_quantity( iv_expected = 6
|
||||
iv_actual = quantity_of( it_demand = lt_demand
|
||||
iv_ingredient = 'FLOUR' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD empty_inputs.
|
||||
DATA(lt_demand) = mo_cut->merge_orders(
|
||||
it_orders_a = VALUE {{p}}if_canteen_plan=>tt_order( )
|
||||
it_orders_b = VALUE {{p}}if_canteen_plan=>tt_order( ) ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_demand ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD duplicate_in_one_list.
|
||||
DATA(lt_a) = VALUE {{p}}if_canteen_plan=>tt_order(
|
||||
( ingredient = 'FLOUR' quantity = 2 )
|
||||
( ingredient = 'FLOUR' quantity = 3 ) ).
|
||||
|
||||
DATA(lt_demand) = mo_cut->merge_orders(
|
||||
it_orders_a = lt_a
|
||||
it_orders_b = VALUE {{p}}if_canteen_plan=>tt_order( ) ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_demand ) ).
|
||||
assert_quantity( iv_expected = 5
|
||||
iv_actual = quantity_of( it_demand = lt_demand
|
||||
iv_ingredient = 'FLOUR' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD packs_round_up.
|
||||
DATA(lt_demand) = VALUE {{p}}if_canteen_plan=>tt_order(
|
||||
( ingredient = 'FLOUR' quantity = 25 )
|
||||
( ingredient = 'SUGAR' quantity = 7 )
|
||||
( ingredient = 'BUTTER' quantity = 3 ) ).
|
||||
DATA(lt_catalogue) = VALUE {{p}}if_canteen_plan=>tt_master(
|
||||
( ingredient = 'FLOUR' pack_size = 10 )
|
||||
( ingredient = 'SUGAR' pack_size = 5 )
|
||||
( ingredient = 'BUTTER' pack_size = 1 ) ).
|
||||
|
||||
DATA(lt_packs) = mo_cut->pack_requirement( it_demand = lt_demand
|
||||
it_catalogue = lt_catalogue ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 3 act = lines( lt_packs ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 3 act = packs_of( it_packs = lt_packs
|
||||
iv_ingredient = 'FLOUR' ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = packs_of( it_packs = lt_packs
|
||||
iv_ingredient = 'SUGAR' ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 3 act = packs_of( it_packs = lt_packs
|
||||
iv_ingredient = 'BUTTER' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD packs_skip_unknown.
|
||||
DATA(lt_demand) = VALUE {{p}}if_canteen_plan=>tt_order(
|
||||
( ingredient = 'FLOUR' quantity = 10 )
|
||||
( ingredient = 'COCOA' quantity = 5 ) ).
|
||||
DATA(lt_catalogue) = VALUE {{p}}if_canteen_plan=>tt_master(
|
||||
( ingredient = 'FLOUR' pack_size = 10 ) ).
|
||||
|
||||
DATA(lt_packs) = mo_cut->pack_requirement( it_demand = lt_demand
|
||||
it_catalogue = lt_catalogue ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_packs ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = packs_of( it_packs = lt_packs
|
||||
iv_ingredient = 'FLOUR' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD packs_sorted.
|
||||
DATA(lt_demand) = VALUE {{p}}if_canteen_plan=>tt_order(
|
||||
( ingredient = 'SUGAR' quantity = 11 )
|
||||
( ingredient = 'FLOUR' quantity = 21 )
|
||||
( ingredient = 'BUTTER' quantity = 4 ) ).
|
||||
DATA(lt_catalogue) = VALUE {{p}}if_canteen_plan=>tt_master(
|
||||
( ingredient = 'SUGAR' pack_size = 5 )
|
||||
( ingredient = 'FLOUR' pack_size = 10 )
|
||||
( ingredient = 'BUTTER' pack_size = 1 ) ).
|
||||
|
||||
DATA(lt_packs) = mo_cut->pack_requirement( it_demand = lt_demand
|
||||
it_catalogue = lt_catalogue ).
|
||||
|
||||
DATA lv_order TYPE string.
|
||||
LOOP AT lt_packs INTO DATA(ls_pack).
|
||||
lv_order = lv_order && ls_pack-ingredient && `|`.
|
||||
ENDLOOP.
|
||||
cl_abap_unit_assert=>assert_equals( exp = `BUTTER|FLOUR|SUGAR|` act = lv_order ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD missing_lists_unknown.
|
||||
DATA(lt_demand) = VALUE {{p}}if_canteen_plan=>tt_order(
|
||||
( ingredient = 'SUGAR' quantity = 5 )
|
||||
( ingredient = 'COCOA' quantity = 1 )
|
||||
( ingredient = 'FLOUR' quantity = 2 )
|
||||
( ingredient = 'COCOA' quantity = 3 ) ).
|
||||
DATA(lt_catalogue) = VALUE {{p}}if_canteen_plan=>tt_master(
|
||||
( ingredient = 'FLOUR' pack_size = 10 )
|
||||
( ingredient = 'SUGAR' pack_size = 5 ) ).
|
||||
|
||||
DATA(lt_missing) = mo_cut->missing_ingredients( it_demand = lt_demand
|
||||
it_catalogue = lt_catalogue ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_missing ) ).
|
||||
LOOP AT lt_missing INTO DATA(lv_ingredient).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'COCOA' act = lv_ingredient ).
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD missing_none.
|
||||
DATA(lt_demand) = VALUE {{p}}if_canteen_plan=>tt_order(
|
||||
( ingredient = 'FLOUR' quantity = 1 ) ).
|
||||
DATA(lt_catalogue) = VALUE {{p}}if_canteen_plan=>tt_master(
|
||||
( ingredient = 'FLOUR' pack_size = 10 ) ).
|
||||
|
||||
DATA(lt_missing) = mo_cut->missing_ingredients( it_demand = lt_demand
|
||||
it_catalogue = lt_catalogue ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_missing ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user