Generator: pilot analysis and fixes; G0002-G0021 tasks; handover notes merged
- Static bundle checks (name length, seed type, reserved words, contract test classes, testclasses_file), local abaplint parser check before SAP, max_tokens, robust JSON parse - Runner: G2 for CDS views with parameters, contract_check detail in report - G0020 and G0013 fixed by review and revalidated (oracle 100, null 0) - Pilot results in docs/faz1-tasarim.md 11e; handover notes merged into CLAUDE.md and docs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
30
tasks_gen/eval/G0006/generation.json
Normal file
30
tasks_gen/eval/G0006/generation.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"id": "G0006",
|
||||
"pool": "eval",
|
||||
"object_type": "CLAS",
|
||||
"category": "E",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": null,
|
||||
"null": null
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": null,
|
||||
"null": null
|
||||
},
|
||||
{
|
||||
"stage": "bundle",
|
||||
"errors": [
|
||||
"invalid JSON: Expecting value: line 1 column 1 (char 0)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": null,
|
||||
"null": null
|
||||
}
|
||||
],
|
||||
"accepted": false
|
||||
}
|
||||
154
tasks_gen/eval/G0006/hidden/t02_hidden.clas.abap
Normal file
154
tasks_gen/eval/G0006/hidden/t02_hidden.clas.abap
Normal file
@@ -0,0 +1,154 @@
|
||||
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}}freight_calculator.
|
||||
|
||||
METHODS setup.
|
||||
METHODS assert_calculation
|
||||
IMPORTING iv_weight_kg TYPE p LENGTH 8 DECIMALS 2
|
||||
iv_zone TYPE string
|
||||
iv_express TYPE abap_bool DEFAULT abap_false
|
||||
is_expected TYPE {{p}}freight_calculator=>ty_result.
|
||||
|
||||
METHODS standard_parcel FOR TESTING.
|
||||
METHODS express_parcel FOR TESTING.
|
||||
METHODS zone_normalization FOR TESTING.
|
||||
METHODS rounding_half_up FOR TESTING.
|
||||
METHODS zero_weight FOR TESTING.
|
||||
METHODS negative_weight FOR TESTING.
|
||||
METHODS unknown_zone FOR TESTING.
|
||||
METHODS weight_error_wins FOR TESTING.
|
||||
METHODS supported_zones FOR TESTING.
|
||||
METHODS unsupported_zones FOR TESTING.
|
||||
METHODS all_rates FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t02_hidden IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}freight_calculator( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD assert_calculation.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = is_expected
|
||||
act = mo_cut->calculate( iv_weight_kg = iv_weight_kg
|
||||
iv_zone = iv_zone
|
||||
iv_express = iv_express )
|
||||
msg = |zone { iv_zone }| ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD standard_parcel.
|
||||
assert_calculation(
|
||||
iv_weight_kg = '10.00'
|
||||
iv_zone = `DE`
|
||||
is_expected = VALUE #( status = {{p}}freight_calculator=>c_status-ok
|
||||
base = '45.00'
|
||||
surcharge = '0.00'
|
||||
total = '45.00' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD express_parcel.
|
||||
assert_calculation(
|
||||
iv_weight_kg = '10.00'
|
||||
iv_zone = `DE`
|
||||
iv_express = abap_true
|
||||
is_expected = VALUE #( status = {{p}}freight_calculator=>c_status-ok
|
||||
base = '45.00'
|
||||
surcharge = '11.25'
|
||||
total = '56.25' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zone_normalization.
|
||||
assert_calculation(
|
||||
iv_weight_kg = '5.00'
|
||||
iv_zone = ` ch `
|
||||
is_expected = VALUE #( status = {{p}}freight_calculator=>c_status-ok
|
||||
base = '39.00'
|
||||
total = '39.00' ) ).
|
||||
assert_calculation(
|
||||
iv_weight_kg = '5.00'
|
||||
iv_zone = `de`
|
||||
is_expected = VALUE #( status = {{p}}freight_calculator=>c_status-ok
|
||||
base = '22.50'
|
||||
total = '22.50' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rounding_half_up.
|
||||
assert_calculation(
|
||||
iv_weight_kg = '3.33'
|
||||
iv_zone = `DE`
|
||||
iv_express = abap_true
|
||||
is_expected = VALUE #( status = {{p}}freight_calculator=>c_status-ok
|
||||
base = '14.99'
|
||||
surcharge = '3.75'
|
||||
total = '18.74' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_weight.
|
||||
assert_calculation(
|
||||
iv_weight_kg = '0.00'
|
||||
iv_zone = `DE`
|
||||
is_expected = VALUE #( status = {{p}}freight_calculator=>c_status-weight ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD negative_weight.
|
||||
assert_calculation(
|
||||
iv_weight_kg = '-2.50'
|
||||
iv_zone = `DE`
|
||||
iv_express = abap_true
|
||||
is_expected = VALUE #( status = {{p}}freight_calculator=>c_status-weight ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_zone.
|
||||
assert_calculation(
|
||||
iv_weight_kg = '5.00'
|
||||
iv_zone = `XX`
|
||||
is_expected = VALUE #( status = {{p}}freight_calculator=>c_status-zone ) ).
|
||||
assert_calculation(
|
||||
iv_weight_kg = '5.00'
|
||||
iv_zone = `DEU`
|
||||
is_expected = VALUE #( status = {{p}}freight_calculator=>c_status-zone ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD weight_error_wins.
|
||||
assert_calculation(
|
||||
iv_weight_kg = '0.00'
|
||||
iv_zone = `XX`
|
||||
is_expected = VALUE #( status = {{p}}freight_calculator=>c_status-weight ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD supported_zones.
|
||||
cl_abap_unit_assert=>assert_equals( exp = abap_true act = mo_cut->is_zone_supported( `de` ) msg = `de` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = abap_true act = mo_cut->is_zone_supported( ` DE ` ) msg = ` DE ` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = abap_true act = mo_cut->is_zone_supported( `at` ) msg = `at` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = abap_true act = mo_cut->is_zone_supported( `es` ) msg = `es` ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unsupported_zones.
|
||||
DATA lv_empty TYPE string.
|
||||
cl_abap_unit_assert=>assert_equals( exp = abap_false act = mo_cut->is_zone_supported( `XX` ) msg = `XX` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = abap_false act = mo_cut->is_zone_supported( lv_empty ) msg = `empty` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = abap_false act = mo_cut->is_zone_supported( ` ` ) msg = `blanks` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = abap_false act = mo_cut->is_zone_supported( `DEU` ) msg = `DEU` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = abap_false act = mo_cut->is_zone_supported( `DE1` ) msg = `DE1` ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD all_rates.
|
||||
assert_calculation( iv_weight_kg = '1.00' iv_zone = `DE`
|
||||
is_expected = VALUE #( status = {{p}}freight_calculator=>c_status-ok base = '4.50' total = '4.50' ) ).
|
||||
assert_calculation( iv_weight_kg = '1.00' iv_zone = `AT`
|
||||
is_expected = VALUE #( status = {{p}}freight_calculator=>c_status-ok base = '5.20' total = '5.20' ) ).
|
||||
assert_calculation( iv_weight_kg = '1.00' iv_zone = `CH`
|
||||
is_expected = VALUE #( status = {{p}}freight_calculator=>c_status-ok base = '7.80' total = '7.80' ) ).
|
||||
assert_calculation( iv_weight_kg = '1.00' iv_zone = `FR`
|
||||
is_expected = VALUE #( status = {{p}}freight_calculator=>c_status-ok base = '6.40' total = '6.40' ) ).
|
||||
assert_calculation( iv_weight_kg = '1.00' iv_zone = `NL`
|
||||
is_expected = VALUE #( status = {{p}}freight_calculator=>c_status-ok base = '4.90' total = '4.90' ) ).
|
||||
assert_calculation( iv_weight_kg = '1.00' iv_zone = `PL`
|
||||
is_expected = VALUE #( status = {{p}}freight_calculator=>c_status-ok base = '5.10' total = '5.10' ) ).
|
||||
assert_calculation( iv_weight_kg = '1.00' iv_zone = `ES`
|
||||
is_expected = VALUE #( status = {{p}}freight_calculator=>c_status-ok base = '6.90' total = '6.90' ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
130
tasks_gen/eval/G0006/reference/freight_calculator.clas.abap
Normal file
130
tasks_gen/eval/G0006/reference/freight_calculator.clas.abap
Normal file
@@ -0,0 +1,130 @@
|
||||
CLASS {{p}}freight_calculator DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
BEGIN OF ty_result,
|
||||
status TYPE c LENGTH 10,
|
||||
base TYPE p LENGTH 9 DECIMALS 2,
|
||||
surcharge TYPE p LENGTH 9 DECIMALS 2,
|
||||
total TYPE p LENGTH 9 DECIMALS 2,
|
||||
END OF ty_result.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_status,
|
||||
ok TYPE c LENGTH 10 VALUE 'OK',
|
||||
weight TYPE c LENGTH 10 VALUE 'WEIGHT',
|
||||
zone TYPE c LENGTH 10 VALUE 'ZONE',
|
||||
END OF c_status.
|
||||
|
||||
METHODS calculate
|
||||
IMPORTING
|
||||
iv_weight_kg TYPE p LENGTH 8 DECIMALS 2
|
||||
iv_zone TYPE string
|
||||
iv_express TYPE abap_bool DEFAULT abap_false
|
||||
RETURNING
|
||||
VALUE(rs_result) TYPE ty_result.
|
||||
|
||||
METHODS is_zone_supported
|
||||
IMPORTING
|
||||
iv_zone TYPE string
|
||||
RETURNING
|
||||
VALUE(rv_supported) TYPE abap_bool.
|
||||
|
||||
PRIVATE SECTION.
|
||||
TYPES:
|
||||
BEGIN OF ty_rate,
|
||||
zone TYPE c LENGTH 2,
|
||||
rate TYPE p LENGTH 6 DECIMALS 2,
|
||||
END OF ty_rate,
|
||||
tt_rate TYPE HASHED TABLE OF ty_rate WITH UNIQUE KEY zone.
|
||||
|
||||
CONSTANTS c_express_share TYPE p LENGTH 5 DECIMALS 2 VALUE '0.25'.
|
||||
|
||||
METHODS normalize_zone
|
||||
IMPORTING iv_zone TYPE string
|
||||
RETURNING VALUE(rv_zone) TYPE string.
|
||||
METHODS rates
|
||||
RETURNING VALUE(rt_rate) TYPE tt_rate.
|
||||
METHODS rate_for_zone
|
||||
IMPORTING iv_zone TYPE string
|
||||
RETURNING VALUE(rv_rate) TYPE p LENGTH 6 DECIMALS 2.
|
||||
METHODS empty_result
|
||||
IMPORTING iv_status TYPE c LENGTH 10
|
||||
RETURNING VALUE(rs_result) TYPE ty_result.
|
||||
METHODS base_amount
|
||||
IMPORTING iv_rate TYPE p LENGTH 6 DECIMALS 2
|
||||
iv_weight_kg TYPE p LENGTH 8 DECIMALS 2
|
||||
RETURNING VALUE(rv_base) TYPE p LENGTH 9 DECIMALS 2.
|
||||
METHODS surcharge_amount
|
||||
IMPORTING iv_base TYPE p LENGTH 9 DECIMALS 2
|
||||
iv_express TYPE abap_bool
|
||||
RETURNING VALUE(rv_surcharge) TYPE p LENGTH 9 DECIMALS 2.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}freight_calculator IMPLEMENTATION.
|
||||
METHOD calculate.
|
||||
DATA(lv_zone) = normalize_zone( iv_zone ).
|
||||
|
||||
IF iv_weight_kg <= 0.
|
||||
rs_result = empty_result( c_status-weight ).
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
IF is_zone_supported( lv_zone ) = abap_false.
|
||||
rs_result = empty_result( c_status-zone ).
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
rs_result-base = base_amount( iv_rate = rate_for_zone( lv_zone )
|
||||
iv_weight_kg = iv_weight_kg ).
|
||||
rs_result-surcharge = surcharge_amount( iv_base = rs_result-base
|
||||
iv_express = iv_express ).
|
||||
rs_result-total = rs_result-base + rs_result-surcharge.
|
||||
rs_result-status = c_status-ok.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD is_zone_supported.
|
||||
DATA(lv_zone) = normalize_zone( iv_zone ).
|
||||
DATA(lt_rate) = rates( ).
|
||||
rv_supported = xsdbool( line_exists( lt_rate[ zone = lv_zone ] ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD normalize_zone.
|
||||
rv_zone = to_upper( replace( val = iv_zone sub = ` ` with = `` occ = 0 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rates.
|
||||
rt_rate = VALUE #( ( zone = 'DE' rate = '4.50' )
|
||||
( zone = 'AT' rate = '5.20' )
|
||||
( zone = 'CH' rate = '7.80' )
|
||||
( zone = 'FR' rate = '6.40' )
|
||||
( zone = 'NL' rate = '4.90' )
|
||||
( zone = 'PL' rate = '5.10' )
|
||||
( zone = 'ES' rate = '6.90' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rate_for_zone.
|
||||
DATA(lt_rate) = rates( ).
|
||||
READ TABLE lt_rate WITH TABLE KEY zone = iv_zone INTO DATA(ls_rate).
|
||||
rv_rate = ls_rate-rate.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD empty_result.
|
||||
rs_result = VALUE #( status = iv_status ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD base_amount.
|
||||
DATA lv_amount TYPE p LENGTH 13 DECIMALS 4.
|
||||
lv_amount = iv_rate * iv_weight_kg.
|
||||
rv_base = round( val = lv_amount dec = 2 ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD surcharge_amount.
|
||||
IF iv_express = abap_false.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
DATA lv_amount TYPE p LENGTH 13 DECIMALS 4.
|
||||
lv_amount = iv_base * c_express_share.
|
||||
rv_surcharge = round( val = lv_amount dec = 2 ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
@@ -0,0 +1,56 @@
|
||||
CLASS ltc_freight_calculator DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}freight_calculator.
|
||||
METHODS setup.
|
||||
METHODS base_parcel FOR TESTING.
|
||||
METHODS express_parcel FOR TESTING.
|
||||
METHODS zone_is_normalized FOR TESTING.
|
||||
METHODS weight_error FOR TESTING.
|
||||
METHODS unknown_zone FOR TESTING.
|
||||
METHODS zone_support FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_freight_calculator IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}freight_calculator( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD base_parcel.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = VALUE {{p}}freight_calculator=>ty_result( status = 'OK' base = '45.00' total = '45.00' )
|
||||
act = mo_cut->calculate( iv_weight_kg = '10.00' iv_zone = `DE` ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD express_parcel.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = VALUE {{p}}freight_calculator=>ty_result( status = 'OK'
|
||||
base = '45.00'
|
||||
surcharge = '11.25'
|
||||
total = '56.25' )
|
||||
act = mo_cut->calculate( iv_weight_kg = '10.00' iv_zone = `DE` iv_express = abap_true ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zone_is_normalized.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = VALUE {{p}}freight_calculator=>ty_result( status = 'OK' base = '39.00' total = '39.00' )
|
||||
act = mo_cut->calculate( iv_weight_kg = '5.00' iv_zone = ` ch ` ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD weight_error.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = VALUE {{p}}freight_calculator=>ty_result( status = 'WEIGHT' )
|
||||
act = mo_cut->calculate( iv_weight_kg = '0.00' iv_zone = `DE` ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_zone.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = VALUE {{p}}freight_calculator=>ty_result( status = 'ZONE' )
|
||||
act = mo_cut->calculate( iv_weight_kg = '5.00' iv_zone = `XX` ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zone_support.
|
||||
cl_abap_unit_assert=>assert_true( mo_cut->is_zone_supported( `de` ) ).
|
||||
cl_abap_unit_assert=>assert_false( mo_cut->is_zone_supported( `XX` ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
106
tasks_gen/eval/G0006/seed/freight_calculator.clas.abap
Normal file
106
tasks_gen/eval/G0006/seed/freight_calculator.clas.abap
Normal file
@@ -0,0 +1,106 @@
|
||||
CLASS {{p}}freight_calculator DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
BEGIN OF ty_result,
|
||||
status TYPE c LENGTH 10,
|
||||
base TYPE p LENGTH 9 DECIMALS 2,
|
||||
surcharge TYPE p LENGTH 9 DECIMALS 2,
|
||||
total TYPE p LENGTH 9 DECIMALS 2,
|
||||
END OF ty_result.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_status,
|
||||
ok TYPE c LENGTH 10 VALUE 'OK',
|
||||
weight TYPE c LENGTH 10 VALUE 'WEIGHT',
|
||||
zone TYPE c LENGTH 10 VALUE 'ZONE',
|
||||
END OF c_status.
|
||||
|
||||
METHODS calculate
|
||||
IMPORTING
|
||||
iv_weight_kg TYPE p LENGTH 8 DECIMALS 2
|
||||
iv_zone TYPE string
|
||||
iv_express TYPE abap_bool DEFAULT abap_false
|
||||
RETURNING
|
||||
VALUE(rs_result) TYPE ty_result.
|
||||
|
||||
METHODS is_zone_supported
|
||||
IMPORTING
|
||||
iv_zone TYPE string
|
||||
RETURNING
|
||||
VALUE(rv_supported) TYPE abap_bool.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA mv_last_zone TYPE string.
|
||||
CONSTANTS c_express_share TYPE p LENGTH 5 DECIMALS 2 VALUE '0.25'.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}freight_calculator IMPLEMENTATION.
|
||||
METHOD calculate.
|
||||
DATA lv_zone TYPE string.
|
||||
DATA lv_rate TYPE p LENGTH 6 DECIMALS 2.
|
||||
DATA lv_amount TYPE p LENGTH 13 DECIMALS 4.
|
||||
DATA lv_express TYPE abap_bool.
|
||||
|
||||
lv_zone = to_upper( replace( val = iv_zone sub = ` ` with = `` occ = 0 ) ).
|
||||
mv_last_zone = lv_zone.
|
||||
|
||||
IF iv_weight_kg <= 0.
|
||||
rs_result-status = 'WEIGHT'.
|
||||
rs_result-base = 0.
|
||||
rs_result-surcharge = 0.
|
||||
rs_result-total = 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
* IF lv_zone = 'BE'.
|
||||
* lv_rate = '5.60'.
|
||||
* ENDIF.
|
||||
IF lv_zone = 'DE'.
|
||||
lv_rate = '4.50'.
|
||||
ELSEIF lv_zone = 'AT'.
|
||||
lv_rate = '5.20'.
|
||||
ELSEIF lv_zone = 'CH'.
|
||||
lv_rate = '7.80'.
|
||||
ELSEIF lv_zone = 'FR'.
|
||||
lv_rate = '6.40'.
|
||||
ELSEIF lv_zone = 'NL'.
|
||||
lv_rate = '4.90'.
|
||||
ELSEIF lv_zone = 'PL'.
|
||||
lv_rate = '5.10'.
|
||||
ELSEIF lv_zone = 'ES'.
|
||||
lv_rate = '6.90'.
|
||||
ELSE.
|
||||
rs_result-status = 'ZONE'.
|
||||
rs_result-base = 0.
|
||||
rs_result-surcharge = 0.
|
||||
rs_result-total = 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
lv_amount = lv_rate * iv_weight_kg.
|
||||
rs_result-base = round( val = lv_amount dec = 2 ).
|
||||
|
||||
lv_express = iv_express.
|
||||
IF lv_express = abap_true.
|
||||
lv_amount = rs_result-base * c_express_share.
|
||||
rs_result-surcharge = round( val = lv_amount dec = 2 ).
|
||||
ELSE.
|
||||
rs_result-surcharge = 0.
|
||||
ENDIF.
|
||||
|
||||
rs_result-total = rs_result-base + rs_result-surcharge.
|
||||
rs_result-status = 'OK'.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD is_zone_supported.
|
||||
DATA lv_zone TYPE string.
|
||||
lv_zone = to_upper( replace( val = iv_zone sub = ` ` with = `` occ = 0 ) ).
|
||||
IF lv_zone = 'DE' OR lv_zone = 'AT' OR lv_zone = 'CH' OR lv_zone = 'FR'
|
||||
OR lv_zone = 'NL' OR lv_zone = 'PL' OR lv_zone = 'ES'.
|
||||
rv_supported = abap_true.
|
||||
ELSE.
|
||||
rv_supported = abap_false.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
@@ -0,0 +1,25 @@
|
||||
CLASS ltc_legacy_freight DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
METHODS base_parcel FOR TESTING.
|
||||
METHODS express_parcel FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_legacy_freight IMPLEMENTATION.
|
||||
METHOD base_parcel.
|
||||
DATA(lo_cut) = NEW {{p}}freight_calculator( ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = VALUE {{p}}freight_calculator=>ty_result( status = 'OK' base = '45.00' total = '45.00' )
|
||||
act = lo_cut->calculate( iv_weight_kg = '10.00' iv_zone = `DE` ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD express_parcel.
|
||||
DATA(lo_cut) = NEW {{p}}freight_calculator( ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = VALUE {{p}}freight_calculator=>ty_result( status = 'OK'
|
||||
base = '45.00'
|
||||
surcharge = '11.25'
|
||||
total = '56.25' )
|
||||
act = lo_cut->calculate( iv_weight_kg = '10.00' iv_zone = `DE` iv_express = abap_true ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
67
tasks_gen/eval/G0006/spec.md
Normal file
67
tasks_gen/eval/G0006/spec.md
Normal file
@@ -0,0 +1,67 @@
|
||||
# 1. Goal
|
||||
Refactor the class {{P}}FREIGHT_CALCULATOR. The class calculates the freight cost of a
|
||||
parcel. The calculation is correct, but the code is hard to read and hard to maintain.
|
||||
Make the code clean. The behavior and the public API must not change.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- The class {{P}}FREIGHT_CALCULATOR exists in package $TMP. It is active.
|
||||
- The class contains legacy code: one long method, nested IF blocks, hard-coded
|
||||
numbers, a private attribute that is written but never read, and commented-out code.
|
||||
- A logistics program calls the class. That program must continue to work without a
|
||||
change. Therefore the behavior of the class must stay the same.
|
||||
|
||||
# 4. Contract
|
||||
The public part of the class must stay exactly as it is:
|
||||
- The class {{P}}FREIGHT_CALCULATOR is public, final, and has a public constructor
|
||||
without parameters.
|
||||
- Public type TY_RESULT with these components: STATUS TYPE c LENGTH 10,
|
||||
BASE TYPE p LENGTH 9 DECIMALS 2, SURCHARGE TYPE p LENGTH 9 DECIMALS 2,
|
||||
TOTAL TYPE p LENGTH 9 DECIMALS 2.
|
||||
- Public constant structure C_STATUS with the components OK, WEIGHT and ZONE. Each
|
||||
component has the type c LENGTH 10. The values are 'OK', 'WEIGHT' and 'ZONE'.
|
||||
- Public method CALCULATE:
|
||||
IMPORTING iv_weight_kg TYPE p LENGTH 8 DECIMALS 2
|
||||
iv_zone TYPE string
|
||||
iv_express TYPE abap_bool DEFAULT abap_false
|
||||
RETURNING VALUE(rs_result) TYPE ty_result.
|
||||
- Public method IS_ZONE_SUPPORTED:
|
||||
IMPORTING iv_zone TYPE string
|
||||
RETURNING VALUE(rv_supported) TYPE abap_bool.
|
||||
- Do not add other public components or public methods.
|
||||
|
||||
# 5. Business rules
|
||||
The rules below describe the behavior of the class. The behavior must not change.
|
||||
1. Normalize the zone: remove all blanks and convert all letters to upper case. A
|
||||
zone is known only if the normalized zone is exactly equal to a zone code. Do not
|
||||
shorten the zone and do not extend the zone.
|
||||
2. Check the weight first. If the weight is not greater than zero, return the status
|
||||
WEIGHT with BASE, SURCHARGE and TOTAL equal to zero. This check comes before the
|
||||
zone check.
|
||||
3. If the normalized zone is not known, return the status ZONE with BASE, SURCHARGE
|
||||
and TOTAL equal to zero.
|
||||
4. The rate per kilogram depends on the zone: DE 4.50, AT 5.20, CH 7.80, FR 6.40,
|
||||
NL 4.90, PL 5.10, ES 6.90.
|
||||
5. BASE = rate x weight. Round BASE to 2 decimal places. Round half away from zero.
|
||||
6. If iv_express is abap_true, SURCHARGE = BASE x 25 / 100, rounded to 2 decimal
|
||||
places. Else SURCHARGE is zero.
|
||||
7. TOTAL = BASE + SURCHARGE.
|
||||
8. Return the status OK.
|
||||
9. IS_ZONE_SUPPORTED returns abap_true if the normalized zone is known, else
|
||||
abap_false. A blank zone is not known.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
|
||||
- Coding standards: Clean ABAP. Every method has less than 40 statements. No global
|
||||
variables. No IF block nested deeper than 2 levels. No hard-coded rate in a
|
||||
statement: use a constant or a table. Remove the private attribute that is never
|
||||
read. Remove the commented-out code. No comment that restates the code.
|
||||
- Out of scope: do not change the public API, do not change the behavior, do not
|
||||
create new global objects, do not change the class name.
|
||||
|
||||
# 7. Acceptance
|
||||
- The class is active and has no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write your own ABAP Unit tests as local test classes in the class.
|
||||
54
tasks_gen/eval/G0006/task.json
Normal file
54
tasks_gen/eval/G0006/task.json
Normal file
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"id": "G0006",
|
||||
"category": "E",
|
||||
"object_type": "CLAS",
|
||||
"difficulty": 2,
|
||||
"release_target": "v816",
|
||||
"expected_outcome": "implement",
|
||||
"budget": {
|
||||
"max_tool_calls": 60,
|
||||
"max_activations": 15
|
||||
},
|
||||
"seed": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}FREIGHT_CALCULATOR",
|
||||
"file": "seed/freight_calculator.clas.abap",
|
||||
"description": "Legacy freight calculator. Correct behavior, poor structure: one long method, nested IF blocks, hard-coded rates, a private attribute that is written but never read, commented-out code."
|
||||
}
|
||||
],
|
||||
"contract": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}FREIGHT_CALCULATOR"
|
||||
}
|
||||
],
|
||||
"out_of_scope": [
|
||||
"New global objects",
|
||||
"Changes to the public API of {{P}}FREIGHT_CALCULATOR",
|
||||
"Changes to the result of the calculation"
|
||||
],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}T02_HIDDEN",
|
||||
"file": "hidden/t02_hidden.clas.abap",
|
||||
"description": "T02 hidden tests for the refactored freight calculator"
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}FREIGHT_CALCULATOR",
|
||||
"file": "reference/freight_calculator.clas.abap",
|
||||
"description": "Refactored freight calculator with extracted methods and a rate table",
|
||||
"testclasses_file": "reference/freight_calculator.testclasses.abap"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length",
|
||||
"nesting_depth",
|
||||
"magic_number",
|
||||
"dead_code"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user