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:
19
tasks_gen/eval/G0008/generation.json
Normal file
19
tasks_gen/eval/G0008/generation.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"id": "G0008",
|
||||
"pool": "eval",
|
||||
"object_type": "CLAS",
|
||||
"category": "G",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 100.0,
|
||||
"null": 0
|
||||
}
|
||||
],
|
||||
"accepted": true
|
||||
}
|
||||
197
tasks_gen/eval/G0008/hidden/t07_hidden.clas.abap
Normal file
197
tasks_gen/eval/G0008/hidden/t07_hidden.clas.abap
Normal file
@@ -0,0 +1,197 @@
|
||||
CLASS {{p}}t07_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}if_freight_calc.
|
||||
|
||||
METHODS setup.
|
||||
METHODS assert_amount
|
||||
IMPORTING iv_expected TYPE {{p}}if_freight_calc=>ty_amount
|
||||
iv_actual TYPE {{p}}if_freight_calc=>ty_amount.
|
||||
METHODS assert_weight
|
||||
IMPORTING iv_expected TYPE {{p}}if_freight_calc=>ty_weight
|
||||
iv_actual TYPE {{p}}if_freight_calc=>ty_weight.
|
||||
|
||||
METHODS weight_not_positive FOR TESTING.
|
||||
METHODS volume_negative FOR TESTING.
|
||||
METHODS distance_not_positive FOR TESTING.
|
||||
METHODS fuel_index_negative FOR TESTING.
|
||||
METHODS fuel_index_too_high FOR TESTING.
|
||||
METHODS base_at_weight_limit FOR TESTING.
|
||||
METHODS base_above_weight_limit FOR TESTING.
|
||||
METHODS volumetric_weight_wins FOR TESTING.
|
||||
METHODS distance_component FOR TESTING.
|
||||
METHODS fuel_rounds_half_up FOR TESTING.
|
||||
METHODS full_load FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t07_hidden IMPLEMENTATION.
|
||||
|
||||
METHOD setup.
|
||||
DATA lo_calc TYPE REF TO {{p}}freight_calc.
|
||||
CREATE OBJECT lo_calc.
|
||||
mo_cut = lo_calc.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD assert_amount.
|
||||
cl_abap_unit_assert=>assert_equals( exp = iv_expected act = iv_actual ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD assert_weight.
|
||||
cl_abap_unit_assert=>assert_equals( exp = iv_expected act = iv_actual ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD weight_not_positive.
|
||||
DATA ls_result TYPE {{p}}if_freight_calc=>ty_result.
|
||||
|
||||
ls_result = mo_cut->calculate( iv_weight_kg = 0
|
||||
iv_volume_m3 = -1
|
||||
iv_distance_km = 0
|
||||
iv_fuel_index = 200 ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_freight_calc=>c_reason-weight
|
||||
act = ls_result-reason ).
|
||||
assert_amount( iv_expected = 0 iv_actual = ls_result-total ).
|
||||
assert_weight( iv_expected = 0 iv_actual = ls_result-chargeable_weight ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD volume_negative.
|
||||
DATA ls_result TYPE {{p}}if_freight_calc=>ty_result.
|
||||
|
||||
ls_result = mo_cut->calculate( iv_weight_kg = 1000
|
||||
iv_volume_m3 = '-0.5'
|
||||
iv_distance_km = 100
|
||||
iv_fuel_index = 50 ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_freight_calc=>c_reason-volume
|
||||
act = ls_result-reason ).
|
||||
assert_amount( iv_expected = 0 iv_actual = ls_result-total ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD distance_not_positive.
|
||||
DATA ls_result TYPE {{p}}if_freight_calc=>ty_result.
|
||||
|
||||
ls_result = mo_cut->calculate( iv_weight_kg = 1000
|
||||
iv_volume_m3 = 0
|
||||
iv_distance_km = 0
|
||||
iv_fuel_index = 50 ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_freight_calc=>c_reason-distance
|
||||
act = ls_result-reason ).
|
||||
assert_amount( iv_expected = 0 iv_actual = ls_result-total ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD fuel_index_negative.
|
||||
DATA ls_result TYPE {{p}}if_freight_calc=>ty_result.
|
||||
|
||||
ls_result = mo_cut->calculate( iv_weight_kg = 1000
|
||||
iv_volume_m3 = 0
|
||||
iv_distance_km = 100
|
||||
iv_fuel_index = '-0.1' ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_freight_calc=>c_reason-fuel
|
||||
act = ls_result-reason ).
|
||||
assert_amount( iv_expected = 0 iv_actual = ls_result-total ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD fuel_index_too_high.
|
||||
DATA ls_result TYPE {{p}}if_freight_calc=>ty_result.
|
||||
|
||||
ls_result = mo_cut->calculate( iv_weight_kg = 1000
|
||||
iv_volume_m3 = 0
|
||||
iv_distance_km = 100
|
||||
iv_fuel_index = '100.1' ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_freight_calc=>c_reason-fuel
|
||||
act = ls_result-reason ).
|
||||
assert_amount( iv_expected = 0 iv_actual = ls_result-total ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD base_at_weight_limit.
|
||||
DATA ls_result TYPE {{p}}if_freight_calc=>ty_result.
|
||||
|
||||
ls_result = mo_cut->calculate( iv_weight_kg = 1000
|
||||
iv_volume_m3 = 0
|
||||
iv_distance_km = 100
|
||||
iv_fuel_index = 0 ).
|
||||
|
||||
assert_weight( iv_expected = 1000 iv_actual = ls_result-chargeable_weight ).
|
||||
assert_amount( iv_expected = 45 iv_actual = ls_result-base ).
|
||||
assert_amount( iv_expected = 0 iv_actual = ls_result-distance ).
|
||||
assert_amount( iv_expected = 0 iv_actual = ls_result-fuel ).
|
||||
assert_amount( iv_expected = 45 iv_actual = ls_result-total ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_freight_calc=>c_reason-ok
|
||||
act = ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD base_above_weight_limit.
|
||||
DATA ls_result TYPE {{p}}if_freight_calc=>ty_result.
|
||||
|
||||
ls_result = mo_cut->calculate( iv_weight_kg = '1100.5'
|
||||
iv_volume_m3 = 0
|
||||
iv_distance_km = 100
|
||||
iv_fuel_index = 0 ).
|
||||
|
||||
assert_weight( iv_expected = '1100.5' iv_actual = ls_result-chargeable_weight ).
|
||||
assert_amount( iv_expected = 58 iv_actual = ls_result-base ).
|
||||
assert_amount( iv_expected = 58 iv_actual = ls_result-total ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD volumetric_weight_wins.
|
||||
DATA ls_result TYPE {{p}}if_freight_calc=>ty_result.
|
||||
|
||||
ls_result = mo_cut->calculate( iv_weight_kg = 500
|
||||
iv_volume_m3 = '4.5'
|
||||
iv_distance_km = 100
|
||||
iv_fuel_index = 0 ).
|
||||
|
||||
assert_weight( iv_expected = 1125 iv_actual = ls_result-chargeable_weight ).
|
||||
assert_amount( iv_expected = 58 iv_actual = ls_result-base ).
|
||||
assert_amount( iv_expected = 58 iv_actual = ls_result-total ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD distance_component.
|
||||
DATA ls_result TYPE {{p}}if_freight_calc=>ty_result.
|
||||
|
||||
ls_result = mo_cut->calculate( iv_weight_kg = 1000
|
||||
iv_volume_m3 = 0
|
||||
iv_distance_km = 350
|
||||
iv_fuel_index = 0 ).
|
||||
|
||||
assert_amount( iv_expected = 45 iv_actual = ls_result-base ).
|
||||
assert_amount( iv_expected = 27 iv_actual = ls_result-distance ).
|
||||
assert_amount( iv_expected = 72 iv_actual = ls_result-total ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD fuel_rounds_half_up.
|
||||
DATA ls_result TYPE {{p}}if_freight_calc=>ty_result.
|
||||
|
||||
ls_result = mo_cut->calculate( iv_weight_kg = 1000
|
||||
iv_volume_m3 = 0
|
||||
iv_distance_km = 100
|
||||
iv_fuel_index = '12.3' ).
|
||||
|
||||
assert_amount( iv_expected = 45 iv_actual = ls_result-base ).
|
||||
assert_amount( iv_expected = 0 iv_actual = ls_result-distance ).
|
||||
assert_amount( iv_expected = '5.54' iv_actual = ls_result-fuel ).
|
||||
assert_amount( iv_expected = '50.54' iv_actual = ls_result-total ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD full_load.
|
||||
DATA ls_result TYPE {{p}}if_freight_calc=>ty_result.
|
||||
|
||||
ls_result = mo_cut->calculate( iv_weight_kg = 2000
|
||||
iv_volume_m3 = 1
|
||||
iv_distance_km = 500
|
||||
iv_fuel_index = 100 ).
|
||||
|
||||
assert_weight( iv_expected = 2000 iv_actual = ls_result-chargeable_weight ).
|
||||
assert_amount( iv_expected = 110 iv_actual = ls_result-base ).
|
||||
assert_amount( iv_expected = 36 iv_actual = ls_result-distance ).
|
||||
assert_amount( iv_expected = 146 iv_actual = ls_result-fuel ).
|
||||
assert_amount( iv_expected = 292 iv_actual = ls_result-total ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_freight_calc=>c_reason-ok
|
||||
act = ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
149
tasks_gen/eval/G0008/reference/freight_calc.clas.abap
Normal file
149
tasks_gen/eval/G0008/reference/freight_calc.clas.abap
Normal file
@@ -0,0 +1,149 @@
|
||||
CLASS {{p}}freight_calc DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_freight_calc.
|
||||
|
||||
PRIVATE SECTION.
|
||||
TYPES ty_quantity TYPE p LENGTH 13 DECIMALS 3.
|
||||
|
||||
CONSTANTS:
|
||||
c_base_amount TYPE {{p}}if_freight_calc=>ty_amount VALUE '45.00',
|
||||
c_base_weight TYPE ty_quantity VALUE '1000.000',
|
||||
c_weight_rate TYPE {{p}}if_freight_calc=>ty_amount VALUE '6.50',
|
||||
c_free_km TYPE i VALUE 100,
|
||||
c_km_rate TYPE {{p}}if_freight_calc=>ty_amount VALUE '9.00',
|
||||
c_step TYPE ty_quantity VALUE '100.000',
|
||||
c_volume_factor TYPE i VALUE 250,
|
||||
c_percent TYPE p LENGTH 3 DECIMALS 2 VALUE '0.01'.
|
||||
|
||||
METHODS check_input
|
||||
IMPORTING iv_weight_kg TYPE {{p}}if_freight_calc=>ty_weight
|
||||
iv_volume_m3 TYPE {{p}}if_freight_calc=>ty_volume
|
||||
iv_distance_km TYPE {{p}}if_freight_calc=>ty_distance
|
||||
iv_fuel_index TYPE {{p}}if_freight_calc=>ty_fuel
|
||||
RETURNING VALUE(rv_reason) TYPE {{p}}if_freight_calc=>ty_reason.
|
||||
|
||||
METHODS chargeable_weight
|
||||
IMPORTING iv_weight_kg TYPE {{p}}if_freight_calc=>ty_weight
|
||||
iv_volume_m3 TYPE {{p}}if_freight_calc=>ty_volume
|
||||
RETURNING VALUE(rv_weight) TYPE ty_quantity.
|
||||
|
||||
METHODS base_freight
|
||||
IMPORTING iv_weight_kg TYPE ty_quantity
|
||||
RETURNING VALUE(rv_amount) TYPE {{p}}if_freight_calc=>ty_amount.
|
||||
|
||||
METHODS distance_freight
|
||||
IMPORTING iv_distance_km TYPE {{p}}if_freight_calc=>ty_distance
|
||||
RETURNING VALUE(rv_amount) TYPE {{p}}if_freight_calc=>ty_amount.
|
||||
|
||||
METHODS fuel_freight
|
||||
IMPORTING iv_amount TYPE {{p}}if_freight_calc=>ty_amount
|
||||
iv_fuel_index TYPE {{p}}if_freight_calc=>ty_fuel
|
||||
RETURNING VALUE(rv_amount) TYPE {{p}}if_freight_calc=>ty_amount.
|
||||
|
||||
METHODS started_steps
|
||||
IMPORTING iv_excess TYPE ty_quantity
|
||||
RETURNING VALUE(rv_steps) TYPE i.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}freight_calc IMPLEMENTATION.
|
||||
|
||||
METHOD {{p}}if_freight_calc~calculate.
|
||||
DATA lv_reason TYPE {{p}}if_freight_calc=>ty_reason.
|
||||
DATA lv_weight TYPE ty_quantity.
|
||||
DATA lv_net TYPE {{p}}if_freight_calc=>ty_amount.
|
||||
|
||||
CLEAR rs_result.
|
||||
lv_reason = check_input( iv_weight_kg = iv_weight_kg
|
||||
iv_volume_m3 = iv_volume_m3
|
||||
iv_distance_km = iv_distance_km
|
||||
iv_fuel_index = iv_fuel_index ).
|
||||
IF lv_reason <> {{p}}if_freight_calc=>c_reason-ok.
|
||||
rs_result-reason = lv_reason.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
lv_weight = chargeable_weight( iv_weight_kg = iv_weight_kg
|
||||
iv_volume_m3 = iv_volume_m3 ).
|
||||
rs_result-chargeable_weight = lv_weight.
|
||||
rs_result-base = base_freight( lv_weight ).
|
||||
rs_result-distance = distance_freight( iv_distance_km ).
|
||||
lv_net = rs_result-base + rs_result-distance.
|
||||
rs_result-fuel = fuel_freight( iv_amount = lv_net
|
||||
iv_fuel_index = iv_fuel_index ).
|
||||
rs_result-total = rs_result-base + rs_result-distance + rs_result-fuel.
|
||||
rs_result-reason = {{p}}if_freight_calc=>c_reason-ok.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_input.
|
||||
IF iv_weight_kg <= 0.
|
||||
rv_reason = {{p}}if_freight_calc=>c_reason-weight.
|
||||
ELSEIF iv_volume_m3 < 0.
|
||||
rv_reason = {{p}}if_freight_calc=>c_reason-volume.
|
||||
ELSEIF iv_distance_km <= 0.
|
||||
rv_reason = {{p}}if_freight_calc=>c_reason-distance.
|
||||
ELSEIF iv_fuel_index < 0 OR iv_fuel_index > 100.
|
||||
rv_reason = {{p}}if_freight_calc=>c_reason-fuel.
|
||||
ELSE.
|
||||
rv_reason = {{p}}if_freight_calc=>c_reason-ok.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD chargeable_weight.
|
||||
DATA lv_volumetric TYPE ty_quantity.
|
||||
|
||||
lv_volumetric = iv_volume_m3 * c_volume_factor.
|
||||
IF lv_volumetric > iv_weight_kg.
|
||||
rv_weight = lv_volumetric.
|
||||
ELSE.
|
||||
rv_weight = iv_weight_kg.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD base_freight.
|
||||
DATA lv_excess TYPE ty_quantity.
|
||||
DATA lv_steps TYPE i.
|
||||
|
||||
lv_excess = iv_weight_kg - c_base_weight.
|
||||
IF lv_excess <= 0.
|
||||
rv_amount = c_base_amount.
|
||||
ELSE.
|
||||
lv_steps = started_steps( lv_excess ).
|
||||
rv_amount = c_base_amount + lv_steps * c_weight_rate.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD distance_freight.
|
||||
DATA lv_excess TYPE ty_quantity.
|
||||
DATA lv_steps TYPE i.
|
||||
|
||||
lv_excess = iv_distance_km - c_free_km.
|
||||
IF lv_excess <= 0.
|
||||
rv_amount = 0.
|
||||
ELSE.
|
||||
lv_steps = started_steps( lv_excess ).
|
||||
rv_amount = lv_steps * c_km_rate.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD fuel_freight.
|
||||
DATA lv_scaled TYPE p LENGTH 15 DECIMALS 3.
|
||||
DATA lv_fuel TYPE p LENGTH 15 DECIMALS 5.
|
||||
|
||||
lv_scaled = iv_amount * iv_fuel_index.
|
||||
lv_fuel = lv_scaled * c_percent.
|
||||
rv_amount = lv_fuel.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD started_steps.
|
||||
DATA lv_excess_scaled TYPE p LENGTH 16 DECIMALS 0.
|
||||
DATA lv_step_scaled TYPE p LENGTH 16 DECIMALS 0.
|
||||
|
||||
lv_excess_scaled = iv_excess * 1000.
|
||||
lv_step_scaled = c_step * 1000.
|
||||
rv_steps = lv_excess_scaled DIV lv_step_scaled.
|
||||
IF lv_excess_scaled MOD lv_step_scaled > 0.
|
||||
rv_steps = rv_steps + 1.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
114
tasks_gen/eval/G0008/reference/freight_calc.testclasses.abap
Normal file
114
tasks_gen/eval/G0008/reference/freight_calc.testclasses.abap
Normal file
@@ -0,0 +1,114 @@
|
||||
CLASS ltc_freight_calc DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}if_freight_calc.
|
||||
|
||||
METHODS setup.
|
||||
METHODS assert_amount
|
||||
IMPORTING iv_expected TYPE {{p}}if_freight_calc=>ty_amount
|
||||
iv_actual TYPE {{p}}if_freight_calc=>ty_amount.
|
||||
METHODS assert_weight
|
||||
IMPORTING iv_expected TYPE {{p}}if_freight_calc=>ty_weight
|
||||
iv_actual TYPE {{p}}if_freight_calc=>ty_weight.
|
||||
|
||||
METHODS base_and_distance FOR TESTING.
|
||||
METHODS fuel_is_rounded FOR TESTING.
|
||||
METHODS volume_sets_chargeable_weight FOR TESTING.
|
||||
METHODS weight_zero_is_rejected FOR TESTING.
|
||||
METHODS distance_zero_is_rejected FOR TESTING.
|
||||
METHODS fuel_index_out_of_range FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_freight_calc IMPLEMENTATION.
|
||||
|
||||
METHOD setup.
|
||||
DATA lo_calc TYPE REF TO {{p}}freight_calc.
|
||||
CREATE OBJECT lo_calc.
|
||||
mo_cut = lo_calc.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD assert_amount.
|
||||
cl_abap_unit_assert=>assert_equals( exp = iv_expected act = iv_actual ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD assert_weight.
|
||||
cl_abap_unit_assert=>assert_equals( exp = iv_expected act = iv_actual ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD base_and_distance.
|
||||
DATA ls_result TYPE {{p}}if_freight_calc=>ty_result.
|
||||
|
||||
ls_result = mo_cut->calculate( iv_weight_kg = 2000
|
||||
iv_volume_m3 = 1
|
||||
iv_distance_km = 500
|
||||
iv_fuel_index = 100 ).
|
||||
|
||||
assert_amount( iv_expected = 110 iv_actual = ls_result-base ).
|
||||
assert_amount( iv_expected = 36 iv_actual = ls_result-distance ).
|
||||
assert_amount( iv_expected = 146 iv_actual = ls_result-fuel ).
|
||||
assert_amount( iv_expected = 292 iv_actual = ls_result-total ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD fuel_is_rounded.
|
||||
DATA ls_result TYPE {{p}}if_freight_calc=>ty_result.
|
||||
|
||||
ls_result = mo_cut->calculate( iv_weight_kg = 1000
|
||||
iv_volume_m3 = 0
|
||||
iv_distance_km = 100
|
||||
iv_fuel_index = '12.3' ).
|
||||
|
||||
assert_amount( iv_expected = '5.54' iv_actual = ls_result-fuel ).
|
||||
assert_amount( iv_expected = '50.54' iv_actual = ls_result-total ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD volume_sets_chargeable_weight.
|
||||
DATA ls_result TYPE {{p}}if_freight_calc=>ty_result.
|
||||
|
||||
ls_result = mo_cut->calculate( iv_weight_kg = 500
|
||||
iv_volume_m3 = '4.5'
|
||||
iv_distance_km = 100
|
||||
iv_fuel_index = 0 ).
|
||||
|
||||
assert_weight( iv_expected = 1125 iv_actual = ls_result-chargeable_weight ).
|
||||
assert_amount( iv_expected = 58 iv_actual = ls_result-base ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD weight_zero_is_rejected.
|
||||
DATA ls_result TYPE {{p}}if_freight_calc=>ty_result.
|
||||
|
||||
ls_result = mo_cut->calculate( iv_weight_kg = 0
|
||||
iv_volume_m3 = 2
|
||||
iv_distance_km = 300
|
||||
iv_fuel_index = 10 ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_freight_calc=>c_reason-weight
|
||||
act = ls_result-reason ).
|
||||
assert_amount( iv_expected = 0 iv_actual = ls_result-total ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD distance_zero_is_rejected.
|
||||
DATA ls_result TYPE {{p}}if_freight_calc=>ty_result.
|
||||
|
||||
ls_result = mo_cut->calculate( iv_weight_kg = 1500
|
||||
iv_volume_m3 = 0
|
||||
iv_distance_km = 0
|
||||
iv_fuel_index = 10 ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_freight_calc=>c_reason-distance
|
||||
act = ls_result-reason ).
|
||||
assert_amount( iv_expected = 0 iv_actual = ls_result-total ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD fuel_index_out_of_range.
|
||||
DATA ls_result TYPE {{p}}if_freight_calc=>ty_result.
|
||||
|
||||
ls_result = mo_cut->calculate( iv_weight_kg = 1500
|
||||
iv_volume_m3 = 0
|
||||
iv_distance_km = 300
|
||||
iv_fuel_index = 120 ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_freight_calc=>c_reason-fuel
|
||||
act = ls_result-reason ).
|
||||
assert_amount( iv_expected = 0 iv_actual = ls_result-total ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
34
tasks_gen/eval/G0008/seed/if_freight_calc.intf.abap
Normal file
34
tasks_gen/eval/G0008/seed/if_freight_calc.intf.abap
Normal file
@@ -0,0 +1,34 @@
|
||||
INTERFACE {{p}}if_freight_calc PUBLIC.
|
||||
TYPES ty_reason TYPE c LENGTH 10.
|
||||
TYPES ty_amount TYPE p LENGTH 9 DECIMALS 2.
|
||||
TYPES ty_weight TYPE p LENGTH 9 DECIMALS 3.
|
||||
TYPES ty_volume TYPE p LENGTH 9 DECIMALS 3.
|
||||
TYPES ty_distance TYPE i.
|
||||
TYPES ty_fuel TYPE p LENGTH 5 DECIMALS 1.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_reason,
|
||||
ok TYPE ty_reason VALUE 'OK',
|
||||
weight TYPE ty_reason VALUE 'WEIGHT',
|
||||
volume TYPE ty_reason VALUE 'VOLUME',
|
||||
distance TYPE ty_reason VALUE 'DISTANCE',
|
||||
fuel TYPE ty_reason VALUE 'FUEL',
|
||||
END OF c_reason.
|
||||
|
||||
TYPES:
|
||||
BEGIN OF ty_result,
|
||||
chargeable_weight TYPE ty_weight,
|
||||
base TYPE ty_amount,
|
||||
distance TYPE ty_amount,
|
||||
fuel TYPE ty_amount,
|
||||
total TYPE ty_amount,
|
||||
reason TYPE ty_reason,
|
||||
END OF ty_result.
|
||||
|
||||
METHODS calculate
|
||||
IMPORTING iv_weight_kg TYPE ty_weight
|
||||
iv_volume_m3 TYPE ty_volume
|
||||
iv_distance_km TYPE ty_distance
|
||||
iv_fuel_index TYPE ty_fuel
|
||||
RETURNING VALUE(rs_result) TYPE ty_result.
|
||||
ENDINTERFACE.
|
||||
61
tasks_gen/eval/G0008/spec.md
Normal file
61
tasks_gen/eval/G0008/spec.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# 1. Goal
|
||||
A freight forwarder calculates the price of an outbound shipment. The
|
||||
calculation service receives the gross weight, the volume, the transport
|
||||
distance, and the current fuel index. It returns the freight components and a
|
||||
reason code.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- The interface {{P}}IF_FREIGHT_CALC exists in package $TMP. It is active.
|
||||
- The interface defines the types TY_REASON, TY_AMOUNT, TY_WEIGHT, TY_VOLUME,
|
||||
TY_DISTANCE, TY_FUEL, and TY_RESULT.
|
||||
- The interface defines the constant structure C_REASON with the components
|
||||
OK, WEIGHT, VOLUME, DISTANCE, and FUEL.
|
||||
- The interface defines the instance method CALCULATE with the importing
|
||||
parameters IV_WEIGHT_KG, IV_VOLUME_M3, IV_DISTANCE_KM, IV_FUEL_INDEX and the
|
||||
returning parameter RS_RESULT.
|
||||
|
||||
# 4. Contract
|
||||
- Create the class {{P}}FREIGHT_CALC in package $TMP.
|
||||
- The class is public, final, and has a public constructor without parameters.
|
||||
- The class implements {{P}}IF_FREIGHT_CALC.
|
||||
- Do not add other public methods.
|
||||
|
||||
# 5. Business rules
|
||||
All amounts are in euro. Apply the rules in this sequence.
|
||||
1. If IV_WEIGHT_KG is less than or equal to 0, return the reason WEIGHT. Set
|
||||
all amounts and the chargeable weight to 0.
|
||||
2. If IV_VOLUME_M3 is less than 0, return the reason VOLUME. Set all amounts
|
||||
and the chargeable weight to 0.
|
||||
3. If IV_DISTANCE_KM is less than or equal to 0, return the reason DISTANCE.
|
||||
Set all amounts and the chargeable weight to 0.
|
||||
4. If IV_FUEL_INDEX is less than 0 or greater than 100, return the reason FUEL.
|
||||
Set all amounts and the chargeable weight to 0.
|
||||
5. The volumetric weight is IV_VOLUME_M3 multiplied by 250.
|
||||
6. The chargeable weight is the greater of IV_WEIGHT_KG and the volumetric
|
||||
weight.
|
||||
7. The base freight is 45.00. For each full or partial 100 kg by which the
|
||||
chargeable weight is greater than 1000 kg, add 6.50.
|
||||
8. The distance freight is 0.00 for a distance up to and including 100 km. For
|
||||
each full or partial 100 km by which IV_DISTANCE_KM is greater than 100 km,
|
||||
add 9.00.
|
||||
9. The fuel freight is the sum of the base freight and the distance freight,
|
||||
multiplied by IV_FUEL_INDEX, divided by 100. Round the result to 2 decimal
|
||||
places. Round a half away from zero.
|
||||
10. The total is the sum of the base freight, the distance freight, and the
|
||||
fuel freight.
|
||||
11. Return the reason OK.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: 7.40 SP05. Do not use syntax that is newer than 7.40 SP05.
|
||||
For example, do not use COND, SWITCH, REDUCE, FOR, or LET.
|
||||
- Coding standards: Clean ABAP. Method length below 40 statements. No global
|
||||
variables. No comment that restates the code.
|
||||
- Out of scope: do not change {{P}}IF_FREIGHT_CALC.
|
||||
|
||||
# 7. Acceptance
|
||||
- The class is active and has no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write your own ABAP Unit tests for the class.
|
||||
51
tasks_gen/eval/G0008/task.json
Normal file
51
tasks_gen/eval/G0008/task.json
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"id": "G0008",
|
||||
"category": "G",
|
||||
"object_type": "CLAS",
|
||||
"difficulty": 2,
|
||||
"release_target": "v740sp05",
|
||||
"expected_outcome": "implement",
|
||||
"budget": {
|
||||
"max_tool_calls": 45,
|
||||
"max_activations": 12
|
||||
},
|
||||
"seed": [
|
||||
{
|
||||
"type": "INTF",
|
||||
"name": "{{P}}IF_FREIGHT_CALC",
|
||||
"file": "seed/if_freight_calc.intf.abap",
|
||||
"description": "Freight calculation contract with result type and reason codes"
|
||||
}
|
||||
],
|
||||
"contract": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}FREIGHT_CALC",
|
||||
"implements": "{{P}}IF_FREIGHT_CALC"
|
||||
}
|
||||
],
|
||||
"out_of_scope": [
|
||||
"{{P}}IF_FREIGHT_CALC"
|
||||
],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}T07_HIDDEN",
|
||||
"file": "hidden/t07_hidden.clas.abap",
|
||||
"description": "T07 hidden tests for the freight calculation"
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}FREIGHT_CALC",
|
||||
"file": "reference/freight_calc.clas.abap",
|
||||
"description": "Freight surcharge calculator",
|
||||
"testclasses_file": "reference/freight_calc.testclasses.abap"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length",
|
||||
"nesting_depth"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user