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 <[email protected]>
---
v2: making a set out of a dict doesn't need to use `.keys()` (Ilia)

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)),         "The offsets dictionary 
contains duplicates"
+assert len(offsets) == max(offsets.values()) + 1, "The offsets dictionary has 
gaps"
+
 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"
+
 """Functions that need dispatch slots but are not used
 
 Some of these functions may have GLX protocol support (for
-- 
Cheers,
  Eric

_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to