Debian Codegraph @

rhino/testsrc/tests/js1_7/regress/regress-351503-01.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-351503-01.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 351503;
9 var summary = 'decompilation of TypeError messages';
10 var actual = '';
11 var expect = '';
12
13 printBugNumber(BUGNUMBER);
14 printStatus (summary);
15
16 expect = 'TypeError: can\'t convert Object to string';
17 try
18 {
19 function p() { return { toString: null } } "fafa".replace(/a/g, p);
20 actual = 'No Error';
21 }
22 catch(ex)
23 {
24 actual = ex + '';
25 }
26 reportCompare(expect, actual, summary + ': 1');
27
28 expect = 'TypeError: can\'t convert Object to string';
29 try
30 {
31 var a=1; b=2; c={toString: null}; "hahbhc".replace(/[abc]/g, eval);
32 actual = 'No Error';
33 }
34 catch(ex)
35 {
36 actual = ex + '';
37 }
38 reportCompare(expect, actual, summary + ': 2');
39
40 expect = 'TypeError: can\'t convert ({toString:(function () {yield 4;})}) to primitive type';
41 try
42 {
43 3 + ({toString:function(){yield 4} });
44 actual = 'No Error';
45 }
46 catch(ex)
47 {
48 actual = ex + '';
49 }
50 reportCompare(expect, actual, summary + ': 3');
51
52 expect = 'TypeError: ({}) is not a function';
53 try
54 {
55 3 + ({toString:({}) }) ;
56 actual = 'No Error';
57 }
58 catch(ex)
59 {
60 actual = ex + '';
61 }
62 reportCompare(expect, actual, summary + ': 4');
63
64 expect = 'TypeError: 3 is not a function';
65 try
66 {
67 ([5].map)(3);
68 actual = 'No Error';
69 }
70 catch(ex)
71 {
72 actual = ex + '';
73 }
74 reportCompare(expect, actual, summary + ': 5');
75
76 expect = 'TypeError: 5 is not a function';
77 try
78 {
79 (1 + (4))();
80 actual = 'No Error';
81 }
82 catch(ex)
83 {
84 actual = ex + '';
85 }
86 reportCompare(expect, actual, summary + ': 6');