def WebIDLTest(parser, harness):
parser.parse( """
// Give our dictionary a required member so we don't need to
// mess with optional and default values.
dictionary Dict {
required long member;
};
callback interface Foo {
};
interface Bar {
// Bit of a pain to get things that have dictionary types
undefined passDict(Dict arg);
undefined passFoo(Foo arg);
undefined passNullableUnion((object? or DOMString) arg);
undefined passNullable(Foo? arg);
}; """
)
results = parser.finish()
harness.ok(dictType.isDictionary(), "Should have dictionary type")
harness.ok(ifaceType.isInterface(), "Should have interface type")
harness.ok(ifaceType.isCallbackInterface(), "Should have callback interface type")
harness.ok( not dictType.isDistinguishableFrom(ifaceType), "Dictionary not distinguishable from callback interface",
)
harness.ok( not ifaceType.isDistinguishableFrom(dictType), "Callback interface not distinguishable from dictionary",
)
harness.ok(nullableUnionType.isUnion(), "Should have union type")
harness.ok(nullableIfaceType.isInterface(), "Should have interface type")
harness.ok(nullableIfaceType.nullable(), "Should have nullable type")
harness.ok( not nullableUnionType.isDistinguishableFrom(nullableIfaceType), "Nullable type not distinguishable from union with nullable ""member type",
)
harness.ok( not nullableIfaceType.isDistinguishableFrom(nullableUnionType), "Union with nullable member type not distinguishable from ""nullable type",
)
iface = results[0]
harness.ok(iface.isInterface(), "Should have interface")
argTypes = [firstArgType(method) for method in iface.members]
unrelatedTypes = [firstArgType(method) for method in iface.members[-3:]]
for type1 in argTypes: for type2 in argTypes:
distinguishable = type1 isnot type2 and (
type1 in unrelatedTypes or type2 in unrelatedTypes
)
harness.check(
type1.isDistinguishableFrom(type2),
distinguishable, "Type %s should %sbe distinguishable from type %s"
% (type1, ""if distinguishable else"not ", type2),
)
harness.check(
type2.isDistinguishableFrom(type1),
distinguishable, "Type %s should %sbe distinguishable from type %s"
% (type2, ""if distinguishable else"not ", type1),
)
parser = parser.reset()
parser.parse( """
interface Dummy {};
interface TestIface {
undefined method(long arg1, TestIface arg2);
undefined method(long arg1, long arg2);
undefined method(long arg1, Dummy arg2);
undefined method(DOMString arg1, DOMString arg2, DOMString arg3);
}; """
)
results = parser.finish()
harness.check(len(results[1].members), 1, "Should look like we have one method")
harness.check(
len(results[1].members[0].signatures()), 4, "Should have four signatures"
)
# Try to categorize things a bit to keep list lengths down def allBut(list1, list2): return [
a for a in list1 if a notin list2 and (a != "any"and a != "Promise"and a != "Promise?")
]
# Build a representation of the distinguishability table as a dict # of dicts, holding True values where needed, holes elsewhere.
data = dict() for type in argTypes:
data[type] = dict()
def setDistinguishable(type, types): for other in types:
data[type][other] = True
if areDistinguishable(type1, type2):
harness.ok( not threw, "Should not throw for '%s' and '%s' because they are distinguishable"
% (type1, type2),
) else:
harness.ok(
threw, "Should throw for '%s' and '%s' because they are not distinguishable"
% (type1, type2),
)
# Enumerate over everything in both orders, since order matters in # terms of our implementation of distinguishability checks for type1 in argTypes: for type2 in argTypes:
checkDistinguishability(parser, type1, type2)
Messung V0.5
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.