B2G/gecko/netwerk/test/httpserver/test/head_utils.js
/**
 * Throws if iter does not contain exactly the CRLF-separated lines in the
 * array expectedLines.
 *
 * @param iter : Iterator
 *   an Iterator which returns lines of text
 * @param expectedLines : [string]
 *   an array of the expected lines of text
 * @throws string
 *   an error message if iter doesn't agree with expectedLines
 */
Throws if iter does not contain exactly the CRLF-separated lines in the
array expectedLines.

@param iter : Iterator
an Iterator which returns lines of text
@param expectedLines : [string]
an array of the expected lines of text
@throws string
an error message if iter doesn't agree with expectedLines
Throws if iter does not contain exactly the CRLF - separated lines in the array expectedLines . @param iter : Iterator an Iterator which returns lines of text @param expectedLines : [ string ] an array of the expected lines of text @throws string an error message if iter doesn ' t agree with expectedLines
function expectLines(iter, expectedLines)
{
  var index = 0;
  for (var line in iter)
  {
    if (expectedLines.length == index)
      throw "Error: got more than " + expectedLines.length + " expected lines!";
    var expected = expectedLines[index++];
    if (expected !== line)
      throw "Error on line " + index + "!\n" +
            "  actual: '" + line + "',\n" +
            "  expect: '" + expected + "'";
  }
  if (expectedLines.length !== index)
  {
    throw "Expected more lines!  Got " + index +
          ", expected " + expectedLines.length;
  }
}
function expectLines ( iter , expectedLines ) { var index = 0 ; for ( var line in iter ) { if ( expectedLines . length == index ) throw "Error: got more than " + expectedLines . length + " expected lines!" ; var expected = expectedLines [ index ++ ] ; if ( expected !== line ) throw "Error on line " + index + "!\n" + "  actual: '" + line + "',\n" + "  expect: '" + expected + "'" ; } if ( expectedLines . length !== index ) { throw "Expected more lines!  Got " + index + ", expected " + expectedLines . length ; } }
Throws if iter does not contain exactly the CRLF-separated lines in the
 array expectedLines.
Throws if iter does not contain exactly the CRLF - separated lines in the array expectedLines .