2012-03-31 08:42:20 +04:00
|
|
|
import WebIDL
|
|
|
|
|
|
|
|
def WebIDLTest(parser, harness):
|
|
|
|
parser.parse("""
|
|
|
|
interface SpecialMethods {
|
|
|
|
getter long long (unsigned long index);
|
|
|
|
setter long long (unsigned long index, long long value);
|
|
|
|
getter boolean (DOMString name);
|
|
|
|
setter boolean (DOMString name, boolean value);
|
|
|
|
deleter boolean (DOMString name);
|
2017-01-25 00:11:33 +03:00
|
|
|
readonly attribute unsigned long length;
|
2012-03-31 08:42:20 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
interface SpecialMethodsCombination {
|
|
|
|
getter deleter boolean (DOMString name);
|
|
|
|
};
|
|
|
|
""")
|
|
|
|
|
|
|
|
results = parser.finish()
|
|
|
|
|
|
|
|
def checkMethod(method, QName, name,
|
2017-11-04 07:36:10 +03:00
|
|
|
static=False, getter=False, setter=False,
|
2012-03-31 08:42:20 +04:00
|
|
|
deleter=False, legacycaller=False, stringifier=False):
|
|
|
|
harness.ok(isinstance(method, WebIDL.IDLMethod),
|
|
|
|
"Should be an IDLMethod")
|
|
|
|
harness.check(method.identifier.QName(), QName, "Method has the right QName")
|
|
|
|
harness.check(method.identifier.name, name, "Method has the right name")
|
|
|
|
harness.check(method.isStatic(), static, "Method has the correct static value")
|
|
|
|
harness.check(method.isGetter(), getter, "Method has the correct getter value")
|
|
|
|
harness.check(method.isSetter(), setter, "Method has the correct setter value")
|
|
|
|
harness.check(method.isDeleter(), deleter, "Method has the correct deleter value")
|
|
|
|
harness.check(method.isLegacycaller(), legacycaller, "Method has the correct legacycaller value")
|
|
|
|
harness.check(method.isStringifier(), stringifier, "Method has the correct stringifier value")
|
|
|
|
|
|
|
|
harness.check(len(results), 2, "Expect 2 interfaces")
|
|
|
|
|
|
|
|
iface = results[0]
|
2017-11-04 07:36:10 +03:00
|
|
|
harness.check(len(iface.members), 6, "Expect 6 members")
|
2012-03-31 08:42:20 +04:00
|
|
|
|
|
|
|
checkMethod(iface.members[0], "::SpecialMethods::__indexedgetter", "__indexedgetter",
|
|
|
|
getter=True)
|
|
|
|
checkMethod(iface.members[1], "::SpecialMethods::__indexedsetter", "__indexedsetter",
|
|
|
|
setter=True)
|
2017-11-04 07:36:10 +03:00
|
|
|
checkMethod(iface.members[2], "::SpecialMethods::__namedgetter", "__namedgetter",
|
2012-03-31 08:42:20 +04:00
|
|
|
getter=True)
|
2017-11-04 07:36:10 +03:00
|
|
|
checkMethod(iface.members[3], "::SpecialMethods::__namedsetter", "__namedsetter",
|
2012-03-31 08:42:20 +04:00
|
|
|
setter=True)
|
2017-11-04 07:36:10 +03:00
|
|
|
checkMethod(iface.members[4], "::SpecialMethods::__nameddeleter", "__nameddeleter",
|
2012-03-31 08:42:20 +04:00
|
|
|
deleter=True)
|
|
|
|
|
|
|
|
iface = results[1]
|
2017-11-04 07:36:10 +03:00
|
|
|
harness.check(len(iface.members), 1, "Expect 1 member")
|
2012-03-31 08:42:20 +04:00
|
|
|
|
2017-11-04 07:36:10 +03:00
|
|
|
checkMethod(iface.members[0], "::SpecialMethodsCombination::__namedgetterdeleter",
|
2012-03-31 08:42:20 +04:00
|
|
|
"__namedgetterdeleter", getter=True, deleter=True)
|
2016-11-04 20:28:17 +03:00
|
|
|
|
|
|
|
parser = parser.reset();
|
|
|
|
|
|
|
|
threw = False
|
|
|
|
try:
|
|
|
|
parser.parse(
|
|
|
|
"""
|
|
|
|
interface IndexedDeleter {
|
|
|
|
deleter void(unsigned long index);
|
|
|
|
};
|
|
|
|
""")
|
|
|
|
parser.finish()
|
|
|
|
except:
|
|
|
|
threw = True
|
|
|
|
|
|
|
|
harness.ok(threw, "There are no indexed deleters")
|
|
|
|
|
|
|
|
|