dom/bindings/parser/tests/test_identifier_conflict.py
author Mike Hommey <mh+mozilla@glandium.org>
Mon, 05 Dec 2022 22:55:14 +0000
changeset 644697 5b124d86f7a10e7427cd90c9baa026b9831a16e3
parent 582228 167c07857eb9f9ec9a63c9f541df6bc7468b4c3e
permissions -rw-r--r--
Bug 1803938 - Adjust patches to clang trunk changes. Differential Revision: https://phabricator.services.mozilla.com/D163799

# Import the WebIDL module, so we can do isinstance checks and whatnot
import WebIDL


def WebIDLTest(parser, harness):
    try:
        parser.parse(
            """
            enum Foo { "a" };
            interface Foo;
        """
        )
        results = parser.finish()
        harness.ok(False, "Should fail to parse")
    except Exception as e:
        harness.ok(
            "Name collision" in str(e), "Should have name collision for interface"
        )

    parser = parser.reset()
    try:
        parser.parse(
            """
            dictionary Foo { long x; };
            enum Foo { "a" };
        """
        )
        results = parser.finish()
        harness.ok(False, "Should fail to parse")
    except Exception as e:
        harness.ok(
            "Name collision" in str(e), "Should have name collision for dictionary"
        )

    parser = parser.reset()
    try:
        parser.parse(
            """
            enum Foo { "a" };
            enum Foo { "b" };
        """
        )
        results = parser.finish()
        harness.ok(False, "Should fail to parse")
    except Exception as e:
        harness.ok(
            "Multiple unresolvable definitions" in str(e),
            "Should have name collision for dictionary",
        )