mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
update to latest tests
This commit is contained in:
parent
175b3c2d27
commit
da40818f25
8 changed files with 156 additions and 29 deletions
|
@ -293,10 +293,49 @@ def WebIDLTest(parser, harness):
|
||||||
try:
|
try:
|
||||||
parser.parse("""
|
parser.parse("""
|
||||||
interface A {
|
interface A {
|
||||||
[SetterInfallible] readonly attribute boolean foo;
|
[SetterThrows] readonly attribute boolean foo;
|
||||||
};
|
};
|
||||||
""")
|
""")
|
||||||
results = parser.finish()
|
results = parser.finish()
|
||||||
except Exception, x:
|
except Exception, x:
|
||||||
threw = True
|
threw = True
|
||||||
harness.ok(threw, "Should not allow [SetterInfallible] on readonly attributes")
|
harness.ok(threw, "Should not allow [SetterThrows] on readonly attributes")
|
||||||
|
|
||||||
|
parser = parser.reset()
|
||||||
|
threw = False
|
||||||
|
try:
|
||||||
|
parser.parse("""
|
||||||
|
interface A {
|
||||||
|
[Throw] readonly attribute boolean foo;
|
||||||
|
};
|
||||||
|
""")
|
||||||
|
results = parser.finish()
|
||||||
|
except Exception, x:
|
||||||
|
threw = True
|
||||||
|
harness.ok(threw, "Should spell [Throws] correctly")
|
||||||
|
|
||||||
|
parser = parser.reset()
|
||||||
|
threw = False
|
||||||
|
try:
|
||||||
|
parser.parse("""
|
||||||
|
interface A {
|
||||||
|
[SameObject] readonly attribute boolean foo;
|
||||||
|
};
|
||||||
|
""")
|
||||||
|
results = parser.finish()
|
||||||
|
except Exception, x:
|
||||||
|
threw = True
|
||||||
|
harness.ok(threw, "Should not allow [SameObject] on attributes not of interface type")
|
||||||
|
|
||||||
|
parser = parser.reset()
|
||||||
|
threw = False
|
||||||
|
try:
|
||||||
|
parser.parse("""
|
||||||
|
interface A {
|
||||||
|
[SameObject] readonly attribute A foo;
|
||||||
|
};
|
||||||
|
""")
|
||||||
|
results = parser.finish()
|
||||||
|
except Exception, x:
|
||||||
|
threw = True
|
||||||
|
harness.ok(not threw, "Should allow [SameObject] on attributes of interface type")
|
||||||
|
|
|
@ -11,8 +11,9 @@ def WebIDLTest(parser, harness):
|
||||||
harness.check(argument.variadic, variadic, "Argument has the right variadic value")
|
harness.check(argument.variadic, variadic, "Argument has the right variadic value")
|
||||||
|
|
||||||
def checkMethod(method, QName, name, signatures,
|
def checkMethod(method, QName, name, signatures,
|
||||||
static=False, getter=False, setter=False, creator=False,
|
static=True, getter=False, setter=False, creator=False,
|
||||||
deleter=False, legacycaller=False, stringifier=False):
|
deleter=False, legacycaller=False, stringifier=False,
|
||||||
|
chromeOnly=False):
|
||||||
harness.ok(isinstance(method, WebIDL.IDLMethod),
|
harness.ok(isinstance(method, WebIDL.IDLMethod),
|
||||||
"Should be an IDLMethod")
|
"Should be an IDLMethod")
|
||||||
harness.ok(method.isMethod(), "Method is a method")
|
harness.ok(method.isMethod(), "Method is a method")
|
||||||
|
@ -27,6 +28,7 @@ def WebIDLTest(parser, harness):
|
||||||
harness.check(method.isDeleter(), deleter, "Method has the correct deleter 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.isLegacycaller(), legacycaller, "Method has the correct legacycaller value")
|
||||||
harness.check(method.isStringifier(), stringifier, "Method has the correct stringifier value")
|
harness.check(method.isStringifier(), stringifier, "Method has the correct stringifier value")
|
||||||
|
harness.check(method.getExtendedAttribute("ChromeOnly") is not None, chromeOnly, "Method has the correct value for ChromeOnly")
|
||||||
harness.check(len(method.signatures()), len(signatures), "Method has the correct number of signatures")
|
harness.check(len(method.signatures()), len(signatures), "Method has the correct number of signatures")
|
||||||
|
|
||||||
sigpairs = zip(method.signatures(), signatures)
|
sigpairs = zip(method.signatures(), signatures)
|
||||||
|
@ -55,11 +57,13 @@ def WebIDLTest(parser, harness):
|
||||||
};
|
};
|
||||||
""")
|
""")
|
||||||
results = parser.finish()
|
results = parser.finish()
|
||||||
harness.check(len(results), 3, "Should be two productions")
|
harness.check(len(results), 3, "Should be three productions")
|
||||||
harness.ok(isinstance(results[0], WebIDL.IDLInterface),
|
harness.ok(isinstance(results[0], WebIDL.IDLInterface),
|
||||||
"Should be an IDLInterface")
|
"Should be an IDLInterface")
|
||||||
harness.ok(isinstance(results[1], WebIDL.IDLInterface),
|
harness.ok(isinstance(results[1], WebIDL.IDLInterface),
|
||||||
"Should be an IDLInterface")
|
"Should be an IDLInterface")
|
||||||
|
harness.ok(isinstance(results[2], WebIDL.IDLInterface),
|
||||||
|
"Should be an IDLInterface")
|
||||||
|
|
||||||
checkMethod(results[0].ctor(), "::TestConstructorNoArgs::constructor",
|
checkMethod(results[0].ctor(), "::TestConstructorNoArgs::constructor",
|
||||||
"constructor", [("TestConstructorNoArgs (Wrapper)", [])])
|
"constructor", [("TestConstructorNoArgs (Wrapper)", [])])
|
||||||
|
@ -73,3 +77,33 @@ def WebIDLTest(parser, harness):
|
||||||
[("::TestConstructorOverloads::constructor::foo", "foo", "Object", False, False)]),
|
[("::TestConstructorOverloads::constructor::foo", "foo", "Object", False, False)]),
|
||||||
("TestConstructorOverloads (Wrapper)",
|
("TestConstructorOverloads (Wrapper)",
|
||||||
[("::TestConstructorOverloads::constructor::bar", "bar", "Boolean", False, False)])])
|
[("::TestConstructorOverloads::constructor::bar", "bar", "Boolean", False, False)])])
|
||||||
|
|
||||||
|
parser = parser.reset()
|
||||||
|
parser.parse("""
|
||||||
|
[ChromeConstructor()]
|
||||||
|
interface TestChromeConstructor {
|
||||||
|
};
|
||||||
|
""")
|
||||||
|
results = parser.finish()
|
||||||
|
harness.check(len(results), 1, "Should be one production")
|
||||||
|
harness.ok(isinstance(results[0], WebIDL.IDLInterface),
|
||||||
|
"Should be an IDLInterface")
|
||||||
|
|
||||||
|
checkMethod(results[0].ctor(), "::TestChromeConstructor::constructor",
|
||||||
|
"constructor", [("TestChromeConstructor (Wrapper)", [])],
|
||||||
|
chromeOnly=True)
|
||||||
|
|
||||||
|
parser = parser.reset()
|
||||||
|
threw = False
|
||||||
|
try:
|
||||||
|
parser.parse("""
|
||||||
|
[Constructor(),
|
||||||
|
ChromeConstructor(DOMString a)]
|
||||||
|
interface TestChromeConstructor {
|
||||||
|
};
|
||||||
|
""")
|
||||||
|
results = parser.finish()
|
||||||
|
except:
|
||||||
|
threw = True
|
||||||
|
|
||||||
|
harness.ok(threw, "Can't have both a Constructor and a ChromeConstructor")
|
||||||
|
|
|
@ -2,9 +2,9 @@ import WebIDL
|
||||||
|
|
||||||
def WebIDLTest(parser, harness):
|
def WebIDLTest(parser, harness):
|
||||||
parser.parse("""
|
parser.parse("""
|
||||||
[Flippety]
|
[NoInterfaceObject]
|
||||||
interface TestExtendedAttr {
|
interface TestExtendedAttr {
|
||||||
[Foopy] attribute byte b;
|
[Unforgeable] readonly attribute byte b;
|
||||||
};
|
};
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
@ -12,9 +12,9 @@ def WebIDLTest(parser, harness):
|
||||||
|
|
||||||
parser = parser.reset()
|
parser = parser.reset()
|
||||||
parser.parse("""
|
parser.parse("""
|
||||||
[Flippety="foo.bar",Floppety=flop]
|
[Pref="foo.bar",Pref=flop]
|
||||||
interface TestExtendedAttr {
|
interface TestExtendedAttr {
|
||||||
[Foopy="foo.bar"] attribute byte b;
|
[Pref="foo.bar"] attribute byte b;
|
||||||
};
|
};
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
|
@ -39,28 +39,27 @@ def WebIDLTest(parser, harness):
|
||||||
attribute DOMString? b;
|
attribute DOMString? b;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Not implemented. */
|
interface TestNullableEquivalency8 {
|
||||||
/*interface TestNullableEquivalency8 {
|
|
||||||
attribute float a;
|
attribute float a;
|
||||||
attribute float? b;
|
attribute float? b;
|
||||||
};*/
|
};
|
||||||
|
|
||||||
interface TestNullableEquivalency8 {
|
interface TestNullableEquivalency9 {
|
||||||
attribute double a;
|
attribute double a;
|
||||||
attribute double? b;
|
attribute double? b;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface TestNullableEquivalency9 {
|
interface TestNullableEquivalency10 {
|
||||||
attribute object a;
|
attribute object a;
|
||||||
attribute object? b;
|
attribute object? b;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface TestNullableEquivalency10 {
|
interface TestNullableEquivalency11 {
|
||||||
attribute double[] a;
|
attribute double[] a;
|
||||||
attribute double[]? b;
|
attribute double[]? b;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface TestNullableEquivalency11 {
|
interface TestNullableEquivalency12 {
|
||||||
attribute TestNullableEquivalency9[] a;
|
attribute TestNullableEquivalency9[] a;
|
||||||
attribute TestNullableEquivalency9[]? b;
|
attribute TestNullableEquivalency9[]? b;
|
||||||
};
|
};
|
||||||
|
@ -91,7 +90,7 @@ def checkEquivalent(iface, harness):
|
||||||
for attr in dir(type1):
|
for attr in dir(type1):
|
||||||
if attr.startswith('_') or \
|
if attr.startswith('_') or \
|
||||||
attr in ['nullable', 'builtin', 'filename', 'location',
|
attr in ['nullable', 'builtin', 'filename', 'location',
|
||||||
'inner', 'QName'] or \
|
'inner', 'QName', 'getDeps', 'name'] or \
|
||||||
(hasattr(type(type1), attr) and not callable(getattr(type1, attr))):
|
(hasattr(type(type1), attr) and not callable(getattr(type1, attr))):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
|
@ -11,4 +11,20 @@ def WebIDLTest(parser, harness):
|
||||||
except:
|
except:
|
||||||
threw = True
|
threw = True
|
||||||
|
|
||||||
harness.ok(threw, "Should have thrown.")
|
harness.ok(not threw,
|
||||||
|
"Should not have thrown on non-optional argument following "
|
||||||
|
"optional argument.")
|
||||||
|
|
||||||
|
parser = parser.reset()
|
||||||
|
parser.parse("""
|
||||||
|
interface OptionalConstraints2 {
|
||||||
|
void foo(optional byte arg1 = 1, optional byte arg2 = 2,
|
||||||
|
optional byte arg3, optional byte arg4 = 4,
|
||||||
|
optional byte arg5, optional byte arg6 = 9);
|
||||||
|
};
|
||||||
|
""")
|
||||||
|
results = parser.finish()
|
||||||
|
args = results[0].members[0].signatures()[0][1]
|
||||||
|
harness.check(len(args), 6, "Should have 6 arguments")
|
||||||
|
harness.check(args[5].defaultValue.value, 9,
|
||||||
|
"Should have correct default value")
|
||||||
|
|
|
@ -2,11 +2,11 @@ import WebIDL
|
||||||
|
|
||||||
def WebIDLTest(parser, harness):
|
def WebIDLTest(parser, harness):
|
||||||
parser.parse("""
|
parser.parse("""
|
||||||
callback Function = any(any... arguments);
|
[TreatNonCallableAsNull] callback Function = any(any... arguments);
|
||||||
|
|
||||||
interface TestTreatNonCallableAsNull1 {
|
interface TestTreatNonCallableAsNull1 {
|
||||||
[TreatNonCallableAsNull] attribute Function? onfoo;
|
attribute Function? onfoo;
|
||||||
attribute Function? onbar;
|
attribute Function onbar;
|
||||||
};
|
};
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
@ -54,3 +54,18 @@ def WebIDLTest(parser, harness):
|
||||||
threw = True
|
threw = True
|
||||||
|
|
||||||
harness.ok(threw, "Should have thrown.")
|
harness.ok(threw, "Should have thrown.")
|
||||||
|
|
||||||
|
parser = parser.reset()
|
||||||
|
|
||||||
|
threw = False
|
||||||
|
try:
|
||||||
|
parser.parse("""
|
||||||
|
[TreatNonCallableAsNull, TreatNonObjectAsNull]
|
||||||
|
callback Function = any(any... arguments);
|
||||||
|
""")
|
||||||
|
|
||||||
|
results = parser.finish()
|
||||||
|
except:
|
||||||
|
threw = True
|
||||||
|
|
||||||
|
harness.ok(threw, "Should have thrown.")
|
||||||
|
|
|
@ -12,7 +12,7 @@ def WebIDLTest(parser, harness):
|
||||||
|
|
||||||
results = parser.finish()
|
results = parser.finish()
|
||||||
|
|
||||||
harness.check(results[2].members[1].type.name, "Long",
|
harness.check(results[2].members[1].type.name, "LongOrNull",
|
||||||
"Should expand typedefs")
|
"Should expand typedefs")
|
||||||
|
|
||||||
parser = parser.reset()
|
parser = parser.reset()
|
||||||
|
|
|
@ -1,39 +1,63 @@
|
||||||
def WebIDLTest(parser, harness):
|
def WebIDLTest(parser, harness):
|
||||||
threw = False
|
threw = False
|
||||||
try:
|
try:
|
||||||
results = parser.parse("""
|
parser.parse("""
|
||||||
interface VariadicConstraints1 {
|
interface VariadicConstraints1 {
|
||||||
void foo(byte... arg1, byte arg2);
|
void foo(byte... arg1, byte arg2);
|
||||||
};
|
};
|
||||||
""")
|
""")
|
||||||
|
results = parser.finish()
|
||||||
|
|
||||||
except:
|
except:
|
||||||
threw = True
|
threw = True
|
||||||
|
|
||||||
harness.ok(threw, "Should have thrown.")
|
harness.ok(threw,
|
||||||
|
"Should have thrown on variadic argument followed by required "
|
||||||
|
"argument.")
|
||||||
|
|
||||||
|
parser = parser.reset()
|
||||||
threw = False
|
threw = False
|
||||||
try:
|
try:
|
||||||
results = parser.parse("""
|
parser.parse("""
|
||||||
interface VariadicConstraints2 {
|
interface VariadicConstraints2 {
|
||||||
void foo(byte... arg1, optional byte arg2);
|
void foo(byte... arg1, optional byte arg2);
|
||||||
};
|
};
|
||||||
""")
|
""")
|
||||||
|
results = parser.finish();
|
||||||
except:
|
except:
|
||||||
threw = True
|
threw = True
|
||||||
|
|
||||||
harness.ok(threw, "Should have thrown.")
|
harness.ok(threw,
|
||||||
|
"Should have thrown on variadic argument followed by optional "
|
||||||
|
"argument.")
|
||||||
|
|
||||||
|
parser = parser.reset()
|
||||||
threw = False
|
threw = False
|
||||||
try:
|
try:
|
||||||
results = parser.parse("""
|
parser.parse("""
|
||||||
interface VariadicConstraints3 {
|
interface VariadicConstraints3 {
|
||||||
void foo(optional byte... arg1);
|
void foo(optional byte... arg1);
|
||||||
};
|
};
|
||||||
""")
|
""")
|
||||||
|
results = parser.finish()
|
||||||
|
|
||||||
except:
|
except:
|
||||||
threw = True
|
threw = True
|
||||||
|
|
||||||
harness.ok(threw, "Should have thrown.")
|
harness.ok(threw,
|
||||||
|
"Should have thrown on variadic argument explicitly flagged as "
|
||||||
|
"optional.")
|
||||||
|
|
||||||
|
parser = parser.reset()
|
||||||
|
threw = False
|
||||||
|
try:
|
||||||
|
parser.parse("""
|
||||||
|
interface VariadicConstraints4 {
|
||||||
|
void foo(byte... arg1 = 0);
|
||||||
|
};
|
||||||
|
""")
|
||||||
|
results = parser.finish()
|
||||||
|
except:
|
||||||
|
threw = True
|
||||||
|
|
||||||
|
harness.ok(threw, "Should have thrown on variadic argument with default value.")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue