Stage 2 summary at 50 accepted trajectories

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Kral
2026-10-05 18:02:52 +02:00
parent 332fb4601d
commit 5bcd1bf9cd
1230 changed files with 77563 additions and 33 deletions

View File

@@ -0,0 +1,38 @@
{
"id": "G1142",
"pool": "train",
"object_type": "FUNC",
"category": "E",
"attempts": [
{
"stage": "validate",
"oracle": 85.0,
"null": 0
},
{
"stage": "bundle",
"errors": [
"hidden/hut_fee_hidden.clas.abap line 113: syntax error for release v758 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"call\""
],
"by_check": {
"abaplint": 1
}
},
{
"stage": "bundle",
"errors": [
"hidden/hut_fee_hidden.clas.abap line 113: syntax error for release v758 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"calc_fee\"",
"hidden/hut_fee_hidden.clas.abap line 116: syntax error for release v758 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"calc_fee\""
],
"by_check": {
"abaplint": 2
}
},
{
"stage": "validate",
"oracle": 81.7,
"null": 0
}
],
"accepted": false
}

View File

@@ -0,0 +1,141 @@
CLASS {{p}}hut_fee_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS fee_of
IMPORTING
iv_type TYPE string
iv_nights TYPE i
iv_member TYPE abap_bool DEFAULT abap_false
iv_breakfast TYPE abap_bool DEFAULT abap_false
RETURNING
VALUE(rv_fee) TYPE decfloat34.
METHODS rc_of
IMPORTING
iv_type TYPE string
iv_nights TYPE i
RETURNING
VALUE(rv_subrc) TYPE sysubrc.
METHODS adult_one_night FOR TESTING.
METHODS child_with_breakfast FOR TESTING.
METHODS member_halves_rate FOR TESTING.
METHODS dog_ignores_member FOR TESTING.
METHODS dog_gets_no_breakfast FOR TESTING.
METHODS unknown_type_as_adult FOR TESTING.
METHODS lower_case_type FOR TESTING.
METHODS three_nights_discount FOR TESTING.
METHODS seven_nights_discount FOR TESTING.
METHODS two_nights_no_discount FOR TESTING.
METHODS member_full_stay FOR TESTING.
METHODS invalid_nights_raise FOR TESTING.
ENDCLASS.
CLASS {{p}}hut_fee_hidden IMPLEMENTATION.
METHOD fee_of.
DATA lv_subrc TYPE sysubrc.
CALL FUNCTION '{{P}}HUT_FEE'
EXPORTING
iv_guest_type = iv_type
iv_nights = iv_nights
iv_member = iv_member
iv_breakfast = iv_breakfast
IMPORTING
ev_fee = rv_fee
EXCEPTIONS
invalid_nights = 1
OTHERS = 2.
lv_subrc = sy-subrc.
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
ENDMETHOD.
METHOD rc_of.
DATA lv_fee TYPE decfloat34.
CALL FUNCTION '{{P}}HUT_FEE'
EXPORTING
iv_guest_type = iv_type
iv_nights = iv_nights
IMPORTING
ev_fee = lv_fee
EXCEPTIONS
invalid_nights = 1
OTHERS = 2.
rv_subrc = sy-subrc.
ENDMETHOD.
METHOD adult_one_night.
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '28.00' )
act = fee_of( iv_type = `ADULT` iv_nights = 1 ) ).
ENDMETHOD.
METHOD child_with_breakfast.
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '47.00' )
act = fee_of( iv_type = `CHILD` iv_nights = 2 iv_breakfast = abap_true ) ).
ENDMETHOD.
METHOD member_halves_rate.
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '28.00' )
act = fee_of( iv_type = `ADULT` iv_nights = 2 iv_member = abap_true ) ).
ENDMETHOD.
METHOD dog_ignores_member.
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '10.00' )
act = fee_of( iv_type = `DOG` iv_nights = 2 iv_member = abap_true ) ).
ENDMETHOD.
METHOD dog_gets_no_breakfast.
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '10.00' )
act = fee_of( iv_type = `DOG` iv_nights = 2 iv_breakfast = abap_true ) ).
ENDMETHOD.
METHOD unknown_type_as_adult.
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '28.00' )
act = fee_of( iv_type = `STUDENT` iv_nights = 1 ) ).
ENDMETHOD.
METHOD lower_case_type.
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '7.00' )
act = fee_of( iv_type = `child` iv_nights = 1 iv_member = abap_true ) ).
ENDMETHOD.
METHOD three_nights_discount.
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '75.60' )
act = fee_of( iv_type = `ADULT` iv_nights = 3 ) ).
ENDMETHOD.
METHOD seven_nights_discount.
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '156.80' )
act = fee_of( iv_type = `ADULT` iv_nights = 7 ) ).
ENDMETHOD.
METHOD two_nights_no_discount.
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '56.00' )
act = fee_of( iv_type = `ADULT` iv_nights = 2 ) ).
ENDMETHOD.
METHOD member_full_stay.
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '144.90' )
act = fee_of( iv_type = `ADULT` iv_nights = 7 iv_member = abap_true iv_breakfast = abap_true ) ).
ENDMETHOD.
METHOD invalid_nights_raise.
cl_abap_unit_assert=>assert_equals(
exp = 1
act = rc_of( iv_type = `ADULT` iv_nights = 0 ) ).
cl_abap_unit_assert=>assert_equals(
exp = 1
act = rc_of( iv_type = `ADULT` iv_nights = -2 ) ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,76 @@
{
"task": "E21",
"mutants": [
{
"object": "{{P}}HUT_FEE",
"mutant": "line 43: c_member_share 50 -> 40 (const)",
"status": "killed",
"hidden": "9/12",
"failed_tests": [
"MEMBER_HALVES_RATE",
"LOWER_CASE_TYPE",
"MEMBER_FULL_STAY"
]
},
{
"object": "{{P}}HUT_FEE",
"mutant": "line 49: c_share_long 80 -> 70 (const)",
"status": "killed",
"hidden": "10/12",
"failed_tests": [
"SEVEN_NIGHTS_DISCOUNT",
"MEMBER_FULL_STAY"
]
},
{
"object": "{{P}}HUT_FEE",
"mutant": "line 50: c_stay_short 3 -> 4 (const)",
"status": "killed",
"hidden": "11/12",
"failed_tests": [
"THREE_NIGHTS_DISCOUNT"
]
},
{
"object": "{{P}}HUT_FEE",
"mutant": "line 42: remove AND lv_type <> 'DOG' (cond)",
"status": "killed",
"hidden": "11/12",
"failed_tests": [
"DOG_IGNORES_MEMBER"
]
},
{
"object": "{{P}}HUT_FEE",
"mutant": "line 31: remove to_upper (func)",
"status": "killed",
"hidden": "11/12",
"failed_tests": [
"LOWER_CASE_TYPE"
]
},
{
"object": "{{P}}HUT_FEE",
"mutant": "line 55: c_breakfast 9.50 -> 8.50 (const)",
"status": "killed",
"hidden": "10/12",
"failed_tests": [
"CHILD_WITH_BREAKFAST",
"MEMBER_FULL_STAY"
]
},
{
"object": "{{P}}HUT_FEE",
"mutant": "line 54: remove ( lv_type = 'ADULT' OR lv_type = 'CHILD' ) (cond)",
"status": "killed",
"hidden": "11/12",
"failed_tests": [
"DOG_GETS_NO_BREAKFAST"
]
}
],
"valid": 7,
"killed": 7,
"kill_rate": 1.0,
"ok": true
}

View File

@@ -0,0 +1,59 @@
FUNCTION {{p}}hut_fee
IMPORTING
iv_guest_type TYPE string
iv_nights TYPE i
iv_member TYPE abap_bool
iv_breakfast TYPE abap_bool
EXPORTING
ev_fee TYPE decfloat34
EXCEPTIONS
invalid_nights.
CONSTANTS: c_rate_adult TYPE p LENGTH 8 DECIMALS 2 VALUE '28.00',
c_rate_child TYPE p LENGTH 8 DECIMALS 2 VALUE '14.00',
c_rate_dog TYPE p LENGTH 8 DECIMALS 2 VALUE '5.00',
c_breakfast TYPE p LENGTH 8 DECIMALS 2 VALUE '9.50',
c_member_share TYPE i VALUE 50,
c_stay_short TYPE i VALUE 3,
c_stay_long TYPE i VALUE 7,
c_share_short TYPE i VALUE 90,
c_share_long TYPE i VALUE 80.
DATA: lv_type TYPE string,
lv_rate TYPE p LENGTH 8 DECIMALS 2,
lv_fee TYPE p LENGTH 10 DECIMALS 2.
ev_fee = 0.
IF iv_nights < 1.
RAISE invalid_nights.
ENDIF.
lv_type = to_upper( iv_guest_type ).
CASE lv_type.
WHEN 'CHILD'.
lv_rate = c_rate_child.
WHEN 'DOG'.
lv_rate = c_rate_dog.
WHEN OTHERS.
lv_rate = c_rate_adult.
ENDCASE.
IF iv_member = abap_true AND lv_type <> 'DOG'.
lv_rate = lv_rate * c_member_share / 100.
ENDIF.
lv_fee = lv_rate * iv_nights.
IF iv_nights >= c_stay_long.
lv_fee = lv_fee * c_share_long / 100.
ELSEIF iv_nights >= c_stay_short.
lv_fee = lv_fee * c_share_short / 100.
ENDIF.
IF iv_breakfast = abap_true AND ( lv_type = 'ADULT' OR lv_type = 'CHILD' ).
lv_fee = lv_fee + c_breakfast * iv_nights.
ENDIF.
ev_fee = lv_fee.
ENDFUNCTION.

View File

@@ -0,0 +1,89 @@
CLASS {{p}}hut_fee_test DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS fee_of
IMPORTING
iv_type TYPE string
iv_nights TYPE i
iv_member TYPE abap_bool DEFAULT abap_false
iv_breakfast TYPE abap_bool DEFAULT abap_false
RETURNING
VALUE(rv_fee) TYPE decfloat34.
METHODS adult_rate FOR TESTING.
METHODS child_with_breakfast FOR TESTING.
METHODS member_share FOR TESTING.
METHODS dog_rules FOR TESTING.
METHODS stay_discount FOR TESTING.
METHODS invalid_nights FOR TESTING.
ENDCLASS.
CLASS {{p}}hut_fee_test IMPLEMENTATION.
METHOD fee_of.
DATA lv_subrc TYPE sysubrc.
CALL FUNCTION '{{P}}HUT_FEE'
EXPORTING
iv_guest_type = iv_type
iv_nights = iv_nights
iv_member = iv_member
iv_breakfast = iv_breakfast
IMPORTING
ev_fee = rv_fee
EXCEPTIONS
invalid_nights = 1
OTHERS = 2.
lv_subrc = sy-subrc.
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
ENDMETHOD.
METHOD adult_rate.
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '28.00' )
act = fee_of( iv_type = `ADULT` iv_nights = 1 ) ).
ENDMETHOD.
METHOD child_with_breakfast.
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '47.00' )
act = fee_of( iv_type = `CHILD` iv_nights = 2 iv_breakfast = abap_true ) ).
ENDMETHOD.
METHOD member_share.
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '28.00' )
act = fee_of( iv_type = `ADULT` iv_nights = 2 iv_member = abap_true ) ).
ENDMETHOD.
METHOD dog_rules.
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '10.00' )
act = fee_of( iv_type = `DOG` iv_nights = 2 iv_member = abap_true iv_breakfast = abap_true ) ).
ENDMETHOD.
METHOD stay_discount.
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '75.60' )
act = fee_of( iv_type = `ADULT` iv_nights = 3 ) ).
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '156.80' )
act = fee_of( iv_type = `ADULT` iv_nights = 7 ) ).
ENDMETHOD.
METHOD invalid_nights.
DATA lv_fee TYPE decfloat34.
DATA lv_subrc TYPE sysubrc.
CALL FUNCTION '{{P}}HUT_FEE'
EXPORTING
iv_guest_type = `ADULT`
iv_nights = 0
IMPORTING
ev_fee = lv_fee
EXCEPTIONS
invalid_nights = 1
OTHERS = 2.
lv_subrc = sy-subrc.
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_subrc ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,67 @@
FUNCTION {{p}}hut_fee
IMPORTING
iv_guest_type TYPE string
iv_nights TYPE i
iv_member TYPE abap_bool
iv_breakfast TYPE abap_bool
EXPORTING
ev_fee TYPE decfloat34
EXCEPTIONS
invalid_nights.
* Fee calculation of the alpine hut Alpenrose.
* Written in 2009. It works, so nobody touched it since then.
DATA: lv_type TYPE string,
lv_rate TYPE p LENGTH 8 DECIMALS 2,
lv_room TYPE p LENGTH 10 DECIMALS 2,
lv_bf TYPE p LENGTH 10 DECIMALS 2,
lv_price TYPE p LENGTH 8 DECIMALS 2.
ev_fee = 0.
lv_type = iv_guest_type.
TRANSLATE lv_type TO UPPER CASE.
lv_price = '9.50'.
IF iv_nights <= 0.
RAISE invalid_nights.
ELSE.
IF lv_type = 'ADULT'.
lv_rate = '28.00'.
IF iv_member = 'X'.
lv_rate = lv_rate / 2.
ENDIF.
ELSEIF lv_type = 'CHILD'.
lv_rate = '14.00'.
IF iv_member = 'X'.
lv_rate = lv_rate / 2.
ENDIF.
ELSEIF lv_type = 'DOG'.
lv_rate = '5.00'.
ELSE.
lv_rate = '28.00'.
IF iv_member = 'X'.
lv_rate = lv_rate / 2.
ENDIF.
ENDIF.
lv_room = lv_rate * iv_nights.
IF iv_nights >= 7.
lv_room = lv_room * 80 / 100.
ELSEIF iv_nights >= 3.
lv_room = lv_room * 90 / 100.
ENDIF.
lv_bf = 0.
IF iv_breakfast = 'X'.
IF lv_type = 'ADULT' OR lv_type = 'CHILD'.
lv_bf = lv_price * iv_nights.
ENDIF.
ENDIF.
lv_room = lv_room + lv_bf.
ev_fee = lv_room.
ENDIF.
ENDFUNCTION.

