Eine aufbereitete Darstellung der Quelle

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

Benutzer

Quelle  serial_test_utils.js

  Sprache: JAVA
 

/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Lightweight Assert helpers for mochitest content tests.
// Assert.sys.mjs cannot be used directly from content because it accesses
// Components.stack. These helpers provide the same API for throws/rejects.
// Once bug 2029683 is fixed we can remove these.
// eslint-disable-next-line no-unused-vars
const Assert = {
  throws(block, expected, message) {
    let actual;
    try {
      block();
    } catch (e) {
      actual = e;
    }
    ok(!!actual, message + " - expected exception");
    if (actual) {
      _assertExpected(actual, expected, message);
    }
  },

  rejects(promise, expected, message) {
    return promise.then(
      () => ok(false, message + " - expected rejection"),
      err => _assertExpected(err, expected, message)
    );
  },
};

function _assertExpected(actual, expected, message) {
  if (expected instanceof RegExp) {
    ok(expected.test(actual), message);
  } else if (typeof expected === "function") {
    ok(expected(actual), message);
  } else {
    ok(actual instanceof expected, message);
  }
}

// Enable autoselect for mochitests by default
navigator.serial.autoselectPorts = true;

async function cleanupSerialPorts() {
  const ports = await navigator.serial.getPorts();

  for (const port of ports) {
    try {
      if (port.readable?.locked) {
        const reader = port.readable.getReader();
        reader.releaseLock();
      }
    } catch (e) {
      // Ignore errors
    }

    try {
      if (port.writable && port.writable.locked) {
        const writer = port.writable.getWriter();
        writer.releaseLock();
      }
    } catch (e) {
      // Ignore errors
    }

    try {
      await port.close();
    } catch (e) {
      // Ignore errors
    }

    try {
      await port.forget();
    } catch (e) {
      // Ignore errors
    }
  }

  // Note: We don't call removeAllMockDevices() here because that would
  // remove the default test devices that other tests depend on.
  // Hotplug tests should call navigator.serial.removeAllMockDevices()
  // explicitly if they need a completely clean slate.
}

async function simulateDeviceConnection(
  deviceId,
  devicePath,
  vendorId,
  productId
) {
  await navigator.serial.simulateDeviceConnection(
    deviceId,
    devicePath,
    vendorId,
    productId
  );
}

async function simulateDeviceDisconnection(deviceId) {
  await navigator.serial.simulateDeviceDisconnection(deviceId);
}

Messung V0.5 in Prozent
C=87 H=96 G=91

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

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

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=752002