michael@0: import WebIDL michael@0: michael@0: def WebIDLTest(parser, harness): michael@0: parser.parse(""" michael@0: interface TestBuiltins { michael@0: attribute boolean b; michael@0: attribute byte s8; michael@0: attribute octet u8; michael@0: attribute short s16; michael@0: attribute unsigned short u16; michael@0: attribute long s32; michael@0: attribute unsigned long u32; michael@0: attribute long long s64; michael@0: attribute unsigned long long u64; michael@0: attribute DOMTimeStamp ts; michael@0: }; michael@0: """) michael@0: michael@0: results = parser.finish() michael@0: michael@0: harness.ok(True, "TestBuiltins interface parsed without error.") michael@0: harness.check(len(results), 1, "Should be one production") michael@0: harness.ok(isinstance(results[0], WebIDL.IDLInterface), michael@0: "Should be an IDLInterface") michael@0: iface = results[0] michael@0: harness.check(iface.identifier.QName(), "::TestBuiltins", "Interface has the right QName") michael@0: harness.check(iface.identifier.name, "TestBuiltins", "Interface has the right name") michael@0: harness.check(iface.parent, None, "Interface has no parent") michael@0: michael@0: members = iface.members michael@0: harness.check(len(members), 10, "Should be one production") michael@0: michael@0: names = ["b", "s8", "u8", "s16", "u16", "s32", "u32", "s64", "u64", "ts"] michael@0: types = ["Boolean", "Byte", "Octet", "Short", "UnsignedShort", "Long", "UnsignedLong", "LongLong", "UnsignedLongLong", "UnsignedLongLong"] michael@0: for i in range(10): michael@0: attr = members[i] michael@0: harness.ok(isinstance(attr, WebIDL.IDLAttribute), "Should be an IDLAttribute") michael@0: harness.check(attr.identifier.QName(), "::TestBuiltins::" + names[i], "Attr has correct QName") michael@0: harness.check(attr.identifier.name, names[i], "Attr has correct name") michael@0: harness.check(str(attr.type), types[i], "Attr type is the correct name") michael@0: harness.ok(attr.type.isPrimitive(), "Should be a primitive type")