@@ -289,6 +289,28 @@ public record Rec(int[] vals);
289289 output . ShouldBe ( new [ ] { "33,99,44" } , generatedCode ) ;
290290 }
291291
292+ [ Fact ]
293+ public void ShouldCreateRecordAddSingleArrayDefault ( )
294+ {
295+ // Given
296+ const string statements = "System.Console.WriteLine(string.Join(',', new Rec().AddVals(99, 44).vals));" ;
297+
298+ // When
299+ var output = @"
300+ namespace Sample
301+ {
302+ using System;
303+ using System.Collections.Generic;
304+ using Immutype;
305+
306+ [Target]
307+ public record Rec(int[] vals = default);
308+ }" . Run ( out var generatedCode , new RunOptions { Statements = statements } ) ;
309+
310+ // Then
311+ output . ShouldBe ( new [ ] { "99,44" } , generatedCode ) ;
312+ }
313+
292314 [ Fact ]
293315 public void ShouldCreateStructWithSingleValue ( )
294316 {
@@ -431,6 +453,28 @@ public record Rec(ImmutableArray<int> vals);
431453 // Then
432454 output . ShouldBe ( new [ ] { "22,55,99,44" } , generatedCode ) ;
433455 }
456+
457+ [ Fact ]
458+ public void ShouldSupportImmutableArrayWhenDefault ( )
459+ {
460+ // Given
461+ const string statements = "System.Console.WriteLine(string.Join(',', new Rec().AddVals(22, 55).AddVals(99,44).vals));" ;
462+
463+ // When
464+ var output = @"
465+ namespace Sample
466+ {
467+ using System;
468+ using System.Collections.Immutable;
469+ using Immutype;
470+
471+ [Target]
472+ public record Rec(ImmutableArray<int> vals = default);
473+ }" . Run ( out var generatedCode , new RunOptions { Statements = statements } ) ;
474+
475+ // Then
476+ output . ShouldBe ( new [ ] { "22,55,99,44" } , generatedCode ) ;
477+ }
434478
435479 [ Fact ]
436480 public void ShouldSupportImmutableQueue ( )
@@ -454,6 +498,29 @@ public record Rec(ImmutableQueue<int> vals);
454498 output . ShouldBe ( new [ ] { "22,55,99,44" } , generatedCode ) ;
455499 }
456500
501+ [ Fact ]
502+ public void ShouldSupportImmutableQueueWhenDefault ( )
503+ {
504+ // Given
505+ const string statements = "System.Console.WriteLine(string.Join(',', new Rec().WithVals(22, 55).AddVals(99,44).vals));" ;
506+
507+ // When
508+ var output = @"
509+ namespace Sample
510+ {
511+ using System;
512+ using System.Collections.Immutable;
513+ using Immutype;
514+
515+ [Target]
516+ public record Rec(ImmutableQueue<int> vals = default);
517+ }" . Run ( out var generatedCode , new RunOptions { Statements = statements } ) ;
518+
519+ // Then
520+ // Then
521+ output . ShouldBe ( new [ ] { "22,55,99,44" } , generatedCode ) ;
522+ }
523+
457524 [ Fact ]
458525 public void ShouldSupportImmutableStack ( )
459526 {
@@ -606,6 +673,28 @@ public record Rec(HashSet<int> vals);
606673 output . ShouldBe ( new [ ] { "55,99,44" } , generatedCode ) ;
607674 }
608675
676+ [ Fact ]
677+ public void ShouldSupportHashSetWithDefault ( )
678+ {
679+ // Given
680+ const string statements = "System.Console.WriteLine(string.Join(',', new Rec().AddVals(55).AddVals(99, 55, 44).vals));" ;
681+
682+ // When
683+ var output = @"
684+ namespace Sample
685+ {
686+ using System;
687+ using System.Collections.Generic;
688+ using Immutype;
689+
690+ [Target]
691+ public record Rec(HashSet<int> vals = default);
692+ }" . Run ( out var generatedCode , new RunOptions { Statements = statements } ) ;
693+
694+ // Then
695+ output . ShouldBe ( new [ ] { "55,99,44" } , generatedCode ) ;
696+ }
697+
609698 [ Fact ]
610699 public void ShouldSupportISet ( )
611700 {
0 commit comments