Eine aufbereitete Darstellung der Quelle

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

Benutzer

Quelle  test_safeErrorString.js

  Sprache: JAVA
 

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


"use strict";

// Test DevToolsUtils.safeErrorString

function run_test() {
  test_with_error();
  test_with_tricky_error();
  test_with_string();
  test_with_thrower();
  test_with_psychotic();
}

function test_with_error() {
  const s = DevToolsUtils.safeErrorString(new Error("foo bar"));
  // Got the message.
  Assert.ok(s.includes("foo bar"));
  // Got the stack.
  Assert.ok(s.includes("test_with_error"));
  Assert.ok(s.includes("test_safeErrorString.js"));
  // Got the lineNumber and columnNumber.
  Assert.ok(s.includes("Line"));
  Assert.ok(s.includes("column"));
}

function test_with_tricky_error() {
  const e = new Error("batman");
  e.stack = { toString: Object.create(null) };
  const s = DevToolsUtils.safeErrorString(e);
  // Still got the message, despite a bad stack property.
  Assert.ok(s.includes("batman"));
}

function test_with_string() {
  const s = DevToolsUtils.safeErrorString("not really an error");
  // Still get the message.
  Assert.ok(s.includes("not really an error"));
}

function test_with_thrower() {
  const s = DevToolsUtils.safeErrorString({
    toString: () => {
      throw new Error("Muahahaha");
    },
  });
  // Still don't fail, get string back.
  Assert.equal(typeof s, "string");
}

function test_with_psychotic() {
  const s = DevToolsUtils.safeErrorString({
    toString: () => Object.create(null),
  });
  // Still get a string out, and no exceptions thrown
  Assert.equal(typeof s, "string");
  Assert.equal(s, "[object Object]");
}

Messung V0.5 in Prozent
C=85 H=100 G=92

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

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