Testing structured variables with C expressions

Component Testing for C

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

STR *l, 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:

Using Field Names in Native Expressions

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


  FAMILY nominal


    VAR l, init = NIL, ev = NONIL

    VAR *l, init == , ev = {str=>"myfoo",next=>NIL,prev=>NIL}

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

    #l = push(l,s);



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

You can also use the position of the fields in the structure or record instead of the field names, on the basis that the field numbers begin at 1:

VAR *l, init ==, ev = {3 => NIL, 2 => NIL, 1 => "myfoo"}

As with arrays, you can also use a range for field positions, as follows:

VAR *l, init ==, ev = {1 => "myfoo", 2..3 => NIL}

Related Topics

Testing variablesTesting structured variablesTesting structured variables with other structured variablesC UnionsOmitting a Field's Initial and Test Values