dom/bindings/parser/tests/test_callback.py

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:ab7a83c2901b
1 import WebIDL
2
3 def WebIDLTest(parser, harness):
4 parser.parse("""
5 interface TestCallback {
6 attribute CallbackType? listener;
7 };
8
9 callback CallbackType = boolean (unsigned long arg);
10 """)
11
12 results = parser.finish()
13
14 harness.ok(True, "TestCallback interface parsed without error.")
15 harness.check(len(results), 2, "Should be two productions.")
16 iface = results[0]
17 harness.ok(isinstance(iface, WebIDL.IDLInterface),
18 "Should be an IDLInterface")
19 harness.check(iface.identifier.QName(), "::TestCallback", "Interface has the right QName")
20 harness.check(iface.identifier.name, "TestCallback", "Interface has the right name")
21 harness.check(len(iface.members), 1, "Expect %s members" % 1)
22
23 attr = iface.members[0]
24 harness.ok(isinstance(attr, WebIDL.IDLAttribute),
25 "Should be an IDLAttribute")
26 harness.ok(attr.isAttr(), "Should be an attribute")
27 harness.ok(not attr.isMethod(), "Attr is not an method")
28 harness.ok(not attr.isConst(), "Attr is not a const")
29 harness.check(attr.identifier.QName(), "::TestCallback::listener", "Attr has the right QName")
30 harness.check(attr.identifier.name, "listener", "Attr has the right name")
31 t = attr.type
32 harness.ok(not isinstance(t, WebIDL.IDLWrapperType), "Attr has the right type")
33 harness.ok(isinstance(t, WebIDL.IDLNullableType), "Attr has the right type")
34 harness.ok(t.isCallback(), "Attr has the right type")

mercurial