test_variadic_constraints.py (1693B)
1 import WebIDL 2 3 4 def WebIDLTest(parser, harness): 5 threw = False 6 try: 7 parser.parse( 8 """ 9 interface VariadicConstraints1 { 10 undefined foo(byte... arg1, byte arg2); 11 }; 12 """ 13 ) 14 parser.finish() 15 16 except WebIDL.WebIDLError: 17 threw = True 18 19 harness.ok( 20 threw, 21 "Should have thrown on variadic argument followed by required argument.", 22 ) 23 24 parser = parser.reset() 25 threw = False 26 try: 27 parser.parse( 28 """ 29 interface VariadicConstraints2 { 30 undefined foo(byte... arg1, optional byte arg2); 31 }; 32 """ 33 ) 34 parser.finish() 35 except WebIDL.WebIDLError: 36 threw = True 37 38 harness.ok( 39 threw, 40 "Should have thrown on variadic argument followed by optional argument.", 41 ) 42 43 parser = parser.reset() 44 threw = False 45 try: 46 parser.parse( 47 """ 48 interface VariadicConstraints3 { 49 undefined foo(optional byte... arg1); 50 }; 51 """ 52 ) 53 parser.finish() 54 55 except WebIDL.WebIDLError: 56 threw = True 57 58 harness.ok( 59 threw, 60 "Should have thrown on variadic argument explicitly flagged as optional.", 61 ) 62 63 parser = parser.reset() 64 threw = False 65 try: 66 parser.parse( 67 """ 68 interface VariadicConstraints4 { 69 undefined foo(byte... arg1 = 0); 70 }; 71 """ 72 ) 73 parser.finish() 74 except WebIDL.WebIDLError: 75 threw = True 76 77 harness.ok(threw, "Should have thrown on variadic argument with default value.")