Snapshot: new training tasks (balanced generation), docs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
43
tasks_gen/train/G1935/generation.json
Normal file
43
tasks_gen/train/G1935/generation.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"id": "G1935",
|
||||
"pool": "train",
|
||||
"object_type": "INTF",
|
||||
"category": "A",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "bundle",
|
||||
"errors": [
|
||||
"hidden/t02_hidden.clas.abap line 45: syntax error for release v758 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"cl_abap_unit_assert\"",
|
||||
"Too close to task G1125 (similarity spec 0.51, rules 0.62, names 0.00). Choose a different business topic and different object names."
|
||||
],
|
||||
"by_check": {
|
||||
"abaplint": 1,
|
||||
"extra": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"stage": "bundle",
|
||||
"errors": [
|
||||
"reference/if_concrete_mix.intf.abap line 91: syntax error for release v758 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"DATA\""
|
||||
],
|
||||
"by_check": {
|
||||
"abaplint": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "bundle",
|
||||
"errors": [
|
||||
"reference/mix_calc.clas.abap line 49: syntax error for release v758 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"ASSIGN\""
|
||||
],
|
||||
"by_check": {
|
||||
"abaplint": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"accepted": false
|
||||
}
|
||||
241
tasks_gen/train/G1935/hidden/t02_hidden.clas.abap
Normal file
241
tasks_gen/train/G1935/hidden/t02_hidden.clas.abap
Normal file
@@ -0,0 +1,241 @@
|
||||
CLASS {{p}}t02_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}if_mix_recipe.
|
||||
METHODS setup.
|
||||
METHODS constants_are_fixed FOR TESTING.
|
||||
METHODS type_lengths_are_fixed FOR TESTING.
|
||||
METHODS check_accepts_order FOR TESTING.
|
||||
METHODS check_rejects_grade FOR TESTING.
|
||||
METHODS check_rejects_volume FOR TESTING.
|
||||
METHODS check_grade_before_volume FOR TESTING.
|
||||
METHODS mix_without_surcharge FOR TESTING.
|
||||
METHODS mix_with_surcharge FOR TESTING.
|
||||
METHODS mix_at_min_volume FOR TESTING.
|
||||
METHODS mix_grade_is_upper FOR TESTING.
|
||||
METHODS mix_of_invalid_order FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS ltc_mix DEFINITION FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_mix_recipe.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS ltc_mix IMPLEMENTATION.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t02_hidden IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW ltc_mix( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD constants_are_fixed.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_grade( 'C20' )
|
||||
act = {{p}}if_mix_recipe=>c_grade-c20 ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_grade( 'C25' )
|
||||
act = {{p}}if_mix_recipe=>c_grade-c25 ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_grade( 'C30' )
|
||||
act = {{p}}if_mix_recipe=>c_grade-c30 ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_grade( 'C35' )
|
||||
act = {{p}}if_mix_recipe=>c_grade-c35 ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_status( 'OK' )
|
||||
act = {{p}}if_mix_recipe=>c_status-ok ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_status( 'GRADE' )
|
||||
act = {{p}}if_mix_recipe=>c_status-grade ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_status( 'VOLUME' )
|
||||
act = {{p}}if_mix_recipe=>c_status-volume ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD type_lengths_are_fixed.
|
||||
DATA(lo_grade) = cl_abap_typedescr=>describe_by_name( '{{P}}IF_MIX_RECIPE=>TY_GRADE' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 4 act = lo_grade->length ).
|
||||
DATA(lo_status) = cl_abap_typedescr=>describe_by_name( '{{P}}IF_MIX_RECIPE=>TY_STATUS' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 10 act = lo_status->length ).
|
||||
DATA(lo_qty) = cl_abap_typedescr=>describe_by_name( '{{P}}IF_MIX_RECIPE=>TY_QTY' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 8 act = lo_qty->length ).
|
||||
DATA(lo_elem) = CAST cl_abap_elemdescr( lo_qty ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lo_elem->decimals ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_accepts_order.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_mix_recipe=>c_status-ok
|
||||
act = mo_cut->check_order( iv_grade = 'C20' iv_volume = '2.50' ) ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_mix_recipe=>c_status-ok
|
||||
act = mo_cut->check_order( iv_grade = 'c35' iv_volume = '20.00' ) ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_mix_recipe=>c_status-ok
|
||||
act = mo_cut->check_order( iv_grade = 'C30' iv_volume = '0.50' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_rejects_grade.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_mix_recipe=>c_status-grade
|
||||
act = mo_cut->check_order( iv_grade = 'C40' iv_volume = '5.00' ) ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_mix_recipe=>c_status-grade
|
||||
act = mo_cut->check_order( iv_grade = ' ' iv_volume = '5.00' ) ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_mix_recipe=>c_status-grade
|
||||
act = mo_cut->check_order( iv_grade = 'C2' iv_volume = '5.00' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_rejects_volume.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_mix_recipe=>c_status-volume
|
||||
act = mo_cut->check_order( iv_grade = 'C20' iv_volume = '0.49' ) ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_mix_recipe=>c_status-volume
|
||||
act = mo_cut->check_order( iv_grade = 'C20' iv_volume = '20.01' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_grade_before_volume.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_mix_recipe=>c_status-grade
|
||||
act = mo_cut->check_order( iv_grade = 'C40' iv_volume = '0.10' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD mix_without_surcharge.
|
||||
DATA(ls_mix) = mo_cut->mix_for( iv_grade = 'C20' iv_volume = '2.50' ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '700.00' )
|
||||
act = ls_mix-cement_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '1800.00' )
|
||||
act = ls_mix-sand_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '2950.00' )
|
||||
act = ls_mix-gravel_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '438.00' )
|
||||
act = ls_mix-water_l ).
|
||||
|
||||
DATA(ls_large) = mo_cut->mix_for( iv_grade = 'C30' iv_volume = '5.00' ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '1800.00' )
|
||||
act = ls_large-cement_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '3400.00' )
|
||||
act = ls_large-sand_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '5700.00' )
|
||||
act = ls_large-gravel_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '850.00' )
|
||||
act = ls_large-water_l ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD mix_with_surcharge.
|
||||
DATA(ls_small) = mo_cut->mix_for( iv_grade = 'C25' iv_volume = '1.30' ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '458.00' )
|
||||
act = ls_small-cement_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '1001.00' )
|
||||
act = ls_small-sand_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '1659.00' )
|
||||
act = ls_small-gravel_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '251.00' )
|
||||
act = ls_small-water_l ).
|
||||
|
||||
DATA(ls_tiny) = mo_cut->mix_for( iv_grade = 'C35' iv_volume = '0.80' ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '352.00' )
|
||||
act = ls_tiny-cement_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '581.00' )
|
||||
act = ls_tiny-sand_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '986.00' )
|
||||
act = ls_tiny-gravel_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '146.00' )
|
||||
act = ls_tiny-water_l ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD mix_at_min_volume.
|
||||
DATA(ls_min) = mo_cut->mix_for( iv_grade = 'C25' iv_volume = '0.50' ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '176.00' )
|
||||
act = ls_min-cement_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '385.00' )
|
||||
act = ls_min-sand_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '638.00' )
|
||||
act = ls_min-gravel_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '97.00' )
|
||||
act = ls_min-water_l ).
|
||||
|
||||
DATA(ls_limit) = mo_cut->mix_for( iv_grade = 'C20' iv_volume = '2.00' ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '560.00' )
|
||||
act = ls_limit-cement_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '1440.00' )
|
||||
act = ls_limit-sand_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '2360.00' )
|
||||
act = ls_limit-gravel_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '350.00' )
|
||||
act = ls_limit-water_l ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD mix_grade_is_upper.
|
||||
DATA(ls_mix) = mo_cut->mix_for( iv_grade = 'c35' iv_volume = '5.00' ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_mix_recipe=>c_grade-c35
|
||||
act = ls_mix-grade ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '2000.00' )
|
||||
act = ls_mix-cement_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '3300.00' )
|
||||
act = ls_mix-sand_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '5600.00' )
|
||||
act = ls_mix-gravel_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '825.00' )
|
||||
act = ls_mix-water_l ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD mix_of_invalid_order.
|
||||
DATA(ls_bad_grade) = mo_cut->mix_for( iv_grade = 'C40' iv_volume = '5.00' ).
|
||||
cl_abap_unit_assert=>assert_initial( act = ls_bad_grade-grade ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '0.00' )
|
||||
act = ls_bad_grade-cement_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '0.00' )
|
||||
act = ls_bad_grade-sand_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '0.00' )
|
||||
act = ls_bad_grade-gravel_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '0.00' )
|
||||
act = ls_bad_grade-water_l ).
|
||||
|
||||
DATA(ls_bad_volume) = mo_cut->mix_for( iv_grade = 'C20' iv_volume = '0.10' ).
|
||||
cl_abap_unit_assert=>assert_initial( act = ls_bad_volume-grade ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '0.00' )
|
||||
act = ls_bad_volume-cement_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '0.00' )
|
||||
act = ls_bad_volume-water_l ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
107
tasks_gen/train/G1935/reference/if_mix_recipe.intf.abap
Normal file
107
tasks_gen/train/G1935/reference/if_mix_recipe.intf.abap
Normal file
@@ -0,0 +1,107 @@
|
||||
INTERFACE {{p}}if_mix_recipe PUBLIC.
|
||||
TYPES ty_grade TYPE c LENGTH 4.
|
||||
TYPES ty_qty TYPE p LENGTH 8 DECIMALS 2.
|
||||
TYPES ty_status TYPE c LENGTH 10.
|
||||
TYPES:
|
||||
BEGIN OF ty_mix,
|
||||
grade TYPE ty_grade,
|
||||
cement_kg TYPE ty_qty,
|
||||
sand_kg TYPE ty_qty,
|
||||
gravel_kg TYPE ty_qty,
|
||||
water_l TYPE ty_qty,
|
||||
END OF ty_mix.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_grade,
|
||||
c20 TYPE ty_grade VALUE 'C20',
|
||||
c25 TYPE ty_grade VALUE 'C25',
|
||||
c30 TYPE ty_grade VALUE 'C30',
|
||||
c35 TYPE ty_grade VALUE 'C35',
|
||||
END OF c_grade,
|
||||
BEGIN OF c_status,
|
||||
ok TYPE ty_status VALUE 'OK',
|
||||
grade TYPE ty_status VALUE 'GRADE',
|
||||
volume TYPE ty_status VALUE 'VOLUME',
|
||||
END OF c_status.
|
||||
|
||||
METHODS check_order
|
||||
IMPORTING iv_grade TYPE ty_grade
|
||||
iv_volume TYPE ty_qty
|
||||
RETURNING VALUE(rv_status) TYPE ty_status.
|
||||
|
||||
METHODS mix_for
|
||||
IMPORTING iv_grade TYPE ty_grade
|
||||
iv_volume TYPE ty_qty
|
||||
RETURNING VALUE(rs_mix) TYPE ty_mix.
|
||||
ENDINTERFACE.
|
||||
|
||||
|
||||
INTERFACE {{p}}if_mix_recipe.
|
||||
METHOD check_order.
|
||||
DATA lv_grade TYPE ty_grade.
|
||||
lv_grade = to_upper( iv_grade ).
|
||||
IF lv_grade <> c_grade-c20
|
||||
AND lv_grade <> c_grade-c25
|
||||
AND lv_grade <> c_grade-c30
|
||||
AND lv_grade <> c_grade-c35.
|
||||
rv_status = c_status-grade.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_volume < '0.50' OR iv_volume > '20.00'.
|
||||
rv_status = c_status-volume.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_status = c_status-ok.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD mix_for.
|
||||
IF check_order( iv_grade = iv_grade iv_volume = iv_volume ) <> c_status-ok.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
DATA lv_grade TYPE ty_grade.
|
||||
lv_grade = to_upper( iv_grade ).
|
||||
|
||||
DATA lv_cement TYPE ty_qty.
|
||||
DATA lv_sand TYPE ty_qty.
|
||||
DATA lv_gravel TYPE ty_qty.
|
||||
DATA lv_water TYPE ty_qty.
|
||||
|
||||
CASE lv_grade.
|
||||
WHEN c_grade-c20.
|
||||
lv_cement = '280.00'.
|
||||
lv_sand = '720.00'.
|
||||
lv_gravel = '1180.00'.
|
||||
lv_water = '175.00'.
|
||||
WHEN c_grade-c25.
|
||||
lv_cement = '320.00'.
|
||||
lv_sand = '700.00'.
|
||||
lv_gravel = '1160.00'.
|
||||
lv_water = '175.00'.
|
||||
WHEN c_grade-c30.
|
||||
lv_cement = '360.00'.
|
||||
lv_sand = '680.00'.
|
||||
lv_gravel = '1140.00'.
|
||||
lv_water = '170.00'.
|
||||
WHEN c_grade-c35.
|
||||
lv_cement = '400.00'.
|
||||
lv_sand = '660.00'.
|
||||
lv_gravel = '1120.00'.
|
||||
lv_water = '165.00'.
|
||||
WHEN OTHERS.
|
||||
RETURN.
|
||||
ENDCASE.
|
||||
|
||||
DATA lv_factor TYPE ty_qty.
|
||||
lv_factor = '1.00'.
|
||||
IF iv_volume < '2.00'.
|
||||
lv_factor = '1.10'.
|
||||
ENDIF.
|
||||
|
||||
rs_mix-grade = lv_grade.
|
||||
rs_mix-cement_kg = ceil( lv_cement * iv_volume * lv_factor ).
|
||||
rs_mix-sand_kg = ceil( lv_sand * iv_volume * lv_factor ).
|
||||
rs_mix-gravel_kg = ceil( lv_gravel * iv_volume * lv_factor ).
|
||||
rs_mix-water_l = ceil( lv_water * iv_volume * lv_factor ).
|
||||
ENDMETHOD.
|
||||
ENDINTERFACE.
|
||||
82
tasks_gen/train/G1935/reference/mix_recipe_test.clas.abap
Normal file
82
tasks_gen/train/G1935/reference/mix_recipe_test.clas.abap
Normal file
@@ -0,0 +1,82 @@
|
||||
CLASS {{p}}mix_recipe_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_mix_recipe.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}if_mix_recipe.
|
||||
METHODS setup.
|
||||
METHODS valid_order_is_ok FOR TESTING.
|
||||
METHODS unknown_grade_is_rejected FOR TESTING.
|
||||
METHODS volume_out_of_range FOR TESTING.
|
||||
METHODS mix_of_small_order FOR TESTING.
|
||||
METHODS mix_of_large_order FOR TESTING.
|
||||
METHODS invalid_order_has_no_mix FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}mix_recipe_test IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = me.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD valid_order_is_ok.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_mix_recipe=>c_status-ok
|
||||
act = mo_cut->check_order( iv_grade = 'C25' iv_volume = '1.30' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_grade_is_rejected.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_mix_recipe=>c_status-grade
|
||||
act = mo_cut->check_order( iv_grade = 'C40' iv_volume = '5.00' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD volume_out_of_range.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_mix_recipe=>c_status-volume
|
||||
act = mo_cut->check_order( iv_grade = 'C20' iv_volume = '25.00' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD mix_of_small_order.
|
||||
DATA(ls_mix) = mo_cut->mix_for( iv_grade = 'C25' iv_volume = '1.30' ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '458.00' )
|
||||
act = ls_mix-cement_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '1001.00' )
|
||||
act = ls_mix-sand_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '1659.00' )
|
||||
act = ls_mix-gravel_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '251.00' )
|
||||
act = ls_mix-water_l ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD mix_of_large_order.
|
||||
DATA(ls_mix) = mo_cut->mix_for( iv_grade = 'C35' iv_volume = '5.00' ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '2000.00' )
|
||||
act = ls_mix-cement_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '3300.00' )
|
||||
act = ls_mix-sand_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '5600.00' )
|
||||
act = ls_mix-gravel_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '825.00' )
|
||||
act = ls_mix-water_l ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_order_has_no_mix.
|
||||
DATA(ls_mix) = mo_cut->mix_for( iv_grade = 'C40' iv_volume = '5.00' ).
|
||||
cl_abap_unit_assert=>assert_initial( act = ls_mix-grade ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '0.00' )
|
||||
act = ls_mix-cement_kg ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_mix_recipe=>ty_qty( '0.00' )
|
||||
act = ls_mix-water_l ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
81
tasks_gen/train/G1935/spec.md
Normal file
81
tasks_gen/train/G1935/spec.md
Normal file
@@ -0,0 +1,81 @@
|
||||
# 1. Goal
|
||||
A ready-mix concrete plant supplies building sites. The plant office needs the
|
||||
quantities of cement, sand, gravel and water for each order. The order desk, the
|
||||
plant control system and the delivery note must use the same calculation. Create
|
||||
one interface that holds this calculation.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- One order has a concrete grade and a volume in cubic metres.
|
||||
- The plant supplies the grades C20, C25, C30 and C35.
|
||||
- Create the interface {{P}}IF_MIX_RECIPE in package $TMP.
|
||||
- The interface holds the types, the constants and the methods of section 4.
|
||||
- The interface contains the logic of section 5. A class that implements the
|
||||
interface and does not redefine the methods must get the results of section 5.
|
||||
|
||||
# 4. Contract
|
||||
Interface {{P}}IF_MIX_RECIPE in package $TMP.
|
||||
|
||||
Types:
|
||||
- TY_GRADE TYPE c LENGTH 4
|
||||
- TY_QTY TYPE p LENGTH 8 DECIMALS 2
|
||||
- TY_STATUS TYPE c LENGTH 10
|
||||
- TY_MIX: a structure with the components GRADE (TY_GRADE), CEMENT_KG, SAND_KG,
|
||||
GRAVEL_KG and WATER_L (each TY_QTY).
|
||||
|
||||
Constant structure C_GRADE with the components C20, C25, C30 and C35. Each
|
||||
component has the type TY_GRADE. The values are 'C20', 'C25', 'C30' and 'C35'.
|
||||
|
||||
Constant structure C_STATUS with the components OK, GRADE and VOLUME. Each
|
||||
component has the type TY_STATUS. The values are 'OK', 'GRADE' and 'VOLUME'.
|
||||
|
||||
Method CHECK_ORDER:
|
||||
IMPORTING iv_grade TYPE ty_grade
|
||||
iv_volume TYPE ty_qty
|
||||
RETURNING VALUE(rv_status) TYPE ty_status
|
||||
|
||||
Method MIX_FOR:
|
||||
IMPORTING iv_grade TYPE ty_grade
|
||||
iv_volume TYPE ty_qty
|
||||
RETURNING VALUE(rs_mix) TYPE ty_mix
|
||||
|
||||
Do not add other public components to the interface.
|
||||
|
||||
# 5. Business rules
|
||||
CHECK_ORDER returns the status of the first rule that fails.
|
||||
1. Compare the grade without regard to case.
|
||||
2. If the grade is not C20, C25, C30 or C35, return GRADE.
|
||||
3. If the volume is below 0.50 or above 20.00, return VOLUME.
|
||||
4. Otherwise return OK.
|
||||
|
||||
MIX_FOR returns the quantities of one order.
|
||||
1. If CHECK_ORDER does not return OK, the component GRADE is empty and the four
|
||||
quantities are 0.
|
||||
2. The quantities for one cubic metre are:
|
||||
|
||||
grade cement sand gravel water
|
||||
C20 280 720 1180 175
|
||||
C25 320 700 1160 175
|
||||
C30 360 680 1140 170
|
||||
C35 400 660 1120 165
|
||||
|
||||
The unit of cement, sand and gravel is one kilogram. The unit of water is one
|
||||
litre.
|
||||
3. Multiply each quantity by the volume.
|
||||
4. If the volume is below 2.00, add 10% to each quantity.
|
||||
5. Round each quantity up to the next full kilogram. Round the water up to the
|
||||
next full litre.
|
||||
6. The component GRADE of the result is the grade of the order in upper case.
|
||||
|
||||
# 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 any other object in package $TMP.
|
||||
|
||||
# 7. Acceptance
|
||||
- The interface is active and has no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write your own ABAP Unit tests for the interface.
|
||||
46
tasks_gen/train/G1935/task.json
Normal file
46
tasks_gen/train/G1935/task.json
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"id": "G1935",
|
||||
"category": "A",
|
||||
"object_type": "INTF",
|
||||
"difficulty": 2,
|
||||
"release_target": "v758",
|
||||
"expected_outcome": "implement",
|
||||
"budget": {
|
||||
"max_tool_calls": 60,
|
||||
"max_activations": 15
|
||||
},
|
||||
"seed": [],
|
||||
"contract": [
|
||||
{
|
||||
"type": "INTF",
|
||||
"name": "{{P}}IF_MIX_RECIPE"
|
||||
}
|
||||
],
|
||||
"out_of_scope": [],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}T02_HIDDEN",
|
||||
"file": "hidden/t02_hidden.clas.abap",
|
||||
"description": "Hidden tests for {{P}}IF_MIX_RECIPE: constant values, type lengths, order check and mix quantities."
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "INTF",
|
||||
"name": "{{P}}IF_MIX_RECIPE",
|
||||
"file": "reference/if_mix_recipe.intf.abap",
|
||||
"description": "Concrete mix interface with the default implementations of CHECK_ORDER and MIX_FOR"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}MIX_RECIPE_TEST",
|
||||
"file": "reference/mix_recipe_test.clas.abap",
|
||||
"description": "Own ABAP Unit tests for the interface"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length",
|
||||
"cyclomatic_complexity"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user