dom/bindings/parser/tests/test_callback_interface.py

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 import WebIDL
michael@0 2
michael@0 3 def WebIDLTest(parser, harness):
michael@0 4 parser.parse("""
michael@0 5 callback interface TestCallbackInterface {
michael@0 6 attribute boolean bool;
michael@0 7 };
michael@0 8 """)
michael@0 9
michael@0 10 results = parser.finish()
michael@0 11
michael@0 12 iface = results[0]
michael@0 13
michael@0 14 harness.ok(iface.isCallback(), "Interface should be a callback")
michael@0 15
michael@0 16 parser = parser.reset()
michael@0 17 threw = False
michael@0 18 try:
michael@0 19 parser.parse("""
michael@0 20 interface TestInterface {
michael@0 21 };
michael@0 22 callback interface TestCallbackInterface : TestInterface {
michael@0 23 attribute boolean bool;
michael@0 24 };
michael@0 25 """)
michael@0 26 results = parser.finish()
michael@0 27 except:
michael@0 28 threw = True
michael@0 29
michael@0 30 harness.ok(threw, "Should not allow non-callback parent of callback interface")
michael@0 31
michael@0 32 parser = parser.reset()
michael@0 33 threw = False
michael@0 34 try:
michael@0 35 parser.parse("""
michael@0 36 interface TestInterface : TestCallbackInterface {
michael@0 37 };
michael@0 38 callback interface TestCallbackInterface {
michael@0 39 attribute boolean bool;
michael@0 40 };
michael@0 41 """)
michael@0 42 results = parser.finish()
michael@0 43 except:
michael@0 44 threw = True
michael@0 45
michael@0 46 harness.ok(threw, "Should not allow callback parent of non-callback interface")
michael@0 47
michael@0 48 parser = parser.reset()
michael@0 49 parser.parse("""
michael@0 50 callback interface TestCallbackInterface1 {
michael@0 51 void foo();
michael@0 52 };
michael@0 53 callback interface TestCallbackInterface2 {
michael@0 54 void foo(DOMString arg);
michael@0 55 void foo(TestCallbackInterface1 arg);
michael@0 56 };
michael@0 57 callback interface TestCallbackInterface3 {
michael@0 58 void foo(DOMString arg);
michael@0 59 void foo(TestCallbackInterface1 arg);
michael@0 60 static void bar();
michael@0 61 };
michael@0 62 callback interface TestCallbackInterface4 {
michael@0 63 void foo(DOMString arg);
michael@0 64 void foo(TestCallbackInterface1 arg);
michael@0 65 static void bar();
michael@0 66 const long baz = 5;
michael@0 67 };
michael@0 68 callback interface TestCallbackInterface5 {
michael@0 69 static attribute boolean bool;
michael@0 70 void foo();
michael@0 71 };
michael@0 72 callback interface TestCallbackInterface6 {
michael@0 73 void foo(DOMString arg);
michael@0 74 void foo(TestCallbackInterface1 arg);
michael@0 75 void bar();
michael@0 76 };
michael@0 77 callback interface TestCallbackInterface7 {
michael@0 78 static attribute boolean bool;
michael@0 79 };
michael@0 80 callback interface TestCallbackInterface8 {
michael@0 81 attribute boolean bool;
michael@0 82 };
michael@0 83 callback interface TestCallbackInterface9 : TestCallbackInterface1 {
michael@0 84 void foo();
michael@0 85 };
michael@0 86 callback interface TestCallbackInterface10 : TestCallbackInterface1 {
michael@0 87 void bar();
michael@0 88 };
michael@0 89 """)
michael@0 90 results = parser.finish()
michael@0 91 for (i, iface) in enumerate(results):
michael@0 92 harness.check(iface.isSingleOperationInterface(), i < 4,
michael@0 93 "Interface %s should be a single operation interface" %
michael@0 94 iface.identifier.name)

mercurial