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:
45
tasks_gen/eval/G0121/reference/roast_sum.func.abap
Normal file
45
tasks_gen/eval/G0121/reference/roast_sum.func.abap
Normal file
@@ -0,0 +1,45 @@
|
||||
FUNCTION {{p}}roast_sum
|
||||
IMPORTING
|
||||
it_orders TYPE STANDARD TABLE OF {{p}}roasts
|
||||
EXPORTING
|
||||
et_totals TYPE STANDARD TABLE OF {{p}}blends
|
||||
ev_grand_total TYPE decfloat34.
|
||||
|
||||
TYPES: BEGIN OF ty_sum,
|
||||
blend TYPE {{p}}blends-blend,
|
||||
total_kg TYPE {{p}}blends-total_kg,
|
||||
END OF ty_sum.
|
||||
|
||||
DATA lt_sum TYPE HASHED TABLE OF ty_sum WITH UNIQUE KEY blend.
|
||||
DATA ls_ord TYPE {{p}}roasts.
|
||||
DATA ls_sum TYPE ty_sum.
|
||||
DATA ls_tot TYPE {{p}}blends.
|
||||
|
||||
CLEAR: et_totals, ev_grand_total.
|
||||
|
||||
LOOP AT it_orders INTO ls_ord.
|
||||
IF ls_ord-quantity_kg <= 0.
|
||||
CONTINUE.
|
||||
ENDIF.
|
||||
|
||||
READ TABLE lt_sum INTO ls_sum WITH TABLE KEY blend = ls_ord-blend.
|
||||
IF sy-subrc = 0.
|
||||
ls_sum-total_kg = ls_sum-total_kg + ls_ord-quantity_kg.
|
||||
MODIFY TABLE lt_sum FROM ls_sum.
|
||||
ELSE.
|
||||
ls_sum-blend = ls_ord-blend.
|
||||
ls_sum-total_kg = ls_ord-quantity_kg.
|
||||
INSERT ls_sum INTO TABLE lt_sum.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
|
||||
LOOP AT lt_sum INTO ls_sum.
|
||||
ls_tot-blend = ls_sum-blend.
|
||||
ls_tot-total_kg = ls_sum-total_kg.
|
||||
ev_grand_total = ev_grand_total + ls_sum-total_kg.
|
||||
APPEND ls_tot TO et_totals.
|
||||
ENDLOOP.
|
||||
|
||||
SORT et_totals BY total_kg DESCENDING blend ASCENDING.
|
||||
|
||||
ENDFUNCTION.
|
||||
109
tasks_gen/eval/G0121/reference/t14_test.clas.abap
Normal file
109
tasks_gen/eval/G0121/reference/t14_test.clas.abap
Normal file
@@ -0,0 +1,109 @@
|
||||
CLASS {{p}}t14_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
|
||||
PRIVATE SECTION.
|
||||
TYPES ty_orders TYPE STANDARD TABLE OF {{p}}roasts.
|
||||
TYPES ty_totals TYPE STANDARD TABLE OF {{p}}blends.
|
||||
|
||||
METHODS run
|
||||
IMPORTING it_orders TYPE ty_orders
|
||||
EXPORTING et_totals TYPE ty_totals
|
||||
ev_grand_total TYPE decfloat34
|
||||
ev_subrc TYPE sysubrc.
|
||||
|
||||
METHODS sums_per_blend FOR TESTING.
|
||||
METHODS ignores_non_positive FOR TESTING.
|
||||
METHODS sorted_by_total FOR TESTING.
|
||||
METHODS tie_break FOR TESTING.
|
||||
METHODS empty_input FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t14_test IMPLEMENTATION.
|
||||
|
||||
METHOD run.
|
||||
CLEAR: et_totals, ev_grand_total.
|
||||
CALL FUNCTION '{{P}}ROAST_SUM'
|
||||
EXPORTING
|
||||
it_orders = it_orders
|
||||
IMPORTING
|
||||
et_totals = et_totals
|
||||
ev_grand_total = ev_grand_total
|
||||
EXCEPTIONS
|
||||
OTHERS = 1.
|
||||
ev_subrc = sy-subrc.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD sums_per_blend.
|
||||
DATA lt_orders TYPE ty_orders.
|
||||
APPEND VALUE #( order_id = '0000000001' blend = 'PILS' quantity_kg = '10.000' ) TO lt_orders.
|
||||
APPEND VALUE #( order_id = '0000000002' blend = 'PILS' quantity_kg = '5.000' ) TO lt_orders.
|
||||
|
||||
DATA lt_totals TYPE ty_totals.
|
||||
run( EXPORTING it_orders = lt_orders
|
||||
IMPORTING et_totals = lt_totals ev_subrc = DATA(lv_subrc) ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_totals ) ).
|
||||
|
||||
DATA ls_tot TYPE {{p}}blends.
|
||||
READ TABLE lt_totals INTO ls_tot INDEX 1.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'PILS' act = ls_tot-blend ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 15 ) act = CONV decfloat34( ls_tot-total_kg ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ignores_non_positive.
|
||||
DATA lt_orders TYPE ty_orders.
|
||||
APPEND VALUE #( order_id = '0000000001' blend = 'PILS' quantity_kg = '0.000' ) TO lt_orders.
|
||||
APPEND VALUE #( order_id = '0000000002' blend = 'WEIZ' quantity_kg = '-4.000' ) TO lt_orders.
|
||||
|
||||
DATA lt_totals TYPE ty_totals.
|
||||
run( EXPORTING it_orders = lt_orders
|
||||
IMPORTING et_totals = lt_totals ev_subrc = DATA(lv_subrc) ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_totals ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD sorted_by_total.
|
||||
DATA lt_orders TYPE ty_orders.
|
||||
APPEND VALUE #( order_id = '0000000001' blend = 'ARAB' quantity_kg = '5.000' ) TO lt_orders.
|
||||
APPEND VALUE #( order_id = '0000000002' blend = 'ROBU' quantity_kg = '30.000' ) TO lt_orders.
|
||||
|
||||
DATA lt_totals TYPE ty_totals.
|
||||
run( EXPORTING it_orders = lt_orders
|
||||
IMPORTING et_totals = lt_totals ev_subrc = DATA(lv_subrc) ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
|
||||
DATA ls_tot TYPE {{p}}blends.
|
||||
READ TABLE lt_totals INTO ls_tot INDEX 1.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'ROBU' act = ls_tot-blend ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD tie_break.
|
||||
DATA lt_orders TYPE ty_orders.
|
||||
APPEND VALUE #( order_id = '0000000001' blend = 'ROBU' quantity_kg = '6.000' ) TO lt_orders.
|
||||
APPEND VALUE #( order_id = '0000000002' blend = 'ARAB' quantity_kg = '6.000' ) TO lt_orders.
|
||||
|
||||
DATA lt_totals TYPE ty_totals.
|
||||
run( EXPORTING it_orders = lt_orders
|
||||
IMPORTING et_totals = lt_totals ev_subrc = DATA(lv_subrc) ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
|
||||
DATA ls_tot TYPE {{p}}blends.
|
||||
READ TABLE lt_totals INTO ls_tot INDEX 1.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'ARAB' act = ls_tot-blend ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD empty_input.
|
||||
DATA lt_orders TYPE ty_orders.
|
||||
DATA lt_totals TYPE ty_totals.
|
||||
DATA lv_grand TYPE decfloat34 VALUE 99.
|
||||
run( EXPORTING it_orders = lt_orders
|
||||
IMPORTING et_totals = lt_totals ev_grand_total = lv_grand ev_subrc = DATA(lv_subrc) ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_totals ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_grand ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user