Ticket #7883: json.diff
| File json.diff, 5.0 kB (added by savetheclocktower, 1 year ago) |
|---|
-
trunk/test/unit/base.html
old new 84 84 methodWithBindArgumentsAndArguments.bind({hi:'withBindArgsAndArgs'},'arg1','arg2')('arg3','arg4'); 85 85 assertEqual('withBindArgsAndArgs,arg1,arg2,arg3,arg4', globalBindTest); 86 86 }}, 87 88 testFunctionCurry: function() { with(this) { 89 var split = function(delimiter, string) { return string.split(delimiter); }; 90 var splitOnColons = split.curry(":"); 91 assertEnumEqual(split(":", "0:1:2:3:4:5"), splitOnColons("0:1:2:3:4:5")); 92 }}, 93 94 testFunctionCompose: function() { with(this) { 95 String.prototype.f = String.prototype.split.curry(':').compose(Array.prototype.sort); 96 String.prototype.composed_underscore = String.prototype.camelize.compose(String.prototype.underscore); 97 assertEnumEqual(['1', '2', '3', '4', '5'], '5:4:3:2:1'.f()); 98 assertEqual("foo_bar_baz", "foo_bar_baz".composed_underscore()); 99 }}, 100 101 testFunctionDefer: function() { with(this) { 102 window.deferred = undefined; 103 var deferredFunction = function() { window.deferred = true; }; 104 deferredFunction.defer(1000); 105 assertUndefined(window.deferred); 106 wait(1000, function() { 107 assert(window.deferred); 108 }); 109 }}, 87 110 88 111 testObjectInspect: function() { with(this) { 89 112 assertEqual('undefined', Object.inspect()); … … 99 122 assertEqual('\"\"', Object.toJSON('')); 100 123 assertEqual('[]', Object.toJSON([])); 101 124 assertEqual('[\"a\"]', Object.toJSON(['a'])); 102 assertEqual('[\"a\", 1]', Object.toJSON(['a', 1]));103 assertEqual('[\"a\", {\"b\":null}]', Object.toJSON(['a', {'b': null}]));104 assertEqual('{\"a\": \"hello!\"}', Object.toJSON({a: 'hello!'}));125 assertEqual('[\"a\", 1]', Object.toJSON(['a', 1])); 126 assertEqual('[\"a\", {\"b\": null}]', Object.toJSON(['a', {'b': null}])); 127 assertEqual('{\"a\": \"hello!\"}', Object.toJSON({a: 'hello!'})); 105 128 assertEqual('{}', Object.toJSON({})); 106 129 assertEqual('{}', Object.toJSON({a: undefined, b: undefined, c: Prototype.K})); 107 assertEqual('{\"b\": [false,true],\"c\":{\"a\":\"hello!\"}}',130 assertEqual('{\"b\": [false, true], \"c\": {\"a\": \"hello!\"}}', 108 131 Object.toJSON({'b': [undefined, false, true, undefined], c: {a: 'hello!'}})); 109 assertEqual('{\"b\": [false,true],\"c\":{\"a\":\"hello!\"}}',132 assertEqual('{\"b\": [false, true], \"c\": {\"a\": \"hello!\"}}', 110 133 Object.toJSON($H({'b': [undefined, false, true, undefined], c: {a: 'hello!'}}))); 111 134 assertEqual('true', Object.toJSON(true)); 112 135 assertEqual('false', Object.toJSON(false)); … … 148 171 div.setAttribute('id','test-'+i); 149 172 document.body.appendChild(div); 150 173 var tobj = new TestObj(); 151 var eventTest = { test:true};174 var eventTest = { test: true }; 152 175 var call = tobj.assertingEventHandler.bindAsEventListener(tobj, 153 this.assertEqual.bind(this, eventTest),154 this.assertEqual.bind(this, arg1),155 this.assertEqual.bind(this, arg2),156 this.assertEqual.bind(this, arg3), arg1, arg2, arg3 );176 this.assertEqual.bind(this, eventTest), 177 this.assertEqual.bind(this, arg1), 178 this.assertEqual.bind(this, arg2), 179 this.assertEqual.bind(this, arg3), arg1, arg2, arg3 ); 157 180 call(eventTest); 158 181 } 159 182 }, -
trunk/src/base.js
old new 42 42 for (var property in object) { 43 43 var value = Object.toJSON(object[property]); 44 44 if (value !== undefined) 45 results.push(property.toJSON() + ': ' + value);45 results.push(property.toJSON() + ': ' + value); 46 46 } 47 return '{' + results.join(', ') + '}';47 return '{' + results.join(', ') + '}'; 48 48 }, 49 49 50 50 keys: function(object) { -
trunk/src/array.js
old new 109 109 var value = Object.toJSON(object); 110 110 if (value !== undefined) results.push(value); 111 111 }); 112 return '[' + results.join(', ') + ']';112 return '[' + results.join(', ') + ']'; 113 113 } 114 114 }); 115 115 -
trunk/src/hash.js
old new 28 28 var results = []; 29 29 this.prototype._each.call(object, function(pair) { 30 30 var value = Object.toJSON(pair.value); 31 if (value !== undefined) results.push(pair.key.toJSON() + ': ' + value);31 if (value !== undefined) results.push(pair.key.toJSON() + ': ' + value); 32 32 }); 33 return '{' + results.join(', ') + '}';33 return '{' + results.join(', ') + '}'; 34 34 } 35 35 }); 36 36