js/src/jsapi-tests/binast/invalid/tests/param-unmatching-name.py
author Tooru Fujisawa <arai_a@mac.com>
Fri, 15 Feb 2019 10:27:06 +0000
changeset 517441 18f508db5b64e076ed9a1b2b71a1cceef03ccfea
child 521400 6b9b50bc446d892779619254ce852f8b2f0c9bcf
permissions -rw-r--r--
Bug 1527791 - Part 2: Add testcase for invalid item in FormalParameters. r=Yoric Depends on D19883 Differential Revision: https://phabricator.services.mozilla.com/D19884

def filter_ast(ast):
    # Set different parameter name than one in scope.
    import filter_utils as utils

    utils.assert_interface(ast, 'Script')
    global_stmts = utils.get_field(ast, 'statements')

    func_stmt = utils.get_element(global_stmts, 0)
    utils.assert_interface(func_stmt, 'EagerFunctionDeclaration')

    func_contents = utils.get_field(func_stmt, 'contents')
    utils.assert_interface(func_contents, 'FunctionOrMethodContents')

    params = utils.get_field(func_contents, 'params')
    utils.assert_interface(params, 'FormalParameters')
    params_items = utils.get_field(params, 'items')

    param = utils.get_element(params_items, 0)
    utils.assert_interface(param, 'BindingIdentifier')

    name = utils.get_field(param, "name")
    utils.set_identifier_name(name, "b")

    return ast