/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* *Date:24September2001 * *SUMMARY:Tryassigningarr.length=newNumber(n) *FromcorrespondencewithIgorBukanov<igor@icesoft.no> *Seehttp://bugzilla.mozilla.org/show_bug.cgi?id=101488 * *Withoutthe"new"keyword,assigningarr.length=Number(n)worked. *Butwithit,Rhinowasgivinganerror"Inappropriatearraylength" *andSpiderMonkeywasexitingwithoutgivinganyerrororreturnvalue- * *CommentsontheRhinocodebyigor@icesoft.no: * *jsSet_lengthrequiresthatthenewlengthvalueshouldbeaninstance *ofNumber.ButaccordingtoEcma15.4.5.1,item12-13,anerrorshould *bethrownonlyifToUint32(length_value)!=ToNumber(length_value)
*/ //----------------------------------------------------------------------------- var UBound = 0; var BUGNUMBER = 101488; var summary = 'Try assigning arr.length = new Number(n)'; var status = ''; var statusitems = []; var actual = ''; var actualvalues = []; var expect= ''; var expectedvalues = []; var arr = [];
status = inSection(1);
arr = Array();
tryThis('arr.length = new Number(1);');
actual = arr.length;
expect = 1;
addThis();
status = inSection(2);
arr = Array(5);
tryThis('arr.length = new Number(1);');
actual = arr.length;
expect = 1;
addThis();
status = inSection(3);
arr = Array();
tryThis('arr.length = new Number(17);');
actual = arr.length;
expect = 17;
addThis();
status = inSection(4);
arr = Array(5);
tryThis('arr.length = new Number(17);');
actual = arr.length;
expect = 17;
addThis();
/* *Alsotrytheabovewiththe"new"keywordbeforeArray(). *Array()andnewArray()shouldbeequivalent,byECMA15.4.1.1
*/
status = inSection(5);
arr = new Array();
tryThis('arr.length = new Number(1);');
actual = arr.length;
expect = 1;
addThis();
status = inSection(6);
arr = new Array(5);
tryThis('arr.length = new Number(1);');
actual = arr.length;
expect = 1;
addThis();
arr = new Array();
tryThis('arr.length = new Number(17);');
actual = arr.length;
expect = 17;
addThis();
status = inSection(7);
arr = new Array(5);
tryThis('arr.length = new Number(17);');
actual = arr.length;
expect = 17;
addThis();
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.