Stage 2 summary at 50 accepted trajectories

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Kral
2026-10-05 18:02:52 +02:00
parent 332fb4601d
commit 5bcd1bf9cd
1230 changed files with 77563 additions and 33 deletions

View File

@@ -0,0 +1,61 @@
FUNCTION {{p}}ice_fee
IMPORTING
iv_flavour TYPE string
iv_scoops TYPE i
iv_topping TYPE string
iv_here TYPE abap_bool
EXPORTING
ev_price TYPE decfloat34
EXCEPTIONS
invalid_scoops
unknown_flavour
unknown_topping.
CONSTANTS lc_vanilla TYPE decfloat34 VALUE '1.20'.
CONSTANTS lc_chocolate TYPE decfloat34 VALUE '1.50'.
CONSTANTS lc_strawberry TYPE decfloat34 VALUE '1.40'.
CONSTANTS lc_nut TYPE decfloat34 VALUE '0.60'.
CONSTANTS lc_sprinkles TYPE decfloat34 VALUE '0.40'.
CONSTANTS lc_service_rate TYPE decfloat34 VALUE '1.05'.
DATA lv_scoop_price TYPE decfloat34.
DATA lv_topping_price TYPE decfloat34.
DATA lv_total TYPE decfloat34.
DATA lv_price TYPE p LENGTH 8 DECIMALS 2.
IF iv_scoops >= 1 OR iv_scoops > 5.
RAISE invalid_scoops.
ENDIF.
CASE iv_flavour.
WHEN 'VA'.
lv_scoop_price = lc_vanilla.
WHEN 'CH'.
lv_scoop_price = lc_chocolate.
WHEN 'ST'.
lv_scoop_price = lc_strawberry.
WHEN OTHERS.
RAISE unknown_flavour.
ENDCASE.
CASE iv_topping.
WHEN 'NON' OR ''.
CLEAR lv_topping_price.
WHEN 'NUT'.
lv_topping_price = lc_nut.
WHEN 'SPR'.
lv_topping_price = lc_sprinkles.
WHEN OTHERS.
RAISE unknown_topping.
ENDCASE.
lv_total = iv_scoops * lv_scoop_price + lv_topping_price.
IF iv_here = abap_true.
lv_total = lv_total * lc_service_rate.
ENDIF.
lv_price = lv_total.
ev_price = lv_price.
ENDFUNCTION.

View File

@@ -0,0 +1,61 @@
FUNCTION {{p}}ice_fee
IMPORTING
iv_flavour TYPE string
iv_scoops TYPE i
iv_topping TYPE string
iv_here TYPE abap_bool
EXPORTING
ev_price TYPE decfloat34
EXCEPTIONS
invalid_scoops
unknown_flavour
unknown_topping.
CONSTANTS lc_vanilla TYPE decfloat34 VALUE '1.20'.
CONSTANTS lc_chocolate TYPE decfloat34 VALUE '1.50'.
CONSTANTS lc_strawberry TYPE decfloat34 VALUE '1.40'.
CONSTANTS lc_nut TYPE decfloat34 VALUE '0.60'.
CONSTANTS lc_sprinkles TYPE decfloat34 VALUE '0.40'.
CONSTANTS lc_service_rate TYPE decfloat34 VALUE '1.05'.
DATA lv_scoop_price TYPE decfloat34.
DATA lv_topping_price TYPE decfloat34.
DATA lv_total TYPE decfloat34.
DATA lv_price TYPE p LENGTH 8 DECIMALS 2.
IF iv_scoops < 1 OR iv_scoops > 5.
RAISE invalid_scoops.
ENDIF.
CASE iv_flavour.
WHEN 'VA'.
lv_scoop_price = lc_vanilla.
WHEN 'CH'.
lv_scoop_price = lc_chocolate.
WHEN 'ST'.
lv_scoop_price = lc_strawberry.
WHEN OTHERS.
RAISE unknown_flavour.
ENDCASE.
CASE iv_topping.
WHEN 'NON' OR ''.
CLEAR lv_topping_price.
WHEN 'NUT'.
lv_topping_price = lc_nut.
WHEN 'SPR'.
lv_topping_price = lc_sprinkles.
WHEN OTHERS.
RAISE unknown_topping.
ENDCASE.
lv_total = iv_scoops / lv_scoop_price + lv_topping_price.
IF iv_here = abap_true.
lv_total = lv_total * lc_service_rate.
ENDIF.
lv_price = lv_total.
ev_price = lv_price.
ENDFUNCTION.

