Testing a Record with Ada Expressions

Component Testing for Ada

To initialize and test a structured variable or record, you must initialize or test all the fields using a list of native language expressions (one per field). The following example illustrates this form:

STR l.all, init == , ev = ("myfoo",NIL,NIL)

Each element in the list must correspond to the structured variable field as it was declared.

Every expression in the list must obey the rules described so far, according to the type of field being initialized and tested:

  • An expression for simple fields or arrays of simple variables initialized using an expression

  • In Ada, an aggregate for fields of type record or array

Using Field Names in Native Expressions

As with arrays, you can specify field names in native expressions by following the field name of the structure with the characters =>, as follows:

TEST 3

FAMILY nominal

ELEMENT

VAR l, init = NIL, ev = NONIL

VAR l.all, init == , ev = (str=>"myfoo",next=>NIL,prev=>NIL)

VAR s, init = "myfoo", ev = init

#l = push(l,s);

END ELEMENT

END TEST

When using this form, you do not have to respect the order of expressions in the list.

Related Topics

Testing Records | Testing a Record with Another Record | Testing Records with Discriminants | Testing Tagged Records | No Test