dom/bindings/parser/tests/test_builtins.py

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:1b55136ac4c5
1 import WebIDL
2
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 """)
18
19 results = parser.finish()
20
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")
29
30 members = iface.members
31 harness.check(len(members), 10, "Should be one production")
32
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