View File

@@ -0,0 +1,61 @@
FUNCTION {{p}}ice_fee
IMPORTING
iv_flavour TYPE string
iv_scoops TYPE i
iv_topping TYPE string
iv_here TYPE abap_bool
EXPORTING
ev_price TYPE decfloat34
EXCEPTIONS
invalid_scoops
unknown_flavour
unknown_topping.
CONSTANTS lc_vanilla TYPE decfloat34 VALUE '1.20'.
CONSTANTS lc_chocolate TYPE decfloat34 VALUE '1.50'.
CONSTANTS lc_strawberry TYPE decfloat34 VALUE '1.40'.
CONSTANTS lc_nut TYPE decfloat34 VALUE '0.60'.
CONSTANTS lc_sprinkles TYPE decfloat34 VALUE '0.40'.
CONSTANTS lc_service_rate TYPE decfloat34 VALUE '1.05'.
DATA lv_scoop_price TYPE decfloat34.
DATA lv_topping_price TYPE decfloat34.
DATA lv_total TYPE decfloat34.
DATA lv_price TYPE p LENGTH 8 DECIMALS 2.
IF iv_scoops < 1 OR iv_scoops > 5.
RAISE invalid_scoops.
ENDIF.
CASE iv_flavour.
WHEN 'VA'.
lv_scoop_price = lc_vanilla.
WHEN 'CH'.
lv_scoop_price = lc_chocolate.
WHEN 'ST'.
lv_scoop_price = lc_strawberry.
WHEN OTHERS.
RAISE unknown_flavour.
ENDCASE.
CASE iv_topping.
WHEN 'NON' OR ''.
CLEAR lv_topping_price.
WHEN 'NUT'.
lv_topping_price = lc_nut.
WHEN 'SPR'.
lv_topping_price = lc_sprinkles.
WHEN OTHERS.
RAISE unknown_topping.
ENDCASE.
lv_total = iv_scoops * lv_scoop_price + lv_topping_price.
IF iv_here = abap_false.
lv_total = lv_total * lc_service_rate.
ENDIF.
lv_price = lv_total.
ev_price = lv_price.
ENDFUNCTION.

View File

@@ -0,0 +1,61 @@
FUNCTION {{p}}ice_fee
IMPORTING
iv_flavour TYPE string
iv_scoops TYPE i
iv_topping TYPE string
iv_here TYPE abap_bool
EXPORTING
ev_price TYPE decfloat34
EXCEPTIONS
invalid_scoops
unknown_flavour
unknown_topping.
CONSTANTS lc_vanilla TYPE decfloat34 VALUE '1.20'.
CONSTANTS lc_chocolate TYPE decfloat34 VALUE '1.50'.
CONSTANTS lc_strawberry TYPE decfloat34 VALUE '1.40'.
CONSTANTS lc_nut TYPE decfloat34 VALUE '0.60'.
CONSTANTS lc_sprinkles TYPE decfloat34 VALUE '0.40'.
CONSTANTS lc_service_rate TYPE decfloat34 VALUE '1.05'.
DATA lv_scoop_price TYPE decfloat34.
DATA lv_topping_price TYPE decfloat34.
DATA lv_total TYPE decfloat34.
DATA lv_price TYPE p LENGTH 8 DECIMALS 2.
IF iv_scoops < 1 OR iv_scoops > 5.
RAISE invalid_scoops.
ENDIF.
CASE iv_flavour.
WHEN 'VA'.
lv_scoop_price = lc_vanilla.
WHEN 'CH'.
lv_scoop_price = lc_chocolate.
WHEN 'ST'.
lv_scoop_price = lc_strawberry.
WHEN OTHERS.
RAISE unknown_flavour.
ENDCASE.
CASE iv_topping.
WHEN 'NON' OR ''.
CLEAR lv_topping_price.
WHEN 'NUT'.
lv_topping_price = lc_nut.
WHEN 'SPR'.
lv_topping_price = lc_sprinkles.
WHEN OTHERS.
RAISE unknown_topping.
ENDCASE.
lv_total = iv_scoops * lv_scoop_price + lv_topping_price.
IF iv_here = abap_true.
lv_total = lv_total / lc_service_rate.
ENDIF.
lv_price = lv_total.
ev_price = lv_price.
ENDFUNCTION.

