Step F first pass: 81/92 accepted; budget floor 60 calls; rejected slots moved for regeneration

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
This commit is contained in:
Kral
2026-10-03 12:10:52 +02:00
parent d3250acfb8
commit 39769afce8
741 changed files with 40573 additions and 317 deletions

View File

@@ -0,0 +1,114 @@
CLASS {{p}}dive_check DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_reason TYPE c LENGTH 10.
TYPES ty_cert_level TYPE c LENGTH 1.
CONSTANTS:
BEGIN OF c_reason,
ok TYPE ty_reason VALUE 'OK',
age TYPE ty_reason VALUE 'AGE',
cert TYPE ty_reason VALUE 'CERT',
depth TYPE ty_reason VALUE 'DEPTH',
dives TYPE ty_reason VALUE 'DIVES',
recent TYPE ty_reason VALUE 'RECENT',
END OF c_reason.
METHODS check_diver
IMPORTING
iv_cert_level TYPE ty_cert_level
iv_depth TYPE i
iv_dives TYPE i
iv_last_dive TYPE d
iv_dive_date TYPE d
iv_age TYPE i
RETURNING
VALUE(rv_reason) TYPE ty_reason.
PRIVATE SECTION.
CONSTANTS:
c_min_age TYPE i VALUE 12,
c_deep_depth TYPE i VALUE 30,
c_days_deep TYPE i VALUE 180,
c_days_shallow TYPE i VALUE 365.
TYPES:
BEGIN OF ty_limit,
cert TYPE ty_cert_level,
max_depth TYPE i,
min_dives TYPE i,
END OF ty_limit,
tt_limit TYPE HASHED TABLE OF ty_limit WITH UNIQUE KEY cert.
METHODS limits
RETURNING VALUE(rt_limit) TYPE tt_limit.
METHODS days_since_last_dive
IMPORTING iv_last_dive TYPE d
iv_dive_date TYPE d
RETURNING VALUE(rv_days) TYPE i.
METHODS max_days_since_last_dive
IMPORTING iv_depth TYPE i
RETURNING VALUE(rv_days) TYPE i.
ENDCLASS.
CLASS {{p}}dive_check IMPLEMENTATION.
METHOD check_diver.
IF iv_age < c_min_age.
rv_reason = c_reason-age.
RETURN.
ENDIF.
DATA(lt_limit) = limits( ).
READ TABLE lt_limit WITH TABLE KEY cert = iv_cert_level ASSIGNING FIELD-SYMBOL(<ls_limit>).
IF sy-subrc <> 0.
rv_reason = c_reason-cert.
RETURN.
ENDIF.
IF iv_depth > <ls_limit>-max_depth.
rv_reason = c_reason-depth.
RETURN.
ENDIF.
IF iv_dives < <ls_limit>-min_dives.
rv_reason = c_reason-dives.
RETURN.
ENDIF.
IF iv_last_dive IS INITIAL.
rv_reason = c_reason-recent.
RETURN.
ENDIF.
IF days_since_last_dive( iv_last_dive = iv_last_dive
iv_dive_date = iv_dive_date ) <= max_days_since_last_dive( iv_depth ).
rv_reason = c_reason-recent.
RETURN.
ENDIF.
rv_reason = c_reason-ok.
ENDMETHOD.
METHOD limits.
rt_limit = VALUE #( ( cert = 'O' max_depth = 18 min_dives = 20 )
( cert = 'A' max_depth = 30 min_dives = 50 )
( cert = 'R' max_depth = 40 min_dives = 80 )
( cert = 'D' max_depth = 40 min_dives = 100 ) ).
ENDMETHOD.
METHOD days_since_last_dive.
rv_days = iv_dive_date - iv_last_dive.
ENDMETHOD.
METHOD max_days_since_last_dive.
IF iv_depth > c_deep_depth.
rv_days = c_days_deep.
ELSE.
rv_days = c_days_shallow.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,114 @@
CLASS {{p}}dive_check DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_reason TYPE c LENGTH 10.
TYPES ty_cert_level TYPE c LENGTH 1.
CONSTANTS:
BEGIN OF c_reason,
ok TYPE ty_reason VALUE 'OK',
age TYPE ty_reason VALUE 'AGE',
cert TYPE ty_reason VALUE 'CERT',
depth TYPE ty_reason VALUE 'DEPTH',
dives TYPE ty_reason VALUE 'DIVES',
recent TYPE ty_reason VALUE 'RECENT',
END OF c_reason.
METHODS check_diver
IMPORTING
iv_cert_level TYPE ty_cert_level
iv_depth TYPE i
iv_dives TYPE i
iv_last_dive TYPE d
iv_dive_date TYPE d
iv_age TYPE i
RETURNING
VALUE(rv_reason) TYPE ty_reason.
PRIVATE SECTION.
CONSTANTS:
c_min_age TYPE i VALUE 12,
c_deep_depth TYPE i VALUE 30,
c_days_deep TYPE i VALUE 180,
c_days_shallow TYPE i VALUE 365.
TYPES:
BEGIN OF ty_limit,
cert TYPE ty_cert_level,
max_depth TYPE i,
min_dives TYPE i,
END OF ty_limit,
tt_limit TYPE HASHED TABLE OF ty_limit WITH UNIQUE KEY cert.
METHODS limits
RETURNING VALUE(rt_limit) TYPE tt_limit.
METHODS days_since_last_dive
IMPORTING iv_last_dive TYPE d
iv_dive_date TYPE d
RETURNING VALUE(rv_days) TYPE i.
METHODS max_days_since_last_dive
IMPORTING iv_depth TYPE i
RETURNING VALUE(rv_days) TYPE i.
ENDCLASS.
CLASS {{p}}dive_check IMPLEMENTATION.
METHOD check_diver.
IF iv_age < c_min_age.
rv_reason = c_reason-age.
RETURN.
ENDIF.
DATA(lt_limit) = limits( ).
READ TABLE lt_limit WITH TABLE KEY cert = iv_cert_level ASSIGNING FIELD-SYMBOL(<ls_limit>).
IF sy-subrc <> 0.
rv_reason = c_reason-cert.
RETURN.
ENDIF.
IF iv_depth > <ls_limit>-max_depth.
rv_reason = c_reason-depth.
RETURN.
ENDIF.
IF iv_dives < <ls_limit>-min_dives.
rv_reason = c_reason-dives.
RETURN.
ENDIF.
IF iv_last_dive IS INITIAL.
rv_reason = c_reason-recent.
RETURN.
ENDIF.
IF days_since_last_dive( iv_last_dive = iv_last_dive
iv_dive_date = iv_dive_date ) > max_days_since_last_dive( iv_depth ).
rv_reason = c_reason-recent.
RETURN.
ENDIF.
rv_reason = c_reason-ok.
ENDMETHOD.
METHOD limits.
rt_limit = VALUE #( ( cert = 'O' max_depth = 19 min_dives = 20 )
( cert = 'A' max_depth = 30 min_dives = 50 )
( cert = 'R' max_depth = 40 min_dives = 80 )
( cert = 'D' max_depth = 40 min_dives = 100 ) ).
ENDMETHOD.
METHOD days_since_last_dive.
rv_days = iv_dive_date - iv_last_dive.
ENDMETHOD.
METHOD max_days_since_last_dive.
IF iv_depth > c_deep_depth.
rv_days = c_days_deep.
ELSE.
rv_days = c_days_shallow.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,114 @@
CLASS {{p}}dive_check DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_reason TYPE c LENGTH 10.
TYPES ty_cert_level TYPE c LENGTH 1.
CONSTANTS:
BEGIN OF c_reason,
ok TYPE ty_reason VALUE 'OK',
age TYPE ty_reason VALUE 'AGE',
cert TYPE ty_reason VALUE 'CERT',
depth TYPE ty_reason VALUE 'DEPTH',
dives TYPE ty_reason VALUE 'DIVES',
recent TYPE ty_reason VALUE 'RECENT',
END OF c_reason.
METHODS check_diver
IMPORTING
iv_cert_level TYPE ty_cert_level
iv_depth TYPE i
iv_dives TYPE i
iv_last_dive TYPE d
iv_dive_date TYPE d
iv_age TYPE i
RETURNING
VALUE(rv_reason) TYPE ty_reason.
PRIVATE SECTION.
CONSTANTS:
c_min_age TYPE i VALUE 12,
c_deep_depth TYPE i VALUE 30,
c_days_deep TYPE i VALUE 180,
c_days_shallow TYPE i VALUE 365.
TYPES:
BEGIN OF ty_limit,
cert TYPE ty_cert_level,
max_depth TYPE i,
min_dives TYPE i,
END OF ty_limit,
tt_limit TYPE HASHED TABLE OF ty_limit WITH UNIQUE KEY cert.
METHODS limits
RETURNING VALUE(rt_limit) TYPE tt_limit.
METHODS days_since_last_dive
IMPORTING iv_last_dive TYPE d
iv_dive_date TYPE d
RETURNING VALUE(rv_days) TYPE i.
METHODS max_days_since_last_dive
IMPORTING iv_depth TYPE i
RETURNING VALUE(rv_days) TYPE i.
ENDCLASS.
CLASS {{p}}dive_check IMPLEMENTATION.
METHOD check_diver.
IF iv_age < c_min_age.
rv_reason = c_reason-age.
RETURN.
ENDIF.
DATA(lt_limit) = limits( ).
READ TABLE lt_limit WITH TABLE KEY cert = iv_cert_level ASSIGNING FIELD-SYMBOL(<ls_limit>).
IF sy-subrc <> 0.
rv_reason = c_reason-cert.
RETURN.
ENDIF.
IF iv_depth > <ls_limit>-max_depth.
rv_reason = c_reason-depth.
RETURN.
ENDIF.
IF iv_dives < <ls_limit>-min_dives.
rv_reason = c_reason-dives.
RETURN.
ENDIF.
IF iv_last_dive IS INITIAL.
rv_reason = c_reason-recent.
RETURN.
ENDIF.
IF days_since_last_dive( iv_last_dive = iv_last_dive
iv_dive_date = iv_dive_date ) > max_days_since_last_dive( iv_depth ).
rv_reason = c_reason-recent.
RETURN.
ENDIF.
rv_reason = c_reason-ok.
ENDMETHOD.
METHOD limits.
rt_limit = VALUE #( ( cert = 'O' max_depth = 18 min_dives = 20 )
( cert = 'A' max_depth = 30 min_dives = 51 )
( cert = 'R' max_depth = 40 min_dives = 80 )
( cert = 'D' max_depth = 40 min_dives = 100 ) ).
ENDMETHOD.
METHOD days_since_last_dive.
rv_days = iv_dive_date - iv_last_dive.
ENDMETHOD.
METHOD max_days_since_last_dive.
IF iv_depth > c_deep_depth.
rv_days = c_days_deep.
ELSE.
rv_days = c_days_shallow.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,114 @@
CLASS {{p}}dive_check DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_reason TYPE c LENGTH 10.
TYPES ty_cert_level TYPE c LENGTH 1.
CONSTANTS:
BEGIN OF c_reason,
ok TYPE ty_reason VALUE 'OK',
age TYPE ty_reason VALUE 'AGE',
cert TYPE ty_reason VALUE 'CERT',
depth TYPE ty_reason VALUE 'DEPTH',
dives TYPE ty_reason VALUE 'DIVES',
recent TYPE ty_reason VALUE 'RECENT',
END OF c_reason.
METHODS check_diver
IMPORTING
iv_cert_level TYPE ty_cert_level
iv_depth TYPE i
iv_dives TYPE i
iv_last_dive TYPE d
iv_dive_date TYPE d
iv_age TYPE i
RETURNING
VALUE(rv_reason) TYPE ty_reason.
PRIVATE SECTION.
CONSTANTS:
c_min_age TYPE i VALUE 12,
c_deep_depth TYPE i VALUE 30,
c_days_deep TYPE i VALUE 180,
c_days_shallow TYPE i VALUE 365.
TYPES:
BEGIN OF ty_limit,
cert TYPE ty_cert_level,
max_depth TYPE i,
min_dives TYPE i,
END OF ty_limit,
tt_limit TYPE HASHED TABLE OF ty_limit WITH UNIQUE KEY cert.
METHODS limits
RETURNING VALUE(rt_limit) TYPE tt_limit.
METHODS days_since_last_dive
IMPORTING iv_last_dive TYPE d
iv_dive_date TYPE d
RETURNING VALUE(rv_days) TYPE i.
METHODS max_days_since_last_dive
IMPORTING iv_depth TYPE i
RETURNING VALUE(rv_days) TYPE i.
ENDCLASS.
CLASS {{p}}dive_check IMPLEMENTATION.
METHOD check_diver.
IF iv_age < c_min_age.
rv_reason = c_reason-age.
RETURN.
ENDIF.
DATA(lt_limit) = limits( ).
READ TABLE lt_limit WITH TABLE KEY cert = iv_cert_level ASSIGNING FIELD-SYMBOL(<ls_limit>).
IF sy-subrc <> 0.
rv_reason = c_reason-cert.
RETURN.
ENDIF.
IF iv_depth > <ls_limit>-max_depth.
rv_reason = c_reason-depth.
RETURN.
ENDIF.
IF iv_dives < <ls_limit>-min_dives.
rv_reason = c_reason-dives.
RETURN.
ENDIF.
IF iv_last_dive IS INITIAL.
rv_reason = c_reason-recent.
RETURN.
ENDIF.
IF days_since_last_dive( iv_last_dive = iv_last_dive
iv_dive_date = iv_dive_date ) > max_days_since_last_dive( iv_depth ).
rv_reason = c_reason-recent.
RETURN.
ENDIF.
rv_reason = c_reason-ok.
ENDMETHOD.
METHOD limits.
rt_limit = VALUE #( ( cert = 'O' max_depth = 18 min_dives = 20 )
( cert = 'A' max_depth = 30 min_dives = 50 )
( cert = 'R' max_depth = 40 min_dives = 80 )
( cert = 'D' max_depth = 40 min_dives = 100 ) ).
ENDMETHOD.
METHOD days_since_last_dive.
rv_days = iv_dive_date + iv_last_dive.
ENDMETHOD.
METHOD max_days_since_last_dive.
IF iv_depth > c_deep_depth.
rv_days = c_days_deep.
ELSE.
rv_days = c_days_shallow.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,19 @@
{
"id": "G0137",
"pool": "eval",
"object_type": "CLAS",
"category": "E",
"attempts": [
{
"stage": "validate",
"oracle": 100.0,
"null": 0,
"mutation": {
"valid": 4,
"killed": 4,
"ok": true
}
}
],
"accepted": true
}

