Snapshot: new training tasks (balanced generation), docs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
41
tasks_gen/train/G1917/faulty/m0_if_bouquet_check.intf.abap
Normal file
41
tasks_gen/train/G1917/faulty/m0_if_bouquet_check.intf.abap
Normal file
@@ -0,0 +1,41 @@
|
||||
INTERFACE {{p}}if_bouquet_check PUBLIC.
|
||||
TYPES ty_band TYPE c LENGTH 1.
|
||||
TYPES ty_reason TYPE c LENGTH 9.
|
||||
|
||||
TYPES:
|
||||
BEGIN OF ty_result,
|
||||
band TYPE ty_band,
|
||||
reason TYPE ty_reason,
|
||||
END OF ty_result.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_band,
|
||||
small TYPE ty_band VALUE 'S',
|
||||
medium TYPE ty_band VALUE 'M',
|
||||
large TYPE ty_band VALUE 'L',
|
||||
END OF c_band.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_reason,
|
||||
ok TYPE ty_reason VALUE 'OK',
|
||||
invalid TYPE ty_reason VALUE 'INVALID',
|
||||
short TYPE ty_reason VALUE 'SHORT',
|
||||
weight TYPE ty_reason VALUE 'WEIGHT',
|
||||
stems TYPE ty_reason VALUE 'STEMS',
|
||||
END OF c_reason.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_limit,
|
||||
max_stems_small TYPE i VALUE 20,
|
||||
max_stems_medium TYPE i VALUE 40,
|
||||
max_stems_large TYPE i VALUE 60,
|
||||
max_weight_g TYPE i VALUE 3000,
|
||||
min_stem_cm TYPE i VALUE 40,
|
||||
END OF c_limit.
|
||||
|
||||
METHODS check_order
|
||||
IMPORTING iv_stems TYPE i
|
||||
iv_weight_g TYPE i
|
||||
iv_stem_cm TYPE i
|
||||
RETURNING VALUE(rs_result) TYPE ty_result.
|
||||
ENDINTERFACE.
|
||||
41
tasks_gen/train/G1917/faulty/m1_if_bouquet_check.intf.abap
Normal file
41
tasks_gen/train/G1917/faulty/m1_if_bouquet_check.intf.abap
Normal file
@@ -0,0 +1,41 @@
|
||||
INTERFACE {{p}}if_bouquet_check PUBLIC.
|
||||
TYPES ty_band TYPE c LENGTH 1.
|
||||
TYPES ty_reason TYPE c LENGTH 10.
|
||||
|
||||
TYPES:
|
||||
BEGIN OF ty_result,
|
||||
band TYPE ty_band,
|
||||
reason TYPE ty_reason,
|
||||
END OF ty_result.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_band,
|
||||
small TYPE ty_band VALUE 'S',
|
||||
medium TYPE ty_band VALUE 'M',
|
||||
large TYPE ty_band VALUE 'L',
|
||||
END OF c_band.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_reason,
|
||||
ok TYPE ty_reason VALUE 'ZK',
|
||||
invalid TYPE ty_reason VALUE 'INVALID',
|
||||
short TYPE ty_reason VALUE 'SHORT',
|
||||
weight TYPE ty_reason VALUE 'WEIGHT',
|
||||
stems TYPE ty_reason VALUE 'STEMS',
|
||||
END OF c_reason.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_limit,
|
||||
max_stems_small TYPE i VALUE 20,
|
||||
max_stems_medium TYPE i VALUE 40,
|
||||
max_stems_large TYPE i VALUE 60,
|
||||
max_weight_g TYPE i VALUE 3000,
|
||||
min_stem_cm TYPE i VALUE 40,
|
||||
END OF c_limit.
|
||||
|
||||
METHODS check_order
|
||||
IMPORTING iv_stems TYPE i
|
||||
iv_weight_g TYPE i
|
||||
iv_stem_cm TYPE i
|
||||
RETURNING VALUE(rs_result) TYPE ty_result.
|
||||
ENDINTERFACE.
|
||||
41
tasks_gen/train/G1917/faulty/m2_if_bouquet_check.intf.abap
Normal file
41
tasks_gen/train/G1917/faulty/m2_if_bouquet_check.intf.abap
Normal file
@@ -0,0 +1,41 @@
|
||||
INTERFACE {{p}}if_bouquet_check PUBLIC.
|
||||
TYPES ty_band TYPE c LENGTH 1.
|
||||
TYPES ty_reason TYPE c LENGTH 10.
|
||||
|
||||
TYPES:
|
||||
BEGIN OF ty_result,
|
||||
band TYPE ty_band,
|
||||
reason TYPE ty_reason,
|
||||
END OF ty_result.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_band,
|
||||
small TYPE ty_band VALUE 'S',
|
||||
medium TYPE ty_band VALUE 'M',
|
||||
large TYPE ty_band VALUE 'L',
|
||||
END OF c_band.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_reason,
|
||||
ok TYPE ty_reason VALUE 'OK',
|
||||
invalid TYPE ty_reason VALUE 'ZNVALID',
|
||||
short TYPE ty_reason VALUE 'SHORT',
|
||||
weight TYPE ty_reason VALUE 'WEIGHT',
|
||||
stems TYPE ty_reason VALUE 'STEMS',
|
||||
END OF c_reason.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_limit,
|
||||
max_stems_small TYPE i VALUE 20,
|
||||
max_stems_medium TYPE i VALUE 40,
|
||||
max_stems_large TYPE i VALUE 60,
|
||||
max_weight_g TYPE i VALUE 3000,
|
||||
min_stem_cm TYPE i VALUE 40,
|
||||
END OF c_limit.
|
||||
|
||||
METHODS check_order
|
||||
IMPORTING iv_stems TYPE i
|
||||
iv_weight_g TYPE i
|
||||
iv_stem_cm TYPE i
|
||||
RETURNING VALUE(rs_result) TYPE ty_result.
|
||||
ENDINTERFACE.
|
||||
41
tasks_gen/train/G1917/faulty/m3_if_bouquet_check.intf.abap
Normal file
41
tasks_gen/train/G1917/faulty/m3_if_bouquet_check.intf.abap
Normal file
@@ -0,0 +1,41 @@
|
||||
INTERFACE {{p}}if_bouquet_check PUBLIC.
|
||||
TYPES ty_band TYPE c LENGTH 1.
|
||||
TYPES ty_reason TYPE c LENGTH 10.
|
||||
|
||||
TYPES:
|
||||
BEGIN OF ty_result,
|
||||
band TYPE ty_band,
|
||||
reason TYPE ty_reason,
|
||||
END OF ty_result.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_band,
|
||||
small TYPE ty_band VALUE 'S',
|
||||
medium TYPE ty_band VALUE 'M',
|
||||
large TYPE ty_band VALUE 'L',
|
||||
END OF c_band.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_reason,
|
||||
ok TYPE ty_reason VALUE 'OK',
|
||||
invalid TYPE ty_reason VALUE 'INVALID',
|
||||
short TYPE ty_reason VALUE 'ZHORT',
|
||||
weight TYPE ty_reason VALUE 'WEIGHT',
|
||||
stems TYPE ty_reason VALUE 'STEMS',
|
||||
END OF c_reason.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_limit,
|
||||
max_stems_small TYPE i VALUE 20,
|
||||
max_stems_medium TYPE i VALUE 40,
|
||||
max_stems_large TYPE i VALUE 60,
|
||||
max_weight_g TYPE i VALUE 3000,
|
||||
min_stem_cm TYPE i VALUE 40,
|
||||
END OF c_limit.
|
||||
|
||||
METHODS check_order
|
||||
IMPORTING iv_stems TYPE i
|
||||
iv_weight_g TYPE i
|
||||
iv_stem_cm TYPE i
|
||||
RETURNING VALUE(rs_result) TYPE ty_result.
|
||||
ENDINTERFACE.
|
||||
41
tasks_gen/train/G1917/faulty/m4_if_bouquet_check.intf.abap
Normal file
41
tasks_gen/train/G1917/faulty/m4_if_bouquet_check.intf.abap
Normal file
@@ -0,0 +1,41 @@
|
||||
INTERFACE {{p}}if_bouquet_check PUBLIC.
|
||||
TYPES ty_band TYPE c LENGTH 1.
|
||||
TYPES ty_reason TYPE c LENGTH 10.
|
||||
|
||||
TYPES:
|
||||
BEGIN OF ty_result,
|
||||
band TYPE ty_band,
|
||||
reason TYPE ty_reason,
|
||||
END OF ty_result.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_band,
|
||||
small TYPE ty_band VALUE 'S',
|
||||
medium TYPE ty_band VALUE 'M',
|
||||
large TYPE ty_band VALUE 'L',
|
||||
END OF c_band.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_reason,
|
||||
ok TYPE ty_reason VALUE 'OK',
|
||||
invalid TYPE ty_reason VALUE 'INVALID',
|
||||
short TYPE ty_reason VALUE 'SHORT',
|
||||
weight TYPE ty_reason VALUE 'ZEIGHT',
|
||||
stems TYPE ty_reason VALUE 'STEMS',
|
||||
END OF c_reason.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_limit,
|
||||
max_stems_small TYPE i VALUE 20,
|
||||
max_stems_medium TYPE i VALUE 40,
|
||||
max_stems_large TYPE i VALUE 60,
|
||||
max_weight_g TYPE i VALUE 3000,
|
||||
min_stem_cm TYPE i VALUE 40,
|
||||
END OF c_limit.
|
||||
|
||||
METHODS check_order
|
||||
IMPORTING iv_stems TYPE i
|
||||
iv_weight_g TYPE i
|
||||
iv_stem_cm TYPE i
|
||||
RETURNING VALUE(rs_result) TYPE ty_result.
|
||||
ENDINTERFACE.
|
||||
38
tasks_gen/train/G1917/generation.json
Normal file
38
tasks_gen/train/G1917/generation.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"id": "G1917",
|
||||
"pool": "train",
|
||||
"object_type": "INTF",
|
||||
"category": "A",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "bundle",
|
||||
"errors": [
|
||||
"Too close to task G1900 (similarity spec 0.58, rules 0.61, names 0.33). Choose a different business topic and different object names."
|
||||
],
|
||||
"by_check": {
|
||||
"extra": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 73.6,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 100.0,
|
||||
"null": 0,
|
||||
"mutation": {
|
||||
"valid": 5,
|
||||
"killed": 5,
|
||||
"ok": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"accepted": true
|
||||
}
|
||||
126
tasks_gen/train/G1917/hidden/bouquet_check_hidden.clas.abap
Normal file
126
tasks_gen/train/G1917/hidden/bouquet_check_hidden.clas.abap
Normal file
@@ -0,0 +1,126 @@
|
||||
CLASS {{p}}bouquet_check_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_bouquet_check.
|
||||
|
||||
PRIVATE SECTION.
|
||||
METHODS band_values FOR TESTING.
|
||||
METHODS reason_values FOR TESTING.
|
||||
METHODS limit_values FOR TESTING.
|
||||
METHODS band_is_one_char FOR TESTING.
|
||||
METHODS reason_is_ten_chars FOR TESTING.
|
||||
METHODS result_structure FOR TESTING.
|
||||
METHODS call_returns_result FOR TESTING.
|
||||
METHODS call_with_variables FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}bouquet_check_hidden IMPLEMENTATION.
|
||||
METHOD {{p}}if_bouquet_check~check_order.
|
||||
rs_result = VALUE #( band = {{p}}if_bouquet_check=>c_band-large
|
||||
reason = {{p}}if_bouquet_check=>c_reason-ok ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD band_values.
|
||||
DATA lv_band TYPE {{p}}if_bouquet_check=>ty_band.
|
||||
lv_band = {{p}}if_bouquet_check=>c_band-small.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'S' act = lv_band msg = `SMALL` ).
|
||||
lv_band = {{p}}if_bouquet_check=>c_band-medium.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'M' act = lv_band msg = `MEDIUM` ).
|
||||
lv_band = {{p}}if_bouquet_check=>c_band-large.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'L' act = lv_band msg = `LARGE` ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD reason_values.
|
||||
DATA lv_exp TYPE {{p}}if_bouquet_check=>ty_reason.
|
||||
DATA lv_act TYPE {{p}}if_bouquet_check=>ty_reason.
|
||||
lv_exp = 'OK'.
|
||||
lv_act = {{p}}if_bouquet_check=>c_reason-ok.
|
||||
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_act msg = `OK` ).
|
||||
lv_exp = 'INVALID'.
|
||||
lv_act = {{p}}if_bouquet_check=>c_reason-invalid.
|
||||
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_act msg = `INVALID` ).
|
||||
lv_exp = 'SHORT'.
|
||||
lv_act = {{p}}if_bouquet_check=>c_reason-short.
|
||||
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_act msg = `SHORT` ).
|
||||
lv_exp = 'WEIGHT'.
|
||||
lv_act = {{p}}if_bouquet_check=>c_reason-weight.
|
||||
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_act msg = `WEIGHT` ).
|
||||
lv_exp = 'STEMS'.
|
||||
lv_act = {{p}}if_bouquet_check=>c_reason-stems.
|
||||
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_act msg = `STEMS` ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD limit_values.
|
||||
DATA lv_limit TYPE i.
|
||||
lv_limit = {{p}}if_bouquet_check=>c_limit-max_stems_small.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 20 act = lv_limit msg = `SMALL` ).
|
||||
lv_limit = {{p}}if_bouquet_check=>c_limit-max_stems_medium.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 40 act = lv_limit msg = `MEDIUM` ).
|
||||
lv_limit = {{p}}if_bouquet_check=>c_limit-max_stems_large.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 60 act = lv_limit msg = `LARGE` ).
|
||||
lv_limit = {{p}}if_bouquet_check=>c_limit-max_weight_g.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 3000 act = lv_limit msg = `WEIGHT` ).
|
||||
lv_limit = {{p}}if_bouquet_check=>c_limit-min_stem_cm.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 40 act = lv_limit msg = `STEM` ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD band_is_one_char.
|
||||
DATA lv_band TYPE {{p}}if_bouquet_check=>ty_band.
|
||||
lv_band = 'XY'.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'X' act = lv_band
|
||||
msg = `band is one character` ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD reason_is_ten_chars.
|
||||
DATA lv_reason TYPE {{p}}if_bouquet_check=>ty_reason.
|
||||
lv_reason = 'ABCDEFGHIJKL'.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'ABCDEFGHIJ' act = lv_reason
|
||||
msg = `reason is ten characters` ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD result_structure.
|
||||
DATA ls_result TYPE {{p}}if_bouquet_check=>ty_result.
|
||||
DATA(lo_struct) = CAST cl_abap_structdescr(
|
||||
cl_abap_typedescr=>describe_by_data( ls_result ) ).
|
||||
DATA(lt_comp) = lo_struct->get_components( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_comp ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'BAND'
|
||||
act = to_upper( lt_comp[ 1 ]-name ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'REASON'
|
||||
act = to_upper( lt_comp[ 2 ]-name ) ).
|
||||
ls_result-band = 'XY'.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'X' act = ls_result-band ).
|
||||
ls_result-reason = 'ABCDEFGHIJKL'.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'ABCDEFGHIJ'
|
||||
act = ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD call_returns_result.
|
||||
DATA mo_cut TYPE REF TO {{p}}if_bouquet_check.
|
||||
mo_cut = NEW {{p}}bouquet_check_hidden( ).
|
||||
DATA(ls_result) = mo_cut->check_order( iv_stems = 30
|
||||
iv_weight_g = 1200
|
||||
iv_stem_cm = 50 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_bouquet_check=>c_band-large
|
||||
act = ls_result-band ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_bouquet_check=>c_reason-ok
|
||||
act = ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD call_with_variables.
|
||||
DATA lv_stems TYPE i VALUE 5.
|
||||
DATA lv_weight TYPE i VALUE 900.
|
||||
DATA lv_stem TYPE i VALUE 45.
|
||||
DATA mo_cut TYPE REF TO {{p}}if_bouquet_check.
|
||||
mo_cut = NEW {{p}}bouquet_check_hidden( ).
|
||||
DATA(ls_result) = mo_cut->check_order( iv_stems = lv_stems
|
||||
iv_weight_g = lv_weight
|
||||
iv_stem_cm = lv_stem ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_bouquet_check=>c_band-large
|
||||
act = ls_result-band ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_bouquet_check=>c_reason-ok
|
||||
act = ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
55
tasks_gen/train/G1917/mutation.json
Normal file
55
tasks_gen/train/G1917/mutation.json
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"task": "G1917",
|
||||
"mutants": [
|
||||
{
|
||||
"object": "{{P}}IF_BOUQUET_CHECK",
|
||||
"mutant": "line 3: LENGTH 10 -> LENGTH 9 (length)",
|
||||
"status": "killed",
|
||||
"hidden": "6/8",
|
||||
"failed_tests": [
|
||||
"REASON_IS_TEN_CHARS",
|
||||
"RESULT_STRUCTURE"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}IF_BOUQUET_CHECK",
|
||||
"mutant": "line 20: VALUE 'OK' -> VALUE 'ZK' (lit)",
|
||||
"status": "killed",
|
||||
"hidden": "7/8",
|
||||
"failed_tests": [
|
||||
"REASON_VALUES"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}IF_BOUQUET_CHECK",
|
||||
"mutant": "line 21: VALUE 'INVALID' -> VALUE 'ZNVALID' (lit)",
|
||||
"status": "killed",
|
||||
"hidden": "7/8",
|
||||
"failed_tests": [
|
||||
"REASON_VALUES"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}IF_BOUQUET_CHECK",
|
||||
"mutant": "line 22: VALUE 'SHORT' -> VALUE 'ZHORT' (lit)",
|
||||
"status": "killed",
|
||||
"hidden": "7/8",
|
||||
"failed_tests": [
|
||||
"REASON_VALUES"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}IF_BOUQUET_CHECK",
|
||||
"mutant": "line 23: VALUE 'WEIGHT' -> VALUE 'ZEIGHT' (lit)",
|
||||
"status": "killed",
|
||||
"hidden": "7/8",
|
||||
"failed_tests": [
|
||||
"REASON_VALUES"
|
||||
]
|
||||
}
|
||||
],
|
||||
"valid": 5,
|
||||
"killed": 5,
|
||||
"kill_rate": 1.0,
|
||||
"ok": true
|
||||
}
|
||||
108
tasks_gen/train/G1917/reference/bouquet_check_test.clas.abap
Normal file
108
tasks_gen/train/G1917/reference/bouquet_check_test.clas.abap
Normal file
@@ -0,0 +1,108 @@
|
||||
CLASS {{p}}bouquet_check_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_bouquet_check.
|
||||
|
||||
PRIVATE SECTION.
|
||||
METHODS bands FOR TESTING.
|
||||
METHODS reasons FOR TESTING.
|
||||
METHODS limits FOR TESTING.
|
||||
METHODS band_is_one_char FOR TESTING.
|
||||
METHODS reason_is_ten_chars FOR TESTING.
|
||||
METHODS result_parts FOR TESTING.
|
||||
METHODS order_contract FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}bouquet_check_test IMPLEMENTATION.
|
||||
METHOD {{p}}if_bouquet_check~check_order.
|
||||
rs_result = VALUE #( band = {{p}}if_bouquet_check=>c_band-small
|
||||
reason = {{p}}if_bouquet_check=>c_reason-ok ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD bands.
|
||||
DATA lv_band TYPE {{p}}if_bouquet_check=>ty_band.
|
||||
lv_band = {{p}}if_bouquet_check=>c_band-small.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'S' act = lv_band ).
|
||||
lv_band = {{p}}if_bouquet_check=>c_band-medium.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'M' act = lv_band ).
|
||||
lv_band = {{p}}if_bouquet_check=>c_band-large.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'L' act = lv_band ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD reasons.
|
||||
DATA lv_exp TYPE {{p}}if_bouquet_check=>ty_reason.
|
||||
DATA lv_act TYPE {{p}}if_bouquet_check=>ty_reason.
|
||||
lv_exp = 'OK'.
|
||||
lv_act = {{p}}if_bouquet_check=>c_reason-ok.
|
||||
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_act ).
|
||||
lv_exp = 'INVALID'.
|
||||
lv_act = {{p}}if_bouquet_check=>c_reason-invalid.
|
||||
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_act ).
|
||||
lv_exp = 'SHORT'.
|
||||
lv_act = {{p}}if_bouquet_check=>c_reason-short.
|
||||
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_act ).
|
||||
lv_exp = 'WEIGHT'.
|
||||
lv_act = {{p}}if_bouquet_check=>c_reason-weight.
|
||||
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_act ).
|
||||
lv_exp = 'STEMS'.
|
||||
lv_act = {{p}}if_bouquet_check=>c_reason-stems.
|
||||
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_act ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD limits.
|
||||
DATA lv_limit TYPE i.
|
||||
lv_limit = {{p}}if_bouquet_check=>c_limit-max_stems_small.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 20 act = lv_limit ).
|
||||
lv_limit = {{p}}if_bouquet_check=>c_limit-max_stems_medium.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 40 act = lv_limit ).
|
||||
lv_limit = {{p}}if_bouquet_check=>c_limit-max_stems_large.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 60 act = lv_limit ).
|
||||
lv_limit = {{p}}if_bouquet_check=>c_limit-max_weight_g.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 3000 act = lv_limit ).
|
||||
lv_limit = {{p}}if_bouquet_check=>c_limit-min_stem_cm.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 40 act = lv_limit ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD band_is_one_char.
|
||||
DATA lv_band TYPE {{p}}if_bouquet_check=>ty_band.
|
||||
lv_band = 'XY'.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'X' act = lv_band ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD reason_is_ten_chars.
|
||||
DATA lv_reason TYPE {{p}}if_bouquet_check=>ty_reason.
|
||||
lv_reason = 'ABCDEFGHIJKL'.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'ABCDEFGHIJ' act = lv_reason ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD result_parts.
|
||||
DATA ls_result TYPE {{p}}if_bouquet_check=>ty_result.
|
||||
DATA(lo_struct) = CAST cl_abap_structdescr(
|
||||
cl_abap_typedescr=>describe_by_data( ls_result ) ).
|
||||
DATA(lt_comp) = lo_struct->get_components( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_comp ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'BAND'
|
||||
act = to_upper( lt_comp[ 1 ]-name ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'REASON'
|
||||
act = to_upper( lt_comp[ 2 ]-name ) ).
|
||||
ls_result-band = 'XY'.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'X' act = ls_result-band ).
|
||||
ls_result-reason = 'ABCDEFGHIJKL'.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'ABCDEFGHIJ'
|
||||
act = ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD order_contract.
|
||||
DATA mo_cut TYPE REF TO {{p}}if_bouquet_check.
|
||||
mo_cut = NEW {{p}}bouquet_check_test( ).
|
||||
DATA(ls_result) = mo_cut->check_order( iv_stems = 25
|
||||
iv_weight_g = 1200
|
||||
iv_stem_cm = 45 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_bouquet_check=>c_band-small
|
||||
act = ls_result-band ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_bouquet_check=>c_reason-ok
|
||||
act = ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
41
tasks_gen/train/G1917/reference/if_bouquet_check.intf.abap
Normal file
41
tasks_gen/train/G1917/reference/if_bouquet_check.intf.abap
Normal file
@@ -0,0 +1,41 @@
|
||||
INTERFACE {{p}}if_bouquet_check PUBLIC.
|
||||
TYPES ty_band TYPE c LENGTH 1.
|
||||
TYPES ty_reason TYPE c LENGTH 10.
|
||||
|
||||
TYPES:
|
||||
BEGIN OF ty_result,
|
||||
band TYPE ty_band,
|
||||
reason TYPE ty_reason,
|
||||
END OF ty_result.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_band,
|
||||
small TYPE ty_band VALUE 'S',
|
||||
medium TYPE ty_band VALUE 'M',
|
||||
large TYPE ty_band VALUE 'L',
|
||||
END OF c_band.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_reason,
|
||||
ok TYPE ty_reason VALUE 'OK',
|
||||
invalid TYPE ty_reason VALUE 'INVALID',
|
||||
short TYPE ty_reason VALUE 'SHORT',
|
||||
weight TYPE ty_reason VALUE 'WEIGHT',
|
||||
stems TYPE ty_reason VALUE 'STEMS',
|
||||
END OF c_reason.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_limit,
|
||||
max_stems_small TYPE i VALUE 20,
|
||||
max_stems_medium TYPE i VALUE 40,
|
||||
max_stems_large TYPE i VALUE 60,
|
||||
max_weight_g TYPE i VALUE 3000,
|
||||
min_stem_cm TYPE i VALUE 40,
|
||||
END OF c_limit.
|
||||
|
||||
METHODS check_order
|
||||
IMPORTING iv_stems TYPE i
|
||||
iv_weight_g TYPE i
|
||||
iv_stem_cm TYPE i
|
||||
RETURNING VALUE(rs_result) TYPE ty_result.
|
||||
ENDINTERFACE.
|
||||
66
tasks_gen/train/G1917/spec.md
Normal file
66
tasks_gen/train/G1917/spec.md
Normal file
@@ -0,0 +1,66 @@
|
||||
# 1. Goal
|
||||
A florist's order desk checks a bouquet order before the workshop starts the
|
||||
work. The order desk software needs one interface for this check. The interface
|
||||
defines the bouquet bands, the reason codes and the limits of the workshop.
|
||||
Create this interface.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- Package $TMP.
|
||||
- A bouquet order has a number of stems, a total weight in grams and the length
|
||||
of a stem in centimetres.
|
||||
- The workshop uses three bouquet bands: S, M and L.
|
||||
- The result of the check is a structure with the band and a reason code.
|
||||
- The reason OK means that the order is correct. INVALID means that a value is
|
||||
not positive. SHORT means that the stem is shorter than the workshop allows.
|
||||
WEIGHT means that the bouquet is heavier than the workshop allows. STEMS means
|
||||
that the order has more stems than the workshop allows.
|
||||
- The workshop accepts at most 3000 g and a stem of at least 40 cm. The bands
|
||||
S, M and L take at most 20, 40 and 60 stems.
|
||||
|
||||
# 4. Contract
|
||||
- Create the interface {{P}}IF_BOUQUET_CHECK in package $TMP.
|
||||
- The interface is public. It contains the types, the constants and the method
|
||||
of the business rules and no other components.
|
||||
- Do not create other repository objects.
|
||||
|
||||
# 5. Business rules
|
||||
1. Type TY_BAND is a character type of length 1.
|
||||
2. Type TY_REASON is a character type of length 10.
|
||||
3. Type TY_RESULT is a structure with exactly two components in this sequence:
|
||||
BAND of type TY_BAND, then REASON of type TY_REASON.
|
||||
4. Constant structure C_BAND has exactly three components of type TY_BAND:
|
||||
SMALL with the value 'S', MEDIUM with the value 'M' and LARGE with the value
|
||||
'L'.
|
||||
5. Constant structure C_REASON has exactly five components of type TY_REASON:
|
||||
OK with the value 'OK', INVALID with the value 'INVALID', SHORT with the
|
||||
value 'SHORT', WEIGHT with the value 'WEIGHT' and STEMS with the value
|
||||
'STEMS'.
|
||||
6. Constant structure C_LIMIT has exactly five components of type I:
|
||||
MAX_STEMS_SMALL with the value 20, MAX_STEMS_MEDIUM with the value 40,
|
||||
MAX_STEMS_LARGE with the value 60, MAX_WEIGHT_G with the value 3000 and
|
||||
MIN_STEM_CM with the value 40.
|
||||
7. The interface has the method CHECK_ORDER with the importing parameters
|
||||
IV_STEMS of type I, IV_WEIGHT_G of type I and IV_STEM_CM of type I, and the
|
||||
returning parameter RS_RESULT of type TY_RESULT.
|
||||
8. The band of the result is SMALL if IV_STEMS is at most MAX_STEMS_SMALL,
|
||||
MEDIUM if IV_STEMS is at most MAX_STEMS_MEDIUM, and LARGE in all other
|
||||
cases.
|
||||
9. The reason of the result is the reason of the first rule that fails, in this
|
||||
sequence: INVALID if IV_STEMS, IV_WEIGHT_G or IV_STEM_CM is less than 1;
|
||||
SHORT if IV_STEM_CM is less than MIN_STEM_CM; WEIGHT if IV_WEIGHT_G is
|
||||
greater than MAX_WEIGHT_G; STEMS if IV_STEMS is greater than
|
||||
MAX_STEMS_LARGE. If no rule fails, the reason is OK.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: ABAP Platform 2025 (SAP_BASIS 816).
|
||||
- Coding standards: Clean ABAP. An interface has no implementation.
|
||||
- Out of scope: no class that implements the interface, no database table, no
|
||||
CDS view entity.
|
||||
|
||||
# 7. Acceptance
|
||||
- The interface {{P}}IF_BOUQUET_CHECK is active and has no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write your own ABAP Unit tests for the interface.
|
||||
52
tasks_gen/train/G1917/task.json
Normal file
52
tasks_gen/train/G1917/task.json
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"id": "G1917",
|
||||
"category": "A",
|
||||
"object_type": "INTF",
|
||||
"difficulty": 2,
|
||||
"release_target": "v816",
|
||||
"expected_outcome": "implement",
|
||||
"budget": {
|
||||
"max_tool_calls": 60,
|
||||
"max_activations": 15
|
||||
},
|
||||
"seed": [],
|
||||
"contract": [
|
||||
{
|
||||
"type": "INTF",
|
||||
"name": "{{P}}IF_BOUQUET_CHECK"
|
||||
}
|
||||
],
|
||||
"out_of_scope": [
|
||||
"No class that implements the interface",
|
||||
"No database table",
|
||||
"No CDS view entity",
|
||||
"No function module",
|
||||
"No report"
|
||||
],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}BOUQUET_CHECK_HIDDEN",
|
||||
"file": "hidden/bouquet_check_hidden.clas.abap",
|
||||
"description": "Contract tests for {{P}}IF_BOUQUET_CHECK: the test class implements the interface, reads the constants, checks the type lengths, the result structure and calls the method through the interface"
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "INTF",
|
||||
"name": "{{P}}IF_BOUQUET_CHECK",
|
||||
"file": "reference/if_bouquet_check.intf.abap",
|
||||
"description": "Bouquet order check contract"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}BOUQUET_CHECK_TEST",
|
||||
"file": "reference/bouquet_check_test.clas.abap",
|
||||
"description": "Own ABAP Unit tests for the interface"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length",
|
||||
"db_operation_in_loop"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user