michael@0: import WebIDL michael@0: michael@0: def WebIDLTest(parser, harness): michael@0: parser.parse(""" michael@0: interface TestCallback { michael@0: attribute CallbackType? listener; michael@0: }; michael@0: michael@0: callback CallbackType = boolean (unsigned long arg); michael@0: """) michael@0: michael@0: results = parser.finish() michael@0: michael@0: harness.ok(True, "TestCallback interface parsed without error.") michael@0: harness.check(len(results), 2, "Should be two productions.") michael@0: iface = results[0] michael@0: harness.ok(isinstance(iface, WebIDL.IDLInterface), michael@0: "Should be an IDLInterface") michael@0: harness.check(iface.identifier.QName(), "::TestCallback", "Interface has the right QName") michael@0: harness.check(iface.identifier.name, "TestCallback", "Interface has the right name") michael@0: harness.check(len(iface.members), 1, "Expect %s members" % 1) michael@0: michael@0: attr = iface.members[0] michael@0: harness.ok(isinstance(attr, WebIDL.IDLAttribute), michael@0: "Should be an IDLAttribute") michael@0: harness.ok(attr.isAttr(), "Should be an attribute") michael@0: harness.ok(not attr.isMethod(), "Attr is not an method") michael@0: harness.ok(not attr.isConst(), "Attr is not a const") michael@0: harness.check(attr.identifier.QName(), "::TestCallback::listener", "Attr has the right QName") michael@0: harness.check(attr.identifier.name, "listener", "Attr has the right name") michael@0: t = attr.type michael@0: harness.ok(not isinstance(t, WebIDL.IDLWrapperType), "Attr has the right type") michael@0: harness.ok(isinstance(t, WebIDL.IDLNullableType), "Attr has the right type") michael@0: harness.ok(t.isCallback(), "Attr has the right type")