View File

@@ -0,0 +1,171 @@
CLASS {{p}}t12_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
CONSTANTS:
c_dive_date TYPE d VALUE '20250401',
c_recent TYPE d VALUE '20250201'.
DATA mo_cut TYPE REF TO {{p}}dive_check.
METHODS setup.
METHODS valid_dive_is_ok FOR TESTING.
METHODS valid_all_certs FOR TESTING.
METHODS too_young FOR TESTING.
METHODS age_before_cert FOR TESTING.
METHODS unknown_cert FOR TESTING.
METHODS cert_before_depth FOR TESTING.
METHODS depth_limits FOR TESTING.
METHODS dive_minimums FOR TESTING.
METHODS stale_last_dive FOR TESTING.
METHODS recent_dive_ok FOR TESTING.
METHODS deep_dive_recent FOR TESTING.
METHODS last_dive_missing FOR TESTING.
ENDCLASS.
CLASS {{p}}t12_hidden IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}dive_check( ).
ENDMETHOD.
METHOD valid_dive_is_ok.
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-ok
act = mo_cut->check_diver( iv_cert_level = 'A'
iv_depth = 25
iv_dives = 60
iv_last_dive = c_recent
iv_dive_date = c_dive_date
iv_age = 30 ) ).
ENDMETHOD.
METHOD valid_all_certs.
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-ok
act = mo_cut->check_diver( iv_cert_level = 'O' iv_depth = 18 iv_dives = 20
iv_last_dive = c_recent iv_dive_date = c_dive_date iv_age = 30 )
msg = `O` ).
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-ok
act = mo_cut->check_diver( iv_cert_level = 'A' iv_depth = 30 iv_dives = 50
iv_last_dive = c_recent iv_dive_date = c_dive_date iv_age = 30 )
msg = `A` ).
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-ok
act = mo_cut->check_diver( iv_cert_level = 'R' iv_depth = 40 iv_dives = 80
iv_last_dive = c_recent iv_dive_date = c_dive_date iv_age = 30 )
msg = `R` ).
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-ok
act = mo_cut->check_diver( iv_cert_level = 'D' iv_depth = 40 iv_dives = 100
iv_last_dive = c_recent iv_dive_date = c_dive_date iv_age = 30 )
msg = `D` ).
ENDMETHOD.
METHOD too_young.
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-age
act = mo_cut->check_diver( iv_cert_level = 'A' iv_depth = 25 iv_dives = 60
iv_last_dive = c_recent iv_dive_date = c_dive_date iv_age = 11 ) ).
ENDMETHOD.
METHOD age_before_cert.
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-age
act = mo_cut->check_diver( iv_cert_level = 'X' iv_depth = 100 iv_dives = 0
iv_last_dive = c_recent iv_dive_date = c_dive_date iv_age = 11 ) ).
ENDMETHOD.
METHOD unknown_cert.
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-cert
act = mo_cut->check_diver( iv_cert_level = 'X' iv_depth = 10 iv_dives = 100
iv_last_dive = c_recent iv_dive_date = c_dive_date iv_age = 30 ) ).
ENDMETHOD.
METHOD cert_before_depth.
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-cert
act = mo_cut->check_diver( iv_cert_level = 'X' iv_depth = 100 iv_dives = 0
iv_last_dive = c_recent iv_dive_date = c_dive_date iv_age = 30 ) ).
ENDMETHOD.
METHOD depth_limits.
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-ok
act = mo_cut->check_diver( iv_cert_level = 'O' iv_depth = 18 iv_dives = 20
iv_last_dive = c_recent iv_dive_date = c_dive_date iv_age = 30 )
msg = `O at limit` ).
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-depth
act = mo_cut->check_diver( iv_cert_level = 'O' iv_depth = 19 iv_dives = 20
iv_last_dive = c_recent iv_dive_date = c_dive_date iv_age = 30 )
msg = `O over limit` ).
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-ok
act = mo_cut->check_diver( iv_cert_level = 'A' iv_depth = 30 iv_dives = 50
iv_last_dive = c_recent iv_dive_date = c_dive_date iv_age = 30 )
msg = `A at limit` ).
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-depth
act = mo_cut->check_diver( iv_cert_level = 'A' iv_depth = 31 iv_dives = 50
iv_last_dive = c_recent iv_dive_date = c_dive_date iv_age = 30 )
msg = `A over limit` ).
ENDMETHOD.
METHOD dive_minimums.
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-ok
act = mo_cut->check_diver( iv_cert_level = 'O' iv_depth = 10 iv_dives = 20
iv_last_dive = c_recent iv_dive_date = c_dive_date iv_age = 30 )
msg = `O at minimum` ).
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-dives
act = mo_cut->check_diver( iv_cert_level = 'O' iv_depth = 10 iv_dives = 19
iv_last_dive = c_recent iv_dive_date = c_dive_date iv_age = 30 )
msg = `O below minimum` ).
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-ok
act = mo_cut->check_diver( iv_cert_level = 'D' iv_depth = 10 iv_dives = 100
iv_last_dive = c_recent iv_dive_date = c_dive_date iv_age = 30 )
msg = `D at minimum` ).
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-dives
act = mo_cut->check_diver( iv_cert_level = 'D' iv_depth = 10 iv_dives = 99
iv_last_dive = c_recent iv_dive_date = c_dive_date iv_age = 30 )
msg = `D below minimum` ).
ENDMETHOD.
METHOD stale_last_dive.
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-recent
act = mo_cut->check_diver( iv_cert_level = 'A' iv_depth = 25 iv_dives = 60
iv_last_dive = '20240101' iv_dive_date = c_dive_date iv_age = 30 ) ).
ENDMETHOD.
METHOD recent_dive_ok.
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-ok
act = mo_cut->check_diver( iv_cert_level = 'A' iv_depth = 25 iv_dives = 60
iv_last_dive = '20240601' iv_dive_date = c_dive_date iv_age = 30 ) ).
ENDMETHOD.
METHOD deep_dive_recent.
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-recent
act = mo_cut->check_diver( iv_cert_level = 'R' iv_depth = 35 iv_dives = 80
iv_last_dive = '20240913' iv_dive_date = c_dive_date iv_age = 30 )
msg = `200 days` ).
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-ok
act = mo_cut->check_diver( iv_cert_level = 'R' iv_depth = 35 iv_dives = 80
iv_last_dive = '20241003' iv_dive_date = c_dive_date iv_age = 30 )
msg = `180 days` ).
ENDMETHOD.
METHOD last_dive_missing.
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-recent
act = mo_cut->check_diver( iv_cert_level = 'A' iv_depth = 25 iv_dives = 60
iv_last_dive = '00000000' iv_dive_date = c_dive_date iv_age = 30 ) ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,64 @@
{
"task": "G0137",
"mutants": [
{
"object": "{{P}}DIVE_CHECK",
"mutant": "line 87: = -> <> (eq)",
"status": "invalid",
"hidden": "0/0",
"failed_tests": []
},
{
"object": "{{P}}DIVE_CHECK",
"mutant": "line 88: > -> <= (rel)",
"status": "killed",
"hidden": "5/12",
"failed_tests": [
"DEEP_DIVE_RECENT",
"DEPTH_LIMITS",
"DIVE_MINIMUMS",
"RECENT_DIVE_OK",
"STALE_LAST_DIVE",
"VALID_ALL_CERTS",
"VALID_DIVE_IS_OK"
]
},
{
"object": "{{P}}DIVE_CHECK",
"mutant": "line 97: 18 -> 19 (const)",
"status": "killed",
"hidden": "11/12",
"failed_tests": [
"DEPTH_LIMITS"
]
},
{
"object": "{{P}}DIVE_CHECK",
"mutant": "line 98: 50 -> 51 (const)",
"status": "killed",
"hidden": "10/12",
"failed_tests": [
"DEPTH_LIMITS",
"VALID_ALL_CERTS"
]
},
{
"object": "{{P}}DIVE_CHECK",
"mutant": "line 104: - -> + (arith)",
"status": "killed",
"hidden": "6/12",
"failed_tests": [
"DEEP_DIVE_RECENT",
"DEPTH_LIMITS",
"DIVE_MINIMUMS",
"RECENT_DIVE_OK",
"VALID_ALL_CERTS",
"VALID_DIVE_IS_OK"
]
}
],
"valid": 4,
"killed": 4,
"kill_rate": 1.0,
"ok": true
}

