<p dir="ltr">Also note... the list is already sorted. You just picked a different sort order. One that I'm pretty sure is subject to locale settings. As I recall C and utf8 do things differently in a way relevant to this list but I haven't checked.</p>
<div class="gmail_extra"><br><div class="gmail_quote">On Sep 24, 2016 10:27 PM, "Ilia Mirkin" <<a href="mailto:imirkin@alum.mit.edu">imirkin@alum.mit.edu</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sat, Sep 24, 2016 at 10:17 PM, Eric Engestrom <<a href="mailto:eric@engestrom.ch">eric@engestrom.ch</a>> wrote:<br>
> Dylan Baker recently added functions to that list and had to try a couple times<br>
> to avoid duplicates. He said [1] he ended up testing it using:<br>
> len(functions) == len(set(functions))<br>
> which I thought should always be done.<br>
><br>
> Add this and a couple other tests using asserts to enforce the ordering and<br>
> uniqueness of the `functions` list, and the uniqueness and compactness of the<br>
> `offsets` dictionary.<br>
><br>
> [1] <a href="https://lists.freedesktop.org/archives/mesa-dev/2016-September/129525.html" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>archives/mesa-dev/2016-<wbr>September/129525.html</a><br>
><br>
> Signed-off-by: Eric Engestrom <<a href="mailto:eric@engestrom.ch">eric@engestrom.ch</a>><br>
> ---<br>
><br>
> If people don't like enforcing the order, I'm happy to drop the previous patch<br>
> and send a revised version of this patch with this last assert removed.<br>
><br>
> ---<br>
> src/mapi/glapi/gen/static_<wbr>data.py | 6 ++++++<br>
> 1 file changed, 6 insertions(+)<br>
><br>
> diff --git a/src/mapi/glapi/gen/static_<wbr>data.py b/src/mapi/glapi/gen/static_<wbr>data.py<br>
> index bb11c1d..ef35b24 100644<br>
> --- a/src/mapi/glapi/gen/static_<wbr>data.py<br>
> +++ b/src/mapi/glapi/gen/static_<wbr>data.py<br>
> @@ -435,6 +435,9 @@ offsets = {<br>
> "MultiTexCoord4sv": 407<br>
> }<br>
><br>
> +assert len(offsets) == len(set(offsets.keys())), "The offsets dictionary contains duplicates"<br>
<br>
set(offsets) should be enough, I think.<br>
<br>
> +assert len(offsets) == max(offsets.values()) + 1, "The offsets dictionary has gaps"<br>
<br>
offsets.itervalues()<br>
<br>
> +<br>
> functions = [<br>
> "Accum",<br>
> "ActiveShaderProgram",<br>
> @@ -1723,6 +1726,9 @@ functions = [<br>
> "WindowPos3svARB",<br>
> ]<br>
><br>
> +assert len(functions) == len(set(functions)), "The functions list contains duplicates"<br>
> +assert functions == sorted(functions), "The functions list is not sorted"<br>
<br>
I'm surprised this passes. Functions is an array, while sorted() is,<br>
iirc, an iterator (or maybe a generator). Does list.__eq__ have some<br>
sort of special cleverness to deal with that?<br>
</blockquote></div></div>