Stage 2 summary at 50 accepted trajectories
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
14
tasks_gen/train/G1119/generation.json
Normal file
14
tasks_gen/train/G1119/generation.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"id": "G1119",
|
||||
"pool": "train",
|
||||
"object_type": "FUNC",
|
||||
"category": "H",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 100,
|
||||
"null": 30
|
||||
}
|
||||
],
|
||||
"accepted": true
|
||||
}
|
||||
51
tasks_gen/train/G1119/reference/bind_fee.func.abap
Normal file
51
tasks_gen/train/G1119/reference/bind_fee.func.abap
Normal file
@@ -0,0 +1,51 @@
|
||||
FUNCTION {{p}}bind_fee
|
||||
IMPORTING
|
||||
iv_binding TYPE string
|
||||
iv_pages TYPE i
|
||||
iv_member TYPE abap_bool
|
||||
EXPORTING
|
||||
ev_rush TYPE abap_bool
|
||||
CHANGING
|
||||
cv_fee TYPE decfloat34
|
||||
EXCEPTIONS
|
||||
invalid_pages.
|
||||
|
||||
CONSTANTS: lc_rate_pb TYPE decfloat34 VALUE '0.05',
|
||||
lc_rate_hb TYPE decfloat34 VALUE '0.12',
|
||||
lc_rate_ex TYPE decfloat34 VALUE '0.20',
|
||||
lc_min_hb TYPE decfloat34 VALUE '15.00',
|
||||
lc_discount TYPE decfloat34 VALUE '0.9'.
|
||||
|
||||
ev_rush = abap_false.
|
||||
IF iv_pages < 1.
|
||||
RAISE invalid_pages.
|
||||
ENDIF.
|
||||
|
||||
CASE iv_binding.
|
||||
WHEN 'PB'.
|
||||
cv_fee = round( val = iv_pages * lc_rate_pb
|
||||
dec = 2
|
||||
mode = cl_abap_math=>round_half_up ).
|
||||
WHEN 'HB'.
|
||||
cv_fee = round( val = iv_pages * lc_rate_hb
|
||||
dec = 2
|
||||
mode = cl_abap_math=>round_half_up ).
|
||||
IF cv_fee < lc_min_hb.
|
||||
cv_fee = lc_min_hb.
|
||||
ENDIF.
|
||||
WHEN 'EX'.
|
||||
ev_rush = abap_true.
|
||||
cv_fee = round( val = iv_pages * lc_rate_ex
|
||||
dec = 2
|
||||
mode = cl_abap_math=>round_half_up ).
|
||||
WHEN OTHERS.
|
||||
cv_fee = 0.
|
||||
ENDCASE.
|
||||
|
||||
IF iv_member = abap_true AND cv_fee > 0.
|
||||
cv_fee = round( val = cv_fee * lc_discount
|
||||
dec = 2
|
||||
mode = cl_abap_math=>round_half_up ).
|
||||
ENDIF.
|
||||
|
||||
ENDFUNCTION.
|
||||
89
tasks_gen/train/G1119/reference/bind_test.clas.abap
Normal file
89
tasks_gen/train/G1119/reference/bind_test.clas.abap
Normal file
@@ -0,0 +1,89 @@
|
||||
CLASS {{p}}bind_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
METHODS fee_for
|
||||
IMPORTING iv_binding TYPE string
|
||||
iv_pages TYPE i
|
||||
iv_member TYPE abap_bool DEFAULT abap_false
|
||||
RETURNING VALUE(rv_fee) TYPE decfloat34.
|
||||
METHODS paperback_fee FOR TESTING.
|
||||
METHODS hardback_minimum FOR TESTING.
|
||||
METHODS member_discount FOR TESTING.
|
||||
METHODS express_sets_rush FOR TESTING.
|
||||
METHODS other_type_zero FOR TESTING.
|
||||
METHODS invalid_pages FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}bind_test IMPLEMENTATION.
|
||||
METHOD fee_for.
|
||||
DATA lv_rush TYPE abap_bool.
|
||||
CALL FUNCTION '{{P}}BIND_FEE'
|
||||
EXPORTING
|
||||
iv_binding = iv_binding
|
||||
iv_pages = iv_pages
|
||||
iv_member = iv_member
|
||||
IMPORTING
|
||||
ev_rush = lv_rush
|
||||
CHANGING
|
||||
cv_fee = rv_fee
|
||||
EXCEPTIONS
|
||||
invalid_pages = 1
|
||||
OTHERS = 2.
|
||||
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD paperback_fee.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV decfloat34( '10.00' )
|
||||
act = fee_for( iv_binding = `PB` iv_pages = 200 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD hardback_minimum.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV decfloat34( '15.00' )
|
||||
act = fee_for( iv_binding = `HB` iv_pages = 50 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD member_discount.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV decfloat34( '9.00' )
|
||||
act = fee_for( iv_binding = `PB` iv_pages = 200 iv_member = abap_true ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD express_sets_rush.
|
||||
DATA lv_rush TYPE abap_bool.
|
||||
DATA lv_fee TYPE decfloat34.
|
||||
CALL FUNCTION '{{P}}BIND_FEE'
|
||||
EXPORTING
|
||||
iv_binding = `EX`
|
||||
iv_pages = 10
|
||||
iv_member = abap_false
|
||||
IMPORTING
|
||||
ev_rush = lv_rush
|
||||
CHANGING
|
||||
cv_fee = lv_fee.
|
||||
cl_abap_unit_assert=>assert_true( lv_rush ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '2.00' ) act = lv_fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD other_type_zero.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV decfloat34( 0 )
|
||||
act = fee_for( iv_binding = `XX` iv_pages = 100 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_pages.
|
||||
DATA lv_fee TYPE decfloat34.
|
||||
CALL FUNCTION '{{P}}BIND_FEE'
|
||||
EXPORTING
|
||||
iv_binding = `PB`
|
||||
iv_pages = 0
|
||||
CHANGING
|
||||
cv_fee = lv_fee
|
||||
EXCEPTIONS
|
||||
invalid_pages = 1
|
||||
OTHERS = 2.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = sy-subrc ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
19
tasks_gen/train/G1119/seed/bind_sample.func.abap
Normal file
19
tasks_gen/train/G1119/seed/bind_sample.func.abap
Normal file
@@ -0,0 +1,19 @@
|
||||
FUNCTION {{p}}bind_sample
|
||||
IMPORTING
|
||||
iv_binding TYPE string
|
||||
iv_pages TYPE i
|
||||
iv_member TYPE abap_bool
|
||||
EXPORTING
|
||||
ev_rush TYPE abap_bool
|
||||
CHANGING
|
||||
cv_fee TYPE decfloat34
|
||||
EXCEPTIONS
|
||||
invalid_pages.
|
||||
|
||||
ev_rush = abap_false.
|
||||
IF iv_pages < 1.
|
||||
RAISE invalid_pages.
|
||||
ENDIF.
|
||||
cv_fee = 0.
|
||||
|
||||
ENDFUNCTION.
|
||||
45
tasks_gen/train/G1119/spec.md
Normal file
45
tasks_gen/train/G1119/spec.md
Normal file
@@ -0,0 +1,45 @@
|
||||
# 1. Goal
|
||||
A bookbinding workshop prices binding jobs. The order desk calls one function
|
||||
module for each job. The function module calculates the fee of the job and
|
||||
reports whether the job is a rush job.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- Function group {{P}}FG_BIND exists in package $TMP.
|
||||
- Function module {{P}}BIND_SAMPLE exists in this group. It shows the interface
|
||||
that the order desk uses.
|
||||
|
||||
# 4. Contract
|
||||
- Create the function module {{P}}BIND_FEE in function group {{P}}FG_BIND.
|
||||
- The interface of {{P}}BIND_FEE:
|
||||
- importing iv_binding TYPE string
|
||||
- importing iv_pages TYPE i
|
||||
- importing iv_member TYPE abap_bool
|
||||
- exporting ev_rush TYPE abap_bool
|
||||
- changing cv_fee TYPE decfloat34
|
||||
- exceptions invalid_pages
|
||||
|
||||
# 5. Business rules
|
||||
1. If the number of pages is less than 1, raise the exception INVALID_PAGES.
|
||||
2. Set the rush flag to false, except in rule 7.
|
||||
3. Binding type PB: the fee is 0.05 per page, rounded half up to 2 decimals.
|
||||
4. Binding type HB: the fee is 0.12 per page, rounded half up to 2 decimals.
|
||||
The minimum fee for hardback binding is 15.00.
|
||||
5. A member receives a discount of 10 % on the fee. The discount is the last
|
||||
step of the calculation and is applied after the minimum fee of rule 4.
|
||||
6. The minimum fee of rule 4 is the last step of the calculation and is applied
|
||||
after all discounts.
|
||||
7. Binding type EX: set the rush flag to true. The fee is 0.20 per page,
|
||||
rounded half up to 2 decimals.
|
||||
8. Other binding types: the fee is 0.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: 8.16.
|
||||
- Coding standards: Clean ABAP.
|
||||
- Out of scope: do not change {{P}}BIND_SAMPLE.
|
||||
|
||||
# 7. Acceptance
|
||||
- The function module is active and has no syntax error.
|
||||
- Write ABAP Unit tests for the function module in a global test class.
|
||||
100
tasks_gen/train/G1119/task.json
Normal file
100
tasks_gen/train/G1119/task.json
Normal file
@@ -0,0 +1,100 @@
|
||||
{
|
||||
"id": "G1119",
|
||||
"category": "H",
|
||||
"object_type": "FUNC",
|
||||
"difficulty": 2,
|
||||
"release_target": "v816",
|
||||
"expected_outcome": "stop",
|
||||
"expected_gap": {
|
||||
"description": "Rules 5 and 6 both claim to be the last step of the calculation, so the order of the member discount and the hardback minimum fee contradicts itself and the fee of a hardback job for a member cannot be calculated.",
|
||||
"keywords": [
|
||||
[
|
||||
"minimum",
|
||||
"discount",
|
||||
"last"
|
||||
],
|
||||
[
|
||||
"minimum",
|
||||
"discount",
|
||||
"priority"
|
||||
],
|
||||
[
|
||||
"minimum",
|
||||
"discount",
|
||||
"order"
|
||||
],
|
||||
[
|
||||
"contradict"
|
||||
]
|
||||
]
|
||||
},
|
||||
"budget": {
|
||||
"max_tool_calls": 60,
|
||||
"max_activations": 15
|
||||
},
|
||||
"seed": [
|
||||
{
|
||||
"type": "FUGR",
|
||||
"name": "{{P}}FG_BIND",
|
||||
"description": "Function group for binding fees"
|
||||
},
|
||||
{
|
||||
"type": "FUNC",
|
||||
"name": "{{P}}BIND_SAMPLE",
|
||||
"functionGroup": "{{P}}FG_BIND",
|
||||
"file": "seed/bind_sample.func.abap",
|
||||
"description": "Sample binding module"
|
||||
}
|
||||
],
|
||||
"contract": [
|
||||
{
|
||||
"type": "FUNC",
|
||||
"name": "{{P}}BIND_FEE",
|
||||
"functionGroup": "{{P}}FG_BIND",
|
||||
"params": [
|
||||
{
|
||||
"name": "iv_binding",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "iv_pages",
|
||||
"type": "i"
|
||||
},
|
||||
{
|
||||
"name": "iv_member",
|
||||
"type": "abap_bool"
|
||||
},
|
||||
{
|
||||
"name": "ev_rush",
|
||||
"type": "abap_bool"
|
||||
},
|
||||
{
|
||||
"name": "cv_fee",
|
||||
"type": "decfloat34"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"out_of_scope": [
|
||||
"{{P}}BIND_SAMPLE"
|
||||
],
|
||||
"hidden_tests": [],
|
||||
"reference": [
|
||||
{
|
||||
"type": "FUNC",
|
||||
"name": "{{P}}BIND_FEE",
|
||||
"functionGroup": "{{P}}FG_BIND",
|
||||
"file": "reference/bind_fee.func.abap",
|
||||
"description": "Binding fee module"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}BIND_TEST",
|
||||
"file": "reference/bind_test.clas.abap",
|
||||
"description": "Own tests for the binding fee module"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user