Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/js/src/tests/non262/Promise/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 1 kB image not shown  

Quelle  promise-subclassing.js   Sprache: JAVA

 
// |reftest| skip-if(!xulRuntime.shell) -- needs drainJobQueue

let results = [];

class SubPromise extends Promise {
  constructor(executor) {
    results.push('SubPromise ctor called');
    super(executor);
  }
  then(res, rej) {
    results.push('SubPromise#then called');
    return intermediatePromise = super.then(res, rej);
  }
}

let subPromise = new SubPromise(function(res, rej) {
  results.push('SubPromise ctor called executor');
  res('result');
});

let intermediatePromise;
let allSubPromise = SubPromise.all([subPromise]);

assertEq(subPromise instanceof SubPromise, true);
assertEq(allSubPromise instanceof SubPromise, true);
assertEq(intermediatePromise instanceof SubPromise, true);

expected = [
'SubPromise ctor called',
'SubPromise ctor called executor',
'SubPromise ctor called',
'SubPromise#then called',
'SubPromise ctor called',
];

assertEq(results.length, expected.length);
expected.forEach((expected,i) => assertEq(results[i], expected));

subPromise.then(val=>results.push('subPromise.then with val ' + val));
allSubPromise.then(val=>results.push('allSubPromise.then with val ' + val));

expected.forEach((expected,i) => assertEq(results[i], expected));
expected = expected.concat([
'SubPromise#then called',
'SubPromise ctor called',
'SubPromise#then called',
'SubPromise ctor called',
]);

assertEq(results.length, expected.length);
expected.forEach((expected,i) => assertEq(results[i], expected));

drainJobQueue();

expected = expected.concat([
'subPromise.then with val result',
'allSubPromise.then with val result',
]);

assertEq(results.length, expected.length);

this.reportCompare && reportCompare(0, 0, "ok");

Messung V0.5
C=97 H=96 G=96

¤ Dauer der Verarbeitung: 0.15 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.