@@ -631,6 +631,79 @@ describe('objc runner', function() {
631
631
done ( ) ;
632
632
} ) ;
633
633
} ) ;
634
+
635
+ it ( 'should support setup code' , function ( done ) {
636
+ // https://github.com/Codewars/codewars.com/issues/1221
637
+ runner . run ( {
638
+ language : 'objc' ,
639
+ testFramework : 'unitkit' ,
640
+ setup : `
641
+ #import <Foundation/Foundation.h>
642
+
643
+ @interface Node: NSObject
644
+ {
645
+ int data;
646
+ Node *next;
647
+ }
648
+ @property (readonly) int data;
649
+ @property (readonly) Node *next;
650
+ - (id)initWithData: (int)d andNext: (Node *)n;
651
+ - (id)initWithData: (int)d;
652
+ + (Node *)nodeWithData: (int)d andNext: (Node *)n;
653
+ + (Node *)nodeWithData: (int)d;
654
+ @end
655
+
656
+ @implementation Node
657
+ @synthesize data;
658
+ @synthesize next;
659
+ - (id)initWithData: (int)d andNext: (Node *)n
660
+ {
661
+ data = d;
662
+ next = n;
663
+ return self;
664
+ }
665
+ - (id)initWithData: (int)d
666
+ {
667
+ data = d;
668
+ next = NULL;
669
+ return self;
670
+ }
671
+ + (Node *)nodeWithData: (int)d andNext: (Node *)n
672
+ {
673
+ return [[Node alloc] initWithData: d andNext: n];
674
+ }
675
+ + (Node *)nodeWithData: (int)d
676
+ {
677
+ return [[Node alloc] initWithData: d];
678
+ }
679
+ @end
680
+ ` ,
681
+ solution : `
682
+ #import <Foundation/Foundation.h>
683
+
684
+ NSString *stringify(Node *list) {
685
+ // TODO: Return a string representation of the list passed in
686
+ return @"";
687
+ }
688
+ ` ,
689
+ fixture : `
690
+ @implementation TestSuite
691
+ - (void)testNULL
692
+ {
693
+ UKStringsEqual(@"", stringify(NULL));
694
+ }
695
+ - (void)testSingle
696
+ {
697
+ UKStringsEqual(@"1", stringify([Node nodeWithData: 1]));
698
+ }
699
+ @end
700
+ ` ,
701
+ } , function ( buffer ) {
702
+ expect ( buffer . stdout ) . to . contain ( '<PASSED::>' ) ;
703
+ expect ( buffer . stdout ) . to . contain ( '<FAILED::>' ) ;
704
+ done ( ) ;
705
+ } ) ;
706
+ } ) ;
634
707
} ) ;
635
708
636
709
describe ( 'CW' , function ( ) {
0 commit comments