4 def WebIDLTest(parser
, harness
):
13 interface TestEnumInterface {
14 TestEnum doFoo(boolean arg);
15 readonly attribute TestEnum foo;
20 results
= parser
.finish()
22 harness
.ok(True, "TestEnumInterfaces interface parsed without error.")
23 harness
.check(len(results
), 2, "Should be one production")
24 harness
.ok(isinstance(results
[0], WebIDL
.IDLEnum
), "Should be an IDLEnum")
25 harness
.ok(isinstance(results
[1], WebIDL
.IDLInterface
), "Should be an IDLInterface")
28 harness
.check(enum
.identifier
.QName(), "::TestEnum", "Enum has the right QName")
29 harness
.check(enum
.identifier
.name
, "TestEnum", "Enum has the right name")
30 harness
.check(enum
.values(), ["", "foo", "bar"], "Enum has the right values")
35 iface
.identifier
.QName(), "::TestEnumInterface", "Interface has the right QName"
38 iface
.identifier
.name
, "TestEnumInterface", "Interface has the right name"
40 harness
.check(iface
.parent
, None, "Interface has no parent")
42 members
= iface
.members
43 harness
.check(len(members
), 2, "Should be one production")
44 harness
.ok(isinstance(members
[0], WebIDL
.IDLMethod
), "Should be an IDLMethod")
47 method
.identifier
.QName(),
48 "::TestEnumInterface::doFoo",
49 "Method has correct QName",
51 harness
.check(method
.identifier
.name
, "doFoo", "Method has correct name")
53 signatures
= method
.signatures()
54 harness
.check(len(signatures
), 1, "Expect one signature")
56 (returnType
, arguments
) = signatures
[0]
58 str(returnType
), "TestEnum (Wrapper)", "Method type is the correct name"
60 harness
.check(len(arguments
), 1, "Method has the right number of arguments")
62 harness
.ok(isinstance(arg
, WebIDL
.IDLArgument
), "Should be an IDLArgument")
63 harness
.check(str(arg
.type), "Boolean", "Argument has the right type")
67 attr
.identifier
.QName(), "::TestEnumInterface::foo", "Attr has correct QName"
69 harness
.check(attr
.identifier
.name
, "foo", "Attr has correct name")
71 harness
.check(str(attr
.type), "TestEnum (Wrapper)", "Attr type is the correct name")
73 # Now reset our parser
74 parser
= parser
.reset()
84 interface TestInterface {
85 undefined foo(optional Enum e = "d");
90 except WebIDL
.WebIDLError
:
93 harness
.ok(threw
, "Should not allow a bogus default value for an enum")
95 # Now reset our parser
96 parser
= parser
.reset()
106 results
= parser
.finish()
107 harness
.check(len(results
), 1, "Should allow trailing comma in enum")