Hard batch G0022-G0026: 5/5 accepted; budget floor, CDS checks, mutation check

- generator: budget floor (2x oracle activations, 3x calls), static checks for CDS
  $parameters and UNION annotation
- harness/mutation.py: deterministic mutants of the reference; hidden tests must fail
- G0022 revalidated with harness fixes: oracle 100, null 0
- results in docs/faz1-tasarim.md 11f

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kral
2026-10-03 05:16:30 +02:00
parent 3570d7ef9b
commit 32f03fcad4
53 changed files with 2931 additions and 14 deletions

View File

@@ -0,0 +1,62 @@
CLASS {{p}}freight_calculator DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES {{p}}if_freight_calc.
PRIVATE SECTION.
TYPES:
BEGIN OF ty_rate,
zone TYPE {{p}}if_freight_calc=>ty_zone,
base TYPE {{p}}if_freight_calc=>ty_amount,
per_kg TYPE {{p}}if_freight_calc=>ty_amount,
minimum TYPE {{p}}if_freight_calc=>ty_amount,
surcharge TYPE p LENGTH 4 DECIMALS 3,
END OF ty_rate,
tt_rate TYPE SORTED TABLE OF ty_rate WITH UNIQUE KEY zone.
CONSTANTS:
c_heavy_limit TYPE {{p}}if_freight_calc=>ty_weight VALUE '1000.000',
c_discount TYPE p LENGTH 3 DECIMALS 2 VALUE '0.95'.
METHODS rates RETURNING VALUE(rt_rate) TYPE tt_rate.
ENDCLASS.
CLASS {{p}}freight_calculator IMPLEMENTATION.
METHOD {{p}}if_freight_calc~calculate.
DATA(lt_rate) = rates( ).
READ TABLE lt_rate INTO DATA(ls_rate) WITH TABLE KEY zone = iv_zone.
IF sy-subrc <> 0.
rv_cost = 0.
RETURN.
ENDIF.
DATA lv_charge TYPE {{p}}if_freight_calc=>ty_amount.
lv_charge = ls_rate-per_kg * iv_weight.
DATA lv_freight TYPE {{p}}if_freight_calc=>ty_amount.
lv_freight = ls_rate-base + lv_charge.
IF lv_freight < ls_rate-minimum.
lv_freight = ls_rate-minimum.
ENDIF.
DATA lv_surcharge TYPE {{p}}if_freight_calc=>ty_amount.
lv_surcharge = lv_freight * ls_rate-surcharge.
DATA lv_total TYPE {{p}}if_freight_calc=>ty_amount.
lv_total = lv_freight + lv_surcharge.
IF iv_weight > c_heavy_limit.
lv_total = lv_total * c_discount.
ENDIF.
rv_cost = lv_total.
ENDMETHOD.
METHOD rates.
rt_rate = VALUE #(
( zone = 'DE' base = '12.50' per_kg = '0.85' minimum = '25.00' surcharge = '0.065' )
( zone = 'FR' base = '15.00' per_kg = '1.10' minimum = '30.00' surcharge = '0.075' )
( zone = 'NL' base = '10.00' per_kg = '0.75' minimum = '20.00' surcharge = '0.055' )
( zone = 'US' base = '20.00' per_kg = '1.40' minimum = '45.00' surcharge = '0.085' )
( zone = 'CN' base = '25.00' per_kg = '1.25' minimum = '50.00' surcharge = '0.095' ) ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,75 @@
CLASS ltc_freight_calculator DEFINITION FINAL FOR TESTING
DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
DATA mo_cut TYPE REF TO {{p}}if_freight_calc.
METHODS setup.
METHODS unknown_zone FOR TESTING.
METHODS minimum_charge FOR TESTING.
METHODS all_zones FOR TESTING.
METHODS heavy_discount FOR TESTING.
METHODS no_discount_at_1000 FOR TESTING.
METHODS rounding_half_up FOR TESTING.
ENDCLASS.
CLASS ltc_freight_calculator IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}freight_calculator( ).
ENDMETHOD.
METHOD unknown_zone.
DATA lv_exp TYPE {{p}}if_freight_calc=>ty_amount.
lv_exp = '0.00'.
cl_abap_unit_assert=>assert_equals(
exp = lv_exp
act = mo_cut->calculate( iv_zone = 'XX' iv_weight = '10.000' ) ).
ENDMETHOD.
METHOD minimum_charge.
DATA lv_exp TYPE {{p}}if_freight_calc=>ty_amount.
lv_exp = '26.63'.
cl_abap_unit_assert=>assert_equals(
exp = lv_exp
act = mo_cut->calculate( iv_zone = 'DE' iv_weight = '1.000' ) ).
ENDMETHOD.
METHOD all_zones.
DATA lv_exp TYPE {{p}}if_freight_calc=>ty_amount.
lv_exp = '103.84'.
cl_abap_unit_assert=>assert_equals(
exp = lv_exp
act = mo_cut->calculate( iv_zone = 'DE' iv_weight = '100.000' ) msg = `DE` ).
lv_exp = '39.78'.
cl_abap_unit_assert=>assert_equals(
exp = lv_exp
act = mo_cut->calculate( iv_zone = 'FR' iv_weight = '20.000' ) msg = `FR` ).
lv_exp = '164.25'.
cl_abap_unit_assert=>assert_equals(
exp = lv_exp
act = mo_cut->calculate( iv_zone = 'CN' iv_weight = '100.000' ) msg = `CN` ).
ENDMETHOD.
METHOD heavy_discount.
DATA lv_exp TYPE {{p}}if_freight_calc=>ty_amount.
lv_exp = '1302.63'.
cl_abap_unit_assert=>assert_equals(
exp = lv_exp
act = mo_cut->calculate( iv_zone = 'DE' iv_weight = '1500.000' ) ).
ENDMETHOD.
METHOD no_discount_at_1000.
DATA lv_exp TYPE {{p}}if_freight_calc=>ty_amount.
lv_exp = '918.56'.
cl_abap_unit_assert=>assert_equals(
exp = lv_exp
act = mo_cut->calculate( iv_zone = 'DE' iv_weight = '1000.000' ) ).
ENDMETHOD.
METHOD rounding_half_up.
DATA lv_exp TYPE {{p}}if_freight_calc=>ty_amount.
lv_exp = '54.76'.
cl_abap_unit_assert=>assert_equals(
exp = lv_exp
act = mo_cut->calculate( iv_zone = 'CN' iv_weight = '20.004' ) ).
ENDMETHOD.
ENDCLASS.