View File

@@ -0,0 +1,48 @@
# 1. Goal
Refactor the legacy function module {{P}}HUT_FEE in function group {{P}}FG_HUT.
The module calculates the fee of a stay in the alpine hut Alpenrose. The hut
keeper calls the module for each booking. The behavior of the module must stay
exactly the same. Improve the internal quality: remove the duplicated code,
reduce the nesting depth, use meaningful names, replace the magic numbers with
constants, and keep the module short and readable.
# 2. Open questions
None.
# 3. Context
- Function group {{P}}FG_HUT exists in package $TMP.
- Function module {{P}}HUT_FEE exists in this group. It is active and it is the
legacy implementation of the hut fee.
- The booking program of the hut calls {{P}}HUT_FEE. The call must not change.
- The legacy source is the only description of the fee rules. Read it.
# 4. Contract
- Refactor the existing function module {{P}}HUT_FEE in function group
{{P}}FG_HUT. The name of the module stays the same.
- The interface stays exactly the same:
- importing iv_guest_type type string
- importing iv_nights type i
- importing iv_member type abap_bool
- importing iv_breakfast type abap_bool
- exporting ev_fee type decfloat34
- exception invalid_nights
- Do not add, remove, or rename a parameter. Do not add another exception.
# 5. Business rules
The legacy implementation of {{P}}HUT_FEE is the specification of the business
rules. The behavior must not change. Keep every rate, every discount, every
special case, and every exception of the legacy source exactly as it is,
including the rules for the guest types, for members, for breakfast, and for
long stays.
# 6. Constraints
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
- Coding standards: Clean ABAP. Keep {{P}}HUT_FEE below 40 statements. Do not
produce an ATC priority 1 or priority 2 finding.
- Out of scope: do not change function group {{P}}FG_HUT. Do not change the
public interface of {{P}}HUT_FEE. Do not add a new function module.
# 7. Acceptance
- {{P}}HUT_FEE is active and has no syntax error.
- The hidden tests pass.
- Write ABAP Unit tests for the function module in a global test class.

