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/G1127/generation.json
Normal file
14
tasks_gen/train/G1127/generation.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"id": "G1127",
|
||||
"pool": "train",
|
||||
"object_type": "FUNC",
|
||||
"category": "H",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 100,
|
||||
"null": 30
|
||||
}
|
||||
],
|
||||
"accepted": true
|
||||
}
|
||||
34
tasks_gen/train/G1127/reference/key_price.func.abap
Normal file
34
tasks_gen/train/G1127/reference/key_price.func.abap
Normal file
@@ -0,0 +1,34 @@
|
||||
FUNCTION {{p}}key_price
|
||||
IMPORTING
|
||||
iv_key_type TYPE string
|
||||
iv_quantity TYPE i
|
||||
EXPORTING
|
||||
ev_price TYPE decfloat34
|
||||
ev_valid TYPE abap_bool
|
||||
EXCEPTIONS
|
||||
invalid_quantity.
|
||||
|
||||
DATA lv_unit_price TYPE decfloat34.
|
||||
ev_price = 0.
|
||||
ev_valid = abap_false.
|
||||
IF iv_quantity < 1.
|
||||
RAISE invalid_quantity.
|
||||
ENDIF.
|
||||
CASE iv_key_type.
|
||||
WHEN 'ST'.
|
||||
lv_unit_price = '3.50'.
|
||||
WHEN 'SE'.
|
||||
lv_unit_price = '12.00'.
|
||||
WHEN 'TR'.
|
||||
lv_unit_price = '45.00'.
|
||||
WHEN OTHERS.
|
||||
RETURN.
|
||||
ENDCASE.
|
||||
ev_price = lv_unit_price * iv_quantity.
|
||||
IF iv_quantity >= 10.
|
||||
ev_price = ev_price * '0.9'.
|
||||
ENDIF.
|
||||
ev_price = round( val = ev_price dec = 2 mode = cl_abap_math=>round_half_up ).
|
||||
ev_valid = abap_true.
|
||||
|
||||
ENDFUNCTION.
|
||||
49
tasks_gen/train/G1127/reference/key_test.clas.abap
Normal file
49
tasks_gen/train/G1127/reference/key_test.clas.abap
Normal file
@@ -0,0 +1,49 @@
|
||||
CLASS {{p}}key_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
METHODS price_for IMPORTING iv_key_type TYPE string iv_quantity TYPE i
|
||||
RETURNING VALUE(rv_price) TYPE decfloat34.
|
||||
METHODS standard_price FOR TESTING.
|
||||
METHODS security_price FOR TESTING.
|
||||
METHODS transponder_price FOR TESTING.
|
||||
METHODS discount FOR TESTING.
|
||||
METHODS invalid_quantity FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}key_test IMPLEMENTATION.
|
||||
METHOD price_for.
|
||||
DATA lv_valid TYPE abap_bool.
|
||||
CALL FUNCTION '{{P}}KEY_PRICE'
|
||||
EXPORTING iv_key_type = iv_key_type iv_quantity = iv_quantity
|
||||
IMPORTING ev_price = rv_price ev_valid = lv_valid
|
||||
EXCEPTIONS invalid_quantity = 1 OTHERS = 2.
|
||||
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD standard_price.
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '10.50' ) act = price_for( iv_key_type = 'ST' iv_quantity = 3 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD security_price.
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '24.00' ) act = price_for( iv_key_type = 'SE' iv_quantity = 2 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD transponder_price.
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '45.00' ) act = price_for( iv_key_type = 'TR' iv_quantity = 1 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD discount.
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '31.50' ) act = price_for( iv_key_type = 'ST' iv_quantity = 10 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_quantity.
|
||||
DATA lv_price TYPE decfloat34.
|
||||
DATA lv_valid TYPE abap_bool.
|
||||
CALL FUNCTION '{{P}}KEY_PRICE'
|
||||
EXPORTING iv_key_type = 'ST' iv_quantity = 0
|
||||
IMPORTING ev_price = lv_price ev_valid = lv_valid
|
||||
EXCEPTIONS invalid_quantity = 1 OTHERS = 2.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = sy-subrc ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
14
tasks_gen/train/G1127/seed/key_sample.func.abap
Normal file
14
tasks_gen/train/G1127/seed/key_sample.func.abap
Normal file
@@ -0,0 +1,14 @@
|
||||
FUNCTION {{p}}key_sample
|
||||
IMPORTING
|
||||
iv_key_type TYPE string
|
||||
iv_quantity TYPE i
|
||||
EXPORTING
|
||||
ev_price TYPE decfloat34
|
||||
ev_valid TYPE abap_bool
|
||||
EXCEPTIONS
|
||||
invalid_quantity.
|
||||
|
||||
ev_price = 0.
|
||||
ev_valid = abap_false.
|
||||
|
||||
ENDFUNCTION.
|
||||
40
tasks_gen/train/G1127/spec.md
Normal file
40
tasks_gen/train/G1127/spec.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# 1. Goal
|
||||
Calculate the price of a key cutting order. The checkout program calls one
|
||||
function module for each order. The function module must have the same interface
|
||||
as the sample function module, because the checkout program calls all order
|
||||
modules in the same way.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- Function group {{P}}FG_KEY exists in package $TMP.
|
||||
- Function module {{P}}KEY_SAMPLE exists in this group. It is the sample order
|
||||
module. Its interface is the interface that all order modules must use.
|
||||
|
||||
# 4. Contract
|
||||
- Create the function module {{P}}KEY_PRICE in function group {{P}}FG_KEY.
|
||||
- Use exactly the interface of {{P}}KEY_SAMPLE: the same parameter names, kinds,
|
||||
types, and exceptions.
|
||||
|
||||
# 5. Business rules
|
||||
1. If the quantity is less than 1, raise the exception INVALID_QUANTITY.
|
||||
2. Key type ST (standard): the unit price is 3.50.
|
||||
3. Key type SE (security): the unit price is 12.00.
|
||||
4. Key type TR (transponder): the unit price is 45.00.
|
||||
5. The total price is the unit price multiplied by the quantity.
|
||||
6. If the quantity is 10 or more, the customer gets a 10 % discount on the total
|
||||
price.
|
||||
7. Round the total price to 2 decimals, half up.
|
||||
8. Set ev_valid to true when the order is priced. Set ev_valid to false when the
|
||||
order is not priced.
|
||||
9. The shop offers only the key types ST, SE, and TR.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: SAP_BASIS 816.
|
||||
- Out of scope: do not change {{P}}KEY_SAMPLE.
|
||||
- Coding standards: Clean ABAP.
|
||||
|
||||
# 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.
|
||||
92
tasks_gen/train/G1127/task.json
Normal file
92
tasks_gen/train/G1127/task.json
Normal file
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"id": "G1127",
|
||||
"category": "H",
|
||||
"object_type": "FUNC",
|
||||
"difficulty": 2,
|
||||
"release_target": "v816",
|
||||
"expected_outcome": "stop",
|
||||
"expected_gap": {
|
||||
"description": "The spec does not define the result for a key type that is not ST, SE, or TR.",
|
||||
"keywords": [
|
||||
[
|
||||
"unknown",
|
||||
"key",
|
||||
"type"
|
||||
],
|
||||
[
|
||||
"other",
|
||||
"key",
|
||||
"types"
|
||||
],
|
||||
[
|
||||
"missing",
|
||||
"rule"
|
||||
]
|
||||
]
|
||||
},
|
||||
"budget": {
|
||||
"max_tool_calls": 60,
|
||||
"max_activations": 15
|
||||
},
|
||||
"seed": [
|
||||
{
|
||||
"type": "FUGR",
|
||||
"name": "{{P}}FG_KEY",
|
||||
"description": "Key cutting function group"
|
||||
},
|
||||
{
|
||||
"type": "FUNC",
|
||||
"name": "{{P}}KEY_SAMPLE",
|
||||
"functionGroup": "{{P}}FG_KEY",
|
||||
"file": "seed/key_sample.func.abap",
|
||||
"description": "Sample key module"
|
||||
}
|
||||
],
|
||||
"contract": [
|
||||
{
|
||||
"type": "FUNC",
|
||||
"name": "{{P}}KEY_PRICE",
|
||||
"functionGroup": "{{P}}FG_KEY",
|
||||
"params": [
|
||||
{
|
||||
"name": "iv_key_type",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "iv_quantity",
|
||||
"type": "i"
|
||||
},
|
||||
{
|
||||
"name": "ev_price",
|
||||
"type": "decfloat34"
|
||||
},
|
||||
{
|
||||
"name": "ev_valid",
|
||||
"type": "abap_bool"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"out_of_scope": [
|
||||
"{{P}}KEY_SAMPLE"
|
||||
],
|
||||
"hidden_tests": [],
|
||||
"reference": [
|
||||
{
|
||||
"type": "FUNC",
|
||||
"name": "{{P}}KEY_PRICE",
|
||||
"functionGroup": "{{P}}FG_KEY",
|
||||
"file": "reference/key_price.func.abap",
|
||||
"description": "Key price module"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}KEY_TEST",
|
||||
"file": "reference/key_test.clas.abap",
|
||||
"description": "Own tests for key price"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user