Bug 1194991 - Part a: rewrite test_const.py to simplify adding new tests; r=khuey
authorMs2ger <Ms2ger@gmail.com>
Tue, 27 Oct 2015 09:18:11 +0100
changeset 304857 4e6be8988177e53ce70aed655d4f21bed4e8b0e8
parent 304856 bbf43055e28b9a12fa913086897b1bda5a629f04
child 304858 f1966d9bbf475e1ed4a3aeaaac0be37fdb61c1ab
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1194991
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1194991 - Part a: rewrite test_const.py to simplify adding new tests; r=khuey
dom/bindings/parser/tests/test_const.py
--- a/dom/bindings/parser/tests/test_const.py
+++ b/dom/bindings/parser/tests/test_const.py
@@ -1,10 +1,27 @@
 import WebIDL
 
+expected = [
+    ("::TestConsts::zero", "zero", "Byte", 0),
+    ("::TestConsts::b", "b", "Byte", -1),
+    ("::TestConsts::o", "o", "Octet", 2),
+    ("::TestConsts::s", "s", "Short", -3),
+    ("::TestConsts::us", "us", "UnsignedShort", 4),
+    ("::TestConsts::l", "l", "Long", -5),
+    ("::TestConsts::ul", "ul", "UnsignedLong", 6),
+    ("::TestConsts::ull", "ull", "UnsignedLongLong", 7),
+    ("::TestConsts::ll", "ll", "LongLong", -8),
+    ("::TestConsts::t", "t", "Boolean", True),
+    ("::TestConsts::f", "f", "Boolean", False),
+    ("::TestConsts::n", "n", "BooleanOrNull", None),
+    ("::TestConsts::nt", "nt", "BooleanOrNull", True),
+    ("::TestConsts::nf", "nf", "BooleanOrNull", False),
+]
+
 def WebIDLTest(parser, harness):
     parser.parse("""
         interface TestConsts {
           const byte zero = 0;
           const byte b = -1;
           const octet o = 2;
           const short s = -3;
           const unsigned short us = 0x4;
@@ -24,41 +41,24 @@ def WebIDLTest(parser, harness):
 
     harness.ok(True, "TestConsts interface parsed without error.")
     harness.check(len(results), 1, "Should be one production.")
     iface = results[0]
     harness.ok(isinstance(iface, WebIDL.IDLInterface),
                "Should be an IDLInterface")
     harness.check(iface.identifier.QName(), "::TestConsts", "Interface has the right QName")
     harness.check(iface.identifier.name, "TestConsts", "Interface has the right name")
-    harness.check(len(iface.members), 14, "Expect 14 members")
+    harness.check(len(iface.members), len(expected), "Expect %s members" % len(expected))
 
-    consts = iface.members
-
-    def checkConst(const, QName, name, type, value):
+    for (const, (QName, name, type, value)) in zip(iface.members, expected):
         harness.ok(isinstance(const, WebIDL.IDLConst),
                    "Should be an IDLConst")
         harness.ok(const.isConst(), "Const is a const")
         harness.ok(not const.isAttr(), "Const is not an attr")
         harness.ok(not const.isMethod(), "Const is not a method")
         harness.check(const.identifier.QName(), QName, "Const has the right QName")
         harness.check(const.identifier.name, name, "Const has the right name")
         harness.check(str(const.type), type, "Const has the right type")
         harness.ok(const.type.isPrimitive(), "All consts should be primitive")
         harness.check(str(const.value.type), str(const.type),
                       "Const's value has the same type as the type")
         harness.check(const.value.value, value, "Const value has the right value.")
 
-    checkConst(consts[0], "::TestConsts::zero", "zero", "Byte", 0)
-    checkConst(consts[1], "::TestConsts::b", "b", "Byte", -1)
-    checkConst(consts[2], "::TestConsts::o", "o", "Octet", 2)
-    checkConst(consts[3], "::TestConsts::s", "s", "Short", -3)
-    checkConst(consts[4], "::TestConsts::us", "us", "UnsignedShort", 4)
-    checkConst(consts[5], "::TestConsts::l", "l", "Long", -5)
-    checkConst(consts[6], "::TestConsts::ul", "ul", "UnsignedLong", 6)
-    checkConst(consts[7], "::TestConsts::ull", "ull", "UnsignedLongLong", 7)
-    checkConst(consts[8], "::TestConsts::ll", "ll", "LongLong", -8)
-    checkConst(consts[9], "::TestConsts::t", "t", "Boolean", True)
-    checkConst(consts[10], "::TestConsts::f", "f", "Boolean", False)
-    checkConst(consts[11], "::TestConsts::n", "n", "BooleanOrNull", None)
-    checkConst(consts[12], "::TestConsts::nt", "nt", "BooleanOrNull", True)
-    checkConst(consts[13], "::TestConsts::nf", "nf", "BooleanOrNull", False)
-