<commit_before>#import <Cedar-iOS/SpecHelper.h>
#define HC_SHORTHAND
#import <OCHamcrest/OCHamcrest.h>

using namespace Cedar::Matchers;

#import "DXSingletone.h"

@interface SingletoneTestClass : NSObject <DXSingletone>

@end

@implementation SingletoneTestClass

@end

SPEC_BEGIN(DXSingletoneSpec)

describe(@"DXSingletone", ^{
    it(@"Should return instance of class", ^{
        assertThat([SingletoneTestClass shared], notNilValue());
        assertThatBool([[SingletoneTestClass shared] isKindOfClass:[SingletoneTestClass class]], equalToBool(YES));
    });
    
    it(@"Should return same instance for each call", ^{
        SingletoneTestClass *instanceA = [SingletoneTestClass shared];
        SingletoneTestClass *instanceB = [SingletoneTestClass shared];
        
        assertThat(instanceA, equalTo(instanceB));
    });
    
    it(@"Should create new shared instance after destroying old instance", ^{
        SingletoneTestClass *instanceA = [SingletoneTestClass shared];
        
        [SingletoneTestClass destroySharedInstance];
        
        SingletoneTestClass *instanceB = [SingletoneTestClass shared];
        
        assertThat(instanceA, isNot(equalTo(instanceB)));
    });
});

SPEC_END<commit_msg>add ability to destroy all shared instances to DXSingletone<commit_after>#import <Cedar-iOS/SpecHelper.h>
#define HC_SHORTHAND
#import <OCHamcrest/OCHamcrest.h>

using namespace Cedar::Matchers;

#import "DXSingletone.h"
#import "DXSingletoneHolder.h"


@interface SingletoneTestClass : NSObject <DXSingletone>

@end

@implementation SingletoneTestClass

@end

SPEC_BEGIN(DXSingletoneSpec)

describe(@"DXSingletone", ^{
    it(@"Should return instance of class", ^{
        assertThat([SingletoneTestClass shared], notNilValue());
        assertThatBool([[SingletoneTestClass shared] isKindOfClass:[SingletoneTestClass class]], equalToBool(YES));
    });
    
    it(@"Should return same instance for each call", ^{
        SingletoneTestClass *instanceA = [SingletoneTestClass shared];
        SingletoneTestClass *instanceB = [SingletoneTestClass shared];
        
        assertThat(instanceA, equalTo(instanceB));
    });
    
    it(@"Should create new shared instance after destroying old instance", ^{
        SingletoneTestClass *instanceA = [SingletoneTestClass shared];
        
        [SingletoneTestClass destroySharedInstance];
        
        SingletoneTestClass *instanceB = [SingletoneTestClass shared];
        
        assertThat(instanceA, isNot(equalTo(instanceB)));
    });
    
    it(@"Should create new shared instance after destroying all old instances", ^{
        SingletoneTestClass *instanceA = [SingletoneTestClass shared];
        
        [[DXSingletoneHolder shared] destroyAll];
        
        SingletoneTestClass *instanceB = [SingletoneTestClass shared];
        
        assertThat(instanceA, isNot(equalTo(instanceB)));
    });
});

SPEC_END
{'fraction_non_alphanumeric': 0.10120068610634649, 'fraction_numerical': 0.0, 'mean_word_length': 3.8926174496644297, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4104815', 'n_tokens_mistral': 873, 'n_tokens_neox': 840, 'n_words': 178}