зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1330699 part 6. Add some tests for distinguishability of unions. r=qdot
This commit is contained in:
Родитель
c2ed802c58
Коммит
c41dd5c904
|
@ -2339,8 +2339,10 @@ class IDLNullableType(IDLParametrizedType):
|
|||
return self
|
||||
|
||||
def isDistinguishableFrom(self, other):
|
||||
if (other.nullable() or (other.isUnion() and other.hasNullableType) or
|
||||
other.isDictionary()):
|
||||
if (other.nullable() or
|
||||
other.isDictionary() or
|
||||
(other.isUnion() and
|
||||
(other.hasNullableType or other.hasDictionaryType()))):
|
||||
# Can't tell which type null should become
|
||||
return False
|
||||
return self.inner.isDistinguishableFrom(other)
|
||||
|
|
|
@ -162,7 +162,9 @@ def WebIDLTest(parser, harness):
|
|||
"Date", "Date?", "any",
|
||||
"Promise<any>", "Promise<any>?",
|
||||
"USVString", "ArrayBuffer", "ArrayBufferView", "SharedArrayBuffer",
|
||||
"Uint8Array", "Uint16Array" ]
|
||||
"Uint8Array", "Uint16Array",
|
||||
"(long or Callback)", "optional (long or Dict)",
|
||||
]
|
||||
# When we can parse Date, we need to add it here.
|
||||
# XXXbz we can, and should really do that...
|
||||
|
||||
|
@ -170,10 +172,11 @@ def WebIDLTest(parser, harness):
|
|||
def allBut(list1, list2):
|
||||
return [a for a in list1 if a not in list2 and
|
||||
(a != "any" and a != "Promise<any>" and a != "Promise<any>?")]
|
||||
unions = [ "(long or Callback)", "optional (long or Dict)" ]
|
||||
numerics = [ "long", "short", "long?", "short?" ]
|
||||
booleans = [ "boolean", "boolean?" ]
|
||||
primitives = numerics + booleans
|
||||
nonNumerics = allBut(argTypes, numerics)
|
||||
nonNumerics = allBut(argTypes, numerics + unions)
|
||||
nonBooleans = allBut(argTypes, booleans)
|
||||
strings = [ "DOMString", "ByteString", "Enum", "Enum2", "USVString" ]
|
||||
nonStrings = allBut(argTypes, strings)
|
||||
|
@ -183,9 +186,10 @@ def WebIDLTest(parser, harness):
|
|||
sharedBufferSourceTypes = ["SharedArrayBuffer"]
|
||||
interfaces = [ "Interface", "Interface?", "AncestorInterface",
|
||||
"UnrelatedInterface", "ImplementedInterface" ] + bufferSourceTypes + sharedBufferSourceTypes
|
||||
nullables = ["long?", "short?", "boolean?", "Interface?",
|
||||
"CallbackInterface?", "optional Dict", "optional Dict2",
|
||||
"Date?", "any", "Promise<any>?"]
|
||||
nullables = (["long?", "short?", "boolean?", "Interface?",
|
||||
"CallbackInterface?", "optional Dict", "optional Dict2",
|
||||
"Date?", "any", "Promise<any>?"] +
|
||||
allBut(unions, [ "(long or Callback)" ]))
|
||||
dates = [ "Date", "Date?" ]
|
||||
sequences = [ "sequence<long>", "sequence<short>" ]
|
||||
nonUserObjects = nonObjects + interfaces + dates + sequences
|
||||
|
@ -245,6 +249,10 @@ def WebIDLTest(parser, harness):
|
|||
setDistinguishable("Uint8Array", allBut(argTypes, ["ArrayBufferView", "Uint8Array", "object"]))
|
||||
setDistinguishable("Uint16Array", allBut(argTypes, ["ArrayBufferView", "Uint16Array", "object"]))
|
||||
setDistinguishable("SharedArrayBuffer", allBut(argTypes, ["SharedArrayBuffer", "object"]))
|
||||
setDistinguishable("(long or Callback)",
|
||||
allBut(nonUserObjects, numerics))
|
||||
setDistinguishable("optional (long or Dict)",
|
||||
allBut(nonUserObjects, numerics + nullables))
|
||||
|
||||
def areDistinguishable(type1, type2):
|
||||
return data[type1].get(type2, False)
|
||||
|
|
Загрузка…
Ссылка в новой задаче