summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/JSON/stringify-toJSON-arguments.js
blob: 7c2013d5883c0355bf569a8e36c9312e7296d1fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/licenses/publicdomain/

var gTestfile = 'stringify-toJSON-arguments.js';
//-----------------------------------------------------------------------------
var BUGNUMBER = 584909;
var summary = "Arguments when an object's toJSON method is called";

print(BUGNUMBER + ": " + summary);

/**************
 * BEGIN TEST *
 **************/

var obj =
  {
    p: {
         toJSON: function(key)
         {
           assertEq(arguments.length, 1);
           assertEq(key, "p");
           return 17;
         }
       }
  };

assertEq(JSON.stringify(obj), '{"p":17}');

/******************************************************************************/

if (typeof reportCompare === "function")
  reportCompare(true, true);

print("Tests complete");