0

Next question to post:

Hi,

I have the following test case:

<’
 struct item_s {
            payload:list of byte;
            kind:[SMALL,BIG];

            when SMALL item_s {
                            keep payload.size() < 10;
            };
      };

extend sys {
            !item:item_s;

            run() is also {
                       for i from 1 to 10 {
                                gen item keeping {
                                       .payload.size() == 100;
                                       };                             
                             };
                    };
           };
 ‘>

I expected the test to generate only BIG items. Instead, I see that occasionally a SMALL item is generated, which leads to a contradiction. What is the explanation for this behavior?

Yuri Tsoglin
  • 963
  • 4
  • 7

1 Answers1

3

The user guide states that

Any field that is declared or constrained under a when subtype depends on the value of the when determinant. In other words, there is an implicit unidirectional constraint (a subtype dependency) between the when determinant and the dependent field:

when-determinant -> dependent-field

This means that kind and payload are generated separately. You'll need to move your constraint outside of the when subtype:

keep kind == SMALL => payload.size() < 10;

You can find more info in the Working with When Subtype Dependencies in Constraints chapter of the Specman Generation User Guide.

Community
  • 1
  • 1
Tudor Timi
  • 7,453
  • 1
  • 24
  • 53