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,44 @@
{
"id": "G1117",
"pool": "train",
"object_type": "FUNC",
"category": "F",
"attempts": [
{
"stage": "bundle",
"errors": [
"Too close to task T13 (similarity spec 0.71, rules 0.64, names 0.33). Choose a different business topic and different object names.",
"Too close to task G0151 (similarity spec 0.72, rules 0.64, names 0.33). Choose a different business topic and different object names.",
"Too close to task T13 (similarity spec 0.71, rules 0.64, names 0.33). Choose a different business topic and different object names."
],
"by_check": {
"extra": 3
}
},
{
"stage": "bundle",
"errors": [
"Too close to task T13 (similarity spec 0.69, rules 0.61, names 0.33). Choose a different business topic and different object names.",
"Too close to task T13 (similarity spec 0.69, rules 0.61, names 0.33). Choose a different business topic and different object names."
],
"by_check": {
"extra": 2
}
},
{
"stage": "validate",
"oracle": 0,
"null": 0
},
{
"stage": "bundle",
"errors": [
"hidden/t21_hidden.clas.abap line 110: syntax error for release v758 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"call\""
],
"by_check": {
"abaplint": 1
}
}
],
"accepted": false
}

View File

@@ -0,0 +1,117 @@
CLASS {{p}}t21_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS call
IMPORTING iv_postcode TYPE string
iv_weight TYPE decfloat34
iv_express TYPE abap_bool DEFAULT abap_false
EXPORTING ev_tour TYPE string
ev_skip TYPE abap_bool
ev_fee TYPE decfloat34
ev_subrc TYPE sysubrc.
METHODS standard_fee FOR TESTING.
METHODS weight_surcharge FOR TESTING.
METHODS started_kilogram FOR TESTING.
METHODS heavy_tour FOR TESTING.
METHODS tour_boundary FOR TESTING.
METHODS express_surcharge FOR TESTING.
METHODS fee_cap FOR TESTING.
METHODS island_skip FOR TESTING.
METHODS unknown_zone FOR TESTING.
METHODS invalid_weight FOR TESTING.
ENDCLASS.
CLASS {{p}}t21_hidden IMPLEMENTATION.
METHOD call.
CALL FUNCTION '{{P}}PARCEL_FEE'
EXPORTING
iv_postcode = iv_postcode
iv_weight = iv_weight
iv_express = iv_express
IMPORTING
ev_tour = ev_tour
ev_skip = ev_skip
ev_fee = ev_fee
EXCEPTIONS
unknown_zone = 1
invalid_weight = 2
OTHERS = 3.
ev_subrc = sy-subrc.
ENDMETHOD.
METHOD standard_fee.
call( EXPORTING iv_postcode = `10115` iv_weight = 1
IMPORTING ev_tour = DATA(lv_tour) ev_skip = DATA(lv_skip) ev_fee = DATA(lv_fee) ).
cl_abap_unit_assert=>assert_equals( exp = `N` act = lv_tour ).
cl_abap_unit_assert=>assert_equals( exp = abap_false act = lv_skip ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '4.90' ) act = lv_fee ).
ENDMETHOD.
METHOD weight_surcharge.
call( EXPORTING iv_postcode = `20095` iv_weight = 3
IMPORTING ev_tour = DATA(lv_tour) ev_fee = DATA(lv_fee) ).
cl_abap_unit_assert=>assert_equals( exp = `W` act = lv_tour ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '6.20' ) act = lv_fee ).
ENDMETHOD.
METHOD started_kilogram.
call( EXPORTING iv_postcode = `40213` iv_weight = '3.01'
IMPORTING ev_tour = DATA(lv_tour) ev_fee = DATA(lv_fee) ).
cl_abap_unit_assert=>assert_equals( exp = `C` act = lv_tour ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '7.25' ) act = lv_fee ).
ENDMETHOD.
METHOD heavy_tour.
call( EXPORTING iv_postcode = `60311` iv_weight = '10.01'
IMPORTING ev_tour = DATA(lv_tour) ev_fee = DATA(lv_fee) ).
cl_abap_unit_assert=>assert_equals( exp = `EH` act = lv_tour ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '10.60' ) act = lv_fee ).
ENDMETHOD.
METHOD tour_boundary.
call( EXPORTING iv_postcode = `60311` iv_weight = 10
IMPORTING ev_tour = DATA(lv_tour) ev_fee = DATA(lv_fee) ).
cl_abap_unit_assert=>assert_equals( exp = `E` act = lv_tour ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '10.25' ) act = lv_fee ).
ENDMETHOD.
METHOD express_surcharge.
call( EXPORTING iv_postcode = `10115` iv_weight = 1 iv_express = abap_true
IMPORTING ev_tour = DATA(lv_tour) ev_skip = DATA(lv_skip) ev_fee = DATA(lv_fee) ).
cl_abap_unit_assert=>assert_equals( exp = `N` act = lv_tour ).
cl_abap_unit_assert=>assert_equals( exp = abap_false act = lv_skip ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '8.40' ) act = lv_fee ).
ENDMETHOD.
METHOD fee_cap.
call( EXPORTING iv_postcode = `60311` iv_weight = 60
IMPORTING ev_tour = DATA(lv_tour) ev_skip = DATA(lv_skip) ev_fee = DATA(lv_fee) ).
cl_abap_unit_assert=>assert_equals( exp = `EH` act = lv_tour ).
cl_abap_unit_assert=>assert_equals( exp = abap_false act = lv_skip ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 25 ) act = lv_fee ).
ENDMETHOD.
METHOD island_skip.
call( EXPORTING iv_postcode = `80331` iv_weight = 2
IMPORTING ev_tour = DATA(lv_tour) ev_skip = DATA(lv_skip) ev_fee = DATA(lv_fee) ).
cl_abap_unit_assert=>assert_equals( exp = `S` act = lv_tour ).
cl_abap_unit_assert=>assert_equals( exp = abap_true act = lv_skip ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_fee ).
ENDMETHOD.
METHOD unknown_zone.
call( EXPORTING iv_postcode = `XYZ` iv_weight = 1
IMPORTING ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
ENDMETHOD.
METHOD invalid_weight.
call( EXPORTING iv_postcode = `10115` iv_weight = 0
IMPORTING ev_subrc = DATA(lv_rc_zero) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_rc_zero ).
call( EXPORTING iv_postcode = `10115` iv_weight = -5
IMPORTING ev_subrc = DATA(lv_rc_neg) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_rc_neg ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,75 @@
{
"task": "T21",
"mutants": [
{
"object": "{{P}}PARCEL_FEE",
"mutant": "line 22: 4.9 -> 5.9 (const)",
"status": "killed",
"hidden": "9/10",
"failed_tests": [
"STANDARD_FEE"
]
},
{
"object": "{{P}}PARCEL_FEE",
"mutant": "line 30: > -> >= (rel)",
"status": "killed",
"hidden": "8/10",
"failed_tests": [
"HEAVY_TOUR",
"TOUR_BOUNDARY"
]
},
{
"object": "{{P}}PARCEL_FEE",
"mutant": "line 41: ceil -> floor",
"status": "killed",
"hidden": "7/10",
"failed_tests": [
"STARTED_KILOGRAM",
"HEAVY_TOUR",
"WEIGHT_SURCHARGE"
]
},
{
"object": "{{P}}PARCEL_FEE",
"mutant": "line 47: 3.5 -> 3.6 (const)",
"status": "killed",
"hidden": "8/10",
"failed_tests": [
"EXPRESS_SURCHARGE"
]
},
{
"object": "{{P}}PARCEL_FEE",
"mutant": "line 51: 25 -> 26 (const)",
"status": "killed",
"hidden": "9/10",
"failed_tests": [
"FEE_CAP"
]
},
{
"object": "{{P}}PARCEL_FEE",
"mutant": "line 54: abap_false -> abap_true (bool)",
"status": "killed",
"hidden": "8/10",
"failed_tests": [
"ISLAND_SKIP"
]
},
{
"object": "{{P}}PARCEL_FEE",
"mutant": "line 12: <= -> < (rel)",
"status": "killed",
"hidden": "9/10",
"failed_tests": [
"INVALID_WEIGHT"
]
}
],
"valid": 7,
"killed": 7,
"kill_rate": 1.0,
"ok": true
}

View File

@@ -0,0 +1,71 @@
FUNCTION {{p}}parcel_fee
IMPORTING
iv_postcode TYPE string
iv_weight TYPE decfloat34
iv_express TYPE abap_bool
EXPORTING
ev_tour TYPE string
ev_skip TYPE abap_bool
ev_fee TYPE decfloat34
EXCEPTIONS
unknown_zone
invalid_weight.
CONSTANTS lc_max_fee TYPE decfloat34 VALUE '25'.
CONSTANTS lc_express_fee TYPE decfloat34 VALUE '3.5'.
CONSTANTS lc_kg_fee TYPE decfloat34 VALUE '0.35'.
CONSTANTS lc_heavy_limit TYPE decfloat34 VALUE '10'.
IF iv_weight <= 0.
RAISE invalid_weight.
ENDIF.
CALL FUNCTION '{{P}}ZONE_LOOKUP'
EXPORTING
iv_postcode = iv_postcode
IMPORTING
ev_zone = DATA(lv_zone).
IF lv_zone IS INITIAL.
RAISE unknown_zone.
ENDIF.
ev_skip = abap_false.
ev_tour = lv_zone.
IF iv_weight > lc_heavy_limit.
ev_tour = |{ ev_tour }H|.
ENDIF.
CASE lv_zone.
WHEN 'N'.
ev_fee = 4.9.
WHEN 'W'.
ev_fee = 5.5.
WHEN 'C'.
ev_fee = 6.2.
WHEN 'E'.
ev_fee = 7.1.
WHEN 'S'.
ev_fee = 8.4.
ENDCASE.
DATA(lv_started_kg) = ceil( iv_weight ).
DATA(lv_extra_kg) = lv_started_kg - 1.
IF lv_extra_kg > 0.
ev_fee = ev_fee + lv_extra_kg * lc_kg_fee.
ENDIF.
IF iv_express = abap_true.
ev_fee = ev_fee + lc_express_fee.
ENDIF.
IF ev_fee > lc_max_fee.
ev_fee = lc_max_fee.
ENDIF.
IF lv_zone = 'S' AND iv_express = abap_false.
ev_skip = abap_true.
ev_fee = 0.
ENDIF.
ENDFUNCTION.

View File

@@ -0,0 +1,80 @@
CLASS {{p}}t21_test DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS fee_for
IMPORTING iv_postcode TYPE string
iv_weight TYPE decfloat34
iv_express TYPE abap_bool DEFAULT abap_false
EXPORTING ev_tour TYPE string
ev_skip TYPE abap_bool
ev_fee TYPE decfloat34.
METHODS standard_parcel FOR TESTING.
METHODS heavy_parcel FOR TESTING.
METHODS express_parcel FOR TESTING.
METHODS island_parcel FOR TESTING.
METHODS unknown_zone FOR TESTING.
ENDCLASS.
CLASS {{p}}t21_test IMPLEMENTATION.
METHOD fee_for.
CALL FUNCTION '{{P}}PARCEL_FEE'
EXPORTING
iv_postcode = iv_postcode
iv_weight = iv_weight
iv_express = iv_express
IMPORTING
ev_tour = ev_tour
ev_skip = ev_skip
ev_fee = ev_fee
EXCEPTIONS
unknown_zone = 1
invalid_weight = 2
OTHERS = 3.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
ENDMETHOD.
METHOD standard_parcel.
fee_for( EXPORTING iv_postcode = `20095` iv_weight = 3
IMPORTING ev_tour = DATA(lv_tour) ev_skip = DATA(lv_skip) ev_fee = DATA(lv_fee) ).
cl_abap_unit_assert=>assert_equals( exp = `W` act = lv_tour ).
cl_abap_unit_assert=>assert_equals( exp = abap_false act = lv_skip ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '6.20' ) act = lv_fee ).
ENDMETHOD.
METHOD heavy_parcel.
fee_for( EXPORTING iv_postcode = `60311` iv_weight = '10.01'
IMPORTING ev_tour = DATA(lv_tour) ev_fee = DATA(lv_fee) ).
cl_abap_unit_assert=>assert_equals( exp = `EH` act = lv_tour ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '10.60' ) act = lv_fee ).
ENDMETHOD.
METHOD express_parcel.
fee_for( EXPORTING iv_postcode = `10115` iv_weight = 1 iv_express = abap_true
IMPORTING ev_fee = DATA(lv_fee) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '8.40' ) act = lv_fee ).
ENDMETHOD.
METHOD island_parcel.
fee_for( EXPORTING iv_postcode = `80331` iv_weight = 2
IMPORTING ev_tour = DATA(lv_tour) ev_skip = DATA(lv_skip) ev_fee = DATA(lv_fee) ).
cl_abap_unit_assert=>assert_equals( exp = `S` act = lv_tour ).
cl_abap_unit_assert=>assert_equals( exp = abap_true act = lv_skip ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_fee ).
ENDMETHOD.
METHOD unknown_zone.
DATA lv_fee TYPE decfloat34.
CALL FUNCTION '{{P}}PARCEL_FEE'
EXPORTING
iv_postcode = `XYZ`
iv_weight = 1
CHANGING
cv_fee = lv_fee
EXCEPTIONS
unknown_zone = 1
invalid_weight = 2
OTHERS = 3.
cl_abap_unit_assert=>assert_equals( exp = 1 act = sy-subrc ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,31 @@
FUNCTION {{p}}zone_lookup
IMPORTING
iv_postcode TYPE string
EXPORTING
ev_zone TYPE string.
DATA lv_first TYPE c LENGTH 1.
CLEAR ev_zone.
IF iv_postcode IS INITIAL.
RETURN.
ENDIF.
lv_first = substring( val = iv_postcode off = 0 len = 1 ).
CASE lv_first.
WHEN '0' OR '1'.
ev_zone = 'N'.
WHEN '2' OR '3'.
ev_zone = 'W'.
WHEN '4' OR '5'.
ev_zone = 'C'.
WHEN '6' OR '7'.
ev_zone = 'E'.
WHEN '8' OR '9'.
ev_zone = 'S'.
WHEN OTHERS.
CLEAR ev_zone.
ENDCASE.
ENDFUNCTION.

View File

@@ -0,0 +1,58 @@
# 1. Goal
A regional parcel delivery company plans the tours of its vans. For each parcel
the dispatch program calls one function module. The function module finds the
delivery zone of the parcel, assigns the parcel to a tour, and calculates the
transport fee. The dispatch program adds the fee to the invoice of the parcel,
except when the skip flag is true.
# 2. Open questions
None.
# 3. Context
- Function group {{P}}FG_PARCEL exists in package $TMP.
- Function module {{P}}ZONE_LOOKUP exists in this group. It returns the
delivery zone of a postcode. Read its interface and its source before you use
it. The zone of a postcode is the value that {{P}}ZONE_LOOKUP returns for that
postcode.
- The dispatch program calls {{P}}PARCEL_FEE for each parcel. It adds ev_fee to
the invoice of the parcel. If ev_skip is true, it does not add the fee.
# 4. Contract
- Create the function module {{P}}PARCEL_FEE in function group {{P}}FG_PARCEL.
- Importing parameters:
- iv_postcode TYPE string
- iv_weight TYPE decfloat34 (the weight of the parcel in kilograms)
- iv_express TYPE abap_bool
- Exporting parameters:
- ev_tour TYPE string
- ev_skip TYPE abap_bool
- ev_fee TYPE decfloat34
- Exceptions: UNKNOWN_ZONE, INVALID_WEIGHT.
# 5. Business rules
1. If iv_weight is less than or equal to 0, raise the exception INVALID_WEIGHT.
2. Find the zone of iv_postcode with {{P}}ZONE_LOOKUP. If the zone is empty,
raise the exception UNKNOWN_ZONE.
3. Set the skip flag to false.
4. Set the tour to the zone. If iv_weight is more than 10, append the character
H to the tour.
5. The base fee of a zone is: N 4.90, W 5.50, C 6.20, E 7.10, S 8.40.
6. The weight surcharge is 0.35 for each started kilogram above the first
kilogram. A started kilogram is a kilogram that is not fully reached.
Examples: 1.00 kg gives 0.00, 1.01 kg gives 0.35, 3.00 kg gives 0.70,
3.01 kg gives 1.05.
7. The fee is the base fee of the zone plus the weight surcharge.
8. If iv_express is true, add 3.50 to the fee.
9. The fee of one parcel is never more than 25.00.
10. A parcel of zone S is collected only as an express parcel. If the zone is S
and iv_express is false, set the skip flag to true and set the fee to 0.00.
# 6. Constraints
- Release target: 8.16.
- Coding standards: Clean ABAP.
- Out of scope: do not change {{P}}ZONE_LOOKUP.
# 7. Acceptance
- The function module 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,88 @@
{
"id": "G1117",
"category": "F",
"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_PARCEL",
"description": "Parcel dispatch function group"
},
{
"type": "FUNC",
"name": "{{P}}ZONE_LOOKUP",
"functionGroup": "{{P}}FG_PARCEL",
"file": "seed/zone_lookup.func.abap",
"description": "Returns the delivery zone of a postcode"
}
],
"contract": [
{
"type": "FUNC",
"name": "{{P}}PARCEL_FEE",
"functionGroup": "{{P}}FG_PARCEL",
"params": [
{
"name": "iv_postcode",
"type": "string"
},
{
"name": "iv_weight",
"type": "decfloat34"
},
{
"name": "iv_express",
"type": "abap_bool"
},
{
"name": "ev_tour",
"type": "string"
},
{
"name": "ev_skip",
"type": "abap_bool"
},
{
"name": "ev_fee",
"type": "decfloat34"
}
]
}
],
"out_of_scope": [
"{{P}}ZONE_LOOKUP"
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}T21_HIDDEN",
"file": "hidden/t21_hidden.clas.abap",
"description": "T21 hidden tests"
}
],
"reference": [
{
"type": "FUNC",
"name": "{{P}}PARCEL_FEE",
"functionGroup": "{{P}}FG_PARCEL",
"file": "reference/parcel_fee.func.abap",
"description": "Parcel dispatch module"
},
{
"type": "CLAS",
"name": "{{P}}T21_TEST",
"file": "reference/t21_test.clas.abap",
"description": "T21 own tests"
}
],
"craft_checks": [
"method_length"
]
}