dom/bindings/parser/tests/test_builtins.py

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 import WebIDL
     3 def WebIDLTest(parser, harness):
     4     parser.parse("""
     5         interface TestBuiltins {
     6           attribute boolean b;
     7           attribute byte s8;
     8           attribute octet u8;
     9           attribute short s16;
    10           attribute unsigned short u16;
    11           attribute long s32;
    12           attribute unsigned long u32;
    13           attribute long long s64;
    14           attribute unsigned long long u64;
    15           attribute DOMTimeStamp ts;
    16         };
    17     """)
    19     results = parser.finish()
    21     harness.ok(True, "TestBuiltins interface parsed without error.")
    22     harness.check(len(results), 1, "Should be one production")
    23     harness.ok(isinstance(results[0], WebIDL.IDLInterface),
    24                "Should be an IDLInterface")
    25     iface = results[0]
    26     harness.check(iface.identifier.QName(), "::TestBuiltins", "Interface has the right QName")
    27     harness.check(iface.identifier.name, "TestBuiltins", "Interface has the right name")
    28     harness.check(iface.parent, None, "Interface has no parent")
    30     members = iface.members
    31     harness.check(len(members), 10, "Should be one production")
    33     names = ["b", "s8", "u8", "s16", "u16", "s32", "u32", "s64", "u64", "ts"]
    34     types = ["Boolean", "Byte", "Octet", "Short", "UnsignedShort", "Long", "UnsignedLong", "LongLong", "UnsignedLongLong", "UnsignedLongLong"]
    35     for i in range(10):
    36         attr = members[i]
    37         harness.ok(isinstance(attr, WebIDL.IDLAttribute), "Should be an IDLAttribute")
    38         harness.check(attr.identifier.QName(), "::TestBuiltins::" + names[i], "Attr has correct QName")
    39         harness.check(attr.identifier.name, names[i], "Attr has correct name")
    40         harness.check(str(attr.type), types[i], "Attr type is the correct name")
    41         harness.ok(attr.type.isPrimitive(), "Should be a primitive type")

mercurial