tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_optional_constraints.py (1024B)


      1 import WebIDL
      2 
      3 
      4 def WebIDLTest(parser, harness):
      5    threw = False
      6    try:
      7        parser.parse(
      8            """
      9            interface OptionalConstraints1 {
     10              undefined foo(optional byte arg1, byte arg2);
     11            };
     12        """
     13        )
     14 
     15        parser.finish()
     16    except WebIDL.WebIDLError:
     17        threw = True
     18 
     19    harness.ok(
     20        not threw,
     21        "Should not have thrown on non-optional argument following optional argument.",
     22    )
     23 
     24    parser = parser.reset()
     25    parser.parse(
     26        """
     27        interface OptionalConstraints2 {
     28          undefined foo(optional byte arg1 = 1, optional byte arg2 = 2,
     29                        optional byte arg3, optional byte arg4 = 4,
     30                        optional byte arg5, optional byte arg6 = 9);
     31        };
     32    """
     33    )
     34    results = parser.finish()
     35    args = results[0].members[0].signatures()[0][1]
     36    harness.check(len(args), 6, "Should have 6 arguments")
     37    harness.check(args[5].defaultValue.value, 9, "Should have correct default value")