Harness: runner, generator, tasks T01 T13 T14 T15, CLAUDE.md
This commit is contained in:
24
tasks_gen/eval/G0001/generation.json
Normal file
24
tasks_gen/eval/G0001/generation.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"id": "G0001",
|
||||
"pool": "eval",
|
||||
"object_type": "CLAS",
|
||||
"category": "C",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": null,
|
||||
"null": null
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 89.2,
|
||||
"null": 0
|
||||
}
|
||||
],
|
||||
"accepted": false
|
||||
}
|
||||
335
tasks_gen/eval/G0001/hidden/t07_hidden.clas.abap
Normal file
335
tasks_gen/eval/G0001/hidden/t07_hidden.clas.abap
Normal file
@@ -0,0 +1,335 @@
|
||||
CLASS {{P}}T07_HIDDEN DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{P}}TOUR_PLANNER.
|
||||
|
||||
METHODS setup.
|
||||
METHODS add_stop
|
||||
IMPORTING iv_tour_id TYPE {{P}}TOUR_PLANNER=>ty_tour_id
|
||||
iv_stop_no TYPE i
|
||||
iv_customer TYPE {{P}}TOUR_PLANNER=>ty_customer
|
||||
iv_packages TYPE i
|
||||
iv_weight TYPE {{P}}TOUR_PLANNER=>ty_weight.
|
||||
METHODS assert_item
|
||||
IMPORTING is_exp TYPE {{P}}TOUR_PLANNER=>ty_item
|
||||
is_act TYPE {{P}}TOUR_PLANNER=>ty_item
|
||||
iv_msg TYPE string.
|
||||
METHODS assert_weight
|
||||
IMPORTING iv_exp TYPE {{P}}TOUR_PLANNER=>ty_weight
|
||||
iv_act TYPE {{P}}TOUR_PLANNER=>ty_weight
|
||||
iv_msg TYPE string.
|
||||
|
||||
METHODS add_one_item FOR TESTING.
|
||||
METHODS items_are_sorted FOR TESTING.
|
||||
METHODS duplicate_is_rejected FOR TESTING.
|
||||
METHODS empty_tour_id_is_invalid FOR TESTING.
|
||||
METHODS bad_stop_no_is_invalid FOR TESTING.
|
||||
METHODS negative_values_are_invalid FOR TESTING.
|
||||
METHODS zero_values_are_valid FOR TESTING.
|
||||
METHODS stops_of_tour_are_sorted FOR TESTING.
|
||||
METHODS unknown_tour_has_no_stops FOR TESTING.
|
||||
METHODS find_stop_works FOR TESTING.
|
||||
METHODS summary_totals FOR TESTING.
|
||||
METHODS remove_tour_works FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{P}}T07_HIDDEN IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{P}}TOUR_PLANNER( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD add_stop.
|
||||
DATA(lv_status) = mo_cut->add_item( iv_tour_id = iv_tour_id
|
||||
iv_stop_no = iv_stop_no
|
||||
iv_customer = iv_customer
|
||||
iv_packages = iv_packages
|
||||
iv_weight = iv_weight ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-ok
|
||||
act = lv_status
|
||||
msg = `add_item must store a valid stop` ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD assert_item.
|
||||
cl_abap_unit_assert=>assert_equals( exp = is_exp-tour_id act = is_act-tour_id msg = iv_msg ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = is_exp-stop_no act = is_act-stop_no msg = iv_msg ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = is_exp-customer act = is_act-customer msg = iv_msg ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = is_exp-packages act = is_act-packages msg = iv_msg ).
|
||||
assert_weight( iv_exp = is_exp-weight iv_act = is_act-weight iv_msg = iv_msg ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD assert_weight.
|
||||
cl_abap_unit_assert=>assert_equals( exp = iv_exp act = iv_act msg = iv_msg ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD add_one_item.
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 3
|
||||
iv_weight = '12.50' ).
|
||||
|
||||
DATA(lt_item) = mo_cut->items( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_item ) ).
|
||||
assert_item( is_exp = VALUE #( tour_id = 'T001'
|
||||
stop_no = 1
|
||||
customer = 'CUST01'
|
||||
packages = 3
|
||||
weight = '12.50' )
|
||||
is_act = lt_item[ 1 ]
|
||||
iv_msg = `one stored stop` ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD items_are_sorted.
|
||||
add_stop( iv_tour_id = 'T002'
|
||||
iv_stop_no = 2
|
||||
iv_customer = 'CUST02'
|
||||
iv_packages = 1
|
||||
iv_weight = '5.00' ).
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 3
|
||||
iv_customer = 'CUST03'
|
||||
iv_packages = 2
|
||||
iv_weight = '6.00' ).
|
||||
add_stop( iv_tour_id = 'T002'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST04'
|
||||
iv_packages = 4
|
||||
iv_weight = '7.00' ).
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST05'
|
||||
iv_packages = 5
|
||||
iv_weight = '8.00' ).
|
||||
|
||||
DATA(lt_item) = mo_cut->items( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 4 act = lines( lt_item ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'T001' act = lt_item[ 1 ]-tour_id msg = `row 1 tour` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lt_item[ 1 ]-stop_no msg = `row 1 stop` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'T001' act = lt_item[ 2 ]-tour_id msg = `row 2 tour` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 3 act = lt_item[ 2 ]-stop_no msg = `row 2 stop` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'T002' act = lt_item[ 3 ]-tour_id msg = `row 3 tour` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lt_item[ 3 ]-stop_no msg = `row 3 stop` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'T002' act = lt_item[ 4 ]-tour_id msg = `row 4 tour` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lt_item[ 4 ]-stop_no msg = `row 4 stop` ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD duplicate_is_rejected.
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 3
|
||||
iv_weight = '12.50' ).
|
||||
|
||||
DATA(lv_status) = mo_cut->add_item( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST99'
|
||||
iv_packages = 9
|
||||
iv_weight = '99.00' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-duplicate act = lv_status ).
|
||||
|
||||
DATA(lt_item) = mo_cut->items( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_item ) ).
|
||||
assert_item( is_exp = VALUE #( tour_id = 'T001'
|
||||
stop_no = 1
|
||||
customer = 'CUST01'
|
||||
packages = 3
|
||||
weight = '12.50' )
|
||||
is_act = lt_item[ 1 ]
|
||||
iv_msg = `stored stop keeps its values` ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD empty_tour_id_is_invalid.
|
||||
DATA(lv_status) = mo_cut->add_item( iv_tour_id = ''
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 1
|
||||
iv_weight = '1.00' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-invalid act = lv_status ).
|
||||
|
||||
DATA(lt_item) = mo_cut->items( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_item ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD bad_stop_no_is_invalid.
|
||||
DATA(lv_status) = mo_cut->add_item( iv_tour_id = 'T001'
|
||||
iv_stop_no = 0
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 1
|
||||
iv_weight = '1.00' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-invalid act = lv_status ).
|
||||
|
||||
lv_status = mo_cut->add_item( iv_tour_id = 'T001'
|
||||
iv_stop_no = -1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 1
|
||||
iv_weight = '1.00' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-invalid act = lv_status ).
|
||||
|
||||
DATA(lt_item) = mo_cut->items( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_item ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD negative_values_are_invalid.
|
||||
DATA(lv_status) = mo_cut->add_item( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = -1
|
||||
iv_weight = '1.00' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-invalid act = lv_status ).
|
||||
|
||||
lv_status = mo_cut->add_item( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 1
|
||||
iv_weight = '-1.00' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-invalid act = lv_status ).
|
||||
|
||||
DATA(lt_item) = mo_cut->items( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_item ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_values_are_valid.
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = ''
|
||||
iv_packages = 0
|
||||
iv_weight = '0.00' ).
|
||||
|
||||
DATA(lt_item) = mo_cut->items( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_item ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lt_item[ 1 ]-packages ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD stops_of_tour_are_sorted.
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 2
|
||||
iv_customer = 'CUST02'
|
||||
iv_packages = 1
|
||||
iv_weight = '5.00' ).
|
||||
add_stop( iv_tour_id = 'T002'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST03'
|
||||
iv_packages = 2
|
||||
iv_weight = '6.00' ).
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST04'
|
||||
iv_packages = 4
|
||||
iv_weight = '7.00' ).
|
||||
|
||||
DATA(lt_item) = mo_cut->stops_of_tour( 'T001' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_item ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lt_item[ 1 ]-stop_no ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'CUST04' act = lt_item[ 1 ]-customer ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lt_item[ 2 ]-stop_no ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_tour_has_no_stops.
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 1
|
||||
iv_weight = '1.00' ).
|
||||
|
||||
DATA(lt_item) = mo_cut->stops_of_tour( 'T999' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_item ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD find_stop_works.
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 3
|
||||
iv_weight = '12.50' ).
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 2
|
||||
iv_customer = 'CUST02'
|
||||
iv_packages = 4
|
||||
iv_weight = '13.50' ).
|
||||
|
||||
assert_item( is_exp = VALUE #( tour_id = 'T001'
|
||||
stop_no = 2
|
||||
customer = 'CUST02'
|
||||
packages = 4
|
||||
weight = '13.50' )
|
||||
is_act = mo_cut->find_stop( iv_tour_id = 'T001' iv_stop_no = 2 )
|
||||
iv_msg = `known stop` ).
|
||||
|
||||
DATA(ls_missing) = mo_cut->find_stop( iv_tour_id = 'T001' iv_stop_no = 9 ).
|
||||
cl_abap_unit_assert=>assert_initial( act = ls_missing-tour_id ).
|
||||
cl_abap_unit_assert=>assert_initial( act = ls_missing-stop_no ).
|
||||
cl_abap_unit_assert=>assert_initial( act = ls_missing-customer ).
|
||||
cl_abap_unit_assert=>assert_initial( act = ls_missing-packages ).
|
||||
cl_abap_unit_assert=>assert_initial( act = ls_missing-weight ).
|
||||
|
||||
ls_missing = mo_cut->find_stop( iv_tour_id = 'T999' iv_stop_no = 1 ).
|
||||
cl_abap_unit_assert=>assert_initial( act = ls_missing-tour_id ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD summary_totals.
|
||||
add_stop( iv_tour_id = 'T002'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 2
|
||||
iv_weight = '10.25' ).
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST02'
|
||||
iv_packages = 3
|
||||
iv_weight = '20.50' ).
|
||||
add_stop( iv_tour_id = 'T002'
|
||||
iv_stop_no = 2
|
||||
iv_customer = 'CUST03'
|
||||
iv_packages = 4
|
||||
iv_weight = '30.75' ).
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 2
|
||||
iv_customer = 'CUST04'
|
||||
iv_packages = 5
|
||||
iv_weight = '40.25' ).
|
||||
|
||||
DATA(lt_tour) = mo_cut->tour_summary( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_tour ) ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'T001' act = lt_tour[ 1 ]-tour_id ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lt_tour[ 1 ]-stops ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 8 act = lt_tour[ 1 ]-packages ).
|
||||
assert_weight( iv_exp = '60.75' iv_act = lt_tour[ 1 ]-weight iv_msg = `T001 weight` ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'T002' act = lt_tour[ 2 ]-tour_id ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lt_tour[ 2 ]-stops ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 6 act = lt_tour[ 2 ]-packages ).
|
||||
assert_weight( iv_exp = '41.00' iv_act = lt_tour[ 2 ]-weight iv_msg = `T002 weight` ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD remove_tour_works.
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 1
|
||||
iv_weight = '1.00' ).
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 2
|
||||
iv_customer = 'CUST02'
|
||||
iv_packages = 2
|
||||
iv_weight = '2.00' ).
|
||||
add_stop( iv_tour_id = 'T002'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST03'
|
||||
iv_packages = 3
|
||||
iv_weight = '3.00' ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = mo_cut->remove_tour( 'T001' ) ).
|
||||
|
||||
DATA(lt_item) = mo_cut->items( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_item ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'T002' act = lt_item[ 1 ]-tour_id ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = mo_cut->remove_tour( 'T001' ) ).
|
||||
|
||||
DATA(lt_tour) = mo_cut->tour_summary( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_tour ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'T002' act = lt_tour[ 1 ]-tour_id ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
143
tasks_gen/eval/G0001/reference/tour_planner.clas.abap
Normal file
143
tasks_gen/eval/G0001/reference/tour_planner.clas.abap
Normal file
@@ -0,0 +1,143 @@
|
||||
CLASS {{P}}TOUR_PLANNER DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES ty_status TYPE c LENGTH 10.
|
||||
TYPES ty_tour_id TYPE c LENGTH 4.
|
||||
TYPES ty_customer TYPE c LENGTH 10.
|
||||
TYPES ty_weight TYPE p LENGTH 8 DECIMALS 2.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_status,
|
||||
ok TYPE ty_status VALUE 'OK',
|
||||
invalid TYPE ty_status VALUE 'INVALID',
|
||||
duplicate TYPE ty_status VALUE 'DUPLICATE',
|
||||
END OF c_status.
|
||||
|
||||
TYPES:
|
||||
BEGIN OF ty_item,
|
||||
tour_id TYPE ty_tour_id,
|
||||
stop_no TYPE i,
|
||||
customer TYPE ty_customer,
|
||||
packages TYPE i,
|
||||
weight TYPE ty_weight,
|
||||
END OF ty_item,
|
||||
tt_item TYPE STANDARD TABLE OF ty_item WITH EMPTY KEY,
|
||||
|
||||
BEGIN OF ty_tour,
|
||||
tour_id TYPE ty_tour_id,
|
||||
stops TYPE i,
|
||||
packages TYPE i,
|
||||
weight TYPE ty_weight,
|
||||
END OF ty_tour,
|
||||
tt_tour TYPE STANDARD TABLE OF ty_tour WITH EMPTY KEY.
|
||||
|
||||
METHODS add_item
|
||||
IMPORTING iv_tour_id TYPE ty_tour_id
|
||||
iv_stop_no TYPE i
|
||||
iv_customer TYPE ty_customer
|
||||
iv_packages TYPE i
|
||||
iv_weight TYPE ty_weight
|
||||
RETURNING VALUE(rv_status) TYPE ty_status.
|
||||
|
||||
METHODS remove_tour
|
||||
IMPORTING iv_tour_id TYPE ty_tour_id
|
||||
RETURNING VALUE(rv_count) TYPE i.
|
||||
|
||||
METHODS items
|
||||
RETURNING VALUE(rt_item) TYPE tt_item.
|
||||
|
||||
METHODS stops_of_tour
|
||||
IMPORTING iv_tour_id TYPE ty_tour_id
|
||||
RETURNING VALUE(rt_item) TYPE tt_item.
|
||||
|
||||
METHODS find_stop
|
||||
IMPORTING iv_tour_id TYPE ty_tour_id
|
||||
iv_stop_no TYPE i
|
||||
RETURNING VALUE(rs_item) TYPE ty_item.
|
||||
|
||||
METHODS tour_summary
|
||||
RETURNING VALUE(rt_tour) TYPE tt_tour.
|
||||
|
||||
PRIVATE SECTION.
|
||||
TYPES tt_stop TYPE SORTED TABLE OF ty_item WITH UNIQUE KEY tour_id stop_no.
|
||||
|
||||
DATA mt_stop TYPE tt_stop.
|
||||
|
||||
METHODS is_invalid
|
||||
IMPORTING iv_tour_id TYPE ty_tour_id
|
||||
iv_stop_no TYPE i
|
||||
iv_packages TYPE i
|
||||
iv_weight TYPE ty_weight
|
||||
RETURNING VALUE(rv_invalid) TYPE abap_bool.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{P}}TOUR_PLANNER IMPLEMENTATION.
|
||||
METHOD add_item.
|
||||
IF is_invalid( iv_tour_id = iv_tour_id
|
||||
iv_stop_no = iv_stop_no
|
||||
iv_packages = iv_packages
|
||||
iv_weight = iv_weight ) = abap_true.
|
||||
rv_status = c_status-invalid.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
DATA(ls_stop) = VALUE ty_item( tour_id = iv_tour_id
|
||||
stop_no = iv_stop_no
|
||||
customer = iv_customer
|
||||
packages = iv_packages
|
||||
weight = iv_weight ).
|
||||
INSERT ls_stop INTO TABLE mt_stop.
|
||||
|
||||
IF sy-subrc <> 0.
|
||||
rv_status = c_status-duplicate.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
rv_status = c_status-ok.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD remove_tour.
|
||||
DELETE mt_stop WHERE tour_id = iv_tour_id.
|
||||
rv_count = sy-dbcnt.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD items.
|
||||
rt_item = mt_stop.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD stops_of_tour.
|
||||
rt_item = VALUE #( FOR ls_stop IN mt_stop WHERE ( tour_id = iv_tour_id ) ( ls_stop ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD find_stop.
|
||||
READ TABLE mt_stop WITH KEY tour_id = iv_tour_id
|
||||
stop_no = iv_stop_no INTO rs_item.
|
||||
IF sy-subrc <> 0.
|
||||
CLEAR rs_item.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD tour_summary.
|
||||
DATA lt_tour TYPE SORTED TABLE OF ty_tour WITH UNIQUE KEY tour_id.
|
||||
|
||||
LOOP AT mt_stop INTO DATA(ls_stop).
|
||||
READ TABLE lt_tour WITH KEY tour_id = ls_stop-tour_id ASSIGNING FIELD-SYMBOL(<ls_tour>).
|
||||
IF sy-subrc <> 0.
|
||||
INSERT VALUE ty_tour( tour_id = ls_stop-tour_id )
|
||||
INTO TABLE lt_tour ASSIGNING <ls_tour>.
|
||||
ENDIF.
|
||||
<ls_tour>-stops = <ls_tour>-stops + 1.
|
||||
<ls_tour>-packages = <ls_tour>-packages + ls_stop-packages.
|
||||
<ls_tour>-weight = <ls_tour>-weight + ls_stop-weight.
|
||||
ENDLOOP.
|
||||
|
||||
rt_tour = lt_tour.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD is_invalid.
|
||||
rv_invalid = xsdbool( iv_tour_id IS INITIAL
|
||||
OR iv_stop_no < 1
|
||||
OR iv_packages < 0
|
||||
OR iv_weight < 0 ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
93
tasks_gen/eval/G0001/reference/tour_planner.testclasses.abap
Normal file
93
tasks_gen/eval/G0001/reference/tour_planner.testclasses.abap
Normal file
@@ -0,0 +1,93 @@
|
||||
CLASS ltc_tour_planner DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{P}}TOUR_PLANNER.
|
||||
METHODS setup.
|
||||
METHODS add_and_read_item FOR TESTING.
|
||||
METHODS duplicate_is_rejected FOR TESTING.
|
||||
METHODS invalid_input_is_rejected FOR TESTING.
|
||||
METHODS summary_totals FOR TESTING.
|
||||
METHODS remove_tour_works FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_tour_planner IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{P}}TOUR_PLANNER( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD add_and_read_item.
|
||||
DATA(lv_status) = mo_cut->add_item( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 3
|
||||
iv_weight = '12.50' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-ok act = lv_status ).
|
||||
|
||||
DATA(lt_item) = mo_cut->items( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_item ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'CUST01' act = lt_item[ 1 ]-customer ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD duplicate_is_rejected.
|
||||
DATA(lv_status) = mo_cut->add_item( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 3
|
||||
iv_weight = '12.50' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-ok act = lv_status ).
|
||||
|
||||
lv_status = mo_cut->add_item( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST02'
|
||||
iv_packages = 1
|
||||
iv_weight = '1.00' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-duplicate act = lv_status ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_input_is_rejected.
|
||||
DATA(lv_status) = mo_cut->add_item( iv_tour_id = ''
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 1
|
||||
iv_weight = '1.00' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-invalid act = lv_status ).
|
||||
|
||||
DATA(lt_item) = mo_cut->items( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_item ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD summary_totals.
|
||||
DATA(lv_status) = mo_cut->add_item( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 2
|
||||
iv_weight = '10.00' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-ok act = lv_status ).
|
||||
|
||||
lv_status = mo_cut->add_item( iv_tour_id = 'T001'
|
||||
iv_stop_no = 2
|
||||
iv_customer = 'CUST02'
|
||||
iv_packages = 3
|
||||
iv_weight = '20.00' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-ok act = lv_status ).
|
||||
|
||||
DATA(lt_tour) = mo_cut->tour_summary( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_tour ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lt_tour[ 1 ]-stops ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 5 act = lt_tour[ 1 ]-packages ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD remove_tour_works.
|
||||
DATA(lv_status) = mo_cut->add_item( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 1
|
||||
iv_weight = '1.00' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-ok act = lv_status ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = mo_cut->remove_tour( 'T001' ) ).
|
||||
|
||||
DATA(lt_item) = mo_cut->items( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_item ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
55
tasks_gen/eval/G0001/seed/if_tour_planner.intf.abap
Normal file
55
tasks_gen/eval/G0001/seed/if_tour_planner.intf.abap
Normal file
@@ -0,0 +1,55 @@
|
||||
INTERFACE {{p}}if_tour_planner PUBLIC.
|
||||
TYPES ty_status TYPE c LENGTH 10.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_status,
|
||||
ok TYPE ty_status VALUE 'OK',
|
||||
invalid TYPE ty_status VALUE 'INVALID',
|
||||
duplicate TYPE ty_status VALUE 'DUPLICATE',
|
||||
END OF c_status.
|
||||
|
||||
TYPES:
|
||||
BEGIN OF ty_item,
|
||||
tour_id TYPE c LENGTH 4,
|
||||
stop_no TYPE i,
|
||||
customer TYPE c LENGTH 10,
|
||||
packages TYPE i,
|
||||
weight TYPE p LENGTH 8 DECIMALS 2,
|
||||
END OF ty_item,
|
||||
tt_item TYPE STANDARD TABLE OF ty_item WITH EMPTY KEY,
|
||||
|
||||
BEGIN OF ty_tour,
|
||||
tour_id TYPE c LENGTH 4,
|
||||
stops TYPE i,
|
||||
packages TYPE i,
|
||||
weight TYPE p LENGTH 8 DECIMALS 2,
|
||||
END OF ty_tour,
|
||||
tt_tour TYPE STANDARD TABLE OF ty_tour WITH EMPTY KEY.
|
||||
|
||||
METHODS add_item
|
||||
IMPORTING iv_tour_id TYPE c LENGTH 4
|
||||
iv_stop_no TYPE i
|
||||
iv_customer TYPE c LENGTH 10
|
||||
iv_packages TYPE i
|
||||
iv_weight TYPE p LENGTH 8 DECIMALS 2
|
||||
RETURNING VALUE(rv_status) TYPE ty_status.
|
||||
|
||||
METHODS remove_tour
|
||||
IMPORTING iv_tour_id TYPE c LENGTH 4
|
||||
RETURNING VALUE(rv_count) TYPE i.
|
||||
|
||||
METHODS items
|
||||
RETURNING VALUE(rt_item) TYPE tt_item.
|
||||
|
||||
METHODS stops_of_tour
|
||||
IMPORTING iv_tour_id TYPE c LENGTH 4
|
||||
RETURNING VALUE(rt_item) TYPE tt_item.
|
||||
|
||||
METHODS find_stop
|
||||
IMPORTING iv_tour_id TYPE c LENGTH 4
|
||||
iv_stop_no TYPE i
|
||||
RETURNING VALUE(rs_item) TYPE ty_item.
|
||||
|
||||
METHODS tour_summary
|
||||
RETURNING VALUE(rt_tour) TYPE tt_tour.
|
||||
ENDINTERFACE.
|
||||
118
tasks_gen/eval/G0001/spec.md
Normal file
118
tasks_gen/eval/G0001/spec.md
Normal file
@@ -0,0 +1,118 @@
|
||||
# 1. Goal
|
||||
A transportation planner collects the stops of delivery tours. The planner needs one
|
||||
class that stores the stops and reports the load of each tour.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- The class {{P}}TOUR_PLANNER is new. Create it in package $TMP.
|
||||
- A tour ID has 4 characters, for example T001. A stop number is a whole number.
|
||||
A customer number has 10 characters. The weight is in kilograms with 2 decimal
|
||||
places.
|
||||
- No other object of this task exists.
|
||||
|
||||
# 4. Contract
|
||||
- Create the class {{P}}TOUR_PLANNER in package $TMP.
|
||||
- The class is public, final, and has a public constructor without parameters.
|
||||
- The class has these public elementary types:
|
||||
|
||||
TYPES ty_status TYPE c LENGTH 10.
|
||||
TYPES ty_tour_id TYPE c LENGTH 4.
|
||||
TYPES ty_customer TYPE c LENGTH 10.
|
||||
TYPES ty_weight TYPE p LENGTH 8 DECIMALS 2.
|
||||
|
||||
- The class has this public constant structure:
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_status,
|
||||
ok TYPE ty_status VALUE 'OK',
|
||||
invalid TYPE ty_status VALUE 'INVALID',
|
||||
duplicate TYPE ty_status VALUE 'DUPLICATE',
|
||||
END OF c_status.
|
||||
|
||||
- The class has these public structured types:
|
||||
|
||||
TYPES:
|
||||
BEGIN OF ty_item,
|
||||
tour_id TYPE ty_tour_id,
|
||||
stop_no TYPE i,
|
||||
customer TYPE ty_customer,
|
||||
packages TYPE i,
|
||||
weight TYPE ty_weight,
|
||||
END OF ty_item,
|
||||
tt_item TYPE STANDARD TABLE OF ty_item WITH EMPTY KEY,
|
||||
|
||||
BEGIN OF ty_tour,
|
||||
tour_id TYPE ty_tour_id,
|
||||
stops TYPE i,
|
||||
packages TYPE i,
|
||||
weight TYPE ty_weight,
|
||||
END OF ty_tour,
|
||||
tt_tour TYPE STANDARD TABLE OF ty_tour WITH EMPTY KEY.
|
||||
|
||||
- The class has these public methods:
|
||||
|
||||
METHODS add_item
|
||||
IMPORTING iv_tour_id TYPE ty_tour_id
|
||||
iv_stop_no TYPE i
|
||||
iv_customer TYPE ty_customer
|
||||
iv_packages TYPE i
|
||||
iv_weight TYPE ty_weight
|
||||
RETURNING VALUE(rv_status) TYPE ty_status.
|
||||
|
||||
METHODS remove_tour
|
||||
IMPORTING iv_tour_id TYPE ty_tour_id
|
||||
RETURNING VALUE(rv_count) TYPE i.
|
||||
|
||||
METHODS items
|
||||
RETURNING VALUE(rt_item) TYPE tt_item.
|
||||
|
||||
METHODS stops_of_tour
|
||||
IMPORTING iv_tour_id TYPE ty_tour_id
|
||||
RETURNING VALUE(rt_item) TYPE tt_item.
|
||||
|
||||
METHODS find_stop
|
||||
IMPORTING iv_tour_id TYPE ty_tour_id
|
||||
iv_stop_no TYPE i
|
||||
RETURNING VALUE(rs_item) TYPE ty_item.
|
||||
|
||||
METHODS tour_summary
|
||||
RETURNING VALUE(rt_tour) TYPE tt_tour.
|
||||
|
||||
- Do not add other public methods.
|
||||
|
||||
# 5. Business rules
|
||||
1. The tour ID and the stop number identify a stop.
|
||||
2. ADD_ITEM stores one stop. It returns INVALID and changes no data if one of these
|
||||
conditions is true:
|
||||
- IV_TOUR_ID is empty,
|
||||
- IV_STOP_NO is smaller than 1,
|
||||
- IV_PACKAGES is smaller than 0,
|
||||
- IV_WEIGHT is smaller than 0.
|
||||
IV_CUSTOMER can be empty.
|
||||
3. ADD_ITEM returns DUPLICATE and changes no data if a stop with the same tour ID and
|
||||
the same stop number is already stored. The stored stop keeps its values.
|
||||
4. Otherwise ADD_ITEM stores the stop and returns OK.
|
||||
5. ITEMS returns all stored stops, sorted by tour ID ascending and, for the same tour
|
||||
ID, by stop number ascending.
|
||||
6. STOPS_OF_TOUR returns the stops of one tour, sorted by stop number ascending. The
|
||||
result is empty if the tour is not known.
|
||||
7. FIND_STOP returns the stop with the given tour ID and stop number. If the stop is
|
||||
not known, all components of the result are initial.
|
||||
8. TOUR_SUMMARY returns one line for each tour that has at least one stop. A line
|
||||
contains the tour ID, the number of stops, the sum of the packages and the sum of
|
||||
the weight. The result is sorted by tour ID ascending.
|
||||
9. REMOVE_TOUR deletes all stops of the tour and returns the number of deleted stops.
|
||||
It returns 0 if the tour is not known.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: 7.58.
|
||||
- Coding standards: Clean ABAP. Method length below 40 statements. No global variables.
|
||||
No comment that restates the code.
|
||||
- Out of scope: do not change objects that are not part of this task.
|
||||
|
||||
# 7. Acceptance
|
||||
- The class is active and has no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write your own ABAP Unit tests for the class.
|
||||
41
tasks_gen/eval/G0001/task.json
Normal file
41
tasks_gen/eval/G0001/task.json
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"id": "G0001",
|
||||
"category": "C",
|
||||
"object_type": "CLAS",
|
||||
"difficulty": 2,
|
||||
"release_target": "v758",
|
||||
"expected_outcome": "implement",
|
||||
"budget": {
|
||||
"max_tool_calls": 60,
|
||||
"max_activations": 15
|
||||
},
|
||||
"seed": [],
|
||||
"contract": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}TOUR_PLANNER"
|
||||
}
|
||||
],
|
||||
"out_of_scope": [],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}T07_HIDDEN",
|
||||
"file": "hidden/t07_hidden.clas.abap",
|
||||
"description": "T07 hidden tests for the tour planner"
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}TOUR_PLANNER",
|
||||
"file": "reference/tour_planner.clas.abap",
|
||||
"description": "Tour planner with stored stops and tour summary",
|
||||
"testclasses_file": "reference/tour_planner.testclasses.abap"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length",
|
||||
"db_operation_in_loop"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user