Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: test/mjsunit/es6/proxies-json.js

Issue 1922603006: [JSON] implement indentation in the BasicJsonStringifier and expose via API. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/mjsunit/es6/symbols.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 17 matching lines...) Expand all
28 28
29 29
30 /////////////////////////////////////////////////////////////////////////////// 30 ///////////////////////////////////////////////////////////////////////////////
31 // JSON.stringify 31 // JSON.stringify
32 32
33 33
34 function testStringify(expected, object) { 34 function testStringify(expected, object) {
35 // Test fast case that bails out to slow case. 35 // Test fast case that bails out to slow case.
36 assertEquals(expected, JSON.stringify(object)); 36 assertEquals(expected, JSON.stringify(object));
37 // Test slow case. 37 // Test slow case.
38 assertEquals(expected, JSON.stringify(object, undefined, 0)); 38 assertEquals(expected, JSON.stringify(object, (key, value) => value));
39 // Test gap.
40 assertEquals(JSON.stringify(object, null, "="),
41 JSON.stringify(object, (key, value) => value, "="));
39 } 42 }
40 43
41 44
42 // Test serializing a proxy, a function proxy, and objects that contain them. 45 // Test serializing a proxy, a function proxy, and objects that contain them.
43 46
44 var handler1 = { 47 var handler1 = {
45 get: function(target, name) { 48 get: function(target, name) {
46 return name.toUpperCase(); 49 return name.toUpperCase();
47 }, 50 },
48 ownKeys: function() { 51 ownKeys: function() {
(...skipping 11 matching lines...) Expand all
60 assertTrue(typeof(proxy_fun) === 'function'); 63 assertTrue(typeof(proxy_fun) === 'function');
61 testStringify(undefined, proxy_fun); 64 testStringify(undefined, proxy_fun);
62 testStringify('[1,null]', [1, proxy_fun]); 65 testStringify('[1,null]', [1, proxy_fun]);
63 66
64 handler1.apply = function() { return 666; }; 67 handler1.apply = function() { return 666; };
65 testStringify(undefined, proxy_fun); 68 testStringify(undefined, proxy_fun);
66 testStringify('[1,null]', [1, proxy_fun]); 69 testStringify('[1,null]', [1, proxy_fun]);
67 70
68 var parent1a = { b: proxy1 }; 71 var parent1a = { b: proxy1 };
69 testStringify('{"b":{"a":"A","b":"B","c":"C"}}', parent1a); 72 testStringify('{"b":{"a":"A","b":"B","c":"C"}}', parent1a);
73 testStringify('{"b":{"a":"A","b":"B","c":"C"}}', parent1a);
70 74
71 var parent1b = { a: 123, b: proxy1, c: true }; 75 var parent1b = { a: 123, b: proxy1, c: true };
72 testStringify('{"a":123,"b":{"a":"A","b":"B","c":"C"},"c":true}', parent1b); 76 testStringify('{"a":123,"b":{"a":"A","b":"B","c":"C"},"c":true}', parent1b);
73 77
74 var parent1c = [123, proxy1, true]; 78 var parent1c = [123, proxy1, true];
75 testStringify('[123,{"a":"A","b":"B","c":"C"},true]', parent1c); 79 testStringify('[123,{"a":"A","b":"B","c":"C"},true]', parent1c);
76 80
77 81
78 // Proxy with side effect. 82 // Proxy with side effect.
79 83
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 500
497 var result = JSON.parse('{"foo":0,"bar":1}', reviver); 501 var result = JSON.parse('{"foo":0,"bar":1}', reviver);
498 assertEquals({foo: 0, bar: proxy}, result); 502 assertEquals({foo: 0, bar: proxy}, result);
499 assertSame(result.bar, proxy); 503 assertSame(result.bar, proxy);
500 assertEquals(3, log.length); 504 assertEquals(3, log.length);
501 for (var i in log) assertSame(target, log[i][1]); 505 for (var i in log) assertSame(target, log[i][1]);
502 506
503 assertEquals(["get", target, "length", proxy], log[0]); 507 assertEquals(["get", target, "length", proxy], log[0]);
504 assertEquals(["get", target, "0", proxy], log[1]); 508 assertEquals(["get", target, "0", proxy], log[1]);
505 assertEquals(["deleteProperty", target, "0"], log[2]); 509 assertEquals(["deleteProperty", target, "0"], log[2]);
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/mjsunit/es6/symbols.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698