function assertProc(def, call, argCount, opt_args, opt_hasStatements) {
    if (opt_hasStatements === false) {
      assert.isNull(def.getInput('STACK'));
    } else {
      opt_hasStatements = true;
      assert.isNotNull(def.getInput('STACK'));
    }
    if (opt_args) {
      assert.sameOrderedMembers(def.getVars(), opt_args);
    }

    const defInputs = def.inputList;
    const callInputs = call.inputList;
    const defLength = defInputs.length;
    const defArgCount = opt_hasStatements ? defLength - 3 : defLength - 2;

    // Just looking at const inputs.
    assert.equal(defArgCount, callInputs.length - 1,
        'def and call have the same number of args');
    assert.equal(defArgCount, argCount,
        'blocks have the expected number of args');

    if (argCount == 0) {
      assert.notInclude(def.toString(), 'with');
      assert.notInclude(call.toString(), 'with');
      return;
    }

    assert.include(def.toString(), 'with');
    assert.include(call.toString(), 'with');

    const argIds = def.argData_.map((element) => element.argId);
    for (let i = 1; i < defLength - 2; i++) {
      const constName = opt_args[i - 1];
      const defInput = defInputs[i];
      const callInput = callInputs[i];
      assert.equal(defInput.type, Blockly.DUMMY_INPUT);
      assert.equal(callInput.type, Blockly.INPUT_VALUE);
      assert.equal(defInput.name, argIds[i - 1]);
      assert.equal(defInput.fieldRow[2].getValue(), constName,
          'Def consts did not match expected');
      assert.equal(callInput.name, 'ARG' + (i - 1));
      assert.equal(callInput.fieldRow[0].getValue(), constName,
          'Call consts did not match expected.');
    }

    // Assert the last input is not a dummy. Sometimes
    // arg inputs don't get moved which is bad.
    assert.equal(defInputs[defLength -1].type, Blockly.INPUT_VALUE);
  }
/**
   * Asserts that the procedure def and caller have the inputs and fields
   * we expect.
   * @param {!Blockly.Block} def The procedure definition block.
   * @param {!Blockly.Block} call The procedure call block.
   * @param {number} argCount The number of arguements we expect.
   * @param {Array<string>?} opt_args An optional array of argument names.
   * @param {boolean?} opt_hasStatements If we expect the procedure def to have
   *     a statement input or not.
   */
Asserts that the procedure def and caller have the inputs and fields
we expect.
@param {!Blockly.Block} def The procedure definition block.
@param {!Blockly.Block} call The procedure call block.
@param {number} argCount The number of arguements we expect.
@param {Array?} opt_args An optional array of argument names.
@param {boolean?} opt_hasStatements If we expect the procedure def to have
a statement input or not.
Asserts that the procedure def and caller have the inputs and fields we expect . @param { !Blockly . Block } def The procedure definition block . @param { !Blockly . Block } call The procedure call block . @param { number } argCount The number of arguements we expect . @param { Array? } opt_args An optional array of argument names . @param { boolean? } opt_hasStatements If we expect the procedure def to have a statement input or not .
function assertProc(def, call, argCount, opt_args, opt_hasStatements) {
    if (opt_hasStatements === false) {
      assert.isNull(def.getInput('STACK'));
    } else {
      opt_hasStatements = true;
      assert.isNotNull(def.getInput('STACK'));
    }
    if (opt_args) {
      assert.sameOrderedMembers(def.getVars(), opt_args);
    }
    const defInputs = def.inputList;
    const callInputs = call.inputList;
    const defLength = defInputs.length;
    const defArgCount = opt_hasStatements ? defLength - 3 : defLength - 2;
    assert.equal(defArgCount, callInputs.length - 1,
        'def and call have the same number of args');
    assert.equal(defArgCount, argCount,
        'blocks have the expected number of args');
    if (argCount == 0) {
      assert.notInclude(def.toString(), 'with');
      assert.notInclude(call.toString(), 'with');
      return;
    }
    assert.include(def.toString(), 'with');
    assert.include(call.toString(), 'with');
    const argIds = def.argData_.map((element) => element.argId);
    for (let i = 1; i < defLength - 2; i++) {
      const constName = opt_args[i - 1];
      const defInput = defInputs[i];
      const callInput = callInputs[i];
      assert.equal(defInput.type, Blockly.DUMMY_INPUT);
      assert.equal(callInput.type, Blockly.INPUT_VALUE);
      assert.equal(defInput.name, argIds[i - 1]);
      assert.equal(defInput.fieldRow[2].getValue(), constName,
          'Def consts did not match expected');
      assert.equal(callInput.name, 'ARG' + (i - 1));
      assert.equal(callInput.fieldRow[0].getValue(), constName,
          'Call consts did not match expected.');
    }
    assert.equal(defInputs[defLength -1].type, Blockly.INPUT_VALUE);
  }
function assertProc ( def , call , argCount , opt_args , opt_hasStatements ) { if ( opt_hasStatements === false ) { assert . isNull ( def . getInput ( 'STACK' ) ) ; } else { opt_hasStatements = true ; assert . isNotNull ( def . getInput ( 'STACK' ) ) ; } if ( opt_args ) { assert . sameOrderedMembers ( def . getVars ( ) , opt_args ) ; } const defInputs = def . inputList ; const callInputs = call . inputList ; const defLength = defInputs . length ; const defArgCount = opt_hasStatements ? defLength - 3 : defLength - 2 ; assert . equal ( defArgCount , callInputs . length - 1 , 'def and call have the same number of args' ) ; assert . equal ( defArgCount , argCount , 'blocks have the expected number of args' ) ; if ( argCount == 0 ) { assert . notInclude ( def . toString ( ) , 'with' ) ; assert . notInclude ( call . toString ( ) , 'with' ) ; return ; } assert . include ( def . toString ( ) , 'with' ) ; assert . include ( call . toString ( ) , 'with' ) ; const argIds = def . argData_ . map ( ( element ) => element . argId ) ; for ( let i = 1 ; i < defLength - 2 ; i ++ ) { const constName = opt_args [ i - 1 ] ; const defInput = defInputs [ i ] ; const callInput = callInputs [ i ] ; assert . equal ( defInput . type , Blockly . DUMMY_INPUT ) ; assert . equal ( callInput . type , Blockly . INPUT_VALUE ) ; assert . equal ( defInput . name , argIds [ i - 1 ] ) ; assert . equal ( defInput . fieldRow [ 2 ] . getValue ( ) , constName , 'Def consts did not match expected' ) ; assert . equal ( callInput . name , 'ARG' + ( i - 1 ) ) ; assert . equal ( callInput . fieldRow [ 0 ] . getValue ( ) , constName , 'Call consts did not match expected.' ) ; } assert . equal ( defInputs [ defLength - 1 ] . type , Blockly . INPUT_VALUE ) ; }
Asserts that the procedure def and caller have the inputs and fields
 we expect.
Asserts that the procedure def and caller have the inputs and fields we expect .
// Just looking at const inputs. // Assert the last input is not a dummy. Sometimes // arg inputs don't get moved which is bad.