diff options
Diffstat (limited to 'components/script/dom/bindings/codegen/parser/tests/test_interface_maplikesetlikeiterable.py')
-rw-r--r-- | components/script/dom/bindings/codegen/parser/tests/test_interface_maplikesetlikeiterable.py | 200 |
1 files changed, 119 insertions, 81 deletions
diff --git a/components/script/dom/bindings/codegen/parser/tests/test_interface_maplikesetlikeiterable.py b/components/script/dom/bindings/codegen/parser/tests/test_interface_maplikesetlikeiterable.py index 159b50f84ff..e070adee7e6 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_interface_maplikesetlikeiterable.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_interface_maplikesetlikeiterable.py @@ -37,10 +37,10 @@ def WebIDLTest(parser, harness): p.finish() harness.ok(False, prefix + " - Interface passed when should've failed") - except WebIDL.WebIDLError, e: + except WebIDL.WebIDLError as e: harness.ok(True, prefix + " - Interface failed as expected") - except Exception, e: + except Exception as e: harness.ok(False, prefix + " - Interface failed but not as a WebIDLError exception: %s" % e) @@ -88,6 +88,8 @@ def WebIDLTest(parser, harness): disallowedNonMethodNames = ["clear", "delete"] mapDisallowedNonMethodNames = ["set"] + disallowedNonMethodNames setDisallowedNonMethodNames = ["add"] + disallowedNonMethodNames + unrelatedMembers = [("unrelatedAttribute", WebIDL.IDLAttribute), + ("unrelatedMethod", WebIDL.IDLMethod)] # # Simple Usage Tests @@ -99,86 +101,171 @@ def WebIDLTest(parser, harness): iterable<long>; readonly attribute unsigned long length; getter long(unsigned long index); + attribute long unrelatedAttribute; + long unrelatedMethod(); }; - """, valueIterableMembers) + """, valueIterableMembers + unrelatedMembers) + + shouldPass("Iterable (key only) inheriting from parent", + """ + interface Foo1 : Foo2 { + iterable<long>; + readonly attribute unsigned long length; + getter long(unsigned long index); + }; + interface Foo2 { + attribute long unrelatedAttribute; + long unrelatedMethod(); + }; + """, valueIterableMembers, numProductions=2) shouldPass("Iterable (key and value)", """ interface Foo1 { iterable<long, long>; + attribute long unrelatedAttribute; + long unrelatedMethod(); }; - """, iterableMembers, + """, iterableMembers + unrelatedMembers, # numProductions == 2 because of the generated iterator iface, numProductions=2) + shouldPass("Iterable (key and value) inheriting from parent", + """ + interface Foo1 : Foo2 { + iterable<long, long>; + }; + interface Foo2 { + attribute long unrelatedAttribute; + long unrelatedMethod(); + }; + """, iterableMembers, + # numProductions == 3 because of the generated iterator iface, + numProductions=3) + shouldPass("Maplike (readwrite)", """ interface Foo1 { maplike<long, long>; + attribute long unrelatedAttribute; + long unrelatedMethod(); + }; + """, mapRWMembers + unrelatedMembers) + + shouldPass("Maplike (readwrite) inheriting from parent", + """ + interface Foo1 : Foo2 { + maplike<long, long>; + }; + interface Foo2 { + attribute long unrelatedAttribute; + long unrelatedMethod(); }; - """, mapRWMembers) + """, mapRWMembers, numProductions=2) shouldPass("Maplike (readwrite)", """ interface Foo1 { maplike<long, long>; + attribute long unrelatedAttribute; + long unrelatedMethod(); + }; + """, mapRWMembers + unrelatedMembers) + + shouldPass("Maplike (readwrite) inheriting from parent", + """ + interface Foo1 : Foo2 { + maplike<long, long>; }; - """, mapRWMembers) + interface Foo2 { + attribute long unrelatedAttribute; + long unrelatedMethod(); + }; + """, mapRWMembers, numProductions=2) shouldPass("Maplike (readonly)", """ interface Foo1 { readonly maplike<long, long>; + attribute long unrelatedAttribute; + long unrelatedMethod(); + }; + """, mapROMembers + unrelatedMembers) + + shouldPass("Maplike (readonly) inheriting from parent", + """ + interface Foo1 : Foo2 { + readonly maplike<long, long>; + }; + interface Foo2 { + attribute long unrelatedAttribute; + long unrelatedMethod(); }; - """, mapROMembers) + """, mapROMembers, numProductions=2) shouldPass("Setlike (readwrite)", """ interface Foo1 { setlike<long>; + attribute long unrelatedAttribute; + long unrelatedMethod(); }; - """, setRWMembers) + """, setRWMembers + unrelatedMembers) + + shouldPass("Setlike (readwrite) inheriting from parent", + """ + interface Foo1 : Foo2 { + setlike<long>; + }; + interface Foo2 { + attribute long unrelatedAttribute; + long unrelatedMethod(); + }; + """, setRWMembers, numProductions=2) shouldPass("Setlike (readonly)", """ interface Foo1 { readonly setlike<long>; + attribute long unrelatedAttribute; + long unrelatedMethod(); }; - """, setROMembers) + """, setROMembers + unrelatedMembers) - shouldPass("Inheritance of maplike/setlike", + shouldPass("Setlike (readonly) inheriting from parent", """ - interface Foo1 { - maplike<long, long>; + interface Foo1 : Foo2 { + readonly setlike<long>; }; - interface Foo2 : Foo1 { + interface Foo2 { + attribute long unrelatedAttribute; + long unrelatedMethod(); }; - """, mapRWMembers, numProductions=2) + """, setROMembers, numProductions=2) - shouldPass("Implements with maplike/setlike", + shouldPass("Inheritance of maplike/setlike", """ interface Foo1 { maplike<long, long>; }; - interface Foo2 { + interface Foo2 : Foo1 { }; - Foo2 implements Foo1; - """, mapRWMembers, numProductions=3) + """, mapRWMembers, numProductions=2) shouldPass("JS Implemented maplike interface", """ - [JSImplementation="@mozilla.org/dom/test-interface-js-maplike;1", - Constructor()] + [JSImplementation="@mozilla.org/dom/test-interface-js-maplike;1"] interface Foo1 { + constructor(); setlike<long>; }; """, setRWChromeMembers) shouldPass("JS Implemented maplike interface", """ - [JSImplementation="@mozilla.org/dom/test-interface-js-maplike;1", - Constructor()] + [JSImplementation="@mozilla.org/dom/test-interface-js-maplike;1"] interface Foo1 { + constructor(); maplike<long, long>; }; """, mapRWChromeMembers) @@ -253,31 +340,6 @@ def WebIDLTest(parser, harness): }; """) - shouldFail("Consequential interface with conflicting maplike/setlike", - """ - interface Foo1 { - maplike<long, long>; - }; - interface Foo2 { - setlike<long>; - }; - Foo2 implements Foo1; - """) - - shouldFail("Consequential interfaces with conflicting maplike/setlike", - """ - interface Foo1 { - maplike<long, long>; - }; - interface Foo2 { - setlike<long>; - }; - interface Foo3 { - }; - Foo3 implements Foo1; - Foo3 implements Foo2; - """) - # # Member name collision tests # @@ -380,52 +442,28 @@ def WebIDLTest(parser, harness): }; """, mapRWMembers, numProductions=3) - shouldFail("Interface with consequential maplike/setlike interface member collision", - """ - interface Foo1 { - void entries(); - }; - interface Foo2 { - maplike<long, long>; - }; - Foo1 implements Foo2; - """) - - shouldFail("Maplike interface with consequential interface member collision", + shouldFail("Maplike interface with mixin member collision", """ interface Foo1 { maplike<long, long>; }; - interface Foo2 { + interface mixin Foo2 { void entries(); }; - Foo1 implements Foo2; + Foo1 includes Foo2; """) - shouldPass("Consequential Maplike interface with inherited interface member collision", - """ - interface Foo1 { - maplike<long, long>; - }; - interface Foo2 { - void entries(); - }; - interface Foo3 : Foo2 { - }; - Foo3 implements Foo1; - """, mapRWMembers, numProductions=4) - shouldPass("Inherited Maplike interface with consequential interface member collision", """ interface Foo1 { maplike<long, long>; }; - interface Foo2 { + interface mixin Foo2 { void entries(); }; interface Foo3 : Foo1 { }; - Foo3 implements Foo2; + Foo3 includes Foo2; """, mapRWMembers, numProductions=4) shouldFail("Inheritance of name collision with child maplike/setlike", @@ -548,7 +586,7 @@ def WebIDLTest(parser, harness): }; """) - shouldPass("Implemented interface with readonly allowable overrides", + shouldPass("Interface with readonly allowable overrides", """ interface Foo1 { readonly setlike<long>; @@ -558,9 +596,9 @@ def WebIDLTest(parser, harness): shouldPass("JS Implemented read-only interface with readonly allowable overrides", """ - [JSImplementation="@mozilla.org/dom/test-interface-js-maplike;1", - Constructor()] + [JSImplementation="@mozilla.org/dom/test-interface-js-maplike;1"] interface Foo1 { + constructor(); readonly setlike<long>; readonly attribute boolean clear; }; @@ -568,9 +606,9 @@ def WebIDLTest(parser, harness): shouldFail("JS Implemented read-write interface with non-readwrite allowable overrides", """ - [JSImplementation="@mozilla.org/dom/test-interface-js-maplike;1", - Constructor()] + [JSImplementation="@mozilla.org/dom/test-interface-js-maplike;1"] interface Foo1 { + constructor(); setlike<long>; readonly attribute boolean clear; }; |