View File

@@ -0,0 +1,114 @@
CLASS {{p}}dive_check DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_reason TYPE c LENGTH 10.
TYPES ty_cert_level TYPE c LENGTH 1.
CONSTANTS:
BEGIN OF c_reason,
ok TYPE ty_reason VALUE 'OK',
age TYPE ty_reason VALUE 'AGE',
cert TYPE ty_reason VALUE 'CERT',
depth TYPE ty_reason VALUE 'DEPTH',
dives TYPE ty_reason VALUE 'DIVES',
recent TYPE ty_reason VALUE 'RECENT',
END OF c_reason.
METHODS check_diver
IMPORTING
iv_cert_level TYPE ty_cert_level
iv_depth TYPE i
iv_dives TYPE i
iv_last_dive TYPE d
iv_dive_date TYPE d
iv_age TYPE i
RETURNING
VALUE(rv_reason) TYPE ty_reason.
PRIVATE SECTION.
CONSTANTS:
c_min_age TYPE i VALUE 12,
c_deep_depth TYPE i VALUE 30,
c_days_deep TYPE i VALUE 180,
c_days_shallow TYPE i VALUE 365.
TYPES:
BEGIN OF ty_limit,
cert TYPE ty_cert_level,
max_depth TYPE i,
min_dives TYPE i,
END OF ty_limit,
tt_limit TYPE HASHED TABLE OF ty_limit WITH UNIQUE KEY cert.
METHODS limits
RETURNING VALUE(rt_limit) TYPE tt_limit.
METHODS days_since_last_dive
IMPORTING iv_last_dive TYPE d
iv_dive_date TYPE d
RETURNING VALUE(rv_days) TYPE i.
METHODS max_days_since_last_dive
IMPORTING iv_depth TYPE i
RETURNING VALUE(rv_days) TYPE i.
ENDCLASS.
CLASS {{p}}dive_check IMPLEMENTATION.
METHOD check_diver.
IF iv_age < c_min_age.
rv_reason = c_reason-age.
RETURN.
ENDIF.
DATA(lt_limit) = limits( ).
READ TABLE lt_limit WITH TABLE KEY cert = iv_cert_level ASSIGNING FIELD-SYMBOL(<ls_limit>).
IF sy-subrc <> 0.
rv_reason = c_reason-cert.
RETURN.
ENDIF.
IF iv_depth > <ls_limit>-max_depth.
rv_reason = c_reason-depth.
RETURN.
ENDIF.
IF iv_dives < <ls_limit>-min_dives.
rv_reason = c_reason-dives.
RETURN.
ENDIF.
IF iv_last_dive IS INITIAL.
rv_reason = c_reason-recent.
RETURN.
ENDIF.
IF days_since_last_dive( iv_last_dive = iv_last_dive
iv_dive_date = iv_dive_date ) > max_days_since_last_dive( iv_depth ).
rv_reason = c_reason-recent.
RETURN.
ENDIF.
rv_reason = c_reason-ok.
ENDMETHOD.
METHOD limits.
rt_limit = VALUE #( ( cert = 'O' max_depth = 18 min_dives = 20 )
( cert = 'A' max_depth = 30 min_dives = 50 )
( cert = 'R' max_depth = 40 min_dives = 80 )
( cert = 'D' max_depth = 40 min_dives = 100 ) ).
ENDMETHOD.
METHOD days_since_last_dive.
rv_days = iv_dive_date - iv_last_dive.
ENDMETHOD.
METHOD max_days_since_last_dive.
IF iv_depth > c_deep_depth.
rv_days = c_days_deep.
ELSE.
rv_days = c_days_shallow.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,75 @@
CLASS ltc_dive_check DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
CONSTANTS:
c_dive_date TYPE d VALUE '20250401',
c_recent TYPE d VALUE '20250201'.
DATA mo_cut TYPE REF TO {{p}}dive_check.
METHODS setup.
METHODS valid_dive_is_ok FOR TESTING.
METHODS too_young FOR TESTING.
METHODS unknown_cert FOR TESTING.
METHODS too_few_dives FOR TESTING.
METHODS stale_last_dive FOR TESTING.
ENDCLASS.
CLASS ltc_dive_check IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}dive_check( ).
ENDMETHOD.
METHOD valid_dive_is_ok.
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-ok
act = mo_cut->check_diver( iv_cert_level = 'A'
iv_depth = 25
iv_dives = 60
iv_last_dive = c_recent
iv_dive_date = c_dive_date
iv_age = 30 ) ).
ENDMETHOD.
METHOD too_young.
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-age
act = mo_cut->check_diver( iv_cert_level = 'A'
iv_depth = 25
iv_dives = 60
iv_last_dive = c_recent
iv_dive_date = c_dive_date
iv_age = 11 ) ).
ENDMETHOD.
METHOD unknown_cert.
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-cert
act = mo_cut->check_diver( iv_cert_level = 'X'
iv_depth = 10
iv_dives = 100
iv_last_dive = c_recent
iv_dive_date = c_dive_date
iv_age = 30 ) ).
ENDMETHOD.
METHOD too_few_dives.
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-dives
act = mo_cut->check_diver( iv_cert_level = 'A'
iv_depth = 25
iv_dives = 49
iv_last_dive = c_recent
iv_dive_date = c_dive_date
iv_age = 30 ) ).
ENDMETHOD.
METHOD stale_last_dive.
cl_abap_unit_assert=>assert_equals(
exp = {{p}}dive_check=>c_reason-recent
act = mo_cut->check_diver( iv_cert_level = 'A'
iv_depth = 25
iv_dives = 60
iv_last_dive = '20240101'
iv_dive_date = c_dive_date
iv_age = 30 ) ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,94 @@
CLASS {{p}}dive_check DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_reason TYPE c LENGTH 10.
TYPES ty_cert_level TYPE c LENGTH 1.
CONSTANTS:
BEGIN OF c_reason,
ok TYPE ty_reason VALUE 'OK',
age TYPE ty_reason VALUE 'AGE',
cert TYPE ty_reason VALUE 'CERT',
depth TYPE ty_reason VALUE 'DEPTH',
dives TYPE ty_reason VALUE 'DIVES',
recent TYPE ty_reason VALUE 'RECENT',
END OF c_reason.
METHODS check_diver
IMPORTING
iv_cert_level TYPE ty_cert_level
iv_depth TYPE i
iv_dives TYPE i
iv_last_dive TYPE d
iv_dive_date TYPE d
iv_age TYPE i
RETURNING
VALUE(rv_reason) TYPE ty_reason.
ENDCLASS.
CLASS {{p}}dive_check IMPLEMENTATION.
METHOD check_diver.
DATA lv_max_depth TYPE i.
DATA lv_min_dives TYPE i.
DATA lv_days TYPE i.
DATA lv_known TYPE c LENGTH 1.
rv_reason = c_reason-ok.
IF iv_age < 12.
rv_reason = c_reason-age.
ELSE.
IF iv_cert_level = 'O'.
lv_max_depth = 18.
lv_min_dives = 20.
lv_known = 'X'.
ELSEIF iv_cert_level = 'A'.
lv_max_depth = 30.
lv_min_dives = 50.
lv_known = 'X'.
ELSEIF iv_cert_level = 'R'.
lv_max_depth = 40.
lv_min_dives = 80.
lv_known = 'X'.
ELSEIF iv_cert_level = 'D'.
lv_max_depth = 40.
lv_min_dives = 100.
lv_known = 'X'.
ELSE.
lv_known = ' '.
ENDIF.
IF lv_known <> 'X'.
rv_reason = c_reason-cert.
ELSE.
IF iv_depth > lv_max_depth.
rv_reason = c_reason-depth.
ELSE.
IF iv_dives < lv_min_dives.
rv_reason = c_reason-dives.
ELSE.
IF iv_last_dive IS INITIAL.
rv_reason = c_reason-recent.
ELSE.
IF iv_depth > 30.
lv_days = iv_dive_date - iv_last_dive.
IF lv_days > 180.
rv_reason = c_reason-recent.
ENDIF.
ELSE.
lv_days = iv_dive_date - iv_last_dive.
IF lv_days > 365.
rv_reason = c_reason-recent.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,56 @@
# 1. Goal
Refactor the legacy class {{P}}DIVE_CHECK. The class checks if a diver may join a
guided dive. A booking program calls the check before it confirms the dive.
The behavior of the class stays the same. Improve the structure and the
readability of the code.
# 2. Open questions
None.
# 3. Context
- The class {{P}}DIVE_CHECK exists in package $TMP. It is active.
- A booking program uses the class. The public interface of the class is fixed.
- The class contains legacy code: one long method, deep nesting, hard-coded
numbers, and duplicated statements. Users report no defect. The task is a
refactoring, not a repair.
- Read the current source of the class before you change it.
# 4. Contract
The class {{P}}DIVE_CHECK stays in package $TMP. The class stays public and
final. Do not change the public interface.
- Public type TY_REASON: type c, length 10.
- Public type TY_CERT_LEVEL: type c, length 1.
- Public constant structure C_REASON with the components OK, AGE, CERT, DEPTH,
DIVES, and RECENT. The component type is TY_REASON. Do not change the values.
- Public instance method CHECK_DIVER with this signature:
IMPORTING
iv_cert_level TYPE ty_cert_level
iv_depth TYPE i
iv_dives TYPE i
iv_last_dive TYPE d
iv_dive_date TYPE d
iv_age TYPE i
RETURNING
VALUE(rv_reason) TYPE ty_reason.
- Do not add other public components. Do not remove a public component.
# 5. Business rules
- The class keeps its current behavior. Read the legacy code and keep every
rule, the sequence of the rules, and every limit.
- Do not add a rule. Do not remove a rule. Do not change a limit. Do not change
the sequence of the rules.
- The method returns the reason of the first rule that fails. If no rule fails,
the method returns OK.
# 6. Constraints
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
- Coding standards: Clean ABAP. Methods below 40 statements. No global
variables. No comment that restates the code. No ATC priority 1 or priority 2
finding.
- Out of scope: do not change the public interface. Do not create other
objects. Do not change the behavior.
# 7. Acceptance
- The class {{P}}DIVE_CHECK is active and has no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests as local test classes of the class.

View File

@@ -0,0 +1,48 @@
{
"id": "G0137",
"category": "E",
"object_type": "CLAS",
"difficulty": 2,
"release_target": "v816",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [
{
"type": "CLAS",
"name": "{{P}}DIVE_CHECK",
"file": "seed/dive_check.clas.abap",
"description": "Legacy dive check class with one long nested method"
}
],
"contract": [
{
"type": "CLAS",
"name": "{{P}}DIVE_CHECK"
}
],
"out_of_scope": [],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}T12_HIDDEN",
"file": "hidden/t12_hidden.clas.abap",
"description": "T12 hidden tests for the unchanged dive check behavior"
}
],
"reference": [
{
"type": "CLAS",
"name": "{{P}}DIVE_CHECK",
"file": "reference/dive_check.clas.abap",
"description": "Refactored dive check class",
"testclasses_file": "reference/dive_check.testclasses.abap"
}
],
"craft_checks": [
"method_length",
"cyclomatic_complexity"
]
}