Snapshot: new training tasks (balanced generation), docs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
6
tasks_gen/train/G1943/reference/edit_stamp.stru.asabap
Normal file
6
tasks_gen/train/G1943/reference/edit_stamp.stru.asabap
Normal file
@@ -0,0 +1,6 @@
|
||||
@EndUserText.label : 'Last edit of a game round'
|
||||
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
|
||||
define structure {{p}}edit_stamp {
|
||||
last_editor : abap.char(12);
|
||||
last_edit_on : abap.dats;
|
||||
}
|
||||
13
tasks_gen/train/G1943/reference/game_round.stru.asabap
Normal file
13
tasks_gen/train/G1943/reference/game_round.stru.asabap
Normal file
@@ -0,0 +1,13 @@
|
||||
@EndUserText.label : 'Line type of the round report'
|
||||
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
|
||||
define structure {{p}}game_round {
|
||||
round_id : abap.char(10);
|
||||
play_date : abap.dats;
|
||||
field_no : abap.numc(2);
|
||||
team_name : abap.char(20);
|
||||
player_count : abap.int4;
|
||||
paintballs : abap.int4;
|
||||
round_fee : abap.dec(9,2);
|
||||
referee : abap.char(15);
|
||||
include {{p}}edit_stamp;
|
||||
}
|
||||
77
tasks_gen/train/G1943/reference/game_stru_test.clas.abap
Normal file
77
tasks_gen/train/G1943/reference/game_stru_test.clas.abap
Normal file
@@ -0,0 +1,77 @@
|
||||
CLASS {{p}}game_stru_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
TYPES: BEGIN OF ty_comp,
|
||||
name TYPE string,
|
||||
type TYPE REF TO cl_abap_datadescr,
|
||||
END OF ty_comp,
|
||||
ty_comps TYPE STANDARD TABLE OF ty_comp WITH DEFAULT KEY.
|
||||
CLASS-DATA go_line TYPE REF TO cl_abap_structdescr.
|
||||
CLASS-METHODS class_setup.
|
||||
CLASS-METHODS flat_components RETURNING VALUE(rt_comp) TYPE ty_comps.
|
||||
METHODS ten_fields FOR TESTING.
|
||||
METHODS field_order FOR TESTING.
|
||||
METHODS fee_decimals FOR TESTING.
|
||||
METHODS stamp_structure FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}game_stru_test IMPLEMENTATION.
|
||||
METHOD class_setup.
|
||||
go_line = CAST cl_abap_structdescr(
|
||||
cl_abap_typedescr=>describe_by_name( '{{P}}GAME_ROUND' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD flat_components.
|
||||
DATA(lt_comp) = go_line->get_components( ).
|
||||
LOOP AT lt_comp INTO DATA(ls_comp).
|
||||
TRY.
|
||||
DATA(lo_sub) = CAST cl_abap_structdescr( ls_comp-type ).
|
||||
DATA(lt_sub) = lo_sub->get_components( ).
|
||||
LOOP AT lt_sub INTO DATA(ls_sub).
|
||||
APPEND VALUE #( name = ls_sub-name type = ls_sub-type ) TO rt_comp.
|
||||
ENDLOOP.
|
||||
CATCH cx_sy_move_cast_error.
|
||||
APPEND VALUE #( name = ls_comp-name type = ls_comp-type ) TO rt_comp.
|
||||
ENDTRY.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ten_fields.
|
||||
DATA(lt_comp) = flat_components( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 10 act = lines( lt_comp ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD field_order.
|
||||
DATA(lt_comp) = flat_components( ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = `ROUND_ID` act = to_upper( lt_comp[ 1 ]-name ) ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = `FIELD_NO` act = to_upper( lt_comp[ 3 ]-name ) ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = `LAST_EDIT_ON` act = to_upper( lt_comp[ 10 ]-name ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD fee_decimals.
|
||||
DATA(lt_comp) = flat_components( ).
|
||||
LOOP AT lt_comp INTO DATA(ls_comp).
|
||||
IF to_upper( ls_comp-name ) = 'ROUND_FEE'.
|
||||
DATA(lo_elem) = CAST cl_abap_elemdescr( ls_comp-type ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lo_elem->decimals ).
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD stamp_structure.
|
||||
DATA(lo_stamp) = CAST cl_abap_structdescr(
|
||||
cl_abap_typedescr=>describe_by_name( '{{P}}EDIT_STAMP' ) ).
|
||||
DATA(lt_comp) = lo_stamp->get_components( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_comp ) ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = `LAST_EDITOR` act = to_upper( lt_comp[ 1 ]-name ) ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = `LAST_EDIT_ON` act = to_upper( lt_comp[ 2 ]-name ) ).
|
||||
DATA(lo_editor) = CAST cl_abap_elemdescr( lt_comp[ 1 ]-type ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 24 act = lo_editor->length ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user