@@ -172,20 +172,22 @@ preserves('should preserve existing object structure', () => {
172172 } ) ;
173173} ) ;
174174
175- preserves ( 'should not convert existing non-object values into object' , ( ) => {
175+ preserves ( 'should overwrite existing non-object values as object' , ( ) => {
176176 let input = {
177177 a : {
178178 b : 123
179179 }
180180 } ;
181181
182- let before = JSON . stringify ( input ) ;
183182 dset ( input , 'a.b.c' , 'hello' ) ;
184183
185- assert . is (
186- JSON . stringify ( input ) ,
187- before
188- ) ;
184+ assert . equal ( input , {
185+ a : {
186+ b : {
187+ c : 'hello'
188+ }
189+ }
190+ } ) ;
189191} ) ;
190192
191193preserves ( 'should preserve existing object tree w/ array value' , ( ) => {
@@ -208,26 +210,6 @@ preserves('should preserve existing object tree w/ array value', () => {
208210 } ) ;
209211} ) ;
210212
211- preserves ( 'should not throw when refusing to convert non-object into object' , ( ) => {
212- try {
213- let input = { b :123 } ;
214- dset ( input , 'b.c.d.e' , 123 ) ;
215- assert . is ( input . b , 123 ) ;
216- } catch ( err ) {
217- assert . unreachable ( 'should not have thrown' ) ;
218- }
219- } ) ;
220-
221- preserves ( 'should not throw when refusing to convert `0` into object' , ( ) => {
222- try {
223- let input = { b :0 } ;
224- dset ( input , 'b.a.s.d' , 123 ) ;
225- assert . equal ( input , { b : 0 } ) ;
226- } catch ( err ) {
227- assert . unreachable ( 'should not have thrown' ) ;
228- }
229- } ) ;
230-
231213preserves . run ( ) ;
232214
233215// ---
@@ -274,8 +256,18 @@ pollution('should ignore "prototype" assignment', () => {
274256 dset ( input , 'a.prototype.hello' , 'world' ) ;
275257
276258 assert . is ( input . a . prototype , undefined ) ;
277- assert . is . not ( input . a . hello , 'world' ) ;
278- assert . equal ( input , { a : 123 } ) ;
259+ assert . is ( input . a . hello , 'world' ) ;
260+
261+ assert . equal ( input , {
262+ a : {
263+ hello : 'world'
264+ }
265+ } ) ;
266+
267+ assert . is (
268+ JSON . stringify ( input ) ,
269+ '{"a":{"hello":"world"}}'
270+ ) ;
279271} ) ;
280272
281273pollution ( 'should ignore "constructor" assignment' , ( ) => {
0 commit comments