test_union_nullable.py (1381B)
1 import WebIDL 2 3 4 def WebIDLTest(parser, harness): 5 threw = False 6 try: 7 parser.parse( 8 """ 9 interface OneNullableInUnion { 10 undefined foo((object? or DOMString?) arg); 11 }; 12 """ 13 ) 14 15 parser.finish() 16 except WebIDL.WebIDLError: 17 threw = True 18 19 harness.ok(threw, "Two nullable member types of a union should have thrown.") 20 21 parser.reset() 22 threw = False 23 24 try: 25 parser.parse( 26 """ 27 interface NullableInNullableUnion { 28 undefined foo((object? or DOMString)? arg); 29 }; 30 """ 31 ) 32 33 parser.finish() 34 except WebIDL.WebIDLError: 35 threw = True 36 37 harness.ok( 38 threw, 39 "A nullable union type with a nullable member type should have thrown.", 40 ) 41 42 parser.reset() 43 threw = False 44 45 try: 46 parser.parse( 47 """ 48 interface NullableInUnionNullableUnionHelper { 49 }; 50 interface NullableInUnionNullableUnion { 51 undefined foo(((object? or DOMString) or NullableInUnionNullableUnionHelper)? arg); 52 }; 53 """ 54 ) 55 56 parser.finish() 57 except WebIDL.WebIDLError: 58 threw = True 59 60 harness.ok( 61 threw, 62 "A nullable union type with a nullable member type should have thrown.", 63 )