Snapshot: new training tasks (balanced generation), docs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
29
tasks_gen/train/G1951/generation.json
Normal file
29
tasks_gen/train/G1951/generation.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"id": "G1951",
|
||||
"pool": "train",
|
||||
"object_type": "INTF",
|
||||
"category": "A",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
}
|
||||
],
|
||||
"accepted": false
|
||||
}
|
||||
250
tasks_gen/train/G1951/hidden/tenancy_hidden.clas.abap
Normal file
250
tasks_gen/train/G1951/hidden/tenancy_hidden.clas.abap
Normal file
@@ -0,0 +1,250 @@
|
||||
CLASS {{p}}tenancy_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
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 bad_rent FOR TESTING.
|
||||
METHODS bad_income FOR TESTING.
|
||||
METHODS no_person FOR TESTING.
|
||||
METHODS overcrowded FOR TESTING.
|
||||
METHODS bad_employment FOR TESTING.
|
||||
METHODS income_too_low FOR TESTING.
|
||||
METHODS pets_raise_factor FOR TESTING.
|
||||
METHODS deposit_without_pets FOR TESTING.
|
||||
METHODS deposit_with_pets FOR TESTING.
|
||||
METHODS constants_and_types FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}tenancy_hidden 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 bad_rent.
|
||||
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 ) msg = `zero rent` ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_tenancy_check=>c_reason-rent
|
||||
act = mo_cut->check( iv_rent = CONV ty_amount( -100 )
|
||||
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 ) msg = `negative rent` ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD bad_income.
|
||||
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 ) msg = `zero income` ).
|
||||
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( -500 )
|
||||
iv_rooms = 2
|
||||
iv_persons = 2
|
||||
iv_employment = {{p}}if_tenancy_check=>c_employment-permanent
|
||||
iv_pets = abap_false ) msg = `negative income` ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD no_person.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_tenancy_check=>c_reason-persons
|
||||
act = mo_cut->check( iv_rent = CONV ty_amount( 1200 )
|
||||
iv_income = CONV ty_amount( 4000 )
|
||||
iv_rooms = 2
|
||||
iv_persons = 0
|
||||
iv_employment = {{p}}if_tenancy_check=>c_employment-permanent
|
||||
iv_pets = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD overcrowded.
|
||||
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 bad_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 ) msg = `permanent needs 3x` ).
|
||||
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( 4700 )
|
||||
iv_rooms = 2
|
||||
iv_persons = 2
|
||||
iv_employment = {{p}}if_tenancy_check=>c_employment-fixed
|
||||
iv_pets = abap_false ) msg = `fixed term needs 4x` ).
|
||||
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( 5900 )
|
||||
iv_rooms = 2
|
||||
iv_persons = 2
|
||||
iv_employment = {{p}}if_tenancy_check=>c_employment-self
|
||||
iv_pets = abap_false ) msg = `self employed needs 5x` ).
|
||||
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( 6000 )
|
||||
iv_rooms = 2
|
||||
iv_persons = 2
|
||||
iv_employment = {{p}}if_tenancy_check=>c_employment-self
|
||||
iv_pets = abap_false ) msg = `self employed is ok` ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD pets_raise_factor.
|
||||
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 ) msg = `pets need 4x` ).
|
||||
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( 4800 )
|
||||
iv_rooms = 2
|
||||
iv_persons = 2
|
||||
iv_employment = {{p}}if_tenancy_check=>c_employment-permanent
|
||||
iv_pets = abap_true ) msg = `pets with 4x is ok` ).
|
||||
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 ) ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV ty_amount( 0 )
|
||||
act = mo_cut->deposit( iv_rent = CONV ty_amount( 0 )
|
||||
iv_pets = abap_false ) msg = `zero rent` ).
|
||||
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 ) ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV ty_amount( 0 )
|
||||
act = mo_cut->deposit( iv_rent = CONV ty_amount( 0 )
|
||||
iv_pets = abap_true ) msg = `zero rent` ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD constants_and_types.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'OK'
|
||||
act = {{p}}if_tenancy_check=>c_reason-ok ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'RENT'
|
||||
act = {{p}}if_tenancy_check=>c_reason-rent ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'INCOME'
|
||||
act = {{p}}if_tenancy_check=>c_reason-income ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'PERSONS'
|
||||
act = {{p}}if_tenancy_check=>c_reason-persons ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'CAPACITY'
|
||||
act = {{p}}if_tenancy_check=>c_reason-capacity ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'EMPLOYMENT'
|
||||
act = {{p}}if_tenancy_check=>c_reason-employment ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'RATIO'
|
||||
act = {{p}}if_tenancy_check=>c_reason-ratio ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'P'
|
||||
act = {{p}}if_tenancy_check=>c_employment-permanent ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'F'
|
||||
act = {{p}}if_tenancy_check=>c_employment-fixed ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'S'
|
||||
act = {{p}}if_tenancy_check=>c_employment-self ).
|
||||
|
||||
DATA lv_reason TYPE {{p}}if_tenancy_check=>ty_reason.
|
||||
DATA lv_employment TYPE {{p}}if_tenancy_check=>ty_employment.
|
||||
DATA lv_amount TYPE {{p}}if_tenancy_check=>ty_amount.
|
||||
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 10
|
||||
act = cl_abap_typedescr=>describe_by_data( lv_reason )->length ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = cl_abap_typedescr=>typekind_char
|
||||
act = cl_abap_typedescr=>describe_by_data( lv_reason )->type_kind ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 1
|
||||
act = cl_abap_typedescr=>describe_by_data( lv_employment )->length ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = cl_abap_typedescr=>typekind_char
|
||||
act = cl_abap_typedescr=>describe_by_data( lv_employment )->type_kind ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 8
|
||||
act = cl_abap_typedescr=>describe_by_data( lv_amount )->length ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 2
|
||||
act = cl_abap_typedescr=>describe_by_data( lv_amount )->decimals ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = cl_abap_typedescr=>typekind_packed
|
||||
act = cl_abap_typedescr=>describe_by_data( lv_amount )->type_kind ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS lcl_tenant DEFINITION.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_tenancy_check.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS lcl_tenant IMPLEMENTATION.
|
||||
METHOD {{p}}if_tenancy_check~check.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD {{p}}if_tenancy_check~deposit.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
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.
|
||||
84
tasks_gen/train/G1951/spec.md
Normal file
84
tasks_gen/train/G1951/spec.md
Normal file
@@ -0,0 +1,84 @@
|
||||
# 1. Goal
|
||||
A property management company checks a tenancy application before it offers a
|
||||
flat to an applicant. The office calls the check for each application. The
|
||||
office also needs the deposit that the applicant must pay.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- The office works with one interface and one class that implements the
|
||||
interface.
|
||||
- The interface {{P}}IF_TENANCY_CHECK holds the types, the constants and the
|
||||
method signatures of the tenancy check.
|
||||
- The class {{P}}TENANCY_CHECKER holds the logic.
|
||||
- The method CHECK returns one reason code for each tenancy application.
|
||||
- The method DEPOSIT returns the deposit of a tenancy application.
|
||||
|
||||
# 4. Contract
|
||||
Create the interface {{P}}IF_TENANCY_CHECK in package $TMP. The interface is
|
||||
public. It has these components and no other components.
|
||||
|
||||
Types:
|
||||
- TY_REASON: type c, length 10.
|
||||
- TY_EMPLOYMENT: type c, length 1.
|
||||
- TY_AMOUNT: type p, length 8, 2 decimal places.
|
||||
|
||||
Constants:
|
||||
- C_EMPLOYMENT: a constant structure with the components PERMANENT, FIXED and
|
||||
SELF. Each component has the type TY_EMPLOYMENT. The values are:
|
||||
PERMANENT = 'P', FIXED = 'F', SELF = 'S'.
|
||||
- C_REASON: a constant structure with the components OK, RENT, INCOME,
|
||||
PERSONS, CAPACITY, EMPLOYMENT and RATIO. Each component has the type
|
||||
TY_REASON. The values are: OK = 'OK', RENT = 'RENT', INCOME = 'INCOME',
|
||||
PERSONS = 'PERSONS', CAPACITY = 'CAPACITY', EMPLOYMENT = 'EMPLOYMENT',
|
||||
RATIO = 'RATIO'.
|
||||
|
||||
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.
|
||||
- DEPOSIT
|
||||
IMPORTING iv_rent TYPE ty_amount
|
||||
iv_pets TYPE abap_bool
|
||||
RETURNING VALUE(rv_deposit) TYPE ty_amount.
|
||||
|
||||
Create the class {{P}}TENANCY_CHECKER in package $TMP.
|
||||
- The class is public, final, and has a public constructor without parameters.
|
||||
- The class implements {{P}}IF_TENANCY_CHECK.
|
||||
- Do not add other public methods.
|
||||
|
||||
# 5. Business rules
|
||||
The method CHECK applies the rules in this sequence. It returns the reason of
|
||||
the first rule that fails.
|
||||
1. If iv_rent is less than or equal to zero, return RENT.
|
||||
2. If iv_income is less than or equal to zero, return INCOME.
|
||||
3. If iv_persons is less than one, return PERSONS.
|
||||
4. If iv_persons is greater than two times iv_rooms, return CAPACITY.
|
||||
5. If iv_employment is not 'P', 'F' or 'S', return EMPLOYMENT.
|
||||
6. The income factor is 3 for 'P', 4 for 'F' and 5 for 'S'. If iv_pets is
|
||||
true, add 1 to the income factor. If iv_income is less than iv_rent
|
||||
multiplied by the income factor, return RATIO.
|
||||
7. Return OK.
|
||||
|
||||
The method DEPOSIT applies the rules in this sequence.
|
||||
1. If iv_rent is less than or equal to zero, return 0.
|
||||
2. If iv_pets is true, return three times iv_rent.
|
||||
3. Return two times iv_rent.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
|
||||
- Coding standards: Clean ABAP. Method length below 40 statements. No global
|
||||
variables. No comment that restates the code.
|
||||
- Out of scope: do not create database tables, CDS views, reports or function
|
||||
modules.
|
||||
|
||||
# 7. Acceptance
|
||||
- The interface and the class are active and have no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write your own ABAP Unit tests for the class.
|
||||
52
tasks_gen/train/G1951/task.json
Normal file
52
tasks_gen/train/G1951/task.json
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"id": "G1951",
|
||||
"category": "A",
|
||||
"object_type": "INTF",
|
||||
"difficulty": 2,
|
||||
"release_target": "v816",
|
||||
"expected_outcome": "implement",
|
||||
"budget": {
|
||||
"max_tool_calls": 60,
|
||||
"max_activations": 15
|
||||
},
|
||||
"seed": [],
|
||||
"contract": [
|
||||
{
|
||||
"type": "INTF",
|
||||
"name": "{{P}}IF_TENANCY_CHECK"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}TENANCY_CHECKER",
|
||||
"implements": "{{P}}IF_TENANCY_CHECK"
|
||||
}
|
||||
],
|
||||
"out_of_scope": [],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}TENANCY_HIDDEN",
|
||||
"file": "hidden/tenancy_hidden.clas.abap",
|
||||
"description": "T_INTF_TENANCY hidden tests"
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "INTF",
|
||||
"name": "{{P}}IF_TENANCY_CHECK",
|
||||
"file": "reference/if_tenancy_check.intf.abap",
|
||||
"description": "Tenancy check interface with types, constants and method signatures"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}TENANCY_CHECKER",
|
||||
"file": "reference/tenancy_checker.clas.abap",
|
||||
"description": "Tenancy checker that implements the interface",
|
||||
"testclasses_file": "reference/tenancy_checker.testclasses.abap"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length",
|
||||
"cyclomatic_complexity"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user