Eine aufbereitete Darstellung der Quelle

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

Benutzer

Quelle  bug1008339.js

  Sprache: JAVA
 


var count = 0;

function Parent() {
    // Scanning "this" properties here with Object.keys() solved the bug in my case
    //Object.keys(this);

    this.log('Parent ctor');
    this.meth1();
    this.log('data3 before : ' + this.data3);
    this.meth2();
    // Added properties lost in ChildA
    this.log('data3 after : ' + this.data3);
    this.log('');

    if (count++)
 assertEq(this.data3, 'z');
}
Parent.prototype.meth1 = function () {
    this.log('Parent.meth1()');
};
Parent.prototype.meth2 = function () {
    this.log('Parent.meth2()');
    // Requirement for the bug : Parent.meth2() needs to add data
    this.data4 = 'x';
};
Parent.prototype.log = function (data) {
    print(data);
}

// Intermediate constructor to instantiate children prototype without executing Parent constructor code
function ParentEmptyCtor() { }
ParentEmptyCtor.prototype = Parent.prototype;

function ChildA() {
    this.log('ChildA ctor');
    Parent.call(this);
}
ChildA.prototype = new ParentEmptyCtor();
// Using Object.create() instead solves the bug
//ChildA.prototype = Object.create(ParentEmptyCtor.prototype);
ChildA.prototype.constructor = ChildA;
ChildA.prototype.meth1 = function () {
    this.log('ChildA.meth1()');
    this.data3 = 'z';
};
ChildA.prototype.meth2 = function () {
    this.log('ChildA.meth2()');
};

function ChildB() {
    this.log('ChildB ctor');
    Parent.call(this);
}
ChildB.prototype = new ParentEmptyCtor();
//ChildB.prototype = Object.create(ParentEmptyCtor.prototype);
ChildB.prototype.constructor = ChildB;

function demo() {
    // Requirement for the bug : ChildB needs to be instantiated before ChildA
    new ChildB();
    new ChildA();
}
demo();

Messung V0.5 in Prozent
C=98 H=97 G=97

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






                                                                                                                                                                                                                                                                                                                                                                                                     


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