4 def WebIDLTest(parser
, harness
):
7 interface TestOverloads {
9 undefined basic(long arg1);
10 boolean abitharder(TestOverloads foo);
11 boolean abitharder(boolean foo);
12 undefined abitharder(ArrayBuffer? foo);
13 undefined withVariadics(long... numbers);
14 undefined withVariadics(TestOverloads iface);
15 undefined withVariadics(long num, TestOverloads iface);
16 undefined optionalTest();
17 undefined optionalTest(optional long num1, long num2);
22 results
= parser
.finish()
24 harness
.ok(True, "TestOverloads interface parsed without error.")
25 harness
.check(len(results
), 1, "Should be one production.")
27 harness
.ok(isinstance(iface
, WebIDL
.IDLInterface
), "Should be an IDLInterface")
29 iface
.identifier
.QName(), "::TestOverloads", "Interface has the right QName"
32 iface
.identifier
.name
, "TestOverloads", "Interface has the right name"
34 harness
.check(len(iface
.members
), 4, "Expect %s members" % 4)
36 member
= iface
.members
[0]
38 member
.identifier
.QName(),
39 "::TestOverloads::basic",
40 "Method has the right QName",
42 harness
.check(member
.identifier
.name
, "basic", "Method has the right name")
43 harness
.check(member
.hasOverloads(), True, "Method has overloads")
45 signatures
= member
.signatures()
46 harness
.check(len(signatures
), 2, "Method should have 2 signatures")
48 (retval
, argumentSet
) = signatures
[0]
50 harness
.check(str(retval
), "Undefined", "Expect an undefined retval")
51 harness
.check(len(argumentSet
), 0, "Expect an empty argument set")
53 (retval
, argumentSet
) = signatures
[1]
54 harness
.check(str(retval
), "Undefined", "Expect an undefined retval")
55 harness
.check(len(argumentSet
), 1, "Expect an argument set with one argument")
57 argument
= argumentSet
[0]
58 harness
.ok(isinstance(argument
, WebIDL
.IDLArgument
), "Should be an IDLArgument")
60 argument
.identifier
.QName(),
61 "::TestOverloads::basic::arg1",
62 "Argument has the right QName",
64 harness
.check(argument
.identifier
.name
, "arg1", "Argument has the right name")
65 harness
.check(str(argument
.type), "Long", "Argument has the right type")
67 member
= iface
.members
[3]
69 len(member
.overloadsForArgCount(0)), 1, "Only one overload for no args"
71 harness
.check(len(member
.overloadsForArgCount(1)), 0, "No overloads for one arg")
73 len(member
.overloadsForArgCount(2)), 1, "Only one overload for two args"