Stage 2 summary at 50 accepted trajectories
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
49
tasks_gen/train/G1096/faulty/m0_adopt_review.func.abap
Normal file
49
tasks_gen/train/G1096/faulty/m0_adopt_review.func.abap
Normal file
@@ -0,0 +1,49 @@
|
||||
FUNCTION {{p}}adopt_review
|
||||
IMPORTING
|
||||
iv_species TYPE string
|
||||
iv_age_years TYPE i
|
||||
iv_housing TYPE string
|
||||
iv_garden TYPE abap_bool
|
||||
iv_pets TYPE i
|
||||
EXPORTING
|
||||
ev_deposit TYPE decfloat34
|
||||
ev_visit_day TYPE string
|
||||
RAISING
|
||||
{{p}}cx_adopt_reject.
|
||||
|
||||
IF iv_age_years < 18.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'TOO_YOUNG' ).
|
||||
ENDIF.
|
||||
|
||||
DATA lv_deposit TYPE decfloat34.
|
||||
CASE iv_species.
|
||||
WHEN 'DOG'.
|
||||
lv_deposit = 150.
|
||||
WHEN 'CAT'.
|
||||
lv_deposit = 80.
|
||||
WHEN 'RABBIT'.
|
||||
lv_deposit = 40.
|
||||
WHEN OTHERS.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'UNKNOWN_SPECIES' ).
|
||||
ENDCASE.
|
||||
|
||||
IF iv_species = 'DOG' AND iv_housing = 'FLAT' OR iv_garden = abap_false.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'NO_GARDEN' ).
|
||||
ENDIF.
|
||||
|
||||
IF iv_pets > 2.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'TOO_MANY_PETS' ).
|
||||
ENDIF.
|
||||
|
||||
IF iv_pets > 0.
|
||||
lv_deposit = lv_deposit + 12.
|
||||
ENDIF.
|
||||
ev_deposit = lv_deposit.
|
||||
|
||||
IF iv_garden = abap_true.
|
||||
ev_visit_day = 'SAT'.
|
||||
ELSE.
|
||||
ev_visit_day = 'WED'.
|
||||
ENDIF.
|
||||
|
||||
ENDFUNCTION.
|
||||
49
tasks_gen/train/G1096/faulty/m1_adopt_review.func.abap
Normal file
49
tasks_gen/train/G1096/faulty/m1_adopt_review.func.abap
Normal file
@@ -0,0 +1,49 @@
|
||||
FUNCTION {{p}}adopt_review
|
||||
IMPORTING
|
||||
iv_species TYPE string
|
||||
iv_age_years TYPE i
|
||||
iv_housing TYPE string
|
||||
iv_garden TYPE abap_bool
|
||||
iv_pets TYPE i
|
||||
EXPORTING
|
||||
ev_deposit TYPE decfloat34
|
||||
ev_visit_day TYPE string
|
||||
RAISING
|
||||
{{p}}cx_adopt_reject.
|
||||
|
||||
IF iv_age_years < 18.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'TOO_YOUNG' ).
|
||||
ENDIF.
|
||||
|
||||
DATA lv_deposit TYPE decfloat34.
|
||||
CASE iv_species.
|
||||
WHEN 'DOG'.
|
||||
lv_deposit = 150.
|
||||
WHEN 'CAT'.
|
||||
lv_deposit = 80.
|
||||
WHEN 'RABBIT'.
|
||||
lv_deposit = 40.
|
||||
WHEN OTHERS.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'UNKNOWN_SPECIES' ).
|
||||
ENDCASE.
|
||||
|
||||
IF iv_species = 'DOG' AND iv_housing = 'FLAT' AND iv_garden = abap_false.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'NO_GARDEN' ).
|
||||
ENDIF.
|
||||
|
||||
IF iv_pets > 2.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'TOO_MANY_PETS' ).
|
||||
ENDIF.
|
||||
|
||||
IF iv_pets <= 0.
|
||||
lv_deposit = lv_deposit + 12.
|
||||
ENDIF.
|
||||
ev_deposit = lv_deposit.
|
||||
|
||||
IF iv_garden = abap_true.
|
||||
ev_visit_day = 'SAT'.
|
||||
ELSE.
|
||||
ev_visit_day = 'WED'.
|
||||
ENDIF.
|
||||
|
||||
ENDFUNCTION.
|
||||
49
tasks_gen/train/G1096/faulty/m2_adopt_review.func.abap
Normal file
49
tasks_gen/train/G1096/faulty/m2_adopt_review.func.abap
Normal file
@@ -0,0 +1,49 @@
|
||||
FUNCTION {{p}}adopt_review
|
||||
IMPORTING
|
||||
iv_species TYPE string
|
||||
iv_age_years TYPE i
|
||||
iv_housing TYPE string
|
||||
iv_garden TYPE abap_bool
|
||||
iv_pets TYPE i
|
||||
EXPORTING
|
||||
ev_deposit TYPE decfloat34
|
||||
ev_visit_day TYPE string
|
||||
RAISING
|
||||
{{p}}cx_adopt_reject.
|
||||
|
||||
IF iv_age_years < 18.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'TOO_YOUNG' ).
|
||||
ENDIF.
|
||||
|
||||
DATA lv_deposit TYPE decfloat34.
|
||||
CASE iv_species.
|
||||
WHEN 'DOG'.
|
||||
lv_deposit = 150.
|
||||
WHEN 'CAT'.
|
||||
lv_deposit = 80.
|
||||
WHEN 'RABBIT'.
|
||||
lv_deposit = 40.
|
||||
WHEN OTHERS.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'UNKNOWN_SPECIES' ).
|
||||
ENDCASE.
|
||||
|
||||
IF iv_species = 'DOG' AND iv_housing = 'FLAT' AND iv_garden = abap_false.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'NO_GARDEN' ).
|
||||
ENDIF.
|
||||
|
||||
IF iv_pets > 2.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'TOO_MANY_PETS' ).
|
||||
ENDIF.
|
||||
|
||||
IF iv_pets > 0.
|
||||
lv_deposit = lv_deposit - 12.
|
||||
ENDIF.
|
||||
ev_deposit = lv_deposit.
|
||||
|
||||
IF iv_garden = abap_true.
|
||||
ev_visit_day = 'SAT'.
|
||||
ELSE.
|
||||
ev_visit_day = 'WED'.
|
||||
ENDIF.
|
||||
|
||||
ENDFUNCTION.
|
||||
49
tasks_gen/train/G1096/faulty/m3_adopt_review.func.abap
Normal file
49
tasks_gen/train/G1096/faulty/m3_adopt_review.func.abap
Normal file
@@ -0,0 +1,49 @@
|
||||
FUNCTION {{p}}adopt_review
|
||||
IMPORTING
|
||||
iv_species TYPE string
|
||||
iv_age_years TYPE i
|
||||
iv_housing TYPE string
|
||||
iv_garden TYPE abap_bool
|
||||
iv_pets TYPE i
|
||||
EXPORTING
|
||||
ev_deposit TYPE decfloat34
|
||||
ev_visit_day TYPE string
|
||||
RAISING
|
||||
{{p}}cx_adopt_reject.
|
||||
|
||||
IF iv_age_years < 18.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'TOO_YOUNG' ).
|
||||
ENDIF.
|
||||
|
||||
DATA lv_deposit TYPE decfloat34.
|
||||
CASE iv_species.
|
||||
WHEN 'DOG'.
|
||||
lv_deposit = 150.
|
||||
WHEN 'CAT'.
|
||||
lv_deposit = 80.
|
||||
WHEN 'RABBIT'.
|
||||
lv_deposit = 40.
|
||||
WHEN OTHERS.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'UNKNOWN_SPECIES' ).
|
||||
ENDCASE.
|
||||
|
||||
IF iv_species = 'DOG' AND iv_housing = 'FLAT' AND iv_garden = abap_false.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'NO_GARDEN' ).
|
||||
ENDIF.
|
||||
|
||||
IF iv_pets > 2.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'TOO_MANY_PETS' ).
|
||||
ENDIF.
|
||||
|
||||
IF iv_pets > 0.
|
||||
lv_deposit = lv_deposit + 12.
|
||||
ENDIF.
|
||||
ev_deposit = lv_deposit.
|
||||
|
||||
IF iv_garden <> abap_true.
|
||||
ev_visit_day = 'SAT'.
|
||||
ELSE.
|
||||
ev_visit_day = 'WED'.
|
||||
ENDIF.
|
||||
|
||||
ENDFUNCTION.
|
||||
49
tasks_gen/train/G1096/faulty/m4_adopt_review.func.abap
Normal file
49
tasks_gen/train/G1096/faulty/m4_adopt_review.func.abap
Normal file
@@ -0,0 +1,49 @@
|
||||
FUNCTION {{p}}adopt_review
|
||||
IMPORTING
|
||||
iv_species TYPE string
|
||||
iv_age_years TYPE i
|
||||
iv_housing TYPE string
|
||||
iv_garden TYPE abap_bool
|
||||
iv_pets TYPE i
|
||||
EXPORTING
|
||||
ev_deposit TYPE decfloat34
|
||||
ev_visit_day TYPE string
|
||||
RAISING
|
||||
{{p}}cx_adopt_reject.
|
||||
|
||||
IF iv_age_years < 18.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'TOO_YOUNG' ).
|
||||
ENDIF.
|
||||
|
||||
DATA lv_deposit TYPE decfloat34.
|
||||
CASE iv_species.
|
||||
WHEN 'DOG'.
|
||||
lv_deposit = 150.
|
||||
WHEN 'CAT'.
|
||||
lv_deposit = 80.
|
||||
WHEN 'RABBIT'.
|
||||
lv_deposit = 40.
|
||||
WHEN OTHERS.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'UNKNOWN_SPECIES' ).
|
||||
ENDCASE.
|
||||
|
||||
IF iv_species = 'DOG' AND iv_housing = 'FLAT' AND iv_garden = abap_false.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'NO_GARDEN' ).
|
||||
ENDIF.
|
||||
|
||||
IF iv_pets > 2.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'TOO_MANY_PETS' ).
|
||||
ENDIF.
|
||||
|
||||
IF iv_pets > 0.
|
||||
lv_deposit = lv_deposit + 12.
|
||||
ENDIF.
|
||||
ev_deposit = lv_deposit.
|
||||
|
||||
IF iv_garden = abap_false.
|
||||
ev_visit_day = 'SAT'.
|
||||
ELSE.
|
||||
ev_visit_day = 'WED'.
|
||||
ENDIF.
|
||||
|
||||
ENDFUNCTION.
|
||||
28
tasks_gen/train/G1096/generation.json
Normal file
28
tasks_gen/train/G1096/generation.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"id": "G1096",
|
||||
"pool": "train",
|
||||
"object_type": "FUNC",
|
||||
"category": "D",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "bundle",
|
||||
"errors": [
|
||||
"Too close to task G0127 (similarity spec 0.67, rules 0.60, names 1.00). Choose a different business topic and different object names."
|
||||
],
|
||||
"by_check": {
|
||||
"extra": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 100.0,
|
||||
"null": 0,
|
||||
"mutation": {
|
||||
"valid": 5,
|
||||
"killed": 5,
|
||||
"ok": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"accepted": true
|
||||
}
|
||||
131
tasks_gen/train/G1096/hidden/adopt_hidden.clas.abap
Normal file
131
tasks_gen/train/G1096/hidden/adopt_hidden.clas.abap
Normal file
@@ -0,0 +1,131 @@
|
||||
CLASS {{p}}adopt_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
TYPES: BEGIN OF ty_result,
|
||||
deposit TYPE decfloat34,
|
||||
visit_day TYPE string,
|
||||
reason TYPE string,
|
||||
END OF ty_result.
|
||||
|
||||
METHODS review
|
||||
IMPORTING iv_species TYPE string
|
||||
iv_age_years TYPE i
|
||||
iv_housing TYPE string
|
||||
iv_garden TYPE abap_bool
|
||||
iv_pets TYPE i
|
||||
RETURNING VALUE(rs_result) TYPE ty_result.
|
||||
|
||||
METHODS dog_deposit FOR TESTING.
|
||||
METHODS cat_deposit FOR TESTING.
|
||||
METHODS rabbit_deposit FOR TESTING.
|
||||
METHODS pet_surcharge FOR TESTING.
|
||||
METHODS pet_limit FOR TESTING.
|
||||
METHODS dog_flat_no_garden FOR TESTING.
|
||||
METHODS too_young FOR TESTING.
|
||||
METHODS age_limit FOR TESTING.
|
||||
METHODS unknown_species FOR TESTING.
|
||||
METHODS check_order FOR TESTING.
|
||||
METHODS rejected_unchanged FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}adopt_hidden IMPLEMENTATION.
|
||||
METHOD review.
|
||||
TRY.
|
||||
CALL FUNCTION '{{P}}ADOPT_REVIEW'
|
||||
EXPORTING
|
||||
iv_species = iv_species
|
||||
iv_age_years = iv_age_years
|
||||
iv_housing = iv_housing
|
||||
iv_garden = iv_garden
|
||||
iv_pets = iv_pets
|
||||
IMPORTING
|
||||
ev_deposit = rs_result-deposit
|
||||
ev_visit_day = rs_result-visit_day.
|
||||
CATCH {{p}}cx_adopt_reject INTO DATA(lo_error).
|
||||
rs_result-reason = lo_error->mv_reason.
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD dog_deposit.
|
||||
DATA(ls_result) = review( iv_species = `DOG` iv_age_years = 30 iv_housing = `HOUSE`
|
||||
iv_garden = abap_false iv_pets = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 150 ) act = ls_result-deposit ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `WED` act = ls_result-visit_day ).
|
||||
cl_abap_unit_assert=>assert_initial( ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD cat_deposit.
|
||||
DATA(ls_result) = review( iv_species = `CAT` iv_age_years = 25 iv_housing = `FLAT`
|
||||
iv_garden = abap_false iv_pets = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 80 ) act = ls_result-deposit ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `WED` act = ls_result-visit_day ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rabbit_deposit.
|
||||
DATA(ls_result) = review( iv_species = `RABBIT` iv_age_years = 20 iv_housing = `FLAT`
|
||||
iv_garden = abap_false iv_pets = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 40 ) act = ls_result-deposit ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `WED` act = ls_result-visit_day ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD pet_surcharge.
|
||||
DATA(ls_result) = review( iv_species = `DOG` iv_age_years = 40 iv_housing = `HOUSE`
|
||||
iv_garden = abap_true iv_pets = 2 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 162 ) act = ls_result-deposit ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `SAT` act = ls_result-visit_day ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD pet_limit.
|
||||
DATA(ls_result) = review( iv_species = `DOG` iv_age_years = 30 iv_housing = `HOUSE`
|
||||
iv_garden = abap_true iv_pets = 3 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `TOO_MANY_PETS` act = ls_result-reason ).
|
||||
cl_abap_unit_assert=>assert_initial( ls_result-deposit ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD dog_flat_no_garden.
|
||||
DATA(ls_result) = review( iv_species = `DOG` iv_age_years = 30 iv_housing = `FLAT`
|
||||
iv_garden = abap_false iv_pets = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `NO_GARDEN` act = ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD too_young.
|
||||
DATA(ls_result) = review( iv_species = `DOG` iv_age_years = 17 iv_housing = `HOUSE`
|
||||
iv_garden = abap_true iv_pets = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `TOO_YOUNG` act = ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD age_limit.
|
||||
DATA(ls_result) = review( iv_species = `DOG` iv_age_years = 18 iv_housing = `HOUSE`
|
||||
iv_garden = abap_true iv_pets = 0 ).
|
||||
cl_abap_unit_assert=>assert_initial( ls_result-reason ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 150 ) act = ls_result-deposit ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `SAT` act = ls_result-visit_day ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_species.
|
||||
DATA(ls_result) = review( iv_species = `BIRD` iv_age_years = 30 iv_housing = `HOUSE`
|
||||
iv_garden = abap_true iv_pets = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `UNKNOWN_SPECIES` act = ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_order.
|
||||
DATA(ls_first) = review( iv_species = `BIRD` iv_age_years = 17 iv_housing = `HOUSE`
|
||||
iv_garden = abap_true iv_pets = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `TOO_YOUNG` act = ls_first-reason ).
|
||||
DATA(ls_second) = review( iv_species = `BIRD` iv_age_years = 30 iv_housing = `HOUSE`
|
||||
iv_garden = abap_true iv_pets = 5 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `UNKNOWN_SPECIES` act = ls_second-reason ).
|
||||
DATA(ls_third) = review( iv_species = `DOG` iv_age_years = 30 iv_housing = `FLAT`
|
||||
iv_garden = abap_false iv_pets = 5 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `NO_GARDEN` act = ls_third-reason ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejected_unchanged.
|
||||
DATA(ls_result) = review( iv_species = `DOG` iv_age_years = 30 iv_housing = `FLAT`
|
||||
iv_garden = abap_false iv_pets = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `NO_GARDEN` act = ls_result-reason ).
|
||||
cl_abap_unit_assert=>assert_initial( ls_result-deposit ).
|
||||
cl_abap_unit_assert=>assert_initial( ls_result-visit_day ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
68
tasks_gen/train/G1096/mutation.json
Normal file
68
tasks_gen/train/G1096/mutation.json
Normal file
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"task": "G1096",
|
||||
"mutants": [
|
||||
{
|
||||
"object": "{{P}}ADOPT_REVIEW",
|
||||
"mutant": "line 30: AND -> OR (logic)",
|
||||
"status": "killed",
|
||||
"hidden": "8/11",
|
||||
"failed_tests": [
|
||||
"CAT_DEPOSIT",
|
||||
"DOG_DEPOSIT",
|
||||
"RABBIT_DEPOSIT"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}ADOPT_REVIEW",
|
||||
"mutant": "line 38: > -> <= (rel)",
|
||||
"status": "killed",
|
||||
"hidden": "6/11",
|
||||
"failed_tests": [
|
||||
"AGE_LIMIT",
|
||||
"CAT_DEPOSIT",
|
||||
"DOG_DEPOSIT",
|
||||
"PET_SURCHARGE",
|
||||
"RABBIT_DEPOSIT"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}ADOPT_REVIEW",
|
||||
"mutant": "line 39: + -> - (arith)",
|
||||
"status": "killed",
|
||||
"hidden": "10/11",
|
||||
"failed_tests": [
|
||||
"PET_SURCHARGE"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}ADOPT_REVIEW",
|
||||
"mutant": "line 43: = -> <> (eq)",
|
||||
"status": "killed",
|
||||
"hidden": "6/11",
|
||||
"failed_tests": [
|
||||
"AGE_LIMIT",
|
||||
"CAT_DEPOSIT",
|
||||
"DOG_DEPOSIT",
|
||||
"PET_SURCHARGE",
|
||||
"RABBIT_DEPOSIT"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}ADOPT_REVIEW",
|
||||
"mutant": "line 43: abap_true -> abap_false (bool)",
|
||||
"status": "killed",
|
||||
"hidden": "6/11",
|
||||
"failed_tests": [
|
||||
"AGE_LIMIT",
|
||||
"CAT_DEPOSIT",
|
||||
"DOG_DEPOSIT",
|
||||
"PET_SURCHARGE",
|
||||
"RABBIT_DEPOSIT"
|
||||
]
|
||||
}
|
||||
],
|
||||
"valid": 5,
|
||||
"killed": 5,
|
||||
"kill_rate": 1.0,
|
||||
"ok": true
|
||||
}
|
||||
49
tasks_gen/train/G1096/reference/adopt_review.func.abap
Normal file
49
tasks_gen/train/G1096/reference/adopt_review.func.abap
Normal file
@@ -0,0 +1,49 @@
|
||||
FUNCTION {{p}}adopt_review
|
||||
IMPORTING
|
||||
iv_species TYPE string
|
||||
iv_age_years TYPE i
|
||||
iv_housing TYPE string
|
||||
iv_garden TYPE abap_bool
|
||||
iv_pets TYPE i
|
||||
EXPORTING
|
||||
ev_deposit TYPE decfloat34
|
||||
ev_visit_day TYPE string
|
||||
RAISING
|
||||
{{p}}cx_adopt_reject.
|
||||
|
||||
IF iv_age_years < 18.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'TOO_YOUNG' ).
|
||||
ENDIF.
|
||||
|
||||
DATA lv_deposit TYPE decfloat34.
|
||||
CASE iv_species.
|
||||
WHEN 'DOG'.
|
||||
lv_deposit = 150.
|
||||
WHEN 'CAT'.
|
||||
lv_deposit = 80.
|
||||
WHEN 'RABBIT'.
|
||||
lv_deposit = 40.
|
||||
WHEN OTHERS.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'UNKNOWN_SPECIES' ).
|
||||
ENDCASE.
|
||||
|
||||
IF iv_species = 'DOG' AND iv_housing = 'FLAT' AND iv_garden = abap_false.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'NO_GARDEN' ).
|
||||
ENDIF.
|
||||
|
||||
IF iv_pets > 2.
|
||||
RAISE EXCEPTION NEW {{p}}cx_adopt_reject( iv_reason = 'TOO_MANY_PETS' ).
|
||||
ENDIF.
|
||||
|
||||
IF iv_pets > 0.
|
||||
lv_deposit = lv_deposit + 12.
|
||||
ENDIF.
|
||||
ev_deposit = lv_deposit.
|
||||
|
||||
IF iv_garden = abap_true.
|
||||
ev_visit_day = 'SAT'.
|
||||
ELSE.
|
||||
ev_visit_day = 'WED'.
|
||||
ENDIF.
|
||||
|
||||
ENDFUNCTION.
|
||||
76
tasks_gen/train/G1096/reference/adopt_test.clas.abap
Normal file
76
tasks_gen/train/G1096/reference/adopt_test.clas.abap
Normal file
@@ -0,0 +1,76 @@
|
||||
CLASS {{p}}adopt_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
TYPES: BEGIN OF ty_result,
|
||||
deposit TYPE decfloat34,
|
||||
visit_day TYPE string,
|
||||
reason TYPE string,
|
||||
END OF ty_result.
|
||||
|
||||
METHODS review
|
||||
IMPORTING iv_species TYPE string
|
||||
iv_age_years TYPE i
|
||||
iv_housing TYPE string
|
||||
iv_garden TYPE abap_bool
|
||||
iv_pets TYPE i
|
||||
RETURNING VALUE(rs_result) TYPE ty_result.
|
||||
|
||||
METHODS dog_deposit FOR TESTING.
|
||||
METHODS surcharge FOR TESTING.
|
||||
METHODS visit_day FOR TESTING.
|
||||
METHODS too_young FOR TESTING.
|
||||
METHODS no_garden FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}adopt_test IMPLEMENTATION.
|
||||
METHOD review.
|
||||
TRY.
|
||||
CALL FUNCTION '{{P}}ADOPT_REVIEW'
|
||||
EXPORTING
|
||||
iv_species = iv_species
|
||||
iv_age_years = iv_age_years
|
||||
iv_housing = iv_housing
|
||||
iv_garden = iv_garden
|
||||
iv_pets = iv_pets
|
||||
IMPORTING
|
||||
ev_deposit = rs_result-deposit
|
||||
ev_visit_day = rs_result-visit_day.
|
||||
CATCH {{p}}cx_adopt_reject INTO DATA(lo_error).
|
||||
rs_result-reason = lo_error->mv_reason.
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD dog_deposit.
|
||||
DATA(ls_result) = review( iv_species = `DOG` iv_age_years = 30 iv_housing = `HOUSE`
|
||||
iv_garden = abap_false iv_pets = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 150 ) act = ls_result-deposit ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD surcharge.
|
||||
DATA(ls_result) = review( iv_species = `CAT` iv_age_years = 25 iv_housing = `FLAT`
|
||||
iv_garden = abap_false iv_pets = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 92 ) act = ls_result-deposit ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD visit_day.
|
||||
DATA(ls_sat) = review( iv_species = `RABBIT` iv_age_years = 20 iv_housing = `HOUSE`
|
||||
iv_garden = abap_true iv_pets = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `SAT` act = ls_sat-visit_day ).
|
||||
DATA(ls_wed) = review( iv_species = `RABBIT` iv_age_years = 20 iv_housing = `FLAT`
|
||||
iv_garden = abap_false iv_pets = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `WED` act = ls_wed-visit_day ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD too_young.
|
||||
DATA(ls_result) = review( iv_species = `CAT` iv_age_years = 17 iv_housing = `HOUSE`
|
||||
iv_garden = abap_true iv_pets = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `TOO_YOUNG` act = ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD no_garden.
|
||||
DATA(ls_result) = review( iv_species = `DOG` iv_age_years = 30 iv_housing = `FLAT`
|
||||
iv_garden = abap_false iv_pets = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `NO_GARDEN` act = ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
21
tasks_gen/train/G1096/reference/cx_adopt_reject.clas.abap
Normal file
21
tasks_gen/train/G1096/reference/cx_adopt_reject.clas.abap
Normal file
@@ -0,0 +1,21 @@
|
||||
CLASS {{p}}cx_adopt_reject DEFINITION
|
||||
PUBLIC
|
||||
INHERITING FROM cx_static_check
|
||||
FINAL
|
||||
CREATE PUBLIC.
|
||||
|
||||
PUBLIC SECTION.
|
||||
DATA mv_reason TYPE string READ-ONLY.
|
||||
|
||||
METHODS constructor
|
||||
IMPORTING
|
||||
iv_reason TYPE string.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cx_adopt_reject IMPLEMENTATION.
|
||||
METHOD constructor.
|
||||
super->constructor( ).
|
||||
mv_reason = iv_reason.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
12
tasks_gen/train/G1096/seed/shelter_sample.func.abap
Normal file
12
tasks_gen/train/G1096/seed/shelter_sample.func.abap
Normal file
@@ -0,0 +1,12 @@
|
||||
FUNCTION {{p}}shelter_sample
|
||||
IMPORTING
|
||||
iv_species TYPE string
|
||||
EXPORTING
|
||||
ev_slots TYPE i.
|
||||
|
||||
ev_slots = 0.
|
||||
IF iv_species IS NOT INITIAL.
|
||||
ev_slots = 1.
|
||||
ENDIF.
|
||||
|
||||
ENDFUNCTION.
|
||||
65
tasks_gen/train/G1096/spec.md
Normal file
65
tasks_gen/train/G1096/spec.md
Normal file
@@ -0,0 +1,65 @@
|
||||
# 1. Goal
|
||||
An animal shelter checks an adoption application before it approves the
|
||||
adoption. The shelter office calls one function module for each application.
|
||||
The function module calculates the deposit and the visit day. If the shelter
|
||||
rejects the application, the function module raises a class-based exception.
|
||||
The exception carries the reason of the rejection.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- The function group {{P}}FG_SHELTER exists in package $TMP.
|
||||
- The function module {{P}}SHELTER_SAMPLE exists in this group. It is a sample
|
||||
module. Do not change it.
|
||||
- The shelter office calls {{P}}ADOPT_REVIEW for each application.
|
||||
- The shelter office catches the class-based exception {{P}}CX_ADOPT_REJECT
|
||||
and reads the reason of the rejection from the attribute MV_REASON.
|
||||
|
||||
# 4. Contract
|
||||
Create the global exception class {{P}}CX_ADOPT_REJECT in package $TMP.
|
||||
- It inherits from CX_STATIC_CHECK.
|
||||
- It has the public read-only attribute MV_REASON of type STRING.
|
||||
- It has a constructor with the importing parameter IV_REASON of type STRING.
|
||||
The constructor stores the value of IV_REASON in MV_REASON.
|
||||
|
||||
Create the function module {{P}}ADOPT_REVIEW in function group {{P}}FG_SHELTER
|
||||
with this interface:
|
||||
- IMPORTING iv_species TYPE string
|
||||
- IMPORTING iv_age_years TYPE i
|
||||
- IMPORTING iv_housing TYPE string
|
||||
- IMPORTING iv_garden TYPE abap_bool
|
||||
- IMPORTING iv_pets TYPE i
|
||||
- EXPORTING ev_deposit TYPE decfloat34
|
||||
- EXPORTING ev_visit_day TYPE string
|
||||
The function module raises the class-based exception {{P}}CX_ADOPT_REJECT.
|
||||
|
||||
# 5. Business rules
|
||||
1. Check the rules 2 to 5 in this order. Raise the exception with the given
|
||||
reason as soon as one check fails. Do not change EV_DEPOSIT or EV_VISIT_DAY
|
||||
in this case.
|
||||
2. If IV_AGE_YEARS is less than 18, the reason is 'TOO_YOUNG'.
|
||||
3. If IV_SPECIES is not 'DOG', not 'CAT' and not 'RABBIT', the reason is
|
||||
'UNKNOWN_SPECIES'.
|
||||
4. If IV_SPECIES is 'DOG' and IV_HOUSING is 'FLAT' and IV_GARDEN is false, the
|
||||
reason is 'NO_GARDEN'.
|
||||
5. If IV_PETS is greater than 2, the reason is 'TOO_MANY_PETS'.
|
||||
6. The deposit is 150.00 for 'DOG', 80.00 for 'CAT' and 40.00 for 'RABBIT'.
|
||||
7. If IV_PETS is greater than 0, add 12.00 to the deposit.
|
||||
8. The visit day is 'SAT' if IV_GARDEN is true. The visit day is 'WED' if
|
||||
IV_GARDEN is false.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: 8.16 (SAP_BASIS 816, ABAP Platform 2025).
|
||||
- Package $TMP. Do not use a transport.
|
||||
- Use class-based exceptions. Do not use classic exceptions. Do not use
|
||||
sy-subrc for the result of a check.
|
||||
- Coding standard: Clean ABAP.
|
||||
- Out of scope: do not change the function group {{P}}FG_SHELTER and the
|
||||
function module {{P}}SHELTER_SAMPLE.
|
||||
|
||||
# 7. Acceptance
|
||||
- The exception class {{P}}CX_ADOPT_REJECT and the function module
|
||||
{{P}}ADOPT_REVIEW are active and have no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write ABAP Unit tests for the function module in a global test class.
|
||||
104
tasks_gen/train/G1096/task.json
Normal file
104
tasks_gen/train/G1096/task.json
Normal file
@@ -0,0 +1,104 @@
|
||||
{
|
||||
"id": "G1096",
|
||||
"category": "D",
|
||||
"object_type": "FUNC",
|
||||
"difficulty": 2,
|
||||
"release_target": "v816",
|
||||
"expected_outcome": "implement",
|
||||
"budget": {
|
||||
"max_tool_calls": 60,
|
||||
"max_activations": 15
|
||||
},
|
||||
"seed": [
|
||||
{
|
||||
"type": "FUGR",
|
||||
"name": "{{P}}FG_SHELTER",
|
||||
"description": "Function group of the animal shelter"
|
||||
},
|
||||
{
|
||||
"type": "FUNC",
|
||||
"name": "{{P}}SHELTER_SAMPLE",
|
||||
"functionGroup": "{{P}}FG_SHELTER",
|
||||
"file": "seed/shelter_sample.func.abap",
|
||||
"description": "Sample module of the shelter"
|
||||
}
|
||||
],
|
||||
"contract": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CX_ADOPT_REJECT",
|
||||
"description": "Class-based exception that carries the rejection reason in MV_REASON"
|
||||
},
|
||||
{
|
||||
"type": "FUNC",
|
||||
"name": "{{P}}ADOPT_REVIEW",
|
||||
"functionGroup": "{{P}}FG_SHELTER",
|
||||
"params": [
|
||||
{
|
||||
"name": "iv_species",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "iv_age_years",
|
||||
"type": "i"
|
||||
},
|
||||
{
|
||||
"name": "iv_housing",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "iv_garden",
|
||||
"type": "abap_bool"
|
||||
},
|
||||
{
|
||||
"name": "iv_pets",
|
||||
"type": "i"
|
||||
},
|
||||
{
|
||||
"name": "ev_deposit",
|
||||
"type": "decfloat34"
|
||||
},
|
||||
{
|
||||
"name": "ev_visit_day",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"out_of_scope": [
|
||||
"{{P}}FG_SHELTER",
|
||||
"{{P}}SHELTER_SAMPLE"
|
||||
],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}ADOPT_HIDDEN",
|
||||
"file": "hidden/adopt_hidden.clas.abap",
|
||||
"description": "T14 hidden tests"
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CX_ADOPT_REJECT",
|
||||
"file": "reference/cx_adopt_reject.clas.abap",
|
||||
"description": "Class-based exception with the rejection reason"
|
||||
},
|
||||
{
|
||||
"type": "FUNC",
|
||||
"name": "{{P}}ADOPT_REVIEW",
|
||||
"functionGroup": "{{P}}FG_SHELTER",
|
||||
"file": "reference/adopt_review.func.abap",
|
||||
"description": "Adoption review module"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}ADOPT_TEST",
|
||||
"file": "reference/adopt_test.clas.abap",
|
||||
"description": "T14 own tests"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user