Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  file_ioutils_test_fixtures.js   Sprache: JAVA

 
// Utility functions.

Uint8Array.prototype.equals = function equals(other) {
  if (this.byteLength !== other.byteLength) {
    return false;
  }
  return this.every((val, i) => val === other[i]);
};

async function createFile(location, contents = "") {
  if (typeof contents === "string") {
    contents = new TextEncoder().encode(contents);
  }
  await IOUtils.write(location, contents);
  const exists = await fileExists(location);
  ok(exists, `Created temporary file at: ${location}`);
}

async function createDir(location) {
  await IOUtils.makeDirectory(location, {
    ignoreExisting: true,
    createAncestors: true,
  });
  const exists = await dirExists(location);
  ok(exists, `Created temporary directory at: ${location}`);
}

async function fileHasBinaryContents(location, expectedContents) {
  if (!(expectedContents instanceof Uint8Array)) {
    throw new TypeError("expectedContents must be a byte array");
  }
  info(`Opening ${location} for reading`);
  const bytes = await IOUtils.read(location);
  return bytes.equals(expectedContents);
}

async function fileHasTextContents(location, expectedContents) {
  if (typeof expectedContents !== "string") {
    throw new TypeError("expectedContents must be a string");
  }
  info(`Opening ${location} for reading`);
  const bytes = await IOUtils.read(location);
  const contents = new TextDecoder().decode(bytes);
  return contents === expectedContents;
}

async function fileExists(file) {
  try {
    let { type } = await IOUtils.stat(file);
    return type === "regular";
  } catch (ex) {
    return false;
  }
}

async function dirExists(dir) {
  try {
    let { type } = await IOUtils.stat(dir);
    return type === "directory";
  } catch (ex) {
    return false;
  }
}

async function cleanup(...files) {
  for (const file of files) {
    await IOUtils.remove(file, {
      ignoreAbsent: true,
      recursive: true,
    });
    const exists = await IOUtils.exists(file);
    ok(!exists, `Removed temporary file: ${file}`);
  }
}

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

Messung V0.5
C=89 H=94 G=91

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge