0

If I have:

<'
type MyEnum : [A1, B2, C3, D4, E5];

extend sys {
     ListA : list of MyEnum;
     keep ListA.size() == 10; // Just for the example,
                              // point being that it is larger than the number of Enums in the type
};
'>

How do I add keeps to have ListA generate with at least one of each enum?

I want this to happen in generation so preferably not to do this on-the-fly. I can add:

extend sys {
     keep ListA.has(it == A1);
     keep ListA.has(it == B2);
     ...
};

But there must be a better way. This also isn't helpful if I start adding more to the type.

I also want all of them to be random so having a keep on the first 5 elements that they should be all different isn't as helpful either.

Thank you!

Ank
  • 1
  • 2
  • 1
    This is my temporary solution but would love if there was something better: ``` type MyEnum : [A1,B2,C3,D4,E5]; extend sys { ListA : list of MyEnum; keep ListA.size() == 10; ListB : list of bool; keep ListB.size() == 10; keep ListB.count(it) == all_values(MyEnum).size(); ListC : list of uint; keep ListC == ListB.all_indices(it).as_a(list of uint); keep for each in ListC { ListA[it] == all_values(MyEnum)[index]; }; }; – Ank Oct 03 '22 at 13:26

1 Answers1

4

i also use an auxiliary list:

all_vals : list of MyEnum;
keep all_vals == all_values(MyEnum);
keep for each in all_vals {
    it in ListA;
};
user3467290
  • 706
  • 3
  • 4