Harness: runner, generator, tasks T01 T13 T14 T15, CLAUDE.md
This commit is contained in:
70
tasks/T13/hidden/t13_hidden.clas.abap
Normal file
70
tasks/T13/hidden/t13_hidden.clas.abap
Normal file
@@ -0,0 +1,70 @@
|
||||
CLASS {{p}}t13_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
METHODS call IMPORTING iv_type TYPE string iv_amount TYPE decfloat34 iv_fee TYPE decfloat34 DEFAULT 7
|
||||
EXPORTING ev_skip TYPE abap_bool ev_fee TYPE decfloat34 ev_subrc TYPE sysubrc.
|
||||
METHODS invoice_percent FOR TESTING.
|
||||
METHODS invoice_minimum FOR TESTING.
|
||||
METHODS invoice_maximum FOR TESTING.
|
||||
METHODS invoice_rounding FOR TESTING.
|
||||
METHODS credit_memo_skips FOR TESTING.
|
||||
METHODS other_type_zero FOR TESTING.
|
||||
METHODS negative_amount FOR TESTING.
|
||||
METHODS skip_false_for_invoice FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t13_hidden IMPLEMENTATION.
|
||||
METHOD call.
|
||||
ev_fee = iv_fee.
|
||||
CALL FUNCTION '{{P}}EVT_FEE'
|
||||
EXPORTING iv_doc_type = iv_type iv_amount = iv_amount
|
||||
IMPORTING ev_skip = ev_skip
|
||||
CHANGING cv_fee = ev_fee
|
||||
EXCEPTIONS invalid_amount = 1 OTHERS = 2.
|
||||
ev_subrc = sy-subrc.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invoice_percent.
|
||||
call( EXPORTING iv_type = `IN` iv_amount = 1000 IMPORTING ev_fee = DATA(lv_fee) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 20 ) act = lv_fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invoice_minimum.
|
||||
call( EXPORTING iv_type = `IN` iv_amount = 10 IMPORTING ev_fee = DATA(lv_fee) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 1 ) act = lv_fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invoice_maximum.
|
||||
call( EXPORTING iv_type = `IN` iv_amount = 100000 IMPORTING ev_fee = DATA(lv_fee) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 50 ) act = lv_fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invoice_rounding.
|
||||
call( EXPORTING iv_type = `IN` iv_amount = '123.25' IMPORTING ev_fee = DATA(lv_fee) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '2.47' ) act = lv_fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD credit_memo_skips.
|
||||
call( EXPORTING iv_type = `CR` iv_amount = 500 iv_fee = 7
|
||||
IMPORTING ev_skip = DATA(lv_skip) ev_fee = DATA(lv_fee) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = abap_true act = lv_skip ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 7 ) act = lv_fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD other_type_zero.
|
||||
call( EXPORTING iv_type = `XX` iv_amount = 500 IMPORTING ev_fee = DATA(lv_fee) ev_skip = DATA(lv_skip) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_fee ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = abap_false act = lv_skip ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD negative_amount.
|
||||
call( EXPORTING iv_type = `IN` iv_amount = -1 IMPORTING ev_subrc = DATA(lv_rc) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD skip_false_for_invoice.
|
||||
call( EXPORTING iv_type = `IN` iv_amount = 100 IMPORTING ev_skip = DATA(lv_skip) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = abap_false act = lv_skip ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
30
tasks/T13/reference/evt_fee.func.abap
Normal file
30
tasks/T13/reference/evt_fee.func.abap
Normal file
@@ -0,0 +1,30 @@
|
||||
FUNCTION {{p}}evt_fee
|
||||
IMPORTING
|
||||
iv_doc_type TYPE string
|
||||
iv_amount TYPE decfloat34
|
||||
EXPORTING
|
||||
ev_skip TYPE abap_bool
|
||||
CHANGING
|
||||
cv_fee TYPE decfloat34
|
||||
EXCEPTIONS
|
||||
invalid_amount.
|
||||
|
||||
ev_skip = abap_false.
|
||||
IF iv_amount < 0.
|
||||
RAISE invalid_amount.
|
||||
ENDIF.
|
||||
CASE iv_doc_type.
|
||||
WHEN 'IN'.
|
||||
cv_fee = round( val = iv_amount * 2 / 100 dec = 2 mode = cl_abap_math=>round_half_up ).
|
||||
IF cv_fee < 1.
|
||||
cv_fee = 1.
|
||||
ELSEIF cv_fee > 50.
|
||||
cv_fee = 50.
|
||||
ENDIF.
|
||||
WHEN 'CR'.
|
||||
ev_skip = abap_true.
|
||||
WHEN OTHERS.
|
||||
cv_fee = 0.
|
||||
ENDCASE.
|
||||
|
||||
ENDFUNCTION.
|
||||
52
tasks/T13/reference/t13_test.clas.abap
Normal file
52
tasks/T13/reference/t13_test.clas.abap
Normal file
@@ -0,0 +1,52 @@
|
||||
CLASS {{p}}t13_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
METHODS fee_for IMPORTING iv_type TYPE string iv_amount TYPE decfloat34
|
||||
RETURNING VALUE(rv_fee) TYPE decfloat34.
|
||||
METHODS invoice_fee FOR TESTING.
|
||||
METHODS fee_limits FOR TESTING.
|
||||
METHODS credit_memo FOR TESTING.
|
||||
METHODS negative_amount FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t13_test IMPLEMENTATION.
|
||||
METHOD fee_for.
|
||||
DATA lv_skip TYPE abap_bool.
|
||||
CALL FUNCTION '{{P}}EVT_FEE'
|
||||
EXPORTING iv_doc_type = iv_type iv_amount = iv_amount
|
||||
IMPORTING ev_skip = lv_skip
|
||||
CHANGING cv_fee = rv_fee
|
||||
EXCEPTIONS invalid_amount = 1 OTHERS = 2.
|
||||
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invoice_fee.
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 4 ) act = fee_for( iv_type = `IN` iv_amount = 200 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD fee_limits.
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 1 ) act = fee_for( iv_type = `IN` iv_amount = 5 ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 50 ) act = fee_for( iv_type = `IN` iv_amount = 9000 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD credit_memo.
|
||||
DATA lv_skip TYPE abap_bool.
|
||||
DATA lv_fee TYPE decfloat34 VALUE 3.
|
||||
CALL FUNCTION '{{P}}EVT_FEE'
|
||||
EXPORTING iv_doc_type = `CR` iv_amount = 100
|
||||
IMPORTING ev_skip = lv_skip
|
||||
CHANGING cv_fee = lv_fee.
|
||||
cl_abap_unit_assert=>assert_true( lv_skip ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 3 ) act = lv_fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD negative_amount.
|
||||
DATA lv_fee TYPE decfloat34.
|
||||
CALL FUNCTION '{{P}}EVT_FEE'
|
||||
EXPORTING iv_doc_type = `IN` iv_amount = -5
|
||||
CHANGING cv_fee = lv_fee
|
||||
EXCEPTIONS invalid_amount = 1 OTHERS = 2.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = sy-subrc ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
14
tasks/T13/seed/evt_sample.func.abap
Normal file
14
tasks/T13/seed/evt_sample.func.abap
Normal file
@@ -0,0 +1,14 @@
|
||||
FUNCTION {{p}}evt_sample
|
||||
IMPORTING
|
||||
iv_doc_type TYPE string
|
||||
iv_amount TYPE decfloat34
|
||||
EXPORTING
|
||||
ev_skip TYPE abap_bool
|
||||
CHANGING
|
||||
cv_fee TYPE decfloat34
|
||||
EXCEPTIONS
|
||||
invalid_amount.
|
||||
|
||||
ev_skip = abap_false.
|
||||
|
||||
ENDFUNCTION.
|
||||
35
tasks/T13/spec.md
Normal file
35
tasks/T13/spec.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# 1. Goal
|
||||
Calculate a processing fee for a posted document. The posting program calls one
|
||||
event module for each document. The event module must have the same interface as
|
||||
the sample event module, because the posting program calls all event modules in
|
||||
the same way.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- Function group {{P}}FG_EVT exists in package $TMP.
|
||||
- Function module {{P}}EVT_SAMPLE exists in this group. It is the sample event
|
||||
module. Its interface is the interface that all event modules must use.
|
||||
|
||||
# 4. Contract
|
||||
- Create the function module {{P}}EVT_FEE in function group {{P}}FG_EVT.
|
||||
- Use exactly the interface of {{P}}EVT_SAMPLE: the same parameter names, kinds,
|
||||
types, and exceptions.
|
||||
|
||||
# 5. Business rules
|
||||
1. If the amount is less than 0, raise the exception INVALID_AMOUNT.
|
||||
2. Set the skip flag to false, except in rule 4.
|
||||
3. Document type IN: the fee is 2 % of the amount, rounded half up to 2
|
||||
decimals. The minimum fee is 1.00. The maximum fee is 50.00.
|
||||
4. Document type CR: set the skip flag to true. Do not change the fee.
|
||||
5. Other document types: the fee is 0.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: 7.58.
|
||||
- Out of scope: do not change {{P}}EVT_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.
|
||||
80
tasks/T13/task.json
Normal file
80
tasks/T13/task.json
Normal file
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"id": "T13",
|
||||
"category": "F",
|
||||
"object_type": "FUNC",
|
||||
"difficulty": 2,
|
||||
"release_target": "v758",
|
||||
"expected_outcome": "implement",
|
||||
"budget": {
|
||||
"max_tool_calls": 40,
|
||||
"max_activations": 10
|
||||
},
|
||||
"seed": [
|
||||
{
|
||||
"type": "FUGR",
|
||||
"name": "{{P}}FG_EVT",
|
||||
"description": "Fee events"
|
||||
},
|
||||
{
|
||||
"type": "FUNC",
|
||||
"name": "{{P}}EVT_SAMPLE",
|
||||
"functionGroup": "{{P}}FG_EVT",
|
||||
"file": "seed/evt_sample.func.abap",
|
||||
"description": "Sample event module"
|
||||
}
|
||||
],
|
||||
"contract": [
|
||||
{
|
||||
"type": "FUNC",
|
||||
"name": "{{P}}EVT_FEE",
|
||||
"functionGroup": "{{P}}FG_EVT",
|
||||
"params": [
|
||||
{
|
||||
"name": "iv_doc_type",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "iv_amount",
|
||||
"type": "decfloat34"
|
||||
},
|
||||
{
|
||||
"name": "ev_skip",
|
||||
"type": "abap_bool"
|
||||
},
|
||||
{
|
||||
"name": "cv_fee",
|
||||
"type": "decfloat34"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"out_of_scope": [
|
||||
"{{P}}EVT_SAMPLE"
|
||||
],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}T13_HIDDEN",
|
||||
"file": "hidden/t13_hidden.clas.abap",
|
||||
"description": "T13 hidden tests"
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "FUNC",
|
||||
"name": "{{P}}EVT_FEE",
|
||||
"functionGroup": "{{P}}FG_EVT",
|
||||
"file": "reference/evt_fee.func.abap",
|
||||
"description": "Fee event module"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}T13_TEST",
|
||||
"file": "reference/t13_test.clas.abap",
|
||||
"description": "T13 own tests"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user