Debian Codegraph @

rhino/testsrc/tests/js1_5/Regress/regress-165201.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-165201.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 165201;
9 var summary = '';
10 var actual = '';
11 var expect = '';
12
13
14 summary = 'RegExp.prototype.toSource should not affect RegExp.prototype.toString';
15
16 printBugNumber(BUGNUMBER);
17 printStatus (summary);
18
19 /*
20 * Define function returning a regular expression literal
21 * and override RegExp.prototype.toSource
22 */
23
24 function f()
25 {
26 return /abc/;
27 }
28
29 RegExp.prototype.toSource = function() { return 'Hi there'; };
30
31 expect = -1;
32 actual = f.toString().indexOf('Hi there');
33
34 reportCompare(expect, actual, summary);
35
36 /*
37 * Define function returning an array literal
38 * and override RegExp.prototype.toSource
39 */
40 summary = 'Array.prototype.toSource should not affect Array.prototype.toString';
41 printBugNumber(BUGNUMBER);
42 printStatus (summary);
43
44 function g()
45 {
46 return [1,2,3];
47 }
48
49 Array.prototype.toSource = function() { return 'Hi there'; }
50
51 expect = -1;
52 actual = g.toString().indexOf('Hi there');
53
54 reportCompare(expect, actual, summary);
55
56