Skip to content

Commit 51173b8

Browse files
author
jennybuckley
committed
Add test for null/{} behavior of deduced types
1 parent 4f746db commit 51173b8

File tree

1 file changed

+238
-0
lines changed

1 file changed

+238
-0
lines changed

typed/symdiff_test.go

Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,244 @@ var symdiffCases = []symdiffTestCase{{
299299
modified: _NS(),
300300
added: _NS(_P("a", "b")),
301301
}},
302+
}, {
303+
name: "untyped deduced",
304+
rootTypeName: "__untyped_deduced_",
305+
schema: `types:
306+
- name: __untyped_atomic_
307+
scalar: untyped
308+
list:
309+
elementType:
310+
namedType: __untyped_atomic_
311+
elementRelationship: atomic
312+
map:
313+
elementType:
314+
namedType: __untyped_atomic_
315+
elementRelationship: atomic
316+
- name: __untyped_deduced_
317+
scalar: untyped
318+
list:
319+
elementType:
320+
namedType: __untyped_atomic_
321+
elementRelationship: atomic
322+
map:
323+
elementType:
324+
namedType: __untyped_deduced_
325+
elementRelationship: separable
326+
`,
327+
quints: []symdiffQuint{{
328+
lhs: `{"a":{}}}`,
329+
rhs: `{"a":{"b":{}}}`,
330+
removed: _NS(),
331+
modified: _NS(),
332+
added: _NS(_P("a", "b")),
333+
}, {
334+
lhs: `{"a":null}`,
335+
rhs: `{"a":{"b":{}}}`,
336+
removed: _NS(),
337+
modified: _NS(),
338+
added: _NS(_P("a", "b")),
339+
}, {
340+
lhs: `{"a":{"b":{}}}`,
341+
rhs: `{"a":{}}}`,
342+
removed: _NS(_P("a", "b")),
343+
modified: _NS(),
344+
added: _NS(),
345+
}, {
346+
lhs: `{"a":{"b":{}}}`,
347+
rhs: `{"a":null}`,
348+
removed: _NS(_P("a", "b")),
349+
modified: _NS(),
350+
added: _NS(),
351+
}, {
352+
lhs: `{"a":[]}`,
353+
rhs: `{"a":["b"]}`,
354+
removed: _NS(),
355+
modified: _NS(_P("a")),
356+
added: _NS(),
357+
}, {
358+
lhs: `{"a":null}`,
359+
rhs: `{"a":["b"]}`,
360+
removed: _NS(),
361+
modified: _NS(_P("a")),
362+
added: _NS(),
363+
}, {
364+
lhs: `{"a":["b"]}`,
365+
rhs: `{"a":[]}`,
366+
removed: _NS(),
367+
modified: _NS(_P("a")),
368+
added: _NS(),
369+
}, {
370+
lhs: `{"a":["b"]}`,
371+
rhs: `{"a":null}`,
372+
removed: _NS(),
373+
modified: _NS(_P("a")),
374+
added: _NS(),
375+
}, {
376+
lhs: `{"a":null}`,
377+
rhs: `{"a":"b"}`,
378+
removed: _NS(),
379+
modified: _NS(_P("a")),
380+
added: _NS(),
381+
}, {
382+
lhs: `{"a":"b"}`,
383+
rhs: `{"a":null}`,
384+
removed: _NS(),
385+
modified: _NS(_P("a")),
386+
added: _NS(),
387+
}, {
388+
lhs: `{"a":{"b":{}}}`,
389+
rhs: `{"a":["b"]}}`,
390+
removed: _NS(_P("a", "b")),
391+
modified: _NS(_P("a")),
392+
added: _NS(),
393+
}, {
394+
lhs: `{"a":["b"]}}`,
395+
rhs: `{"a":{"b":{}}}`,
396+
removed: _NS(),
397+
modified: _NS(_P("a")),
398+
added: _NS(_P("a", "b")),
399+
}, {
400+
lhs: `{"a":{"b":{}}}`,
401+
rhs: `{"a":"b"}`,
402+
removed: _NS(_P("a", "b")),
403+
modified: _NS(_P("a")),
404+
added: _NS(),
405+
}, {
406+
lhs: `{"a":"b"}`,
407+
rhs: `{"a":{"b":{}}}`,
408+
removed: _NS(),
409+
modified: _NS(_P("a")),
410+
added: _NS(_P("a", "b")),
411+
}, {
412+
lhs: `{"a":["b"]}}`,
413+
rhs: `{"a":"b"}`,
414+
removed: _NS(),
415+
modified: _NS(_P("a")),
416+
added: _NS(),
417+
}, {
418+
lhs: `{"a":"b"}`,
419+
rhs: `{"a":["b"]}}`,
420+
removed: _NS(),
421+
modified: _NS(_P("a")),
422+
added: _NS(),
423+
}},
424+
}, {
425+
name: "untyped separable",
426+
rootTypeName: "__untyped_separable_",
427+
schema: `types:
428+
- name: __untyped_separable_
429+
scalar: untyped
430+
list:
431+
elementType:
432+
namedType: __untyped_separable_
433+
elementRelationship: associative
434+
map:
435+
elementType:
436+
namedType: __untyped_separable_
437+
elementRelationship: separable
438+
`,
439+
quints: []symdiffQuint{{
440+
lhs: `{"a":{}}}`,
441+
rhs: `{"a":{"b":{}}}`,
442+
removed: _NS(),
443+
modified: _NS(),
444+
added: _NS(_P("a", "b")),
445+
}, {
446+
lhs: `{"a":null}`,
447+
rhs: `{"a":{"b":{}}}`,
448+
removed: _NS(),
449+
modified: _NS(),
450+
added: _NS(_P("a", "b")),
451+
}, {
452+
lhs: `{"a":{"b":{}}}`,
453+
rhs: `{"a":{}}}`,
454+
removed: _NS(_P("a", "b")),
455+
modified: _NS(),
456+
added: _NS(),
457+
}, {
458+
lhs: `{"a":{"b":{}}}`,
459+
rhs: `{"a":null}`,
460+
removed: _NS(_P("a", "b")),
461+
modified: _NS(),
462+
added: _NS(),
463+
}, {
464+
lhs: `{"a":[]}`,
465+
rhs: `{"a":["b"]}`,
466+
removed: _NS(),
467+
modified: _NS(),
468+
added: _NS(_P("a", _SV("b"))),
469+
}, {
470+
lhs: `{"a":null}`,
471+
rhs: `{"a":["b"]}`,
472+
removed: _NS(),
473+
// TODO: result should be the same as the previous case
474+
// nothing shoule be modified here.
475+
modified: _NS(_P("a")),
476+
added: _NS(_P("a", _SV("b"))),
477+
}, {
478+
lhs: `{"a":["b"]}`,
479+
rhs: `{"a":[]}`,
480+
removed: _NS(_P("a", _SV("b"))),
481+
modified: _NS(),
482+
added: _NS(),
483+
}, {
484+
lhs: `{"a":["b"]}`,
485+
rhs: `{"a":null}`,
486+
removed: _NS(_P("a", _SV("b"))),
487+
// TODO: result should be the same as the previous case
488+
// nothing shoule be modified here.
489+
modified: _NS(_P("a")),
490+
added: _NS(),
491+
}, {
492+
lhs: `{"a":null}`,
493+
rhs: `{"a":"b"}`,
494+
removed: _NS(),
495+
modified: _NS(_P("a")),
496+
added: _NS(),
497+
}, {
498+
lhs: `{"a":"b"}`,
499+
rhs: `{"a":null}`,
500+
removed: _NS(),
501+
modified: _NS(_P("a")),
502+
added: _NS(),
503+
}, {
504+
lhs: `{"a":{"b":{}}}`,
505+
rhs: `{"a":["b"]}}`,
506+
removed: _NS(_P("a", "b")),
507+
modified: _NS(),
508+
added: _NS(_P("a", _SV("b"))),
509+
}, {
510+
lhs: `{"a":["b"]}}`,
511+
rhs: `{"a":{"b":{}}}`,
512+
removed: _NS(_P("a", _SV("b"))),
513+
modified: _NS(),
514+
added: _NS(_P("a", "b")),
515+
}, {
516+
lhs: `{"a":{"b":{}}}`,
517+
rhs: `{"a":"b"}`,
518+
removed: _NS(_P("a", "b")),
519+
modified: _NS(_P("a")),
520+
added: _NS(),
521+
}, {
522+
lhs: `{"a":"b"}`,
523+
rhs: `{"a":{"b":{}}}`,
524+
removed: _NS(),
525+
modified: _NS(_P("a")),
526+
added: _NS(_P("a", "b")),
527+
}, {
528+
lhs: `{"a":["b"]}}`,
529+
rhs: `{"a":"b"}`,
530+
removed: _NS(_P("a", _SV("b"))),
531+
modified: _NS(_P("a")),
532+
added: _NS(),
533+
}, {
534+
lhs: `{"a":"b"}`,
535+
rhs: `{"a":["b"]}}`,
536+
removed: _NS(),
537+
modified: _NS(_P("a")),
538+
added: _NS(_P("a", _SV("b"))),
539+
}},
302540
}, {
303541
name: "struct grab bag",
304542
rootTypeName: "myStruct",

0 commit comments

Comments
 (0)