js/src/tests/js1_5/extensions/regress-354541-04.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:cddc0365fb36
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 //-----------------------------------------------------------------------------
7 var BUGNUMBER = 354541;
8 var summary = 'Regression to standard class constructors in case labels';
9 var actual = '';
10 var expect = '';
11
12 //-----------------------------------------------------------------------------
13 test();
14 //-----------------------------------------------------------------------------
15
16 function test()
17 {
18 enterFunc ('test');
19 printBugNumber(BUGNUMBER);
20 printStatus (summary + ': in function');
21
22 String.prototype.trim = function() { return 'hallo'; };
23
24 const S = String;
25 const Sp = String.prototype;
26
27 expect = 'hallo';
28 var expectStringInvariant = true;
29 var actualStringInvariant;
30 var expectStringPrototypeInvariant = true;
31 var actualStringPrototypeInvariant;
32
33 if (typeof Script == 'undefined')
34 {
35 print('Test skipped. Script is not defined');
36 reportCompare("Script not defined, Test skipped.",
37 "Script not defined, Test skipped.",
38 summary);
39 }
40 else
41 {
42 s = Script('var tmp = function(o) { switch(o) { case String: case 1: return ""; } }; actualStringInvariant = (String === S); actualStringPrototypeInvariant = (String.prototype === Sp); actual = "".trim();');
43 try
44 {
45 s();
46 }
47 catch(ex)
48 {
49 actual = ex + '';
50 }
51
52 reportCompare(expect, actual, 'trim() returned');
53 reportCompare(expectStringInvariant, actualStringInvariant, 'String invariant');
54 reportCompare(expectStringPrototypeInvariant,
55 actualStringPrototypeInvariant,
56 'String.prototype invariant');
57 }
58
59 exitFunc ('test');
60 }

mercurial