Fix coverage with several contract classes; table annotation and file path checks; clean task dir on write
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
This commit is contained in:
102
tasks_gen/eval/G0106/reference/app_scorer.clas.abap
Normal file
102
tasks_gen/eval/G0106/reference/app_scorer.clas.abap
Normal file
@@ -0,0 +1,102 @@
|
||||
CLASS {{p}}app_scorer DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES ty_status TYPE c LENGTH 4.
|
||||
|
||||
TYPES: BEGIN OF ty_result,
|
||||
status TYPE ty_status,
|
||||
score TYPE i,
|
||||
rating TYPE string,
|
||||
END OF ty_result.
|
||||
|
||||
CONSTANTS: BEGIN OF co_status,
|
||||
ok TYPE ty_status VALUE 'OK',
|
||||
bad_years TYPE ty_status VALUE 'YEAR',
|
||||
bad_match TYPE ty_status VALUE 'MATC',
|
||||
bad_degree TYPE ty_status VALUE 'DEGR',
|
||||
END OF co_status.
|
||||
|
||||
METHODS evaluate
|
||||
IMPORTING
|
||||
iv_years TYPE i
|
||||
iv_degree TYPE string
|
||||
iv_match TYPE i
|
||||
RETURNING
|
||||
VALUE(rs_result) TYPE ty_result.
|
||||
|
||||
PRIVATE SECTION.
|
||||
METHODS experience_points
|
||||
IMPORTING iv_years TYPE i
|
||||
RETURNING VALUE(rv_points) TYPE i.
|
||||
METHODS education_points
|
||||
IMPORTING iv_degree TYPE string
|
||||
RETURNING VALUE(rv_points) TYPE i.
|
||||
METHODS skill_points
|
||||
IMPORTING iv_match TYPE i
|
||||
RETURNING VALUE(rv_points) TYPE i.
|
||||
METHODS rating_for
|
||||
IMPORTING iv_score TYPE i
|
||||
RETURNING VALUE(rv_rating) TYPE string.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}app_scorer IMPLEMENTATION.
|
||||
|
||||
METHOD evaluate.
|
||||
rs_result = VALUE #( status = co_status-ok ).
|
||||
|
||||
IF iv_years < 0.
|
||||
rs_result-status = co_status-bad_years.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
IF iv_match < 0 OR iv_match > 100.
|
||||
rs_result-status = co_status-bad_match.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
DATA(lv_education) = education_points( iv_degree ).
|
||||
IF lv_education < 0.
|
||||
rs_result-status = co_status-bad_degree.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
rs_result-score = experience_points( iv_years ) + lv_education + skill_points( iv_match ).
|
||||
rs_result-rating = rating_for( rs_result-score ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD experience_points.
|
||||
rv_points = iv_years * 8.
|
||||
IF rv_points > 40.
|
||||
rv_points = 40.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD education_points.
|
||||
CASE iv_degree.
|
||||
WHEN 'PHD'.
|
||||
rv_points = 30.
|
||||
WHEN 'MAS'.
|
||||
rv_points = 25.
|
||||
WHEN 'BAC'.
|
||||
rv_points = 20.
|
||||
WHEN 'VOC'.
|
||||
rv_points = 10.
|
||||
WHEN OTHERS.
|
||||
rv_points = -1.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD skill_points.
|
||||
rv_points = ( iv_match * 30 + 50 ) DIV 100.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rating_for.
|
||||
IF iv_score >= 75.
|
||||
rv_rating = 'INVITE'.
|
||||
ELSEIF iv_score >= 50.
|
||||
rv_rating = 'REVIEW'.
|
||||
ELSE.
|
||||
rv_rating = 'REJECT'.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
@@ -0,0 +1,33 @@
|
||||
CLASS ltc_scorer DEFINITION FOR TESTING
|
||||
DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
METHODS high_score FOR TESTING.
|
||||
METHODS low_score FOR TESTING.
|
||||
METHODS invalid_years FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_scorer IMPLEMENTATION.
|
||||
|
||||
METHOD high_score.
|
||||
DATA(lo_scorer) = NEW {{p}}app_scorer( ).
|
||||
DATA(ls_result) = lo_scorer->evaluate( iv_years = 5 iv_degree = 'PHD' iv_match = 100 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'OK' act = ls_result-status ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 100 act = ls_result-score ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'INVITE' act = ls_result-rating ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD low_score.
|
||||
DATA(lo_scorer) = NEW {{p}}app_scorer( ).
|
||||
DATA(ls_result) = lo_scorer->evaluate( iv_years = 0 iv_degree = 'VOC' iv_match = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 10 act = ls_result-score ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'REJECT' act = ls_result-rating ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_years.
|
||||
DATA(lo_scorer) = NEW {{p}}app_scorer( ).
|
||||
DATA(ls_result) = lo_scorer->evaluate( iv_years = -1 iv_degree = 'PHD' iv_match = 100 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'YEAR' act = ls_result-status ).
|
||||
cl_abap_unit_assert=>assert_initial( act = ls_result-rating ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
31
tasks_gen/eval/G0106/reference/appl_score.func.abap
Normal file
31
tasks_gen/eval/G0106/reference/appl_score.func.abap
Normal file
@@ -0,0 +1,31 @@
|
||||
FUNCTION {{p}}appl_score
|
||||
IMPORTING
|
||||
iv_years TYPE i
|
||||
iv_degree TYPE string
|
||||
iv_match TYPE i
|
||||
EXPORTING
|
||||
ev_score TYPE i
|
||||
ev_rating TYPE string
|
||||
EXCEPTIONS
|
||||
invalid_years
|
||||
invalid_match
|
||||
invalid_degree.
|
||||
|
||||
DATA(lo_scorer) = NEW {{p}}app_scorer( ).
|
||||
DATA(ls_result) = lo_scorer->evaluate(
|
||||
iv_years = iv_years
|
||||
iv_degree = iv_degree
|
||||
iv_match = iv_match ).
|
||||
|
||||
IF ls_result-status = {{p}}app_scorer=>co_status-bad_years.
|
||||
RAISE invalid_years.
|
||||
ELSEIF ls_result-status = {{p}}app_scorer=>co_status-bad_match.
|
||||
RAISE invalid_match.
|
||||
ELSEIF ls_result-status = {{p}}app_scorer=>co_status-bad_degree.
|
||||
RAISE invalid_degree.
|
||||
ENDIF.
|
||||
|
||||
ev_score = ls_result-score.
|
||||
ev_rating = ls_result-rating.
|
||||
|
||||
ENDFUNCTION.
|
||||
61
tasks_gen/eval/G0106/reference/t41_test.clas.abap
Normal file
61
tasks_gen/eval/G0106/reference/t41_test.clas.abap
Normal file
@@ -0,0 +1,61 @@
|
||||
CLASS {{p}}t41_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
METHODS score_of
|
||||
IMPORTING iv_years TYPE i iv_degree TYPE string iv_match TYPE i
|
||||
RETURNING VALUE(rv_score) TYPE i.
|
||||
METHODS invite_for_expert FOR TESTING.
|
||||
METHODS review_for_graduate FOR TESTING.
|
||||
METHODS reject_for_junior FOR TESTING.
|
||||
METHODS invalid_input FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t41_test IMPLEMENTATION.
|
||||
|
||||
METHOD score_of.
|
||||
CALL FUNCTION '{{P}}APPL_SCORE'
|
||||
EXPORTING
|
||||
iv_years = iv_years
|
||||
iv_degree = iv_degree
|
||||
iv_match = iv_match
|
||||
IMPORTING
|
||||
ev_score = rv_score
|
||||
EXCEPTIONS
|
||||
invalid_years = 1
|
||||
invalid_match = 2
|
||||
invalid_degree = 3
|
||||
OTHERS = 4.
|
||||
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invite_for_expert.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 100
|
||||
act = score_of( iv_years = 5 iv_degree = 'PHD' iv_match = 100 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD review_for_graduate.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 50
|
||||
act = score_of( iv_years = 5 iv_degree = 'VOC' iv_match = 0 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD reject_for_junior.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 18
|
||||
act = score_of( iv_years = 1 iv_degree = 'VOC' iv_match = 0 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_input.
|
||||
CALL FUNCTION '{{P}}APPL_SCORE'
|
||||
EXPORTING
|
||||
iv_years = -1
|
||||
iv_degree = 'PHD'
|
||||
iv_match = 50
|
||||
EXCEPTIONS
|
||||
invalid_years = 1
|
||||
OTHERS = 2.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = sy-subrc ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user