diff options
author | Prabhjyot Singh Sodhi <prabhjyotsingh95@gmail.com> | 2016-01-22 02:57:06 +0530 |
---|---|---|
committer | Prabhjyot Singh Sodhi <prabhyotsingh95@gmail.com> | 2016-01-21 21:53:47 +0530 |
commit | da40818f251bc9b5d07bb631a5fe15bfadf63d36 (patch) | |
tree | 99d4212901a8b3f73429d1a129a2ce70c26962f6 /components/script/dom/bindings/codegen/parser/tests | |
parent | 175b3c2d271cdfdfcac4c3daf5cde3060748b0b8 (diff) | |
download | servo-da40818f251bc9b5d07bb631a5fe15bfadf63d36.tar.gz servo-da40818f251bc9b5d07bb631a5fe15bfadf63d36.zip |
update to latest tests
Diffstat (limited to 'components/script/dom/bindings/codegen/parser/tests')
8 files changed, 156 insertions, 29 deletions
diff --git a/components/script/dom/bindings/codegen/parser/tests/test_attr.py b/components/script/dom/bindings/codegen/parser/tests/test_attr.py index 6b6142b6243..fb0c9196460 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_attr.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_attr.py @@ -293,10 +293,49 @@ def WebIDLTest(parser, harness): try: parser.parse(""" interface A { - [SetterInfallible] readonly attribute boolean foo; + [SetterThrows] readonly attribute boolean foo; }; """) results = parser.finish() except Exception, x: 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") diff --git a/components/script/dom/bindings/codegen/parser/tests/test_constructor.py b/components/script/dom/bindings/codegen/parser/tests/test_constructor.py index 6ec1be1871b..348204c7dc1 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_constructor.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_constructor.py @@ -11,8 +11,9 @@ def WebIDLTest(parser, harness): harness.check(argument.variadic, variadic, "Argument has the right variadic value") def checkMethod(method, QName, name, signatures, - static=False, getter=False, setter=False, creator=False, - deleter=False, legacycaller=False, stringifier=False): + static=True, getter=False, setter=False, creator=False, + deleter=False, legacycaller=False, stringifier=False, + chromeOnly=False): harness.ok(isinstance(method, WebIDL.IDLMethod), "Should be an IDLMethod") 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.isLegacycaller(), legacycaller, "Method has the correct legacycaller 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") sigpairs = zip(method.signatures(), signatures) @@ -55,11 +57,13 @@ def WebIDLTest(parser, harness): }; """) 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), "Should be an IDLInterface") harness.ok(isinstance(results[1], WebIDL.IDLInterface), "Should be an IDLInterface") + harness.ok(isinstance(results[2], WebIDL.IDLInterface), + "Should be an IDLInterface") checkMethod(results[0].ctor(), "::TestConstructorNoArgs::constructor", "constructor", [("TestConstructorNoArgs (Wrapper)", [])]) @@ -73,3 +77,33 @@ def WebIDLTest(parser, harness): [("::TestConstructorOverloads::constructor::foo", "foo", "Object", False, False)]), ("TestConstructorOverloads (Wrapper)", [("::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") diff --git a/components/script/dom/bindings/codegen/parser/tests/test_extended_attributes.py b/components/script/dom/bindings/codegen/parser/tests/test_extended_attributes.py index 5c6887331e7..85a70d98f2c 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_extended_attributes.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_extended_attributes.py @@ -2,9 +2,9 @@ import WebIDL def WebIDLTest(parser, harness): parser.parse(""" - [Flippety] + [NoInterfaceObject] interface TestExtendedAttr { - [Foopy] attribute byte b; + [Unforgeable] readonly attribute byte b; }; """) @@ -12,9 +12,9 @@ def WebIDLTest(parser, harness): parser = parser.reset() parser.parse(""" - [Flippety="foo.bar",Floppety=flop] + [Pref="foo.bar",Pref=flop] interface TestExtendedAttr { - [Foopy="foo.bar"] attribute byte b; + [Pref="foo.bar"] attribute byte b; }; """) diff --git a/components/script/dom/bindings/codegen/parser/tests/test_nullable_equivalency.py b/components/script/dom/bindings/codegen/parser/tests/test_nullable_equivalency.py index 3366b9fbbbd..1f72b2c6e67 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_nullable_equivalency.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_nullable_equivalency.py @@ -39,28 +39,27 @@ def WebIDLTest(parser, harness): attribute DOMString? b; }; - /* Not implemented. */ - /*interface TestNullableEquivalency8 { + interface TestNullableEquivalency8 { attribute float a; attribute float? b; - };*/ + }; - interface TestNullableEquivalency8 { + interface TestNullableEquivalency9 { attribute double a; attribute double? b; }; - interface TestNullableEquivalency9 { + interface TestNullableEquivalency10 { attribute object a; attribute object? b; }; - interface TestNullableEquivalency10 { + interface TestNullableEquivalency11 { attribute double[] a; attribute double[]? b; }; - interface TestNullableEquivalency11 { + interface TestNullableEquivalency12 { attribute TestNullableEquivalency9[] a; attribute TestNullableEquivalency9[]? b; }; @@ -91,7 +90,7 @@ def checkEquivalent(iface, harness): for attr in dir(type1): if attr.startswith('_') or \ attr in ['nullable', 'builtin', 'filename', 'location', - 'inner', 'QName'] or \ + 'inner', 'QName', 'getDeps', 'name'] or \ (hasattr(type(type1), attr) and not callable(getattr(type1, attr))): continue diff --git a/components/script/dom/bindings/codegen/parser/tests/test_optional_constraints.py b/components/script/dom/bindings/codegen/parser/tests/test_optional_constraints.py index 1dcdc7fb8a5..6217465ce7d 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_optional_constraints.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_optional_constraints.py @@ -11,4 +11,20 @@ def WebIDLTest(parser, harness): except: 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") diff --git a/components/script/dom/bindings/codegen/parser/tests/test_treatNonCallableAsNull.py b/components/script/dom/bindings/codegen/parser/tests/test_treatNonCallableAsNull.py index 3d0e5ca479f..7a0bde8a6dc 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_treatNonCallableAsNull.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_treatNonCallableAsNull.py @@ -2,11 +2,11 @@ import WebIDL def WebIDLTest(parser, harness): parser.parse(""" - callback Function = any(any... arguments); + [TreatNonCallableAsNull] callback Function = any(any... arguments); interface TestTreatNonCallableAsNull1 { - [TreatNonCallableAsNull] attribute Function? onfoo; - attribute Function? onbar; + attribute Function? onfoo; + attribute Function onbar; }; """) @@ -54,3 +54,18 @@ def WebIDLTest(parser, harness): threw = True 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.") diff --git a/components/script/dom/bindings/codegen/parser/tests/test_typedef.py b/components/script/dom/bindings/codegen/parser/tests/test_typedef.py index 9d2f3b3c2ce..8921985c5ca 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_typedef.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_typedef.py @@ -12,7 +12,7 @@ def WebIDLTest(parser, harness): results = parser.finish() - harness.check(results[2].members[1].type.name, "Long", + harness.check(results[2].members[1].type.name, "LongOrNull", "Should expand typedefs") parser = parser.reset() diff --git a/components/script/dom/bindings/codegen/parser/tests/test_variadic_constraints.py b/components/script/dom/bindings/codegen/parser/tests/test_variadic_constraints.py index 9cba22c5842..7448e40d5a9 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_variadic_constraints.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_variadic_constraints.py @@ -1,39 +1,63 @@ def WebIDLTest(parser, harness): threw = False try: - results = parser.parse(""" + parser.parse(""" interface VariadicConstraints1 { void foo(byte... arg1, byte arg2); }; """) + results = parser.finish() except: 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 try: - results = parser.parse(""" + parser.parse(""" interface VariadicConstraints2 { void foo(byte... arg1, optional byte arg2); }; """) - + results = parser.finish(); except: 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 try: - results = parser.parse(""" + parser.parse(""" interface VariadicConstraints3 { void foo(optional byte... arg1); }; """) + results = parser.finish() + + except: + threw = True + + 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.") + harness.ok(threw, "Should have thrown on variadic argument with default value.") |