dom/bindings/parser/tests/test_treatNonCallableAsNull.py

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/bindings/parser/tests/test_treatNonCallableAsNull.py	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,71 @@
     1.4 +import WebIDL
     1.5 +
     1.6 +def WebIDLTest(parser, harness):
     1.7 +    parser.parse("""
     1.8 +        [TreatNonCallableAsNull] callback Function = any(any... arguments);
     1.9 +
    1.10 +        interface TestTreatNonCallableAsNull1 {
    1.11 +          attribute Function? onfoo;
    1.12 +          attribute Function onbar;
    1.13 +        };
    1.14 +    """)
    1.15 +
    1.16 +    results = parser.finish()
    1.17 +
    1.18 +    iface = results[1]
    1.19 +    attr = iface.members[0]
    1.20 +    harness.check(attr.type.treatNonCallableAsNull(), True, "Got the expected value")
    1.21 +    attr = iface.members[1]
    1.22 +    harness.check(attr.type.treatNonCallableAsNull(), False, "Got the expected value")
    1.23 +
    1.24 +    parser = parser.reset()
    1.25 +
    1.26 +    threw = False
    1.27 +    try:
    1.28 +        parser.parse("""
    1.29 +            callback Function = any(any... arguments);
    1.30 +
    1.31 +            interface TestTreatNonCallableAsNull2 {
    1.32 +              [TreatNonCallableAsNull] attribute Function onfoo;
    1.33 +            };
    1.34 +        """)
    1.35 +
    1.36 +        results = parser.finish()
    1.37 +    except:
    1.38 +        threw = True
    1.39 +
    1.40 +    harness.ok(threw, "Should have thrown.")
    1.41 +
    1.42 +    parser = parser.reset()
    1.43 +
    1.44 +    threw = False
    1.45 +    try:
    1.46 +        parser.parse("""
    1.47 +            callback Function = any(any... arguments);
    1.48 +
    1.49 +            [TreatNonCallableAsNull]
    1.50 +            interface TestTreatNonCallableAsNull3 {
    1.51 +               attribute Function onfoo;
    1.52 +            };
    1.53 +        """)
    1.54 +
    1.55 +        results = parser.finish()
    1.56 +    except:
    1.57 +        threw = True
    1.58 +
    1.59 +    harness.ok(threw, "Should have thrown.")
    1.60 +
    1.61 +    parser = parser.reset()
    1.62 +
    1.63 +    threw = False
    1.64 +    try:
    1.65 +        parser.parse("""
    1.66 +            [TreatNonCallableAsNull, TreatNonObjectAsNull]
    1.67 +            callback Function = any(any... arguments);
    1.68 +        """)
    1.69 +
    1.70 +        results = parser.finish()
    1.71 +    except:
    1.72 +        threw = True
    1.73 +
    1.74 +    harness.ok(threw, "Should have thrown.")

mercurial