Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/js/src/jit-test/tests/basic/   (Firefox Browser Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 803 B image not shown  

Quelle  testReplaceMap.js

  Sprache: JAVA
 


// String.replace on functions returning hashmap elements.

function first() {
  var arr = {a: "hello", b: "there"};
  var s = 'a|b';
  return s.replace(/[a-z]/g, function(a) { return arr[a]; }, 'g');
}
assertEq(first(), "hello|there");

function second() {
  var arr = {a: "hello", c: "there"};
  var s = 'a|b|c';
  return s.replace(/[a-z]/g, function(a) { return arr[a]; }, 'g');
}
assertEq(second(), "hello|undefined|there");

Object.defineProperty(Object.prototype, "b", {get: function() { return "what"; }});

assertEq(second(), "hello|what|there");

function third() {
  var arr = {a: "hello", b: {toString: function() { arr = {}; return "three"; }}, c: "there"};
  var s = 'a|b|c';
  return s.replace(/[a-z]/g, function(a) { return arr[a]; }, 'g');
}
assertEq(third(), "hello|three|undefined");

Messung V0.5 in Prozent
C=90 H=95 G=92

¤ Dauer der Verarbeitung: 0.17 Sekunden  (vorverarbeitet am  2026-06-10) ¤

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