ADT fallback: Accept headers for FUNC; G0189 accepted; regen2 results
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
This commit is contained in:
45
tasks_gen/eval/G0143/generation.json
Normal file
45
tasks_gen/eval/G0143/generation.json
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"id": "G0143",
|
||||
"pool": "eval",
|
||||
"object_type": "FUNC",
|
||||
"category": "E",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "bundle",
|
||||
"errors": [
|
||||
"category E: the contract object must be the seed object that the model changes in place (same name in seed, contract and reference)"
|
||||
],
|
||||
"by_check": {
|
||||
"static": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "revalidate",
|
||||
"by": "harness fix 2026-10-03",
|
||||
"change": "ADT activation fallback for a second FUNC write. Bundle not changed.",
|
||||
"oracle": 0,
|
||||
"null": 0,
|
||||
"mutation": {
|
||||
"valid": 0,
|
||||
"killed": 0,
|
||||
"ok": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"accepted": false
|
||||
}
|
||||
97
tasks_gen/eval/G0143/hidden/crane_hidden.clas.abap
Normal file
97
tasks_gen/eval/G0143/hidden/crane_hidden.clas.abap
Normal file
@@ -0,0 +1,97 @@
|
||||
CLASS {{p}}crane_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
METHODS call
|
||||
IMPORTING iv_type TYPE string
|
||||
iv_hours TYPE decfloat34
|
||||
iv_km TYPE i
|
||||
iv_weekend TYPE abap_bool
|
||||
iv_customer TYPE string
|
||||
EXPORTING ev_base TYPE decfloat34
|
||||
ev_travel TYPE decfloat34
|
||||
ev_surcharge TYPE decfloat34
|
||||
ev_discount TYPE decfloat34
|
||||
ev_total TYPE decfloat34
|
||||
ev_subrc TYPE sysubrc.
|
||||
METHODS small_crane_base FOR TESTING.
|
||||
METHODS invalid_crane_type FOR TESTING.
|
||||
METHODS invalid_hours FOR TESTING.
|
||||
METHODS travel_fee_cap FOR TESTING.
|
||||
METHODS weekend_surcharge FOR TESTING.
|
||||
METHODS gold_discount FOR TESTING.
|
||||
METHODS rounding_order FOR TESTING.
|
||||
METHODS total_calculation FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}crane_hidden IMPLEMENTATION.
|
||||
METHOD call.
|
||||
CALL FUNCTION '{{P}}CRANE_FEE_OLD'
|
||||
EXPORTING
|
||||
iv_crane_type = iv_type
|
||||
iv_hours = iv_hours
|
||||
iv_distance_km = iv_km
|
||||
iv_weekend = iv_weekend
|
||||
iv_customer = iv_customer
|
||||
IMPORTING
|
||||
ev_base_fee = ev_base
|
||||
ev_travel_fee = ev_travel
|
||||
ev_surcharge = ev_surcharge
|
||||
ev_discount = ev_discount
|
||||
ev_total = ev_total
|
||||
EXCEPTIONS
|
||||
invalid_crane_type = 1
|
||||
invalid_hours = 2
|
||||
OTHERS = 3.
|
||||
ev_subrc = sy-subrc.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD small_crane_base.
|
||||
call( EXPORTING iv_type = 'SM' iv_hours = 2 iv_km = 0 iv_weekend = abap_false iv_customer = 'STD'
|
||||
IMPORTING ev_base = DATA(lv_base) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 230 ) act = lv_base ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_crane_type.
|
||||
call( EXPORTING iv_type = 'XX' iv_hours = 1 iv_km = 0 iv_weekend = abap_false iv_customer = 'STD'
|
||||
IMPORTING ev_subrc = DATA(lv_rc) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_hours.
|
||||
call( EXPORTING iv_type = 'SM' iv_hours = 0 iv_km = 0 iv_weekend = abap_false iv_customer = 'STD'
|
||||
IMPORTING ev_subrc = DATA(lv_rc) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_rc ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD travel_fee_cap.
|
||||
call( EXPORTING iv_type = 'SM' iv_hours = 1 iv_km = 200 iv_weekend = abap_false iv_customer = 'STD'
|
||||
IMPORTING ev_travel = DATA(lv_travel) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 125 ) act = lv_travel ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD weekend_surcharge.
|
||||
call( EXPORTING iv_type = 'MD' iv_hours = 2 iv_km = 0 iv_weekend = abap_true iv_customer = 'STD'
|
||||
IMPORTING ev_surcharge = DATA(lv_surcharge) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '92.50' ) act = lv_surcharge ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD gold_discount.
|
||||
call( EXPORTING iv_type = 'LG' iv_hours = 1 iv_km = 10 iv_weekend = abap_false iv_customer = 'GOLD'
|
||||
IMPORTING ev_discount = DATA(lv_discount) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '36.85' ) act = lv_discount ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rounding_order.
|
||||
call( EXPORTING iv_type = 'SM' iv_hours = CONV decfloat34( '0.87' ) iv_km = 0 iv_weekend = abap_false iv_customer = 'GOLD'
|
||||
IMPORTING ev_discount = DATA(lv_discount) ev_total = DATA(lv_total) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '10.01' ) act = lv_discount ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '90.05' ) act = lv_total ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD total_calculation.
|
||||
call( EXPORTING iv_type = 'MD' iv_hours = 3 iv_km = 20 iv_weekend = abap_true iv_customer = 'GOLD'
|
||||
IMPORTING ev_total = DATA(lv_total) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '655.88' ) act = lv_total ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
@@ -1,106 +0,0 @@
|
||||
CLASS {{p}}t14_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
METHODS call
|
||||
IMPORTING
|
||||
iv_players TYPE i
|
||||
iv_games TYPE i
|
||||
iv_day TYPE i
|
||||
iv_shoes TYPE abap_bool DEFAULT abap_false
|
||||
EXPORTING
|
||||
ev_fee TYPE decfloat34
|
||||
ev_note TYPE string
|
||||
ev_subrc TYPE sysubrc.
|
||||
METHODS weekday_rate FOR TESTING.
|
||||
METHODS weekend_rate FOR TESTING.
|
||||
METHODS lane_count FOR TESTING.
|
||||
METHODS shoe_charge FOR TESTING.
|
||||
METHODS group_discount FOR TESTING.
|
||||
METHODS group_discount_negative FOR TESTING.
|
||||
METHODS day_above_five FOR TESTING.
|
||||
METHODS invalid_players FOR TESTING.
|
||||
METHODS invalid_games FOR TESTING.
|
||||
METHODS no_discount_below_twelve FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS {{p}}t14_hidden IMPLEMENTATION.
|
||||
METHOD call.
|
||||
CALL FUNCTION '{{P}}BOWL_FEE_OLD'
|
||||
EXPORTING
|
||||
iv_players = iv_players
|
||||
iv_games = iv_games
|
||||
iv_day = iv_day
|
||||
iv_shoes = iv_shoes
|
||||
IMPORTING
|
||||
ev_fee = ev_fee
|
||||
ev_note = ev_note
|
||||
EXCEPTIONS
|
||||
invalid_input = 1
|
||||
OTHERS = 2.
|
||||
ev_subrc = sy-subrc.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD weekday_rate.
|
||||
call( EXPORTING iv_players = 1 iv_games = 1 iv_day = 1
|
||||
IMPORTING ev_fee = DATA(lv_fee) ev_note = DATA(lv_note) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '3.50' ) act = lv_fee ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'BOOKED' act = lv_note ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD weekend_rate.
|
||||
call( EXPORTING iv_players = 6 iv_games = 2 iv_day = 6
|
||||
IMPORTING ev_fee = DATA(lv_fee) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '10.00' ) act = lv_fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD lane_count.
|
||||
call( EXPORTING iv_players = 7 iv_games = 1 iv_day = 1
|
||||
IMPORTING ev_fee = DATA(lv_fee) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '7.00' ) act = lv_fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD shoe_charge.
|
||||
call( EXPORTING iv_players = 7 iv_games = 1 iv_day = 1 iv_shoes = abap_true
|
||||
IMPORTING ev_fee = DATA(lv_fee) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '21.00' ) act = lv_fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD group_discount.
|
||||
call( EXPORTING iv_players = 12 iv_games = 1 iv_day = 1 iv_shoes = abap_true
|
||||
IMPORTING ev_fee = DATA(lv_fee) ev_note = DATA(lv_note) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '21.00' ) act = lv_fee ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'GROUP' act = lv_note ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD group_discount_negative.
|
||||
call( EXPORTING iv_players = 12 iv_games = 1 iv_day = 1
|
||||
IMPORTING ev_fee = DATA(lv_fee) ev_note = DATA(lv_note) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '-3.00' ) act = lv_fee ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'GROUP' act = lv_note ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD day_above_five.
|
||||
call( EXPORTING iv_players = 1 iv_games = 1 iv_day = 8
|
||||
IMPORTING ev_fee = DATA(lv_fee) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '5.00' ) act = lv_fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_players.
|
||||
call( EXPORTING iv_players = 0 iv_games = 1 iv_day = 1
|
||||
IMPORTING ev_subrc = DATA(lv_rc) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_games.
|
||||
call( EXPORTING iv_players = 1 iv_games = 0 iv_day = 1
|
||||
IMPORTING ev_subrc = DATA(lv_rc) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD no_discount_below_twelve.
|
||||
call( EXPORTING iv_players = 11 iv_games = 1 iv_day = 1
|
||||
IMPORTING ev_fee = DATA(lv_fee) ev_note = DATA(lv_note) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '7.00' ) act = lv_fee ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'BOOKED' act = lv_note ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
59
tasks_gen/eval/G0143/mutation.json
Normal file
59
tasks_gen/eval/G0143/mutation.json
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"task": "T_CRANE",
|
||||
"mutants": [
|
||||
{
|
||||
"object": "{{P}}CRANE_FEE_OLD",
|
||||
"mutant": "weekend surcharge 25 -> 20",
|
||||
"status": "killed",
|
||||
"hidden": "6/8",
|
||||
"failed_tests": [
|
||||
"WEEKEND_SURCHARGE",
|
||||
"TOTAL_CALCULATION"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}CRANE_FEE_OLD",
|
||||
"mutant": "gold discount 10 -> 5",
|
||||
"status": "killed",
|
||||
"hidden": "5/8",
|
||||
"failed_tests": [
|
||||
"GOLD_DISCOUNT",
|
||||
"ROUNDING_ORDER",
|
||||
"TOTAL_CALCULATION"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}CRANE_FEE_OLD",
|
||||
"mutant": "travel cap 100 -> 50",
|
||||
"status": "killed",
|
||||
"hidden": "7/8",
|
||||
"failed_tests": [
|
||||
"TRAVEL_FEE_CAP"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}CRANE_FEE_OLD",
|
||||
"mutant": "round half up -> half down",
|
||||
"status": "killed",
|
||||
"hidden": "6/8",
|
||||
"failed_tests": [
|
||||
"ROUNDING_ORDER",
|
||||
"TOTAL_CALCULATION"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}CRANE_FEE_OLD",
|
||||
"mutant": "SM hourly 115 -> 110",
|
||||
"status": "killed",
|
||||
"hidden": "6/8",
|
||||
"failed_tests": [
|
||||
"SMALL_CRANE_BASE",
|
||||
"ROUNDING_ORDER"
|
||||
]
|
||||
}
|
||||
],
|
||||
"valid": 5,
|
||||
"killed": 5,
|
||||
"kill_rate": 1.0,
|
||||
"ok": true
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
FUNCTION {{p}}bowl_fee_old
|
||||
IMPORTING
|
||||
iv_players TYPE i
|
||||
iv_games TYPE i
|
||||
iv_day TYPE i
|
||||
iv_shoes TYPE abap_bool
|
||||
EXPORTING
|
||||
ev_fee TYPE decfloat34
|
||||
ev_note TYPE string
|
||||
EXCEPTIONS
|
||||
invalid_input.
|
||||
|
||||
TYPES ty_rate TYPE p LENGTH 8 DECIMALS 2.
|
||||
|
||||
CLASS lcl_bowling DEFINITION.
|
||||
PUBLIC SECTION.
|
||||
METHODS calculate
|
||||
IMPORTING
|
||||
iv_players TYPE i
|
||||
iv_games TYPE i
|
||||
iv_day TYPE i
|
||||
iv_shoes TYPE abap_bool
|
||||
EXPORTING
|
||||
ev_fee TYPE decfloat34
|
||||
ev_note TYPE string.
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS:
|
||||
c_lane_size TYPE i VALUE 6,
|
||||
c_group_size TYPE i VALUE 12,
|
||||
c_rate_weekday TYPE ty_rate VALUE '3.50',
|
||||
c_rate_weekend TYPE ty_rate VALUE '5.00',
|
||||
c_shoe_price TYPE ty_rate VALUE '2.00',
|
||||
c_group_discount TYPE ty_rate VALUE '10.00'.
|
||||
METHODS lanes_for
|
||||
IMPORTING iv_players TYPE i
|
||||
RETURNING VALUE(rv_lanes) TYPE i.
|
||||
METHODS rate_for
|
||||
IMPORTING iv_day TYPE i
|
||||
RETURNING VALUE(rv_rate) TYPE ty_rate.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_bowling IMPLEMENTATION.
|
||||
METHOD calculate.
|
||||
DATA(lv_lanes) = lanes_for( iv_players ).
|
||||
DATA(lv_rate) = rate_for( iv_day ).
|
||||
DATA lv_sum TYPE p LENGTH 15 DECIMALS 2.
|
||||
lv_sum = lv_lanes * iv_games * lv_rate.
|
||||
IF iv_shoes = abap_true.
|
||||
lv_sum = lv_sum + iv_players * c_shoe_price.
|
||||
ENDIF.
|
||||
ev_note = 'BOOKED'.
|
||||
IF iv_players >= c_group_size.
|
||||
lv_sum = lv_sum - c_group_discount.
|
||||
ev_note = 'GROUP'.
|
||||
ENDIF.
|
||||
ev_fee = lv_sum.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD lanes_for.
|
||||
rv_lanes = iv_players DIV c_lane_size.
|
||||
IF iv_players MOD c_lane_size > 0.
|
||||
rv_lanes = rv_lanes + 1.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rate_for.
|
||||
IF iv_day > 5.
|
||||
rv_rate = c_rate_weekend.
|
||||
ELSE.
|
||||
rv_rate = c_rate_weekday.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
|
||||
IF iv_players < 1 OR iv_games < 1.
|
||||
RAISE invalid_input.
|
||||
ENDIF.
|
||||
|
||||
DATA(lo_bowling) = NEW lcl_bowling( ).
|
||||
lo_bowling->calculate(
|
||||
EXPORTING
|
||||
iv_players = iv_players
|
||||
iv_games = iv_games
|
||||
iv_day = iv_day
|
||||
iv_shoes = iv_shoes
|
||||
IMPORTING
|
||||
ev_fee = ev_fee
|
||||
ev_note = ev_note ).
|
||||
|
||||
ENDFUNCTION.
|
||||
71
tasks_gen/eval/G0143/reference/crane_test.clas.abap
Normal file
71
tasks_gen/eval/G0143/reference/crane_test.clas.abap
Normal file
@@ -0,0 +1,71 @@
|
||||
CLASS {{p}}crane_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
METHODS fee_for
|
||||
IMPORTING iv_type TYPE string
|
||||
iv_hours TYPE decfloat34
|
||||
iv_km TYPE i
|
||||
iv_weekend TYPE abap_bool
|
||||
iv_customer TYPE string
|
||||
RETURNING VALUE(rv_total) TYPE decfloat34.
|
||||
METHODS small_crane FOR TESTING.
|
||||
METHODS weekend_and_gold FOR TESTING.
|
||||
METHODS travel_cap FOR TESTING.
|
||||
METHODS invalid_input FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}crane_test IMPLEMENTATION.
|
||||
METHOD fee_for.
|
||||
CALL FUNCTION '{{P}}CRANE_FEE_OLD'
|
||||
EXPORTING
|
||||
iv_crane_type = iv_type
|
||||
iv_hours = iv_hours
|
||||
iv_distance_km = iv_km
|
||||
iv_weekend = iv_weekend
|
||||
iv_customer = iv_customer
|
||||
IMPORTING
|
||||
ev_total = rv_total
|
||||
EXCEPTIONS
|
||||
invalid_crane_type = 1
|
||||
invalid_hours = 2
|
||||
OTHERS = 3.
|
||||
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD small_crane.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV decfloat34( 230 )
|
||||
act = fee_for( iv_type = 'SM' iv_hours = 2 iv_km = 0 iv_weekend = abap_false iv_customer = 'STD' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD weekend_and_gold.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV decfloat34( '655.88' )
|
||||
act = fee_for( iv_type = 'MD' iv_hours = 3 iv_km = 20 iv_weekend = abap_true iv_customer = 'GOLD' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD travel_cap.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV decfloat34( 240 )
|
||||
act = fee_for( iv_type = 'SM' iv_hours = 1 iv_km = 200 iv_weekend = abap_false iv_customer = 'STD' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_input.
|
||||
DATA lv_total TYPE decfloat34.
|
||||
CALL FUNCTION '{{P}}CRANE_FEE_OLD'
|
||||
EXPORTING
|
||||
iv_crane_type = 'XX'
|
||||
iv_hours = 1
|
||||
iv_distance_km = 0
|
||||
iv_weekend = abap_false
|
||||
iv_customer = 'STD'
|
||||
IMPORTING
|
||||
ev_total = lv_total
|
||||
EXCEPTIONS
|
||||
invalid_crane_type = 1
|
||||
invalid_hours = 2
|
||||
OTHERS = 3.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = sy-subrc ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
@@ -1,74 +0,0 @@
|
||||
CLASS {{p}}t14_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
METHODS weekday_fee FOR TESTING.
|
||||
METHODS weekend_fee FOR TESTING.
|
||||
METHODS group_fee FOR TESTING.
|
||||
METHODS invalid_input FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS {{p}}t14_test IMPLEMENTATION.
|
||||
METHOD weekday_fee.
|
||||
DATA lv_fee TYPE decfloat34.
|
||||
CALL FUNCTION '{{P}}BOWL_FEE_OLD'
|
||||
EXPORTING
|
||||
iv_players = 1
|
||||
iv_games = 1
|
||||
iv_day = 1
|
||||
IMPORTING
|
||||
ev_fee = lv_fee
|
||||
EXCEPTIONS
|
||||
invalid_input = 1
|
||||
OTHERS = 2.
|
||||
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '3.50' ) act = lv_fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD weekend_fee.
|
||||
DATA lv_fee TYPE decfloat34.
|
||||
CALL FUNCTION '{{P}}BOWL_FEE_OLD'
|
||||
EXPORTING
|
||||
iv_players = 6
|
||||
iv_games = 2
|
||||
iv_day = 6
|
||||
IMPORTING
|
||||
ev_fee = lv_fee
|
||||
EXCEPTIONS
|
||||
invalid_input = 1
|
||||
OTHERS = 2.
|
||||
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '10.00' ) act = lv_fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD group_fee.
|
||||
DATA lv_fee TYPE decfloat34.
|
||||
CALL FUNCTION '{{P}}BOWL_FEE_OLD'
|
||||
EXPORTING
|
||||
iv_players = 12
|
||||
iv_games = 1
|
||||
iv_day = 1
|
||||
iv_shoes = abap_true
|
||||
IMPORTING
|
||||
ev_fee = lv_fee
|
||||
EXCEPTIONS
|
||||
invalid_input = 1
|
||||
OTHERS = 2.
|
||||
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '21.00' ) act = lv_fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_input.
|
||||
DATA lv_fee TYPE decfloat34.
|
||||
CALL FUNCTION '{{P}}BOWL_FEE_OLD'
|
||||
EXPORTING
|
||||
iv_players = 0
|
||||
iv_games = 1
|
||||
iv_day = 1
|
||||
IMPORTING
|
||||
ev_fee = lv_fee
|
||||
EXCEPTIONS
|
||||
invalid_input = 1
|
||||
OTHERS = 2.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = sy-subrc ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
@@ -1,50 +0,0 @@
|
||||
FUNCTION {{p}}bowl_fee_old
|
||||
IMPORTING
|
||||
iv_players TYPE i
|
||||
iv_games TYPE i
|
||||
iv_day TYPE i
|
||||
iv_shoes TYPE abap_bool
|
||||
EXPORTING
|
||||
ev_fee TYPE decfloat34
|
||||
ev_note TYPE string
|
||||
EXCEPTIONS
|
||||
invalid_input.
|
||||
|
||||
DATA: lv_lanes TYPE i,
|
||||
lv_rate TYPE p LENGTH 8 DECIMALS 2,
|
||||
lv_sum TYPE p LENGTH 15 DECIMALS 2.
|
||||
|
||||
IF iv_players < 1.
|
||||
RAISE invalid_input.
|
||||
ENDIF.
|
||||
IF iv_games < 1.
|
||||
RAISE invalid_input.
|
||||
ENDIF.
|
||||
|
||||
COMPUTE lv_lanes = iv_players DIV 6.
|
||||
IF iv_players MOD 6 > 0.
|
||||
ADD 1 TO lv_lanes.
|
||||
ENDIF.
|
||||
|
||||
IF iv_day > 5.
|
||||
MOVE '5.00' TO lv_rate.
|
||||
ELSE.
|
||||
MOVE '3.50' TO lv_rate.
|
||||
ENDIF.
|
||||
|
||||
COMPUTE lv_sum = lv_lanes * iv_games * lv_rate.
|
||||
|
||||
IF iv_shoes = 'X'.
|
||||
COMPUTE lv_sum = lv_sum + iv_players * '2.00'.
|
||||
ENDIF.
|
||||
|
||||
ev_note = 'BOOKED'.
|
||||
|
||||
IF iv_players >= 12.
|
||||
COMPUTE lv_sum = lv_sum - '10.00'.
|
||||
ev_note = 'GROUP'.
|
||||
ENDIF.
|
||||
|
||||
ev_fee = lv_sum.
|
||||
|
||||
ENDFUNCTION.
|
||||
71
tasks_gen/eval/G0143/seed/crane_fee_old.func.abap
Normal file
71
tasks_gen/eval/G0143/seed/crane_fee_old.func.abap
Normal file
@@ -0,0 +1,71 @@
|
||||
FUNCTION {{p}}crane_fee_old
|
||||
IMPORTING
|
||||
iv_crane_type TYPE string
|
||||
iv_hours TYPE decfloat34
|
||||
iv_distance_km TYPE i
|
||||
iv_weekend TYPE abap_bool
|
||||
iv_customer TYPE string
|
||||
EXPORTING
|
||||
ev_base_fee TYPE decfloat34
|
||||
ev_travel_fee TYPE decfloat34
|
||||
ev_surcharge TYPE decfloat34
|
||||
ev_discount TYPE decfloat34
|
||||
ev_total TYPE decfloat34
|
||||
EXCEPTIONS
|
||||
invalid_crane_type
|
||||
invalid_hours.
|
||||
|
||||
DATA lv_hourly TYPE decfloat34.
|
||||
DATA lv_per_km TYPE decfloat34.
|
||||
DATA lv_km TYPE i.
|
||||
DATA lv_sum TYPE decfloat34.
|
||||
|
||||
IF iv_hours <= 0.
|
||||
RAISE invalid_hours.
|
||||
ENDIF.
|
||||
|
||||
CASE iv_crane_type.
|
||||
WHEN 'SM'.
|
||||
lv_hourly = 115.
|
||||
lv_per_km = '1.25'.
|
||||
WHEN 'MD'.
|
||||
lv_hourly = 185.
|
||||
lv_per_km = '1.75'.
|
||||
WHEN 'LG'.
|
||||
lv_hourly = 345.
|
||||
lv_per_km = '2.35'.
|
||||
WHEN OTHERS.
|
||||
RAISE invalid_crane_type.
|
||||
ENDCASE.
|
||||
|
||||
ev_base_fee = iv_hours * lv_hourly.
|
||||
|
||||
lv_km = iv_distance_km.
|
||||
IF lv_km > 100.
|
||||
lv_km = 100.
|
||||
ENDIF.
|
||||
ev_travel_fee = lv_km * lv_per_km.
|
||||
|
||||
IF iv_weekend = abap_true.
|
||||
ev_surcharge = ev_base_fee * 25 / 100.
|
||||
ELSE.
|
||||
ev_surcharge = 0.
|
||||
ENDIF.
|
||||
|
||||
lv_sum = ev_base_fee + ev_travel_fee + ev_surcharge.
|
||||
|
||||
IF iv_customer = 'GOLD'.
|
||||
ev_discount = lv_sum * 10 / 100.
|
||||
ELSE.
|
||||
ev_discount = 0.
|
||||
ENDIF.
|
||||
|
||||
ev_total = lv_sum - ev_discount.
|
||||
|
||||
ev_base_fee = round( val = ev_base_fee dec = 2 mode = cl_abap_math=>round_half_up ).
|
||||
ev_travel_fee = round( val = ev_travel_fee dec = 2 mode = cl_abap_math=>round_half_up ).
|
||||
ev_surcharge = round( val = ev_surcharge dec = 2 mode = cl_abap_math=>round_half_up ).
|
||||
ev_discount = round( val = ev_discount dec = 2 mode = cl_abap_math=>round_half_up ).
|
||||
ev_total = round( val = ev_total dec = 2 mode = cl_abap_math=>round_half_up ).
|
||||
|
||||
ENDFUNCTION.
|
||||
@@ -1,36 +1,48 @@
|
||||
# 1. Goal
|
||||
Refactor the legacy function module {{P}}BOWL_FEE_OLD in place. The behavior must
|
||||
stay the same. Improve the code quality so that the module is easier to maintain.
|
||||
Refactor the legacy function module {{P}}CRANE_FEE_OLD in function group
|
||||
{{P}}FG_CRANE. The function module calculates the fee of a crane hire job. The
|
||||
refactoring must improve the quality of the code. The behavior stays the same.
|
||||
The name and the public interface stay the same.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- Function group {{P}}FG_BOWL exists in package $TMP.
|
||||
- Function module {{P}}BOWL_FEE_OLD exists in this group. It is the legacy
|
||||
implementation of the bowling fee calculation.
|
||||
- The booking program calls this function module. The interface must not change.
|
||||
- Function group {{P}}FG_CRANE exists in package $TMP.
|
||||
- Function module {{P}}CRANE_FEE_OLD exists in this group. It is the legacy
|
||||
implementation of the fee calculation. Read its source. The source defines
|
||||
the fee rules of the crane hire company.
|
||||
- A crane hire company uses the function module to price jobs. The dispatcher
|
||||
enters the crane type, the number of hours, the distance in kilometres,
|
||||
whether the job is on a weekend, and the customer category. The function
|
||||
module returns the base fee, the travel fee, the surcharge, the discount, and
|
||||
the total fee.
|
||||
|
||||
# 4. Contract
|
||||
- Refactor the function module {{P}}BOWL_FEE_OLD in function group {{P}}FG_BOWL.
|
||||
- Keep the exact interface: the same parameter names, types, and exceptions.
|
||||
- The function module name stays the same.
|
||||
- Refactor the function module {{P}}CRANE_FEE_OLD in function group
|
||||
{{P}}FG_CRANE in place.
|
||||
- Keep the name and the public interface exactly as they are.
|
||||
- The interface is:
|
||||
- Importing: iv_crane_type TYPE string, iv_hours TYPE decfloat34,
|
||||
iv_distance_km TYPE i, iv_weekend TYPE abap_bool, iv_customer TYPE string.
|
||||
- Exporting: ev_base_fee TYPE decfloat34, ev_travel_fee TYPE decfloat34,
|
||||
ev_surcharge TYPE decfloat34, ev_discount TYPE decfloat34,
|
||||
ev_total TYPE decfloat34.
|
||||
- Exceptions: invalid_crane_type, invalid_hours.
|
||||
|
||||
# 5. Business rules
|
||||
The business rules are defined by the current behavior of the legacy code.
|
||||
Read the legacy source code in {{P}}BOWL_FEE_OLD. The refactored function module
|
||||
must produce exactly the same results as the legacy code for every input.
|
||||
Do not change any rule.
|
||||
The behavior of the current implementation is the specification. The
|
||||
refactored function module must return exactly the same values as the current
|
||||
implementation for every input. Read the legacy source carefully to learn the
|
||||
rules. Do not change the behavior.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: SAP_BASIS 816.
|
||||
- Coding standards: Clean ABAP. Use modern ABAP syntax. No obsolete statements
|
||||
(for example COMPUTE, MOVE, ADD ... TO ...). Methods below 40 statements.
|
||||
Pass large parameters by reference. No ATC priority 1 or 2 findings.
|
||||
- Out of scope: do not change the function group {{P}}FG_BOWL. Do not change
|
||||
the function module interface.
|
||||
- Release target: 7.58.
|
||||
- Coding standards: Clean ABAP. Methods must be shorter than 40 statements.
|
||||
Pass large parameters by reference.
|
||||
- Out of scope: do not change the function group {{P}}FG_CRANE.
|
||||
|
||||
# 7. Acceptance
|
||||
- The function module is active and has no syntax error.
|
||||
- The function module {{P}}CRANE_FEE_OLD is active and has no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write ABAP Unit tests for the function module in a global test class.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"category": "E",
|
||||
"object_type": "FUNC",
|
||||
"difficulty": 2,
|
||||
"release_target": "v816",
|
||||
"release_target": "v758",
|
||||
"expected_outcome": "implement",
|
||||
"budget": {
|
||||
"max_tool_calls": 60,
|
||||
@@ -12,72 +12,83 @@
|
||||
"seed": [
|
||||
{
|
||||
"type": "FUGR",
|
||||
"name": "{{P}}FG_BOWL",
|
||||
"description": "Bowling fee function group"
|
||||
"name": "{{P}}FG_CRANE",
|
||||
"description": "Crane hire function group"
|
||||
},
|
||||
{
|
||||
"type": "FUNC",
|
||||
"name": "{{P}}BOWL_FEE_OLD",
|
||||
"functionGroup": "{{P}}FG_BOWL",
|
||||
"file": "seed/bowl_fee_old.func.abap",
|
||||
"description": "Legacy bowling fee calculation"
|
||||
"name": "{{P}}CRANE_FEE_OLD",
|
||||
"functionGroup": "{{P}}FG_CRANE",
|
||||
"file": "seed/crane_fee_old.func.abap",
|
||||
"description": "Legacy crane fee calculation"
|
||||
}
|
||||
],
|
||||
"contract": [
|
||||
{
|
||||
"type": "FUNC",
|
||||
"name": "{{P}}BOWL_FEE_OLD",
|
||||
"functionGroup": "{{P}}FG_BOWL",
|
||||
"name": "{{P}}CRANE_FEE_OLD",
|
||||
"functionGroup": "{{P}}FG_CRANE",
|
||||
"params": [
|
||||
{
|
||||
"name": "iv_players",
|
||||
"type": "i"
|
||||
"name": "iv_crane_type",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "iv_games",
|
||||
"type": "i"
|
||||
},
|
||||
{
|
||||
"name": "iv_day",
|
||||
"type": "i"
|
||||
},
|
||||
{
|
||||
"name": "iv_shoes",
|
||||
"type": "abap_bool"
|
||||
},
|
||||
{
|
||||
"name": "ev_fee",
|
||||
"name": "iv_hours",
|
||||
"type": "decfloat34"
|
||||
},
|
||||
{
|
||||
"name": "ev_note",
|
||||
"name": "iv_distance_km",
|
||||
"type": "i"
|
||||
},
|
||||
{
|
||||
"name": "iv_weekend",
|
||||
"type": "abap_bool"
|
||||
},
|
||||
{
|
||||
"name": "iv_customer",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "ev_base_fee",
|
||||
"type": "decfloat34"
|
||||
},
|
||||
{
|
||||
"name": "ev_travel_fee",
|
||||
"type": "decfloat34"
|
||||
},
|
||||
{
|
||||
"name": "ev_surcharge",
|
||||
"type": "decfloat34"
|
||||
},
|
||||
{
|
||||
"name": "ev_discount",
|
||||
"type": "decfloat34"
|
||||
},
|
||||
{
|
||||
"name": "ev_total",
|
||||
"type": "decfloat34"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"out_of_scope": [],
|
||||
"out_of_scope": [
|
||||
"{{P}}FG_CRANE"
|
||||
],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}T14_HIDDEN",
|
||||
"file": "hidden/t14_hidden.clas.abap",
|
||||
"description": "T14 hidden tests"
|
||||
"name": "{{P}}CRANE_HIDDEN",
|
||||
"file": "hidden/crane_hidden.clas.abap",
|
||||
"description": "Hidden behaviour tests for the crane fee"
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "FUNC",
|
||||
"name": "{{P}}BOWL_FEE_OLD",
|
||||
"functionGroup": "{{P}}FG_BOWL",
|
||||
"file": "reference/bowl_fee_old.func.abap",
|
||||
"description": "Refactored bowling fee calculation"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}T14_TEST",
|
||||
"file": "reference/t14_test.clas.abap",
|
||||
"description": "T14 own tests"
|
||||
"name": "{{P}}CRANE_TEST",
|
||||
"file": "reference/crane_test.clas.abap",
|
||||
"description": "Own tests for the crane fee"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
|
||||
Reference in New Issue
Block a user