Fix coverage with several contract classes; table annotation and file path checks; clean task dir on write
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
This commit is contained in:
51
tasks_gen/eval/G0107/faulty/m0_energy_bill.func.abap
Normal file
51
tasks_gen/eval/G0107/faulty/m0_energy_bill.func.abap
Normal file
@@ -0,0 +1,51 @@
|
||||
FUNCTION {{p}}energy_bill
|
||||
IMPORTING
|
||||
iv_consumption TYPE decfloat34
|
||||
iv_tariff TYPE string
|
||||
iv_direct_debit TYPE abap_bool
|
||||
EXPORTING
|
||||
ev_bill TYPE decfloat34
|
||||
EXCEPTIONS
|
||||
invalid_consumption
|
||||
invalid_tariff.
|
||||
|
||||
CONSTANTS lc_base_fee TYPE decfloat34 VALUE '12.00'.
|
||||
CONSTANTS lc_tier_limit TYPE decfloat34 VALUE '300'.
|
||||
CONSTANTS lc_tier_factor TYPE decfloat34 VALUE '0.8'.
|
||||
CONSTANTS lc_debit_factor TYPE decfloat34 VALUE '0.98'.
|
||||
|
||||
IF iv_consumption >= 0.
|
||||
RAISE invalid_consumption.
|
||||
ENDIF.
|
||||
|
||||
DATA lv_rate TYPE decfloat34.
|
||||
CASE iv_tariff.
|
||||
WHEN 'BASIC'.
|
||||
lv_rate = '0.32'.
|
||||
WHEN 'GREEN'.
|
||||
lv_rate = '0.38'.
|
||||
WHEN 'NIGHT'.
|
||||
lv_rate = '0.24'.
|
||||
WHEN OTHERS.
|
||||
RAISE invalid_tariff.
|
||||
ENDCASE.
|
||||
|
||||
DATA lv_standard_qty TYPE decfloat34.
|
||||
DATA lv_reduced_qty TYPE decfloat34.
|
||||
IF iv_consumption > lc_tier_limit.
|
||||
lv_standard_qty = lc_tier_limit.
|
||||
lv_reduced_qty = iv_consumption - lc_tier_limit.
|
||||
ELSE.
|
||||
lv_standard_qty = iv_consumption.
|
||||
lv_reduced_qty = 0.
|
||||
ENDIF.
|
||||
|
||||
DATA lv_bill TYPE decfloat34.
|
||||
lv_bill = lc_base_fee + lv_standard_qty * lv_rate
|
||||
+ lv_reduced_qty * lv_rate * lc_tier_factor.
|
||||
IF iv_direct_debit = abap_true.
|
||||
lv_bill = lv_bill * lc_debit_factor.
|
||||
ENDIF.
|
||||
|
||||
ev_bill = round( val = lv_bill dec = 2 mode = cl_abap_math=>round_half_up ).
|
||||
ENDFUNCTION.
|
||||
51
tasks_gen/eval/G0107/faulty/m1_energy_bill.func.abap
Normal file
51
tasks_gen/eval/G0107/faulty/m1_energy_bill.func.abap
Normal file
@@ -0,0 +1,51 @@
|
||||
FUNCTION {{p}}energy_bill
|
||||
IMPORTING
|
||||
iv_consumption TYPE decfloat34
|
||||
iv_tariff TYPE string
|
||||
iv_direct_debit TYPE abap_bool
|
||||
EXPORTING
|
||||
ev_bill TYPE decfloat34
|
||||
EXCEPTIONS
|
||||
invalid_consumption
|
||||
invalid_tariff.
|
||||
|
||||
CONSTANTS lc_base_fee TYPE decfloat34 VALUE '12.00'.
|
||||
CONSTANTS lc_tier_limit TYPE decfloat34 VALUE '300'.
|
||||
CONSTANTS lc_tier_factor TYPE decfloat34 VALUE '0.8'.
|
||||
CONSTANTS lc_debit_factor TYPE decfloat34 VALUE '0.98'.
|
||||
|
||||
IF iv_consumption < 0.
|
||||
RAISE invalid_consumption.
|
||||
ENDIF.
|
||||
|
||||
DATA lv_rate TYPE decfloat34.
|
||||
CASE iv_tariff.
|
||||
WHEN 'BASIC'.
|
||||
lv_rate = '0.32'.
|
||||
WHEN 'GREEN'.
|
||||
lv_rate = '0.38'.
|
||||
WHEN 'NIGHT'.
|
||||
lv_rate = '0.24'.
|
||||
WHEN OTHERS.
|
||||
RAISE invalid_tariff.
|
||||
ENDCASE.
|
||||
|
||||
DATA lv_standard_qty TYPE decfloat34.
|
||||
DATA lv_reduced_qty TYPE decfloat34.
|
||||
IF iv_consumption > lc_tier_limit.
|
||||
lv_standard_qty = lc_tier_limit.
|
||||
lv_reduced_qty = iv_consumption - lc_tier_limit.
|
||||
ELSE.
|
||||
lv_standard_qty = iv_consumption.
|
||||
lv_reduced_qty = 0.
|
||||
ENDIF.
|
||||
|
||||
DATA lv_bill TYPE decfloat34.
|
||||
lv_bill = lc_base_fee + lv_standard_qty / lv_rate
|
||||
+ lv_reduced_qty * lv_rate * lc_tier_factor.
|
||||
IF iv_direct_debit = abap_true.
|
||||
lv_bill = lv_bill * lc_debit_factor.
|
||||
ENDIF.
|
||||
|
||||
ev_bill = round( val = lv_bill dec = 2 mode = cl_abap_math=>round_half_up ).
|
||||
ENDFUNCTION.
|
||||
51
tasks_gen/eval/G0107/faulty/m2_energy_bill.func.abap
Normal file
51
tasks_gen/eval/G0107/faulty/m2_energy_bill.func.abap
Normal file
@@ -0,0 +1,51 @@
|
||||
FUNCTION {{p}}energy_bill
|
||||
IMPORTING
|
||||
iv_consumption TYPE decfloat34
|
||||
iv_tariff TYPE string
|
||||
iv_direct_debit TYPE abap_bool
|
||||
EXPORTING
|
||||
ev_bill TYPE decfloat34
|
||||
EXCEPTIONS
|
||||
invalid_consumption
|
||||
invalid_tariff.
|
||||
|
||||
CONSTANTS lc_base_fee TYPE decfloat34 VALUE '12.00'.
|
||||
CONSTANTS lc_tier_limit TYPE decfloat34 VALUE '300'.
|
||||
CONSTANTS lc_tier_factor TYPE decfloat34 VALUE '0.8'.
|
||||
CONSTANTS lc_debit_factor TYPE decfloat34 VALUE '0.98'.
|
||||
|
||||
IF iv_consumption < 0.
|
||||
RAISE invalid_consumption.
|
||||
ENDIF.
|
||||
|
||||
DATA lv_rate TYPE decfloat34.
|
||||
CASE iv_tariff.
|
||||
WHEN 'BASIC'.
|
||||
lv_rate = '0.32'.
|
||||
WHEN 'GREEN'.
|
||||
lv_rate = '0.38'.
|
||||
WHEN 'NIGHT'.
|
||||
lv_rate = '0.24'.
|
||||
WHEN OTHERS.
|
||||
RAISE invalid_tariff.
|
||||
ENDCASE.
|
||||
|
||||
DATA lv_standard_qty TYPE decfloat34.
|
||||
DATA lv_reduced_qty TYPE decfloat34.
|
||||
IF iv_consumption > lc_tier_limit.
|
||||
lv_standard_qty = lc_tier_limit.
|
||||
lv_reduced_qty = iv_consumption - lc_tier_limit.
|
||||
ELSE.
|
||||
lv_standard_qty = iv_consumption.
|
||||
lv_reduced_qty = 0.
|
||||
ENDIF.
|
||||
|
||||
DATA lv_bill TYPE decfloat34.
|
||||
lv_bill = lc_base_fee + lv_standard_qty * lv_rate
|
||||
+ lv_reduced_qty * lv_rate / lc_tier_factor.
|
||||
IF iv_direct_debit = abap_true.
|
||||
lv_bill = lv_bill * lc_debit_factor.
|
||||
ENDIF.
|
||||
|
||||
ev_bill = round( val = lv_bill dec = 2 mode = cl_abap_math=>round_half_up ).
|
||||
ENDFUNCTION.
|
||||
51
tasks_gen/eval/G0107/faulty/m3_energy_bill.func.abap
Normal file
51
tasks_gen/eval/G0107/faulty/m3_energy_bill.func.abap
Normal file
@@ -0,0 +1,51 @@
|
||||
FUNCTION {{p}}energy_bill
|
||||
IMPORTING
|
||||
iv_consumption TYPE decfloat34
|
||||
iv_tariff TYPE string
|
||||
iv_direct_debit TYPE abap_bool
|
||||
EXPORTING
|
||||
ev_bill TYPE decfloat34
|
||||
EXCEPTIONS
|
||||
invalid_consumption
|
||||
invalid_tariff.
|
||||
|
||||
CONSTANTS lc_base_fee TYPE decfloat34 VALUE '12.00'.
|
||||
CONSTANTS lc_tier_limit TYPE decfloat34 VALUE '300'.
|
||||
CONSTANTS lc_tier_factor TYPE decfloat34 VALUE '0.8'.
|
||||
CONSTANTS lc_debit_factor TYPE decfloat34 VALUE '0.98'.
|
||||
|
||||
IF iv_consumption < 0.
|
||||
RAISE invalid_consumption.
|
||||
ENDIF.
|
||||
|
||||
DATA lv_rate TYPE decfloat34.
|
||||
CASE iv_tariff.
|
||||
WHEN 'BASIC'.
|
||||
lv_rate = '0.32'.
|
||||
WHEN 'GREEN'.
|
||||
lv_rate = '0.38'.
|
||||
WHEN 'NIGHT'.
|
||||
lv_rate = '0.24'.
|
||||
WHEN OTHERS.
|
||||
RAISE invalid_tariff.
|
||||
ENDCASE.
|
||||
|
||||
DATA lv_standard_qty TYPE decfloat34.
|
||||
DATA lv_reduced_qty TYPE decfloat34.
|
||||
IF iv_consumption > lc_tier_limit.
|
||||
lv_standard_qty = lc_tier_limit.
|
||||
lv_reduced_qty = iv_consumption - lc_tier_limit.
|
||||
ELSE.
|
||||
lv_standard_qty = iv_consumption.
|
||||
lv_reduced_qty = 0.
|
||||
ENDIF.
|
||||
|
||||
DATA lv_bill TYPE decfloat34.
|
||||
lv_bill = lc_base_fee + lv_standard_qty * lv_rate
|
||||
+ lv_reduced_qty * lv_rate * lc_tier_factor.
|
||||
IF iv_direct_debit <> abap_true.
|
||||
lv_bill = lv_bill * lc_debit_factor.
|
||||
ENDIF.
|
||||
|
||||
ev_bill = round( val = lv_bill dec = 2 mode = cl_abap_math=>round_half_up ).
|
||||
ENDFUNCTION.
|
||||
51
tasks_gen/eval/G0107/faulty/m4_energy_bill.func.abap
Normal file
51
tasks_gen/eval/G0107/faulty/m4_energy_bill.func.abap
Normal file
@@ -0,0 +1,51 @@
|
||||
FUNCTION {{p}}energy_bill
|
||||
IMPORTING
|
||||
iv_consumption TYPE decfloat34
|
||||
iv_tariff TYPE string
|
||||
iv_direct_debit TYPE abap_bool
|
||||
EXPORTING
|
||||
ev_bill TYPE decfloat34
|
||||
EXCEPTIONS
|
||||
invalid_consumption
|
||||
invalid_tariff.
|
||||
|
||||
CONSTANTS lc_base_fee TYPE decfloat34 VALUE '12.00'.
|
||||
CONSTANTS lc_tier_limit TYPE decfloat34 VALUE '300'.
|
||||
CONSTANTS lc_tier_factor TYPE decfloat34 VALUE '0.8'.
|
||||
CONSTANTS lc_debit_factor TYPE decfloat34 VALUE '0.98'.
|
||||
|
||||
IF iv_consumption < 0.
|
||||
RAISE invalid_consumption.
|
||||
ENDIF.
|
||||
|
||||
DATA lv_rate TYPE decfloat34.
|
||||
CASE iv_tariff.
|
||||
WHEN 'BASIC'.
|
||||
lv_rate = '0.32'.
|
||||
WHEN 'GREEN'.
|
||||
lv_rate = '0.38'.
|
||||
WHEN 'NIGHT'.
|
||||
lv_rate = '0.24'.
|
||||
WHEN OTHERS.
|
||||
RAISE invalid_tariff.
|
||||
ENDCASE.
|
||||
|
||||
DATA lv_standard_qty TYPE decfloat34.
|
||||
DATA lv_reduced_qty TYPE decfloat34.
|
||||
IF iv_consumption > lc_tier_limit.
|
||||
lv_standard_qty = lc_tier_limit.
|
||||
lv_reduced_qty = iv_consumption - lc_tier_limit.
|
||||
ELSE.
|
||||
lv_standard_qty = iv_consumption.
|
||||
lv_reduced_qty = 0.
|
||||
ENDIF.
|
||||
|
||||
DATA lv_bill TYPE decfloat34.
|
||||
lv_bill = lc_base_fee + lv_standard_qty * lv_rate
|
||||
+ lv_reduced_qty * lv_rate * lc_tier_factor.
|
||||
IF iv_direct_debit = abap_true.
|
||||
lv_bill = lv_bill * lc_debit_factor.
|
||||
ENDIF.
|
||||
|
||||
ev_bill = round( val = lv_bill dec = 3 mode = cl_abap_math=>round_half_up ).
|
||||
ENDFUNCTION.
|
||||
29
tasks_gen/eval/G0107/generation.json
Normal file
29
tasks_gen/eval/G0107/generation.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"id": "G0107",
|
||||
"pool": "eval",
|
||||
"object_type": "FUNC",
|
||||
"category": "A",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 85.0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 100.0,
|
||||
"null": 0,
|
||||
"mutation": {
|
||||
"valid": 5,
|
||||
"killed": 5,
|
||||
"ok": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"accepted": true
|
||||
}
|
||||
100
tasks_gen/eval/G0107/hidden/t21_hidden.clas.abap
Normal file
100
tasks_gen/eval/G0107/hidden/t21_hidden.clas.abap
Normal file
@@ -0,0 +1,100 @@
|
||||
CLASS {{p}}t21_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
METHODS bill
|
||||
IMPORTING
|
||||
iv_consumption TYPE decfloat34
|
||||
iv_tariff TYPE string
|
||||
iv_direct_debit TYPE abap_bool DEFAULT abap_false
|
||||
EXPORTING
|
||||
ev_bill TYPE decfloat34
|
||||
ev_subrc TYPE sysubrc.
|
||||
METHODS basic_no_tier FOR TESTING.
|
||||
METHODS tier_discount FOR TESTING.
|
||||
METHODS green_tariff FOR TESTING.
|
||||
METHODS night_tariff FOR TESTING.
|
||||
METHODS direct_debit FOR TESTING.
|
||||
METHODS rounding FOR TESTING.
|
||||
METHODS tier_boundary FOR TESTING.
|
||||
METHODS zero_consumption FOR TESTING.
|
||||
METHODS negative_consumption FOR TESTING.
|
||||
METHODS unknown_tariff FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t21_hidden IMPLEMENTATION.
|
||||
METHOD bill.
|
||||
CALL FUNCTION '{{P}}ENERGY_BILL'
|
||||
EXPORTING
|
||||
iv_consumption = iv_consumption
|
||||
iv_tariff = iv_tariff
|
||||
iv_direct_debit = iv_direct_debit
|
||||
IMPORTING
|
||||
ev_bill = ev_bill
|
||||
EXCEPTIONS
|
||||
invalid_consumption = 1
|
||||
invalid_tariff = 2
|
||||
OTHERS = 3.
|
||||
ev_subrc = sy-subrc.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD basic_no_tier.
|
||||
bill( EXPORTING iv_consumption = 100 iv_tariff = `BASIC`
|
||||
IMPORTING ev_bill = DATA(lv_bill) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '44.00' ) act = lv_bill ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD tier_discount.
|
||||
bill( EXPORTING iv_consumption = 400 iv_tariff = `BASIC`
|
||||
IMPORTING ev_bill = DATA(lv_bill) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '133.60' ) act = lv_bill ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD green_tariff.
|
||||
bill( EXPORTING iv_consumption = 250 iv_tariff = `GREEN`
|
||||
IMPORTING ev_bill = DATA(lv_bill) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '107.00' ) act = lv_bill ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD night_tariff.
|
||||
bill( EXPORTING iv_consumption = 500 iv_tariff = `NIGHT`
|
||||
IMPORTING ev_bill = DATA(lv_bill) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '122.40' ) act = lv_bill ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD direct_debit.
|
||||
bill( EXPORTING iv_consumption = 400 iv_tariff = `BASIC` iv_direct_debit = abap_true
|
||||
IMPORTING ev_bill = DATA(lv_bill) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '130.93' ) act = lv_bill ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rounding.
|
||||
bill( EXPORTING iv_consumption = 309 iv_tariff = `BASIC`
|
||||
IMPORTING ev_bill = DATA(lv_bill) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '110.30' ) act = lv_bill ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD tier_boundary.
|
||||
bill( EXPORTING iv_consumption = 300 iv_tariff = `BASIC`
|
||||
IMPORTING ev_bill = DATA(lv_bill) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '108.00' ) act = lv_bill ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_consumption.
|
||||
bill( EXPORTING iv_consumption = 0 iv_tariff = `NIGHT`
|
||||
IMPORTING ev_bill = DATA(lv_bill) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '12.00' ) act = lv_bill ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD negative_consumption.
|
||||
bill( EXPORTING iv_consumption = -1 iv_tariff = `BASIC`
|
||||
IMPORTING ev_subrc = DATA(lv_rc) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_tariff.
|
||||
bill( EXPORTING iv_consumption = 100 iv_tariff = `ECO`
|
||||
IMPORTING ev_subrc = DATA(lv_rc) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_rc ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
80
tasks_gen/eval/G0107/mutation.json
Normal file
80
tasks_gen/eval/G0107/mutation.json
Normal file
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"task": "G0107",
|
||||
"mutants": [
|
||||
{
|
||||
"object": "{{P}}ENERGY_BILL",
|
||||
"mutant": "line 17: < -> >= (rel)",
|
||||
"status": "killed",
|
||||
"hidden": "0/10",
|
||||
"failed_tests": [
|
||||
"BASIC_NO_TIER",
|
||||
"DIRECT_DEBIT",
|
||||
"GREEN_TARIFF",
|
||||
"NEGATIVE_CONSUMPTION",
|
||||
"NIGHT_TARIFF",
|
||||
"ROUNDING",
|
||||
"TIER_BOUNDARY",
|
||||
"TIER_DISCOUNT",
|
||||
"UNKNOWN_TARIFF",
|
||||
"ZERO_CONSUMPTION"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}ENERGY_BILL",
|
||||
"mutant": "line 44: * -> / (arith)",
|
||||
"status": "killed",
|
||||
"hidden": "3/10",
|
||||
"failed_tests": [
|
||||
"BASIC_NO_TIER",
|
||||
"DIRECT_DEBIT",
|
||||
"GREEN_TARIFF",
|
||||
"NIGHT_TARIFF",
|
||||
"ROUNDING",
|
||||
"TIER_BOUNDARY",
|
||||
"TIER_DISCOUNT"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}ENERGY_BILL",
|
||||
"mutant": "line 45: * -> / (arith)",
|
||||
"status": "killed",
|
||||
"hidden": "6/10",
|
||||
"failed_tests": [
|
||||
"DIRECT_DEBIT",
|
||||
"NIGHT_TARIFF",
|
||||
"ROUNDING",
|
||||
"TIER_DISCOUNT"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}ENERGY_BILL",
|
||||
"mutant": "line 46: = -> <> (eq)",
|
||||
"status": "killed",
|
||||
"hidden": "2/10",
|
||||
"failed_tests": [
|
||||
"BASIC_NO_TIER",
|
||||
"DIRECT_DEBIT",
|
||||
"GREEN_TARIFF",
|
||||
"NIGHT_TARIFF",
|
||||
"ROUNDING",
|
||||
"TIER_BOUNDARY",
|
||||
"TIER_DISCOUNT",
|
||||
"ZERO_CONSUMPTION"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}ENERGY_BILL",
|
||||
"mutant": "line 50: 2 -> 3 (const)",
|
||||
"status": "killed",
|
||||
"hidden": "8/10",
|
||||
"failed_tests": [
|
||||
"DIRECT_DEBIT",
|
||||
"ROUNDING"
|
||||
]
|
||||
}
|
||||
],
|
||||
"valid": 5,
|
||||
"killed": 5,
|
||||
"kill_rate": 1.0,
|
||||
"ok": true
|
||||
}
|
||||
51
tasks_gen/eval/G0107/reference/energy_bill.func.abap
Normal file
51
tasks_gen/eval/G0107/reference/energy_bill.func.abap
Normal file
@@ -0,0 +1,51 @@
|
||||
FUNCTION {{p}}energy_bill
|
||||
IMPORTING
|
||||
iv_consumption TYPE decfloat34
|
||||
iv_tariff TYPE string
|
||||
iv_direct_debit TYPE abap_bool
|
||||
EXPORTING
|
||||
ev_bill TYPE decfloat34
|
||||
EXCEPTIONS
|
||||
invalid_consumption
|
||||
invalid_tariff.
|
||||
|
||||
CONSTANTS lc_base_fee TYPE decfloat34 VALUE '12.00'.
|
||||
CONSTANTS lc_tier_limit TYPE decfloat34 VALUE '300'.
|
||||
CONSTANTS lc_tier_factor TYPE decfloat34 VALUE '0.8'.
|
||||
CONSTANTS lc_debit_factor TYPE decfloat34 VALUE '0.98'.
|
||||
|
||||
IF iv_consumption < 0.
|
||||
RAISE invalid_consumption.
|
||||
ENDIF.
|
||||
|
||||
DATA lv_rate TYPE decfloat34.
|
||||
CASE iv_tariff.
|
||||
WHEN 'BASIC'.
|
||||
lv_rate = '0.32'.
|
||||
WHEN 'GREEN'.
|
||||
lv_rate = '0.38'.
|
||||
WHEN 'NIGHT'.
|
||||
lv_rate = '0.24'.
|
||||
WHEN OTHERS.
|
||||
RAISE invalid_tariff.
|
||||
ENDCASE.
|
||||
|
||||
DATA lv_standard_qty TYPE decfloat34.
|
||||
DATA lv_reduced_qty TYPE decfloat34.
|
||||
IF iv_consumption > lc_tier_limit.
|
||||
lv_standard_qty = lc_tier_limit.
|
||||
lv_reduced_qty = iv_consumption - lc_tier_limit.
|
||||
ELSE.
|
||||
lv_standard_qty = iv_consumption.
|
||||
lv_reduced_qty = 0.
|
||||
ENDIF.
|
||||
|
||||
DATA lv_bill TYPE decfloat34.
|
||||
lv_bill = lc_base_fee + lv_standard_qty * lv_rate
|
||||
+ lv_reduced_qty * lv_rate * lc_tier_factor.
|
||||
IF iv_direct_debit = abap_true.
|
||||
lv_bill = lv_bill * lc_debit_factor.
|
||||
ENDIF.
|
||||
|
||||
ev_bill = round( val = lv_bill dec = 2 mode = cl_abap_math=>round_half_up ).
|
||||
ENDFUNCTION.
|
||||
68
tasks_gen/eval/G0107/reference/t21_test.clas.abap
Normal file
68
tasks_gen/eval/G0107/reference/t21_test.clas.abap
Normal file
@@ -0,0 +1,68 @@
|
||||
CLASS {{p}}t21_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
METHODS bill
|
||||
IMPORTING
|
||||
iv_consumption TYPE decfloat34
|
||||
iv_tariff TYPE string
|
||||
iv_direct_debit TYPE abap_bool DEFAULT abap_false
|
||||
EXPORTING
|
||||
ev_bill TYPE decfloat34
|
||||
ev_subrc TYPE sysubrc.
|
||||
METHODS basic_bill FOR TESTING.
|
||||
METHODS tier_bill FOR TESTING.
|
||||
METHODS debit_bill FOR TESTING.
|
||||
METHODS invalid_input FOR TESTING.
|
||||
METHODS unknown_tariff FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t21_test IMPLEMENTATION.
|
||||
METHOD bill.
|
||||
CALL FUNCTION '{{P}}ENERGY_BILL'
|
||||
EXPORTING
|
||||
iv_consumption = iv_consumption
|
||||
iv_tariff = iv_tariff
|
||||
iv_direct_debit = iv_direct_debit
|
||||
IMPORTING
|
||||
ev_bill = ev_bill
|
||||
EXCEPTIONS
|
||||
invalid_consumption = 1
|
||||
invalid_tariff = 2
|
||||
OTHERS = 3.
|
||||
ev_subrc = sy-subrc.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD basic_bill.
|
||||
bill( EXPORTING iv_consumption = 100 iv_tariff = `BASIC`
|
||||
IMPORTING ev_bill = DATA(lv_bill) ev_subrc = DATA(lv_rc) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '44.00' ) act = lv_bill ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD tier_bill.
|
||||
bill( EXPORTING iv_consumption = 400 iv_tariff = `BASIC`
|
||||
IMPORTING ev_bill = DATA(lv_bill) ev_subrc = DATA(lv_rc) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '133.60' ) act = lv_bill ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD debit_bill.
|
||||
bill( EXPORTING iv_consumption = 400 iv_tariff = `BASIC` iv_direct_debit = abap_true
|
||||
IMPORTING ev_bill = DATA(lv_bill) ev_subrc = DATA(lv_rc) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '130.93' ) act = lv_bill ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_input.
|
||||
bill( EXPORTING iv_consumption = -1 iv_tariff = `BASIC`
|
||||
IMPORTING ev_subrc = DATA(lv_rc) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_tariff.
|
||||
bill( EXPORTING iv_consumption = 100 iv_tariff = `ECO`
|
||||
IMPORTING ev_subrc = DATA(lv_rc) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_rc ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
61
tasks_gen/eval/G0107/spec.md
Normal file
61
tasks_gen/eval/G0107/spec.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# 1. Goal
|
||||
|
||||
An energy supplier bills households for electricity. The billing program calls
|
||||
one function module for each household. The function module calculates the bill
|
||||
of one month.
|
||||
|
||||
# 2. Open questions
|
||||
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
|
||||
- The function group {{P}}FG_BILL exists in package $TMP. The group is empty.
|
||||
- The billing program calls the function module once for each household. It
|
||||
passes the consumption of the month, the tariff, and the payment method.
|
||||
- The consumption is a quantity in kilowatt hours (kWh).
|
||||
- The bill is an amount in euro.
|
||||
|
||||
# 4. Contract
|
||||
|
||||
- Create the function module {{P}}ENERGY_BILL in function group {{P}}FG_BILL.
|
||||
- Use this interface:
|
||||
|
||||
| Parameter | Kind | Type | Meaning |
|
||||
| --- | --- | --- | --- |
|
||||
| iv_consumption | Importing | decfloat34 | Consumption of the month in kWh |
|
||||
| iv_tariff | Importing | string | Tariff code |
|
||||
| iv_direct_debit | Importing | abap_bool | abap_true if the customer pays by direct debit |
|
||||
| ev_bill | Exporting | decfloat34 | Bill in euro |
|
||||
| invalid_consumption | Exception | | See rule 1 |
|
||||
| invalid_tariff | Exception | | See rule 2 |
|
||||
|
||||
# 5. Business rules
|
||||
|
||||
1. If the consumption is less than zero, raise the exception
|
||||
INVALID_CONSUMPTION. Do not set the bill.
|
||||
2. The valid tariff codes are BASIC, GREEN, and NIGHT. Any other tariff code
|
||||
raises the exception INVALID_TARIFF. Do not set the bill.
|
||||
3. Every bill contains a base fee of 12.00 euro.
|
||||
4. The working price for one kWh is:
|
||||
- BASIC: 0.32 euro
|
||||
- GREEN: 0.38 euro
|
||||
- NIGHT: 0.24 euro
|
||||
5. For a consumption above 300 kWh, the working price of the part above 300 kWh
|
||||
is 80 % of the working price of the tariff.
|
||||
6. If the customer pays by direct debit, the bill is 2 % lower.
|
||||
7. Round the bill half up to 2 decimals.
|
||||
|
||||
# 6. Constraints
|
||||
|
||||
- Release target: ABAP Platform 2025 (SAP_BASIS 816).
|
||||
- Package: $TMP. Do not use transports.
|
||||
- Coding standard: Clean ABAP. Keep every method below 40 statements.
|
||||
- Out of scope: database access, CDS views, reports, ALV, dynpro, and changes
|
||||
to other objects.
|
||||
|
||||
# 7. Acceptance
|
||||
|
||||
- The function module {{P}}ENERGY_BILL is active and has no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write ABAP Unit tests for the function module in a global test class.
|
||||
71
tasks_gen/eval/G0107/task.json
Normal file
71
tasks_gen/eval/G0107/task.json
Normal file
@@ -0,0 +1,71 @@
|
||||
{
|
||||
"id": "G0107",
|
||||
"category": "A",
|
||||
"object_type": "FUNC",
|
||||
"difficulty": 2,
|
||||
"release_target": "v816",
|
||||
"expected_outcome": "implement",
|
||||
"budget": {
|
||||
"max_tool_calls": 40,
|
||||
"max_activations": 10
|
||||
},
|
||||
"seed": [
|
||||
{
|
||||
"type": "FUGR",
|
||||
"name": "{{P}}FG_BILL",
|
||||
"description": "Billing function group (empty)"
|
||||
}
|
||||
],
|
||||
"contract": [
|
||||
{
|
||||
"type": "FUNC",
|
||||
"name": "{{P}}ENERGY_BILL",
|
||||
"functionGroup": "{{P}}FG_BILL",
|
||||
"params": [
|
||||
{
|
||||
"name": "iv_consumption",
|
||||
"type": "decfloat34"
|
||||
},
|
||||
{
|
||||
"name": "iv_tariff",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "iv_direct_debit",
|
||||
"type": "abap_bool"
|
||||
},
|
||||
{
|
||||
"name": "ev_bill",
|
||||
"type": "decfloat34"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"out_of_scope": [],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}T21_HIDDEN",
|
||||
"file": "hidden/t21_hidden.clas.abap",
|
||||
"description": "T21 hidden tests"
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "FUNC",
|
||||
"name": "{{P}}ENERGY_BILL",
|
||||
"functionGroup": "{{P}}FG_BILL",
|
||||
"file": "reference/energy_bill.func.abap",
|
||||
"description": "Electricity bill module"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}T21_TEST",
|
||||
"file": "reference/t21_test.clas.abap",
|
||||
"description": "T21 own tests"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user