On Sat, Sep 24, 2016 at 10:17 PM, Eric Engestrom <e...@engestrom.ch> wrote: > Dylan Baker recently added functions to that list and had to try a couple > times > to avoid duplicates. He said [1] he ended up testing it using: > len(functions) == len(set(functions)) > which I thought should always be done. > > Add this and a couple other tests using asserts to enforce the ordering and > uniqueness of the `functions` list, and the uniqueness and compactness of the > `offsets` dictionary. > > [1] https://lists.freedesktop.org/archives/mesa-dev/2016-September/129525.html > > Signed-off-by: Eric Engestrom <e...@engestrom.ch> > --- > > If people don't like enforcing the order, I'm happy to drop the previous patch > and send a revised version of this patch with this last assert removed. > > --- > src/mapi/glapi/gen/static_data.py | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/src/mapi/glapi/gen/static_data.py > b/src/mapi/glapi/gen/static_data.py > index bb11c1d..ef35b24 100644 > --- a/src/mapi/glapi/gen/static_data.py > +++ b/src/mapi/glapi/gen/static_data.py > @@ -435,6 +435,9 @@ offsets = { > "MultiTexCoord4sv": 407 > } > > +assert len(offsets) == len(set(offsets.keys())), "The offsets dictionary > contains duplicates"
set(offsets) should be enough, I think. > +assert len(offsets) == max(offsets.values()) + 1, "The offsets dictionary > has gaps" offsets.itervalues() > + > functions = [ > "Accum", > "ActiveShaderProgram", > @@ -1723,6 +1726,9 @@ functions = [ > "WindowPos3svARB", > ] > > +assert len(functions) == len(set(functions)), "The functions list contains > duplicates" > +assert functions == sorted(functions), "The functions list is not > sorted" I'm surprised this passes. Functions is an array, while sorted() is, iirc, an iterator (or maybe a generator). Does list.__eq__ have some sort of special cleverness to deal with that? _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev