Snapshot: new training tasks (balanced generation), docs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
35
tasks_gen/train/G1951/reference/if_tenancy_check.intf.abap
Normal file
35
tasks_gen/train/G1951/reference/if_tenancy_check.intf.abap
Normal file
@@ -0,0 +1,35 @@
|
||||
INTERFACE {{p}}if_tenancy_check PUBLIC.
|
||||
TYPES ty_reason TYPE c LENGTH 10.
|
||||
TYPES ty_employment TYPE c LENGTH 1.
|
||||
TYPES ty_amount TYPE p LENGTH 8 DECIMALS 2.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_employment,
|
||||
permanent TYPE ty_employment VALUE 'P',
|
||||
fixed TYPE ty_employment VALUE 'F',
|
||||
self TYPE ty_employment VALUE 'S',
|
||||
END OF c_employment,
|
||||
BEGIN OF c_reason,
|
||||
ok TYPE ty_reason VALUE 'OK',
|
||||
rent TYPE ty_reason VALUE 'RENT',
|
||||
income TYPE ty_reason VALUE 'INCOME',
|
||||
persons TYPE ty_reason VALUE 'PERSONS',
|
||||
capacity TYPE ty_reason VALUE 'CAPACITY',
|
||||
employment TYPE ty_reason VALUE 'EMPLOYMENT',
|
||||
ratio TYPE ty_reason VALUE 'RATIO',
|
||||
END OF c_reason.
|
||||
|
||||
METHODS check
|
||||
IMPORTING iv_rent TYPE ty_amount
|
||||
iv_income TYPE ty_amount
|
||||
iv_rooms TYPE i
|
||||
iv_persons TYPE i
|
||||
iv_employment TYPE ty_employment
|
||||
iv_pets TYPE abap_bool
|
||||
RETURNING VALUE(rv_reason) TYPE ty_reason.
|
||||
|
||||
METHODS deposit
|
||||
IMPORTING iv_rent TYPE ty_amount
|
||||
iv_pets TYPE abap_bool
|
||||
RETURNING VALUE(rv_deposit) TYPE ty_amount.
|
||||
ENDINTERFACE.
|
||||
75
tasks_gen/train/G1951/reference/tenancy_checker.clas.abap
Normal file
75
tasks_gen/train/G1951/reference/tenancy_checker.clas.abap
Normal file
@@ -0,0 +1,75 @@
|
||||
CLASS {{p}}tenancy_checker DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_tenancy_check.
|
||||
|
||||
PRIVATE SECTION.
|
||||
METHODS income_factor
|
||||
IMPORTING iv_employment TYPE {{p}}if_tenancy_check=>ty_employment
|
||||
iv_pets TYPE abap_bool
|
||||
RETURNING VALUE(rv_factor) TYPE i.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}tenancy_checker IMPLEMENTATION.
|
||||
METHOD {{p}}if_tenancy_check~check.
|
||||
IF iv_rent <= 0.
|
||||
rv_reason = {{p}}if_tenancy_check=>c_reason-rent.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
IF iv_income <= 0.
|
||||
rv_reason = {{p}}if_tenancy_check=>c_reason-income.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
IF iv_persons < 1.
|
||||
rv_reason = {{p}}if_tenancy_check=>c_reason-persons.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
IF iv_persons > 2 * iv_rooms.
|
||||
rv_reason = {{p}}if_tenancy_check=>c_reason-capacity.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
IF iv_employment <> {{p}}if_tenancy_check=>c_employment-permanent
|
||||
AND iv_employment <> {{p}}if_tenancy_check=>c_employment-fixed
|
||||
AND iv_employment <> {{p}}if_tenancy_check=>c_employment-self.
|
||||
rv_reason = {{p}}if_tenancy_check=>c_reason-employment.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
DATA(lv_factor) = income_factor( iv_employment = iv_employment
|
||||
iv_pets = iv_pets ).
|
||||
IF iv_income < iv_rent * lv_factor.
|
||||
rv_reason = {{p}}if_tenancy_check=>c_reason-ratio.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
rv_reason = {{p}}if_tenancy_check=>c_reason-ok.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD {{p}}if_tenancy_check~deposit.
|
||||
IF iv_rent <= 0.
|
||||
rv_deposit = 0.
|
||||
ELSEIF iv_pets = abap_true.
|
||||
rv_deposit = 3 * iv_rent.
|
||||
ELSE.
|
||||
rv_deposit = 2 * iv_rent.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD income_factor.
|
||||
CASE iv_employment.
|
||||
WHEN {{p}}if_tenancy_check=>c_employment-permanent.
|
||||
rv_factor = 3.
|
||||
WHEN {{p}}if_tenancy_check=>c_employment-fixed.
|
||||
rv_factor = 4.
|
||||
WHEN OTHERS.
|
||||
rv_factor = 5.
|
||||
ENDCASE.
|
||||
IF iv_pets = abap_true.
|
||||
rv_factor = rv_factor + 1.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
117
tasks_gen/train/G1951/reference/tenancy_checker.testclasses.abap
Normal file
117
tasks_gen/train/G1951/reference/tenancy_checker.testclasses.abap
Normal file
@@ -0,0 +1,117 @@
|
||||
CLASS ltc_tenancy_checker DEFINITION FINAL FOR TESTING
|
||||
DURATION SHORT RISK LEVEL HARMLESS.
|
||||
|
||||
PRIVATE SECTION.
|
||||
TYPES ty_amount TYPE {{p}}if_tenancy_check=>ty_amount.
|
||||
|
||||
DATA mo_cut TYPE REF TO {{p}}if_tenancy_check.
|
||||
|
||||
METHODS setup.
|
||||
METHODS ok_application FOR TESTING.
|
||||
METHODS rent_must_be_positive FOR TESTING.
|
||||
METHODS income_must_be_positive FOR TESTING.
|
||||
METHODS overcrowded_flat FOR TESTING.
|
||||
METHODS unknown_employment FOR TESTING.
|
||||
METHODS income_too_low FOR TESTING.
|
||||
METHODS pets_need_more_income FOR TESTING.
|
||||
METHODS deposit_with_pets FOR TESTING.
|
||||
METHODS deposit_without_pets FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_tenancy_checker IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}tenancy_checker( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ok_application.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_tenancy_check=>c_reason-ok
|
||||
act = mo_cut->check( iv_rent = CONV ty_amount( 1200 )
|
||||
iv_income = CONV ty_amount( 4000 )
|
||||
iv_rooms = 2
|
||||
iv_persons = 2
|
||||
iv_employment = {{p}}if_tenancy_check=>c_employment-permanent
|
||||
iv_pets = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rent_must_be_positive.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_tenancy_check=>c_reason-rent
|
||||
act = mo_cut->check( iv_rent = CONV ty_amount( 0 )
|
||||
iv_income = CONV ty_amount( 4000 )
|
||||
iv_rooms = 2
|
||||
iv_persons = 2
|
||||
iv_employment = {{p}}if_tenancy_check=>c_employment-permanent
|
||||
iv_pets = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD income_must_be_positive.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_tenancy_check=>c_reason-income
|
||||
act = mo_cut->check( iv_rent = CONV ty_amount( 1200 )
|
||||
iv_income = CONV ty_amount( 0 )
|
||||
iv_rooms = 2
|
||||
iv_persons = 2
|
||||
iv_employment = {{p}}if_tenancy_check=>c_employment-permanent
|
||||
iv_pets = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD overcrowded_flat.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_tenancy_check=>c_reason-capacity
|
||||
act = mo_cut->check( iv_rent = CONV ty_amount( 1200 )
|
||||
iv_income = CONV ty_amount( 4000 )
|
||||
iv_rooms = 2
|
||||
iv_persons = 5
|
||||
iv_employment = {{p}}if_tenancy_check=>c_employment-permanent
|
||||
iv_pets = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_employment.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_tenancy_check=>c_reason-employment
|
||||
act = mo_cut->check( iv_rent = CONV ty_amount( 1200 )
|
||||
iv_income = CONV ty_amount( 4000 )
|
||||
iv_rooms = 2
|
||||
iv_persons = 2
|
||||
iv_employment = 'X'
|
||||
iv_pets = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD income_too_low.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_tenancy_check=>c_reason-ratio
|
||||
act = mo_cut->check( iv_rent = CONV ty_amount( 1200 )
|
||||
iv_income = CONV ty_amount( 3500 )
|
||||
iv_rooms = 2
|
||||
iv_persons = 2
|
||||
iv_employment = {{p}}if_tenancy_check=>c_employment-permanent
|
||||
iv_pets = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD pets_need_more_income.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_tenancy_check=>c_reason-ratio
|
||||
act = mo_cut->check( iv_rent = CONV ty_amount( 1200 )
|
||||
iv_income = CONV ty_amount( 4000 )
|
||||
iv_rooms = 2
|
||||
iv_persons = 2
|
||||
iv_employment = {{p}}if_tenancy_check=>c_employment-permanent
|
||||
iv_pets = abap_true ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD deposit_with_pets.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV ty_amount( 3600 )
|
||||
act = mo_cut->deposit( iv_rent = CONV ty_amount( 1200 )
|
||||
iv_pets = abap_true ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD deposit_without_pets.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV ty_amount( 2400 )
|
||||
act = mo_cut->deposit( iv_rent = CONV ty_amount( 1200 )
|
||||
iv_pets = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user