Debian Codegraph @

rhino/testsrc/tests/js1_5/extensions/regress-354541-03.js

raw symbols SCIP
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 var gTestfile = 'regress-354541-03.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 354541;
9 var summary = 'Regression to standard class constructors in case labels';
10 var actual = '';
11 var expect = '';
12
13
14 printBugNumber(BUGNUMBER);
15 printStatus (summary + ': top level');
16
17 String.prototype.trim = function() { print('hallo'); };
18
19 String.prototype.trim = function() { return 'hallo'; };
20
21 const S = String;
22 const Sp = String.prototype;
23
24 expect = 'hallo';
25 var expectStringInvariant = true
26 var actualStringInvariant;
27 var expectStringPrototypeInvariant = true;
28 var actualStringPrototypeInvariant;
29
30 if (typeof Script == 'undefined')
31 {
32 print('Test skipped. Script not defined.');
33 reportCompare("Script not defined, Test skipped.",
34 "Script not defined, Test skipped.",
35 summary);
36 }
37 else
38 {
39 var s = Script('var tmp = function(o) { switch(o) { case String: case 1: return ""; } }; actualStringInvariant = (String === S); actualStringPrototypeInvariant = (String.prototype === Sp); actual = "".trim();');
40 try
41 {
42 s();
43 }
44 catch(ex)
45 {
46 actual = ex + '';
47 }
48 reportCompare(expect, actual, 'trim() returned');
49 reportCompare(expectStringInvariant, actualStringInvariant,
50 'String invariant');
51 reportCompare(expectStringPrototypeInvariant,
52 actualStringPrototypeInvariant,
53 'String.prototype invariant');
54
55 }
56