dom/bindings/parser/tests/test_variadic_constraints.py
author Boris Zbarsky <bzbarsky@mit.edu>
Fri, 11 Oct 2013 12:28:23 -0400
changeset 150526 877a227c502f07a77a1600edf3285665218ae0fb
parent 115730 7a5e83065d9f20209a702ab857662818ae50d049
child 150638 fcddc11fb2ef7747a638f7f5efc1fb1c62614996
permissions -rw-r--r--
Bug 882541 part 1. Don't require all arguments after an optional argument to be optional. r=khuey

def WebIDLTest(parser, harness):
    threw = False
    try:
        parser.parse("""
            interface VariadicConstraints1 {
              void foo(byte... arg1, byte arg2);
            };
        """)
        results = parser.finish()

    except:
        threw = True

    harness.ok(threw,
               "Should have thrown on variadic argument followed by required "
               "argument.")

    parser = parser.reset()
    threw = False
    try:
        parser.parse("""
            interface VariadicConstraints2 {
              void foo(byte... arg1, optional byte arg2);
            };
        """)
        results = parser.finish();
    except:
        threw = True

    harness.ok(threw,
               "Should have thrown on variadic argument followed by optional "
               "argument.")

    parser = parser.reset()
    threw = False
    try:
        parser.parse("""
            interface VariadicConstraints3 {
              void foo(optional byte... arg1);
            };
        """)
        results = parser.finish()

    except:
        threw = True

    harness.ok(threw,
               "Should have thrown on variadic argument explicitly flagged as "
               "optional.")

    parser = parser.reset()
    threw = False
    try:
        parser.parse("""
            interface VariadicConstraints4 {
              void foo(byte... arg1 = 0);
            };
        """)
        results = parser.finish()
    except:
        threw = True

    harness.ok(threw, "Should have thrown on variadic argument with default value.")