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:
38
tasks_gen/eval/G0124/generation.json
Normal file
38
tasks_gen/eval/G0124/generation.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"id": "G0124",
|
||||
"pool": "eval",
|
||||
"object_type": "PROG",
|
||||
"category": "C",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 100.0,
|
||||
"null": 0,
|
||||
"mutation": {
|
||||
"valid": 0,
|
||||
"killed": 0,
|
||||
"ok": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 80.6,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "bundle",
|
||||
"errors": [
|
||||
"seed: file seed/t20 seed.clas.abap missing"
|
||||
],
|
||||
"by_check": {
|
||||
"structure": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
}
|
||||
],
|
||||
"accepted": false
|
||||
}
|
||||
212
tasks_gen/eval/G0124/hidden/t20_hidden.clas.abap
Normal file
212
tasks_gen/eval/G0124/hidden/t20_hidden.clas.abap
Normal file
@@ -0,0 +1,212 @@
|
||||
CLASS {{p}}t20_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
TYPES tt_region TYPE RANGE OF {{p}}farm-region.
|
||||
METHODS run
|
||||
IMPORTING iv_from TYPE d
|
||||
iv_to TYPE d
|
||||
it_region TYPE tt_region OPTIONAL
|
||||
RETURNING VALUE(rr_data) TYPE REF TO data.
|
||||
METHODS value_of
|
||||
IMPORTING ir_data TYPE REF TO data
|
||||
iv_row TYPE i
|
||||
iv_col TYPE string
|
||||
RETURNING VALUE(rv_value) TYPE string.
|
||||
METHODS lines_of
|
||||
IMPORTING ir_data TYPE REF TO data
|
||||
RETURNING VALUE(rv_lines) TYPE i.
|
||||
METHODS all_farms_listed FOR TESTING.
|
||||
METHODS litres_summed FOR TESTING.
|
||||
METHODS delivery_count FOR TESTING.
|
||||
METHODS date_bounds FOR TESTING.
|
||||
METHODS date_range_wide FOR TESTING.
|
||||
METHODS region_filter FOR TESTING.
|
||||
METHODS region_exclude FOR TESTING.
|
||||
METHODS sorted_by_litres FOR TESTING.
|
||||
METHODS tie_break_farm_id FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t20_hidden IMPLEMENTATION.
|
||||
METHOD run.
|
||||
cl_salv_bs_runtime_info=>set( display = abap_false metadata = abap_false data = abap_true ).
|
||||
SUBMIT {{p}}milk_sum WITH p_from = iv_from WITH p_to = iv_to
|
||||
WITH s_reg IN it_region AND RETURN.
|
||||
TRY.
|
||||
cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data = rr_data ).
|
||||
CATCH cx_salv_bs_sc_runtime_info.
|
||||
ENDTRY.
|
||||
cl_salv_bs_runtime_info=>clear_all( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD lines_of.
|
||||
FIELD-SYMBOLS <lt_data> TYPE STANDARD TABLE.
|
||||
IF ir_data IS BOUND.
|
||||
ASSIGN ir_data->* TO <lt_data>.
|
||||
rv_lines = lines( <lt_data> ).
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD value_of.
|
||||
FIELD-SYMBOLS <lt_data> TYPE STANDARD TABLE.
|
||||
ASSIGN ir_data->* TO <lt_data>.
|
||||
ASSIGN <lt_data>[ iv_row ] TO FIELD-SYMBOL(<ls_line>).
|
||||
ASSIGN COMPONENT iv_col OF STRUCTURE <ls_line> TO FIELD-SYMBOL(<lv_value>).
|
||||
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = |Column { iv_col } missing| ).
|
||||
rv_value = condense( CONV string( <lv_value> ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD all_farms_listed.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 5
|
||||
act = lines_of( run( iv_from = '20260101' iv_to = '20260131' ) ) ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 2
|
||||
act = lines_of( run( iv_from = '20260101' iv_to = '20260131'
|
||||
it_region = VALUE #( ( sign = 'I' option = 'EQ' low = 'CH' ) ) ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD litres_summed.
|
||||
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20260131' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1000`
|
||||
act = value_of( ir_data = lr_data iv_row = 1 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `200.50`
|
||||
act = value_of( ir_data = lr_data iv_row = 1 iv_col = `LITRES` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1001`
|
||||
act = value_of( ir_data = lr_data iv_row = 2 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `200.00`
|
||||
act = value_of( ir_data = lr_data iv_row = 2 iv_col = `LITRES` ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD delivery_count.
|
||||
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20260131' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `2`
|
||||
act = value_of( ir_data = lr_data iv_row = 1 iv_col = `DELIVERIES` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1`
|
||||
act = value_of( ir_data = lr_data iv_row = 3 iv_col = `DELIVERIES` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1003`
|
||||
act = value_of( ir_data = lr_data iv_row = 5 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `0`
|
||||
act = value_of( ir_data = lr_data iv_row = 5 iv_col = `DELIVERIES` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `0.00`
|
||||
act = value_of( ir_data = lr_data iv_row = 5 iv_col = `LITRES` ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD date_bounds.
|
||||
DATA(lr_one) = run( iv_from = '20260105' iv_to = '20260105' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 5 act = lines_of( lr_one ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1000`
|
||||
act = value_of( ir_data = lr_one iv_row = 1 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `120.50`
|
||||
act = value_of( ir_data = lr_one iv_row = 1 iv_col = `LITRES` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1`
|
||||
act = value_of( ir_data = lr_one iv_row = 1 iv_col = `DELIVERIES` ) ).
|
||||
|
||||
DATA(lr_two) = run( iv_from = '20260105' iv_to = '20260106' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 5 act = lines_of( lr_two ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1001`
|
||||
act = value_of( ir_data = lr_two iv_row = 1 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `200.00`
|
||||
act = value_of( ir_data = lr_two iv_row = 1 iv_col = `LITRES` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1000`
|
||||
act = value_of( ir_data = lr_two iv_row = 2 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `120.50`
|
||||
act = value_of( ir_data = lr_two iv_row = 2 iv_col = `LITRES` ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD date_range_wide.
|
||||
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20260228' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1001`
|
||||
act = value_of( ir_data = lr_data iv_row = 1 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `240.00`
|
||||
act = value_of( ir_data = lr_data iv_row = 1 iv_col = `LITRES` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `2`
|
||||
act = value_of( ir_data = lr_data iv_row = 1 iv_col = `DELIVERIES` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1000`
|
||||
act = value_of( ir_data = lr_data iv_row = 2 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `200.50`
|
||||
act = value_of( ir_data = lr_data iv_row = 2 iv_col = `LITRES` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `2`
|
||||
act = value_of( ir_data = lr_data iv_row = 2 iv_col = `DELIVERIES` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1003`
|
||||
act = value_of( ir_data = lr_data iv_row = 5 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `0.00`
|
||||
act = value_of( ir_data = lr_data iv_row = 5 iv_col = `LITRES` ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD region_filter.
|
||||
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20260131'
|
||||
it_region = VALUE #( ( sign = 'I' option = 'EQ' low = 'CH' ) ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines_of( lr_data ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1000`
|
||||
act = value_of( ir_data = lr_data iv_row = 1 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `200.50`
|
||||
act = value_of( ir_data = lr_data iv_row = 1 iv_col = `LITRES` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1001`
|
||||
act = value_of( ir_data = lr_data iv_row = 2 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `200.00`
|
||||
act = value_of( ir_data = lr_data iv_row = 2 iv_col = `LITRES` ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD region_exclude.
|
||||
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20260131'
|
||||
it_region = VALUE #( ( sign = 'E' option = 'EQ' low = 'CH' ) ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 3 act = lines_of( lr_data ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1002`
|
||||
act = value_of( ir_data = lr_data iv_row = 1 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `50.25`
|
||||
act = value_of( ir_data = lr_data iv_row = 1 iv_col = `LITRES` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1004`
|
||||
act = value_of( ir_data = lr_data iv_row = 2 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `50.25`
|
||||
act = value_of( ir_data = lr_data iv_row = 2 iv_col = `LITRES` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1003`
|
||||
act = value_of( ir_data = lr_data iv_row = 3 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `0.00`
|
||||
act = value_of( ir_data = lr_data iv_row = 3 iv_col = `LITRES` ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD sorted_by_litres.
|
||||
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20260131' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1000`
|
||||
act = value_of( ir_data = lr_data iv_row = 1 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1001`
|
||||
act = value_of( ir_data = lr_data iv_row = 2 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1002`
|
||||
act = value_of( ir_data = lr_data iv_row = 3 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1004`
|
||||
act = value_of( ir_data = lr_data iv_row = 4 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1003`
|
||||
act = value_of( ir_data = lr_data iv_row = 5 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `Alpine Dairy`
|
||||
act = value_of( ir_data = lr_data iv_row = 1 iv_col = `FARM_NAME` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `CH`
|
||||
act = value_of( ir_data = lr_data iv_row = 1 iv_col = `REGION` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `Hilltop Farm`
|
||||
act = value_of( ir_data = lr_data iv_row = 5 iv_col = `FARM_NAME` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `AT`
|
||||
act = value_of( ir_data = lr_data iv_row = 5 iv_col = `REGION` ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD tie_break_farm_id.
|
||||
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20260131' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `50.25`
|
||||
act = value_of( ir_data = lr_data iv_row = 3 iv_col = `LITRES` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `50.25`
|
||||
act = value_of( ir_data = lr_data iv_row = 4 iv_col = `LITRES` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1002`
|
||||
act = value_of( ir_data = lr_data iv_row = 3 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1004`
|
||||
act = value_of( ir_data = lr_data iv_row = 4 iv_col = `FARM_ID` ) ).
|
||||
|
||||
DATA(lr_zero) = run( iv_from = '20260105' iv_to = '20260105' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1001`
|
||||
act = value_of( ir_data = lr_zero iv_row = 2 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1002`
|
||||
act = value_of( ir_data = lr_zero iv_row = 3 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1003`
|
||||
act = value_of( ir_data = lr_zero iv_row = 4 iv_col = `FARM_ID` ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `1004`
|
||||
act = value_of( ir_data = lr_zero iv_row = 5 iv_col = `FARM_ID` ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
96
tasks_gen/eval/G0124/mutation.json
Normal file
96
tasks_gen/eval/G0124/mutation.json
Normal file
@@ -0,0 +1,96 @@
|
||||
{
|
||||
"task": "T20",
|
||||
"mutants": [
|
||||
{
|
||||
"object": "{{P}}MILK_SUM",
|
||||
"mutant": "BETWEEN -> >= only (rel)",
|
||||
"status": "killed",
|
||||
"hidden": "0/9",
|
||||
"failed_tests": [
|
||||
"ALL_FARMS_LISTED",
|
||||
"LITRES_SUMMED",
|
||||
"DELIVERY_COUNT",
|
||||
"DATE_BOUNDS",
|
||||
"DATE_RANGE_WIDE",
|
||||
"REGION_FILTER",
|
||||
"REGION_EXCLUDE",
|
||||
"SORTED_BY_LITRES",
|
||||
"TIE_BREAK_FARM_ID"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}MILK_SUM",
|
||||
"mutant": "BETWEEN -> <= only (rel)",
|
||||
"status": "killed",
|
||||
"hidden": "0/9",
|
||||
"failed_tests": [
|
||||
"LITRES_SUMMED",
|
||||
"DATE_BOUNDS",
|
||||
"DATE_RANGE_WIDE",
|
||||
"SORTED_BY_LITRES",
|
||||
"TIE_BREAK_FARM_ID"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}MILK_SUM",
|
||||
"mutant": "region IN -> region NOT IN (logic)",
|
||||
"status": "killed",
|
||||
"hidden": "0/9",
|
||||
"failed_tests": [
|
||||
"ALL_FARMS_LISTED",
|
||||
"LITRES_SUMMED",
|
||||
"DELIVERY_COUNT",
|
||||
"DATE_BOUNDS",
|
||||
"DATE_RANGE_WIDE",
|
||||
"REGION_FILTER",
|
||||
"REGION_EXCLUDE",
|
||||
"SORTED_BY_LITRES",
|
||||
"TIE_BREAK_FARM_ID"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}MILK_SUM",
|
||||
"mutant": "farm without delivery skipped (inner join)",
|
||||
"status": "killed",
|
||||
"hidden": "0/9",
|
||||
"failed_tests": [
|
||||
"ALL_FARMS_LISTED",
|
||||
"DELIVERY_COUNT",
|
||||
"DATE_BOUNDS",
|
||||
"DATE_RANGE_WIDE",
|
||||
"REGION_EXCLUDE",
|
||||
"SORTED_BY_LITRES",
|
||||
"TIE_BREAK_FARM_ID"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}MILK_SUM",
|
||||
"mutant": "SORT litres DESCENDING -> ASCENDING (rel)",
|
||||
"status": "killed",
|
||||
"hidden": "0/9",
|
||||
"failed_tests": [
|
||||
"LITRES_SUMMED",
|
||||
"DATE_BOUNDS",
|
||||
"DATE_RANGE_WIDE",
|
||||
"REGION_FILTER",
|
||||
"REGION_EXCLUDE",
|
||||
"SORTED_BY_LITRES",
|
||||
"TIE_BREAK_FARM_ID"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}MILK_SUM",
|
||||
"mutant": "secondary sort farm_id removed (tie)",
|
||||
"status": "killed",
|
||||
"hidden": "0/9",
|
||||
"failed_tests": [
|
||||
"SORTED_BY_LITRES",
|
||||
"TIE_BREAK_FARM_ID"
|
||||
]
|
||||
}
|
||||
],
|
||||
"valid": 6,
|
||||
"killed": 6,
|
||||
"kill_rate": 1.0,
|
||||
"ok": true
|
||||
}
|
||||
170
tasks_gen/eval/G0124/reference/milk_sum.prog.abap
Normal file
170
tasks_gen/eval/G0124/reference/milk_sum.prog.abap
Normal file
@@ -0,0 +1,170 @@
|
||||
REPORT {{p}}milk_sum.
|
||||
|
||||
DATA gv_region TYPE {{p}}farm-region.
|
||||
|
||||
PARAMETERS p_from TYPE d OBLIGATORY.
|
||||
PARAMETERS p_to TYPE d OBLIGATORY.
|
||||
SELECT-OPTIONS s_reg FOR gv_region.
|
||||
|
||||
CLASS lcl_report DEFINITION FINAL.
|
||||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
BEGIN OF ty_line,
|
||||
farm_id TYPE {{p}}farm-farm_id,
|
||||
farm_name TYPE {{p}}farm-farm_name,
|
||||
region TYPE {{p}}farm-region,
|
||||
litres TYPE {{p}}milk-litres,
|
||||
deliveries TYPE i,
|
||||
END OF ty_line,
|
||||
tt_line TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY,
|
||||
tt_region TYPE RANGE OF {{p}}farm-region.
|
||||
METHODS select_data
|
||||
IMPORTING iv_from TYPE d
|
||||
iv_to TYPE d
|
||||
it_region TYPE tt_region
|
||||
RETURNING VALUE(rt_lines) TYPE tt_line.
|
||||
METHODS display
|
||||
CHANGING ct_lines TYPE tt_line.
|
||||
PRIVATE SECTION.
|
||||
TYPES:
|
||||
BEGIN OF ty_sum,
|
||||
farm_id TYPE {{p}}milk-farm_id,
|
||||
litres TYPE {{p}}milk-litres,
|
||||
deliveries TYPE i,
|
||||
END OF ty_sum,
|
||||
tt_sum TYPE HASHED TABLE OF ty_sum WITH UNIQUE KEY farm_id.
|
||||
METHODS sum_deliveries
|
||||
IMPORTING iv_from TYPE d
|
||||
iv_to TYPE d
|
||||
RETURNING VALUE(rt_sum) TYPE tt_sum.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_report IMPLEMENTATION.
|
||||
METHOD select_data.
|
||||
SELECT farm_id, farm_name, region
|
||||
FROM {{p}}farm
|
||||
WHERE region IN @it_region
|
||||
INTO TABLE @DATA(lt_farm).
|
||||
|
||||
DATA(lt_sum) = sum_deliveries( iv_from = iv_from iv_to = iv_to ).
|
||||
|
||||
LOOP AT lt_farm INTO DATA(ls_farm).
|
||||
DATA(ls_line) = VALUE ty_line( farm_id = ls_farm-farm_id
|
||||
farm_name = ls_farm-farm_name
|
||||
region = ls_farm-region ).
|
||||
READ TABLE lt_sum ASSIGNING FIELD-SYMBOL(<ls_sum>)
|
||||
WITH TABLE KEY farm_id = ls_farm-farm_id.
|
||||
IF sy-subrc = 0.
|
||||
ls_line-litres = <ls_sum>-litres.
|
||||
ls_line-deliveries = <ls_sum>-deliveries.
|
||||
ENDIF.
|
||||
APPEND ls_line TO rt_lines.
|
||||
ENDLOOP.
|
||||
|
||||
SORT rt_lines BY litres DESCENDING farm_id ASCENDING.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD sum_deliveries.
|
||||
SELECT farm_id, litres
|
||||
FROM {{p}}milk
|
||||
WHERE deliv_date BETWEEN @iv_from AND @iv_to
|
||||
INTO TABLE @DATA(lt_milk).
|
||||
|
||||
LOOP AT lt_milk INTO DATA(ls_milk).
|
||||
READ TABLE rt_sum ASSIGNING FIELD-SYMBOL(<ls_sum>)
|
||||
WITH TABLE KEY farm_id = ls_milk-farm_id.
|
||||
IF sy-subrc <> 0.
|
||||
DATA(ls_new) = VALUE ty_sum( farm_id = ls_milk-farm_id ).
|
||||
INSERT ls_new INTO TABLE rt_sum ASSIGNING <ls_sum>.
|
||||
ENDIF.
|
||||
<ls_sum>-litres += ls_milk-litres.
|
||||
<ls_sum>-deliveries += 1.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD display.
|
||||
TRY.
|
||||
cl_salv_table=>factory( IMPORTING r_salv_table = DATA(lo_alv)
|
||||
CHANGING t_table = ct_lines ).
|
||||
lo_alv->display( ).
|
||||
CATCH cx_salv_msg INTO DATA(lx_error).
|
||||
MESSAGE lx_error TYPE 'I' DISPLAY LIKE 'E'.
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
|
||||
START-OF-SELECTION.
|
||||
DATA(go_report) = NEW lcl_report( ).
|
||||
DATA(gt_lines) = go_report->select_data( iv_from = p_from iv_to = p_to it_region = s_reg[] ).
|
||||
go_report->display( CHANGING ct_lines = gt_lines ).
|
||||
|
||||
CLASS ltc_report DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
CLASS-DATA go_env TYPE REF TO if_osql_test_environment.
|
||||
CLASS-METHODS class_setup.
|
||||
CLASS-METHODS class_teardown.
|
||||
METHODS sums_and_counts FOR TESTING.
|
||||
METHODS missing_delivery FOR TESTING.
|
||||
METHODS date_range FOR TESTING.
|
||||
METHODS tie_break FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS ltc_report IMPLEMENTATION.
|
||||
METHOD class_setup.
|
||||
go_env = cl_osql_test_environment=>create(
|
||||
i_dependency_list = VALUE #( ( '{{P}}FARM' ) ( '{{P}}MILK' ) ) ).
|
||||
DATA lt_farm TYPE STANDARD TABLE OF {{p}}farm WITH EMPTY KEY.
|
||||
lt_farm = VALUE #( ( farm_id = '1' farm_name = 'A' region = 'X' )
|
||||
( farm_id = '2' farm_name = 'B' region = 'X' )
|
||||
( farm_id = '3' farm_name = 'C' region = 'Y' )
|
||||
( farm_id = '4' farm_name = 'D' region = 'Y' )
|
||||
( farm_id = '5' farm_name = 'E' region = 'X' ) ).
|
||||
go_env->insert_test_data( lt_farm ).
|
||||
DATA lt_milk TYPE STANDARD TABLE OF {{p}}milk WITH EMPTY KEY.
|
||||
lt_milk = VALUE #( ( deliv_id = 1 farm_id = '1' deliv_date = '20260110' litres = 10 )
|
||||
( deliv_id = 2 farm_id = '1' deliv_date = '20260120' litres = 5 )
|
||||
( deliv_id = 3 farm_id = '2' deliv_date = '20260115' litres = 40 )
|
||||
( deliv_id = 4 farm_id = '3' deliv_date = '20260116' litres = 20 )
|
||||
( deliv_id = 5 farm_id = '5' deliv_date = '20260111' litres = 15 ) ).
|
||||
go_env->insert_test_data( lt_milk ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD class_teardown.
|
||||
go_env->destroy( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD sums_and_counts.
|
||||
DATA(lt_lines) = NEW lcl_report( )->select_data(
|
||||
iv_from = '20260101' iv_to = '20260131' it_region = VALUE #( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 5 act = lines( lt_lines ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = '2' act = lt_lines[ 1 ]-farm_id ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV {{p}}milk-litres( 40 ) act = lt_lines[ 1 ]-litres ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lt_lines[ 1 ]-deliveries ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD missing_delivery.
|
||||
DATA(lt_lines) = NEW lcl_report( )->select_data(
|
||||
iv_from = '20260101' iv_to = '20260131' it_region = VALUE #( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = '4' act = lt_lines[ 5 ]-farm_id ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lt_lines[ 5 ]-deliveries ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lt_lines[ 5 ]-litres ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD date_range.
|
||||
DATA(lt_lines) = NEW lcl_report( )->select_data(
|
||||
iv_from = '20260115' iv_to = '20260131' it_region = VALUE #( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 5 act = lines( lt_lines ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = '2' act = lt_lines[ 1 ]-farm_id ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV {{p}}milk-litres( 40 ) act = lt_lines[ 1 ]-litres ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = '1' act = lt_lines[ 3 ]-farm_id ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV {{p}}milk-litres( 5 ) act = lt_lines[ 3 ]-litres ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lt_lines[ 3 ]-deliveries ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD tie_break.
|
||||
DATA(lt_lines) = NEW lcl_report( )->select_data(
|
||||
iv_from = '20260101' iv_to = '20260131' it_region = VALUE #( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = '1' act = lt_lines[ 3 ]-farm_id ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = '5' act = lt_lines[ 4 ]-farm_id ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
11
tasks_gen/eval/G0124/seed/farm.tabl.asabap
Normal file
11
tasks_gen/eval/G0124/seed/farm.tabl.asabap
Normal file
@@ -0,0 +1,11 @@
|
||||
@EndUserText.label : 'Farm'
|
||||
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
|
||||
@AbapCatalog.tableCategory : #TRANSPARENT
|
||||
@AbapCatalog.deliveryClass : #A
|
||||
@AbapCatalog.dataMaintenance : #RESTRICTED
|
||||
define table {{p}}farm {
|
||||
key client : abap.clnt not null;
|
||||
key farm_id : abap.char(10) not null;
|
||||
farm_name : abap.char(40);
|
||||
region : abap.char(4);
|
||||
}
|
||||
12
tasks_gen/eval/G0124/seed/milk.tabl.asabap
Normal file
12
tasks_gen/eval/G0124/seed/milk.tabl.asabap
Normal file
@@ -0,0 +1,12 @@
|
||||
@EndUserText.label : 'Milk delivery'
|
||||
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
|
||||
@AbapCatalog.tableCategory : #TRANSPARENT
|
||||
@AbapCatalog.deliveryClass : #A
|
||||
@AbapCatalog.dataMaintenance : #RESTRICTED
|
||||
define table {{p}}milk {
|
||||
key client : abap.clnt not null;
|
||||
key deliv_id : abap.int4 not null;
|
||||
farm_id : abap.char(10);
|
||||
deliv_date : abap.dats;
|
||||
litres : abap.dec(13,2);
|
||||
}
|
||||
26
tasks_gen/eval/G0124/seed/t20_seed.clas.abap
Normal file
26
tasks_gen/eval/G0124/seed/t20_seed.clas.abap
Normal file
@@ -0,0 +1,26 @@
|
||||
CLASS {{p}}t20_seed DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES if_oo_adt_classrun.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS {{p}}t20_seed IMPLEMENTATION.
|
||||
METHOD if_oo_adt_classrun~main.
|
||||
DELETE FROM {{p}}milk.
|
||||
DELETE FROM {{p}}farm.
|
||||
INSERT {{p}}farm FROM TABLE @( VALUE #(
|
||||
( farm_id = '1000' farm_name = 'Alpine Dairy' region = 'CH' )
|
||||
( farm_id = '1001' farm_name = 'Valley Farm' region = 'CH' )
|
||||
( farm_id = '1002' farm_name = 'Lakeside Farm' region = 'DE' )
|
||||
( farm_id = '1003' farm_name = 'Hilltop Farm' region = 'AT' )
|
||||
( farm_id = '1004' farm_name = 'Sunny Acres' region = 'DE' ) ) ).
|
||||
INSERT {{p}}milk FROM TABLE @( VALUE #(
|
||||
( deliv_id = 1 farm_id = '1000' deliv_date = '20260105' litres = '120.50' )
|
||||
( deliv_id = 2 farm_id = '1000' deliv_date = '20260112' litres = '80.00' )
|
||||
( deliv_id = 3 farm_id = '1001' deliv_date = '20260106' litres = '200.00' )
|
||||
( deliv_id = 4 farm_id = '1002' deliv_date = '20260107' litres = '50.25' )
|
||||
( deliv_id = 5 farm_id = '1003' deliv_date = '20251220' litres = '300.00' )
|
||||
( deliv_id = 6 farm_id = '1001' deliv_date = '20260215' litres = '40.00' )
|
||||
( deliv_id = 7 farm_id = '1004' deliv_date = '20260108' litres = '50.25' ) ) ).
|
||||
out->write( sy-dbcnt ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
47
tasks_gen/eval/G0124/spec.md
Normal file
47
tasks_gen/eval/G0124/spec.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# 1. Goal
|
||||
Show the milk deliveries of each farm in an ALV list. The cooperative uses the
|
||||
list to compare the farms of a region for a period.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- Table {{P}}FARM exists in package $TMP. It contains data.
|
||||
Fields: FARM_ID (CHAR 10, key), FARM_NAME (CHAR 40), REGION (CHAR 4).
|
||||
- Table {{P}}MILK exists in package $TMP. It contains data.
|
||||
Fields: DELIV_ID (INT4, key), FARM_ID (CHAR 10), DELIV_DATE (DATS),
|
||||
LITRES (DEC 13,2).
|
||||
|
||||
# 4. Contract
|
||||
- Create the executable program {{P}}MILK_SUM in package $TMP.
|
||||
- Selection screen:
|
||||
- Parameter P_FROM, type DATS, mandatory: the first delivery date to include.
|
||||
- Parameter P_TO, type DATS, mandatory: the last delivery date to include.
|
||||
- Select-option S_REG for the region.
|
||||
- Show the result with CL_SALV_TABLE. The output table has these columns, with
|
||||
these names: FARM_ID, FARM_NAME, REGION, LITRES, DELIVERIES.
|
||||
|
||||
# 5. Business rules
|
||||
1. Include a delivery only if DELIV_DATE is on or after P_FROM and on or before
|
||||
P_TO. Both limits are included.
|
||||
2. Include a farm only if REGION is in S_REG. An empty S_REG includes every
|
||||
region. A line with sign E in S_REG excludes its region.
|
||||
3. Show one line for each included farm. A farm without an included delivery also
|
||||
gets a line.
|
||||
4. LITRES is the sum of the litres of the included deliveries of the farm. LITRES
|
||||
is 0 if the farm has no included delivery.
|
||||
5. DELIVERIES is the number of included deliveries of the farm. DELIVERIES is 0
|
||||
if the farm has no included delivery.
|
||||
6. Sort the lines by LITRES, the highest value first. If two lines have the same
|
||||
LITRES, sort them by FARM_ID, the lowest value first.
|
||||
7. FARM_NAME and REGION are the values of the farm.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: 7.58.
|
||||
- Coding standards: Clean ABAP. Read each table with one database access.
|
||||
- Out of scope: do not change {{P}}FARM and {{P}}MILK.
|
||||
|
||||
# 7. Acceptance
|
||||
- The program is active and has no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write ABAP Unit tests as local test classes in the program.
|
||||
68
tasks_gen/eval/G0124/task.json
Normal file
68
tasks_gen/eval/G0124/task.json
Normal file
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"id": "G0124",
|
||||
"category": "C",
|
||||
"object_type": "PROG",
|
||||
"difficulty": 2,
|
||||
"release_target": "v758",
|
||||
"expected_outcome": "implement",
|
||||
"budget": {
|
||||
"max_tool_calls": 40,
|
||||
"max_activations": 10
|
||||
},
|
||||
"seed": [
|
||||
{
|
||||
"type": "TABL",
|
||||
"name": "{{P}}FARM",
|
||||
"file": "seed/farm.tabl.asabap",
|
||||
"description": "Farms of the cooperative"
|
||||
},
|
||||
{
|
||||
"type": "TABL",
|
||||
"name": "{{P}}MILK",
|
||||
"file": "seed/milk.tabl.asabap",
|
||||
"description": "Milk deliveries"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}T20_SEED",
|
||||
"file": "seed/t20_seed.clas.abap",
|
||||
"description": "T20 seed data",
|
||||
"run": true
|
||||
}
|
||||
],
|
||||
"contract": [
|
||||
{
|
||||
"type": "PROG",
|
||||
"name": "{{P}}MILK_SUM",
|
||||
"parameters": [
|
||||
"p_from",
|
||||
"p_to",
|
||||
"s_reg"
|
||||
]
|
||||
}
|
||||
],
|
||||
"out_of_scope": [
|
||||
"{{P}}FARM",
|
||||
"{{P}}MILK"
|
||||
],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}T20_HIDDEN",
|
||||
"file": "hidden/t20_hidden.clas.abap",
|
||||
"description": "T20 hidden tests"
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "PROG",
|
||||
"name": "{{P}}MILK_SUM",
|
||||
"file": "reference/milk_sum.prog.abap",
|
||||
"description": "Milk litres per farm"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"db_operation_in_loop",
|
||||
"method_length"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user