View File

@@ -0,0 +1,19 @@
{
"id": "G1058",
"pool": "train",
"object_type": "FUNC",
"category": "G",
"attempts": [
{
"stage": "validate",
"oracle": 100.0,
"null": 0,
"mutation": {
"valid": 4,
"killed": 4,
"ok": true
}
}
],
"accepted": true
}

View File

@@ -0,0 +1,127 @@
CLASS {{p}}t37_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS call
IMPORTING
iv_flavour TYPE string
iv_scoops TYPE i
iv_topping TYPE string
iv_here TYPE abap_bool
EXPORTING
ev_price TYPE decfloat34
ev_subrc TYPE sysubrc.
METHODS one_scoop_vanilla FOR TESTING.
METHODS three_scoops_chocolate FOR TESTING.
METHODS five_scoops_strawberry FOR TESTING.
METHODS topping_nut FOR TESTING.
METHODS topping_sprinkles FOR TESTING.
METHODS empty_topping FOR TESTING.
METHODS service_charge FOR TESTING.
METHODS service_rounding FOR TESTING.
METHODS rejects_zero_scoops FOR TESTING.
METHODS rejects_six_scoops FOR TESTING.
METHODS rejects_unknown_flavour FOR TESTING.
METHODS rejects_unknown_topping FOR TESTING.
ENDCLASS.
CLASS {{p}}t37_hidden IMPLEMENTATION.
METHOD call.
DATA lv_price TYPE decfloat34.
CALL FUNCTION '{{P}}ICE_FEE'
EXPORTING
iv_flavour = iv_flavour
iv_scoops = iv_scoops
iv_topping = iv_topping
iv_here = iv_here
IMPORTING
ev_price = lv_price
EXCEPTIONS
invalid_scoops = 1
unknown_flavour = 2
unknown_topping = 3
OTHERS = 4.
ev_subrc = sy-subrc.
ev_price = lv_price.
ENDMETHOD.
METHOD one_scoop_vanilla.
call( EXPORTING iv_flavour = 'VA' iv_scoops = 1 iv_topping = 'NON' iv_here = abap_false
IMPORTING ev_price = DATA(lv_price) ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '1.20' ) act = lv_price ).
ENDMETHOD.
METHOD three_scoops_chocolate.
call( EXPORTING iv_flavour = 'CH' iv_scoops = 3 iv_topping = 'NON' iv_here = abap_false
IMPORTING ev_price = DATA(lv_price) ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '4.50' ) act = lv_price ).
ENDMETHOD.
METHOD five_scoops_strawberry.
call( EXPORTING iv_flavour = 'ST' iv_scoops = 5 iv_topping = 'NON' iv_here = abap_false
IMPORTING ev_price = DATA(lv_price) ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '7.00' ) act = lv_price ).
ENDMETHOD.
METHOD topping_nut.
call( EXPORTING iv_flavour = 'VA' iv_scoops = 2 iv_topping = 'NUT' iv_here = abap_false
IMPORTING ev_price = DATA(lv_price) ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '3.00' ) act = lv_price ).
ENDMETHOD.
METHOD topping_sprinkles.
call( EXPORTING iv_flavour = 'ST' iv_scoops = 1 iv_topping = 'SPR' iv_here = abap_false
IMPORTING ev_price = DATA(lv_price) ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '1.80' ) act = lv_price ).
ENDMETHOD.
METHOD empty_topping.
call( EXPORTING iv_flavour = 'CH' iv_scoops = 2 iv_topping = '' iv_here = abap_false
IMPORTING ev_price = DATA(lv_price) ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '3.00' ) act = lv_price ).
ENDMETHOD.
METHOD service_charge.
call( EXPORTING iv_flavour = 'VA' iv_scoops = 1 iv_topping = 'NON' iv_here = abap_true
IMPORTING ev_price = DATA(lv_price) ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '1.26' ) act = lv_price ).
ENDMETHOD.
METHOD service_rounding.
call( EXPORTING iv_flavour = 'CH' iv_scoops = 1 iv_topping = 'NON' iv_here = abap_true
IMPORTING ev_price = DATA(lv_price) ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '1.58' ) act = lv_price ).
ENDMETHOD.
METHOD rejects_zero_scoops.
call( EXPORTING iv_flavour = 'VA' iv_scoops = 0 iv_topping = 'NON' iv_here = abap_false
IMPORTING ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_subrc ).
ENDMETHOD.
METHOD rejects_six_scoops.
call( EXPORTING iv_flavour = 'VA' iv_scoops = 6 iv_topping = 'NON' iv_here = abap_false
IMPORTING ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_subrc ).
ENDMETHOD.
METHOD rejects_unknown_flavour.
call( EXPORTING iv_flavour = 'XX' iv_scoops = 1 iv_topping = 'NON' iv_here = abap_false
IMPORTING ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_subrc ).
ENDMETHOD.
METHOD rejects_unknown_topping.
call( EXPORTING iv_flavour = 'VA' iv_scoops = 1 iv_topping = 'ZZ' iv_here = abap_false
IMPORTING ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 3 act = lv_subrc ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,77 @@
{
"task": "G1058",
"mutants": [
{
"object": "{{P}}ICE_FEE",
"mutant": "line 26: < -> >= (rel)",
"status": "killed",
"hidden": "1/12",
"failed_tests": [
"EMPTY_TOPPING",
"FIVE_SCOOPS_STRAWBERRY",
"ONE_SCOOP_VANILLA",
"REJECTS_UNKNOWN_FLAVOUR",
"REJECTS_UNKNOWN_TOPPING",
"REJECTS_ZERO_SCOOPS",
"SERVICE_CHARGE",
"SERVICE_ROUNDING",
"THREE_SCOOPS_CHOCOLATE",
"TOPPING_NUT",
"TOPPING_SPRINKLES"
]
},
{
"object": "{{P}}ICE_FEE",
"mutant": "line 42: OR -> AND (logic)",
"status": "invalid",
"hidden": "0/0",
"failed_tests": []
},
{
"object": "{{P}}ICE_FEE",
"mutant": "line 52: * -> / (arith)",
"status": "killed",
"hidden": "4/12",
"failed_tests": [
"EMPTY_TOPPING",
"FIVE_SCOOPS_STRAWBERRY",
"ONE_SCOOP_VANILLA",
"SERVICE_CHARGE",
"SERVICE_ROUNDING",
"THREE_SCOOPS_CHOCOLATE",
"TOPPING_NUT",
"TOPPING_SPRINKLES"
]
},
{
"object": "{{P}}ICE_FEE",
"mutant": "line 54: abap_true -> abap_false (bool)",
"status": "killed",
"hidden": "4/12",
"failed_tests": [
"EMPTY_TOPPING",
"FIVE_SCOOPS_STRAWBERRY",
"ONE_SCOOP_VANILLA",
"SERVICE_CHARGE",
"SERVICE_ROUNDING",
"THREE_SCOOPS_CHOCOLATE",
"TOPPING_NUT",
"TOPPING_SPRINKLES"
]
},
{
"object": "{{P}}ICE_FEE",
"mutant": "line 55: * -> / (arith)",
"status": "killed",
"hidden": "10/12",
"failed_tests": [
"SERVICE_CHARGE",
"SERVICE_ROUNDING"
]
}
],
"valid": 4,
"killed": 4,
"kill_rate": 1.0,
"ok": true
}

View File

@@ -0,0 +1,61 @@
FUNCTION {{p}}ice_fee
IMPORTING
iv_flavour TYPE string
iv_scoops TYPE i
iv_topping TYPE string
iv_here TYPE abap_bool
EXPORTING
ev_price TYPE decfloat34
EXCEPTIONS
invalid_scoops
unknown_flavour
unknown_topping.
CONSTANTS lc_vanilla TYPE decfloat34 VALUE '1.20'.
CONSTANTS lc_chocolate TYPE decfloat34 VALUE '1.50'.
CONSTANTS lc_strawberry TYPE decfloat34 VALUE '1.40'.
CONSTANTS lc_nut TYPE decfloat34 VALUE '0.60'.
CONSTANTS lc_sprinkles TYPE decfloat34 VALUE '0.40'.
CONSTANTS lc_service_rate TYPE decfloat34 VALUE '1.05'.
DATA lv_scoop_price TYPE decfloat34.
DATA lv_topping_price TYPE decfloat34.
DATA lv_total TYPE decfloat34.
DATA lv_price TYPE p LENGTH 8 DECIMALS 2.
IF iv_scoops < 1 OR iv_scoops > 5.
RAISE invalid_scoops.
ENDIF.
CASE iv_flavour.
WHEN 'VA'.
lv_scoop_price = lc_vanilla.
WHEN 'CH'.
lv_scoop_price = lc_chocolate.
WHEN 'ST'.
lv_scoop_price = lc_strawberry.
WHEN OTHERS.
RAISE unknown_flavour.
ENDCASE.
CASE iv_topping.
WHEN 'NON' OR ''.
CLEAR lv_topping_price.
WHEN 'NUT'.
lv_topping_price = lc_nut.
WHEN 'SPR'.
lv_topping_price = lc_sprinkles.
WHEN OTHERS.
RAISE unknown_topping.
ENDCASE.
lv_total = iv_scoops * lv_scoop_price + lv_topping_price.
IF iv_here = abap_true.
lv_total = lv_total * lc_service_rate.
ENDIF.
lv_price = lv_total.
ev_price = lv_price.
ENDFUNCTION.

View File

@@ -0,0 +1,135 @@
CLASS {{p}}ice_test DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS price_of
IMPORTING
iv_flavour TYPE string
iv_scoops TYPE i
iv_topping TYPE string
iv_here TYPE abap_bool
RETURNING
VALUE(rv_price) TYPE decfloat34.
METHODS one_scoop_vanilla FOR TESTING.
METHODS three_scoops_chocolate FOR TESTING.
METHODS topping_prices FOR TESTING.
METHODS service_charge FOR TESTING.
METHODS rejects_bad_scoops FOR TESTING.
METHODS rejects_unknown_codes FOR TESTING.
ENDCLASS.
CLASS {{p}}ice_test IMPLEMENTATION.
METHOD price_of.
CALL FUNCTION '{{P}}ICE_FEE'
EXPORTING
iv_flavour = iv_flavour
iv_scoops = iv_scoops
iv_topping = iv_topping
iv_here = iv_here
IMPORTING
ev_price = rv_price
EXCEPTIONS
OTHERS = 1.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
ENDMETHOD.
METHOD one_scoop_vanilla.
CONSTANTS lc_exp TYPE decfloat34 VALUE '1.20'.
cl_abap_unit_assert=>assert_equals(
exp = lc_exp
act = price_of( iv_flavour = 'VA' iv_scoops = 1 iv_topping = 'NON' iv_here = abap_false ) ).
ENDMETHOD.
METHOD three_scoops_chocolate.
CONSTANTS lc_exp TYPE decfloat34 VALUE '4.50'.
cl_abap_unit_assert=>assert_equals(
exp = lc_exp
act = price_of( iv_flavour = 'CH' iv_scoops = 3 iv_topping = 'NON' iv_here = abap_false ) ).
ENDMETHOD.
METHOD topping_prices.
CONSTANTS lc_nut_exp TYPE decfloat34 VALUE '3.00'.
CONSTANTS lc_spr_exp TYPE decfloat34 VALUE '1.80'.
cl_abap_unit_assert=>assert_equals(
exp = lc_nut_exp
act = price_of( iv_flavour = 'VA' iv_scoops = 2 iv_topping = 'NUT' iv_here = abap_false ) ).
cl_abap_unit_assert=>assert_equals(
exp = lc_spr_exp
act = price_of( iv_flavour = 'ST' iv_scoops = 1 iv_topping = 'SPR' iv_here = abap_false ) ).
ENDMETHOD.
METHOD service_charge.
CONSTANTS lc_plain_exp TYPE decfloat34 VALUE '1.26'.
CONSTANTS lc_round_exp TYPE decfloat34 VALUE '1.58'.
cl_abap_unit_assert=>assert_equals(
exp = lc_plain_exp
act = price_of( iv_flavour = 'VA' iv_scoops = 1 iv_topping = 'NON' iv_here = abap_true ) ).
cl_abap_unit_assert=>assert_equals(
exp = lc_round_exp
act = price_of( iv_flavour = 'CH' iv_scoops = 1 iv_topping = 'NON' iv_here = abap_true ) ).
ENDMETHOD.
METHOD rejects_bad_scoops.
DATA lv_price TYPE decfloat34.
DATA lv_rc TYPE sysubrc.
CALL FUNCTION '{{P}}ICE_FEE'
EXPORTING
iv_flavour = 'VA'
iv_scoops = 0
iv_topping = 'NON'
iv_here = abap_false
IMPORTING
ev_price = lv_price
EXCEPTIONS
invalid_scoops = 1
OTHERS = 2.
lv_rc = sy-subrc.
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
CALL FUNCTION '{{P}}ICE_FEE'
EXPORTING
iv_flavour = 'VA'
iv_scoops = 6
iv_topping = 'NON'
iv_here = abap_false
IMPORTING
ev_price = lv_price
EXCEPTIONS
invalid_scoops = 1
OTHERS = 2.
lv_rc = sy-subrc.
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
ENDMETHOD.
METHOD rejects_unknown_codes.
DATA lv_price TYPE decfloat34.
DATA lv_rc TYPE sysubrc.
CALL FUNCTION '{{P}}ICE_FEE'
EXPORTING
iv_flavour = 'XX'
iv_scoops = 1
iv_topping = 'NON'
iv_here = abap_false
IMPORTING
ev_price = lv_price
EXCEPTIONS
unknown_flavour = 1
OTHERS = 2.
lv_rc = sy-subrc.
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
CALL FUNCTION '{{P}}ICE_FEE'
EXPORTING
iv_flavour = 'VA'
iv_scoops = 1
iv_topping = 'ZZ'
iv_here = abap_false
IMPORTING
ev_price = lv_price
EXCEPTIONS
unknown_topping = 1
OTHERS = 2.
lv_rc = sy-subrc.
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,18 @@
FUNCTION {{p}}ice_sample
IMPORTING
iv_flavour TYPE string
iv_scoops TYPE i
iv_topping TYPE string
iv_here TYPE abap_bool
EXPORTING
ev_price TYPE decfloat34
EXCEPTIONS
invalid_scoops
unknown_flavour
unknown_topping.
" Sample module of the group. It only shows the interface of the group.
" The logic of this sample module is not part of this task.
ev_price = 0.
ENDFUNCTION.

View File

@@ -0,0 +1,55 @@
# 1. Goal
An ice cream parlour sells ice cream by the scoop. The checkout program calls
one function module for each order. The function module calculates the price of
the order.
# 2. Open questions
None.
# 3. Context
- Function group {{P}}FG_ICE is in package $TMP.
- Function module {{P}}ICE_SAMPLE is in this group. It is a sample module. Its
interface is the interface that all modules of this group use.
# 4. Contract
- Create the function module {{P}}ICE_FEE in function group {{P}}FG_ICE.
- Use exactly the interface of {{P}}ICE_SAMPLE:
- iv_flavour, importing, type string. The flavour code.
- iv_scoops, importing, type i. The number of scoops.
- iv_topping, importing, type string. The topping code.
- iv_here, importing, type abap_bool. True if the customer eats the ice cream
in the parlour.
- ev_price, exporting, type decfloat34. The price of the order.
- Exceptions: invalid_scoops, unknown_flavour, unknown_topping.
# 5. Business rules
1. The number of scoops must be between 1 and 5. If it is not, raise the
exception INVALID_SCOOPS.
2. The flavour code gives the price of one scoop:
- VA: 1.20
- CH: 1.50
- ST: 1.40
Any other flavour code raises the exception UNKNOWN_FLAVOUR.
3. The topping code gives the price of the topping:
- NON or empty: 0.00
- NUT: 0.60
- SPR: 0.40
Any other topping code raises the exception UNKNOWN_TOPPING.
4. The base price is the number of scoops multiplied by the price of one scoop,
plus the price of the topping.
5. If iv_here is true, add a service charge of 5 percent of the base price. If
iv_here is false, there is no service charge.
6. Round the final price half up to 2 decimals. Return the result in ev_price.
# 6. Constraints
- Release target: 7.40 SP05. Use only ABAP syntax that exists in 7.40 SP05. Do
not use syntax that was introduced later. For example, do not use common
table expressions (WITH), UNION, INTERSECT or EXCEPT in Open SQL, IS INSTANCE
OF, or CASE TYPE OF.
- Coding standard: Clean ABAP.
- Out of scope: do not change {{P}}ICE_SAMPLE.
# 7. Acceptance
- The function module is active and has no syntax error.
- The hidden tests pass.
- Write ABAP Unit tests for the function module in a global test class.

View File

@@ -0,0 +1,84 @@
{
"id": "G1058",
"category": "G",
"object_type": "FUNC",
"difficulty": 2,
"release_target": "v740sp05",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [
{
"type": "FUGR",
"name": "{{P}}FG_ICE",
"description": "Ice cream pricing"
},
{
"type": "FUNC",
"name": "{{P}}ICE_SAMPLE",
"functionGroup": "{{P}}FG_ICE",
"file": "seed/ice_sample.func.abap",
"description": "Sample module that shows the interface of the group"
}
],
"contract": [
{
"type": "FUNC",
"name": "{{P}}ICE_FEE",
"functionGroup": "{{P}}FG_ICE",
"params": [
{
"name": "iv_flavour",
"type": "string"
},
{
"name": "iv_scoops",
"type": "i"
},
{
"name": "iv_topping",
"type": "string"
},
{
"name": "iv_here",
"type": "abap_bool"
},
{
"name": "ev_price",
"type": "decfloat34"
}
]
}
],
"out_of_scope": [
"{{P}}ICE_SAMPLE"
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}T37_HIDDEN",
"file": "hidden/t37_hidden.clas.abap",
"description": "T37 hidden tests"
}
],
"reference": [
{
"type": "FUNC",
"name": "{{P}}ICE_FEE",
"functionGroup": "{{P}}FG_ICE",
"file": "reference/ice_fee.func.abap",
"description": "Ice cream price module"
},
{
"type": "CLAS",
"name": "{{P}}ICE_TEST",
"file": "reference/t37_test.clas.abap",
"description": "T37 own tests"
}
],
"craft_checks": [
"method_length"
]
}