From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../non262/extensions/uneval/regress-90596-002.js | 264 +++++++++++++++++++++ 1 file changed, 264 insertions(+) create mode 100644 js/src/tests/non262/extensions/uneval/regress-90596-002.js (limited to 'js/src/tests/non262/extensions/uneval/regress-90596-002.js') diff --git a/js/src/tests/non262/extensions/uneval/regress-90596-002.js b/js/src/tests/non262/extensions/uneval/regress-90596-002.js new file mode 100644 index 0000000000..ae66ea7142 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-90596-002.js @@ -0,0 +1,264 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- 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. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 28 August 2001 + * + * SUMMARY: A [DontEnum] prop, if overridden, should appear in uneval(). + * See http://bugzilla.mozilla.org/show_bug.cgi?id=90596 + * + * NOTE: some inefficiencies in the test are made for the sake of readability. + * Sorting properties alphabetically is done for definiteness in comparisons. + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 90596; +var summary = 'A [DontEnum] prop, if overridden, should appear in uneval()'; +var cnCOMMA = ','; +var cnLBRACE = '{'; +var cnRBRACE = '}'; +var cnLPAREN = '('; +var cnRPAREN = ')'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var obj = {}; + + +status = inSection(1); +obj = {toString:9}; +actual = uneval(obj); +expect = '({toString:9})'; +addThis(); + +status = inSection(2); +obj = {hasOwnProperty:"Hi"}; +actual = uneval(obj); +expect = '({hasOwnProperty:"Hi"})'; +addThis(); + +status = inSection(3); +obj = {toString:9, hasOwnProperty:"Hi"}; +actual = uneval(obj); +expect = '({toString:9, hasOwnProperty:"Hi"})'; +addThis(); + +status = inSection(4); +obj = {prop1:1, toString:9, hasOwnProperty:"Hi"}; +actual = uneval(obj); +expect = '({prop1:1, toString:9, hasOwnProperty:"Hi"})'; +addThis(); + + +// TRY THE SAME THING IN EVAL CODE +var s = ''; + +status = inSection(5); +s = 'obj = {toString:9}'; +eval(s); +actual = uneval(obj); +expect = '({toString:9})'; +addThis(); + +status = inSection(6); +s = 'obj = {hasOwnProperty:"Hi"}'; +eval(s); +actual = uneval(obj); +expect = '({hasOwnProperty:"Hi"})'; +addThis(); + +status = inSection(7); +s = 'obj = {toString:9, hasOwnProperty:"Hi"}'; +eval(s); +actual = uneval(obj); +expect = '({toString:9, hasOwnProperty:"Hi"})'; +addThis(); + +status = inSection(8); +s = 'obj = {prop1:1, toString:9, hasOwnProperty:"Hi"}'; +eval(s); +actual = uneval(obj); +expect = '({prop1:1, toString:9, hasOwnProperty:"Hi"})'; +addThis(); + + +// TRY THE SAME THING IN FUNCTION CODE +function A() +{ + status = inSection(9); + var s = 'obj = {toString:9}'; + eval(s); + actual = uneval(obj); + expect = '({toString:9})'; + addThis(); +} +A(); + +function B() +{ + status = inSection(10); + var s = 'obj = {hasOwnProperty:"Hi"}'; + eval(s); + actual = uneval(obj); + expect = '({hasOwnProperty:"Hi"})'; + addThis(); +} +B(); + +function C() +{ + status = inSection(11); + var s = 'obj = {toString:9, hasOwnProperty:"Hi"}'; + eval(s); + actual = uneval(obj); + expect = '({toString:9, hasOwnProperty:"Hi"})'; + addThis(); +} +C(); + +function D() +{ + status = inSection(12); + var s = 'obj = {prop1:1, toString:9, hasOwnProperty:"Hi"}'; + eval(s); + actual = uneval(obj); + expect = '({prop1:1, toString:9, hasOwnProperty:"Hi"})'; + addThis(); +} +D(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +/* + * Sort properties alphabetically - + */ +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = sortThis(actual); + expectedvalues[UBound] = sortThis(expect); + UBound++; +} + + +/* + * Takes string of form '({"c", "b", "a", 2})' and returns '({"a","b","c",2})' + */ +function sortThis(sList) +{ + sList = compactThis(sList); + sList = stripParens(sList); + sList = stripBraces(sList); + var arr = sList.split(cnCOMMA); + arr = arr.sort(); + var ret = String(arr); + ret = addBraces(ret); + ret = addParens(ret); + return ret; +} + + +/* + * Strips out any whitespace from the text - + */ +function compactThis(text) +{ + var charCode = 0; + var ret = ''; + + for (var i=0; i