H and K tested (G0168, G0178 accepted); keyword fast path needs all groups
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
This commit is contained in:
50
tasks_gen/eval/G0168/reference/volume_discount.clas.abap
Normal file
50
tasks_gen/eval/G0168/reference/volume_discount.clas.abap
Normal file
@@ -0,0 +1,50 @@
|
||||
CLASS {{p}}volume_discount DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_discount.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS:
|
||||
c_max_discount TYPE {{p}}if_discount=>ty_percent VALUE '12.00',
|
||||
c_key_discount TYPE {{p}}if_discount=>ty_percent VALUE '6.00',
|
||||
c_mid_discount TYPE {{p}}if_discount=>ty_percent VALUE '3.00',
|
||||
c_high_discount TYPE {{p}}if_discount=>ty_percent VALUE '7.00',
|
||||
c_no_discount TYPE {{p}}if_discount=>ty_percent VALUE '0.00',
|
||||
c_mid_limit TYPE i VALUE 100,
|
||||
c_high_limit TYPE i VALUE 500.
|
||||
|
||||
METHODS customer_discount
|
||||
IMPORTING iv_group TYPE {{p}}if_discount=>ty_group
|
||||
RETURNING VALUE(rv_percent) TYPE {{p}}if_discount=>ty_percent.
|
||||
|
||||
METHODS volume_discount
|
||||
IMPORTING iv_quantity TYPE i
|
||||
RETURNING VALUE(rv_percent) TYPE {{p}}if_discount=>ty_percent.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}volume_discount IMPLEMENTATION.
|
||||
METHOD {{p}}if_discount~calculate.
|
||||
rv_percent = customer_discount( iv_group ) + volume_discount( iv_quantity ).
|
||||
IF rv_percent > c_max_discount.
|
||||
rv_percent = c_max_discount.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD customer_discount.
|
||||
IF iv_group = {{p}}if_discount=>c_group_key.
|
||||
rv_percent = c_key_discount.
|
||||
ELSE.
|
||||
rv_percent = c_no_discount.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD volume_discount.
|
||||
IF iv_quantity < c_mid_limit.
|
||||
rv_percent = c_no_discount.
|
||||
ELSEIF iv_quantity < c_high_limit.
|
||||
rv_percent = c_mid_discount.
|
||||
ELSE.
|
||||
rv_percent = c_high_discount.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
@@ -0,0 +1,63 @@
|
||||
CLASS ltc_volume_discount DEFINITION FINAL FOR TESTING
|
||||
DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}if_discount.
|
||||
METHODS setup.
|
||||
METHODS key_high_volume FOR TESTING.
|
||||
METHODS key_mid_volume FOR TESTING.
|
||||
METHODS standard_small FOR TESTING.
|
||||
METHODS standard_high FOR TESTING.
|
||||
METHODS unknown_group FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_volume_discount IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}volume_discount( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD key_high_volume.
|
||||
DATA lv_expected TYPE {{p}}if_discount=>ty_percent.
|
||||
lv_expected = '12.00'.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = lv_expected
|
||||
act = mo_cut->calculate( iv_quantity = 800
|
||||
iv_group = {{p}}if_discount=>c_group_key ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD key_mid_volume.
|
||||
DATA lv_expected TYPE {{p}}if_discount=>ty_percent.
|
||||
lv_expected = '9.00'.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = lv_expected
|
||||
act = mo_cut->calculate( iv_quantity = 250
|
||||
iv_group = {{p}}if_discount=>c_group_key ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD standard_small.
|
||||
DATA lv_expected TYPE {{p}}if_discount=>ty_percent.
|
||||
lv_expected = '0.00'.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = lv_expected
|
||||
act = mo_cut->calculate( iv_quantity = 50
|
||||
iv_group = {{p}}if_discount=>c_group_standard ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD standard_high.
|
||||
DATA lv_expected TYPE {{p}}if_discount=>ty_percent.
|
||||
lv_expected = '7.00'.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = lv_expected
|
||||
act = mo_cut->calculate( iv_quantity = 600
|
||||
iv_group = {{p}}if_discount=>c_group_standard ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_group.
|
||||
DATA lv_expected TYPE {{p}}if_discount=>ty_percent.
|
||||
lv_expected = '7.00'.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = lv_expected
|
||||
act = mo_cut->calculate( iv_quantity = 600
|
||||
iv_group = 'X' ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user