Eine aufbereitete Darstellung der Quelle

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

Benutzer

Quelle  Map-forEach.js

  Sprache: JAVA
 

/* test Map.prototype.forEach */

load(libdir + 'asserts.js');
load(libdir + 'iteration.js');

// testing success conditions of Map.prototype.forEach

var testMap = new Map();

function callback(value, key, map) {
    testMap.set(key, value);
    assertEq(map.has(key), true);
    assertEq(map.get(key), value);
}

var initialMap = new Map([['a'1], ['b'2.3], [false, undefined]]);
initialMap.forEach(callback);

// test that both the Maps are equal and are in same order
var iterator = initialMap[Symbol.iterator]();
var count = 0;
for (var [k, v] of testMap) {
    assertEq(initialMap.has(k), true);
    assertEq(initialMap.get(k), testMap.get(k));
    assertIteratorNext(iterator, [k, testMap.get(k)]);
    count++;
}

//check both the Maps we have are equal in size
assertEq(initialMap.size, testMap.size);
assertEq(initialMap.size, count);

var x = { abc: 'test'};
function callback2(value, key, map) {
    assertEq(x, this);
}
initialMap = new Map([['a'1]]);
initialMap.forEach(callback2, x);

// testing failure conditions of Map.prototype.forEach

var s = new Set([123]);
assertThrowsInstanceOf(function() {
    Map.prototype.forEach.call(s, callback);
}, TypeError, "Map.prototype.forEach should raise TypeError if not used on a Map");

var fn = 2;
assertThrowsInstanceOf(function() {
    initialMap.forEach(fn);
}, TypeError, "Map.prototype.forEach should raise TypeError if callback is not a function");

// testing that Map#forEach uses internal next() function.

var m = new Map([["one"1]]);
Object.getPrototypeOf(m[Symbol.iterator]()).next = function () { throw "FAIL"; };
assertThrowsValue(function () {
  m.forEach(function () { throw Math; });
}, Math, "Map.prototype.forEach should use intrinsic next method.");

Messung V0.5 in Prozent
C=93 H=88 G=90

¤ Dauer der Verarbeitung: 0.9 Sekunden  (vorverarbeitet am  2026-06-04) ¤

*© 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

Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik