test_interface_identifier_conflicts_across_members.py (4118B)
1 import WebIDL 2 3 4 def WebIDLTest(parser, harness): 5 threw = False 6 try: 7 parser.parse( 8 """ 9 interface IdentifierConflictAcrossMembers1 { 10 const byte thing1 = 1; 11 readonly attribute long thing1; 12 }; 13 """ 14 ) 15 16 parser.finish() 17 except WebIDL.WebIDLError: 18 threw = True 19 20 harness.ok(threw, "Should have thrown for IdentifierConflictAcrossMembers1.") 21 22 parser = parser.reset() 23 threw = False 24 try: 25 parser.parse( 26 """ 27 interface IdentifierConflictAcrossMembers2 { 28 readonly attribute long thing1; 29 const byte thing1 = 1; 30 }; 31 """ 32 ) 33 34 parser.finish() 35 except WebIDL.WebIDLError: 36 threw = True 37 38 harness.ok(threw, "Should have thrown for IdentifierConflictAcrossMembers2.") 39 40 parser = parser.reset() 41 threw = False 42 try: 43 parser.parse( 44 """ 45 interface IdentifierConflictAcrossMembers3 { 46 getter boolean thing1(DOMString name); 47 readonly attribute long thing1; 48 }; 49 """ 50 ) 51 52 parser.finish() 53 except WebIDL.WebIDLError: 54 threw = True 55 56 harness.ok(threw, "Should have thrown for IdentifierConflictAcrossMembers3.") 57 58 parser = parser.reset() 59 threw = False 60 try: 61 parser.parse( 62 """ 63 interface IdentifierConflictAcrossMembers4 { 64 const byte thing1 = 1; 65 long thing1(); 66 }; 67 """ 68 ) 69 70 parser.finish() 71 except WebIDL.WebIDLError: 72 threw = True 73 74 harness.ok(threw, "Should have thrown for IdentifierConflictAcrossMembers4.") 75 76 parser = parser.reset() 77 threw = False 78 try: 79 parser.parse( 80 """ 81 interface IdentifierConflictAcrossMembers5 { 82 static long thing1(); 83 undefined thing1(); 84 }; 85 """ 86 ) 87 88 parser.finish() 89 except WebIDL.WebIDLError: 90 threw = True 91 92 harness.ok( 93 not threw, "Should not have thrown for IdentifierConflictAcrossMembers5." 94 ) 95 96 parser = parser.reset() 97 threw = False 98 try: 99 parser.parse( 100 """ 101 interface mixin IdentifierConflictAcrossMembers6Mixin { 102 undefined thing1(); 103 }; 104 interface IdentifierConflictAcrossMembers6 { 105 static long thing1(); 106 }; 107 IdentifierConflictAcrossMembers6 includes IdentifierConflictAcrossMembers6Mixin; 108 """ 109 ) 110 111 parser.finish() 112 except WebIDL.WebIDLError: 113 threw = True 114 115 harness.ok( 116 not threw, "Should not have thrown for IdentifierConflictAcrossMembers6." 117 ) 118 119 parser = parser.reset() 120 threw = False 121 try: 122 parser.parse( 123 """ 124 interface IdentifierConflictAcrossMembers7 { 125 const byte thing1 = 1; 126 static readonly attribute long thing1; 127 }; 128 """ 129 ) 130 131 parser.finish() 132 except WebIDL.WebIDLError: 133 threw = True 134 135 harness.ok(threw, "Should have thrown for IdentifierConflictAcrossMembers7.") 136 137 parser = parser.reset() 138 threw = False 139 try: 140 parser.parse( 141 """ 142 interface IdentifierConflictAcrossMembers8 { 143 readonly attribute long thing1 = 1; 144 static readonly attribute long thing1; 145 }; 146 """ 147 ) 148 149 parser.finish() 150 except WebIDL.WebIDLError: 151 threw = True 152 153 harness.ok(threw, "Should have thrown for IdentifierConflictAcrossMembers8.") 154 155 parser = parser.reset() 156 threw = False 157 try: 158 parser.parse( 159 """ 160 interface IdentifierConflictAcrossMembers9 { 161 void thing1(); 162 static readonly attribute long thing1; 163 }; 164 """ 165 ) 166 167 parser.finish() 168 except WebIDL.WebIDLError: 169 threw = True 170 171 harness.ok(threw, "Should have thrown for IdentifierConflictAcrossMembers9.")