View File

@@ -0,0 +1,85 @@
{
"id": "G1142",
"category": "E",
"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_HUT",
"description": "Function group of the alpine hut fee"
},
{
"type": "FUNC",
"name": "{{P}}HUT_FEE",
"functionGroup": "{{P}}FG_HUT",
"file": "seed/hut_fee.func.abap",
"description": "Legacy fee module of the alpine hut"
}
],
"contract": [
{
"type": "FUNC",
"name": "{{P}}HUT_FEE",
"functionGroup": "{{P}}FG_HUT",
"params": [
{
"name": "iv_guest_type",
"type": "string"
},
{
"name": "iv_nights",
"type": "i"
},
{
"name": "iv_member",
"type": "abap_bool"
},
{
"name": "iv_breakfast",
"type": "abap_bool"
},
{
"name": "ev_fee",
"type": "decfloat34"
}
]
}
],
"out_of_scope": [
"{{P}}FG_HUT"
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}HUT_FEE_HIDDEN",
"file": "hidden/hut_fee_hidden.clas.abap",
"description": "Hidden tests for the hut fee"
}
],
"reference": [
{
"type": "FUNC",
"name": "{{P}}HUT_FEE",
"functionGroup": "{{P}}FG_HUT",
"file": "reference/hut_fee.func.abap",
"description": "Refactored fee module of the alpine hut"
},
{
"type": "CLAS",
"name": "{{P}}HUT_FEE_TEST",
"file": "reference/hut_fee_test.clas.abap",
"description": "Own tests of the hut fee"
}
],
"craft_checks": [
"method_length",
"nesting_depth"
]
}