<commit_before>/**
 * author: <NAME>  http://github.com/0xor1
 */

part of EventableTest;

void runEventDetectorTests(){

  group('EventDetector', (){

    setUp(setUpTestObjects);

    tearDown(tearDownTestObjects);

    test('.ignoreAllEvents() unhooks all EventActions.', (){
      detector.ignoreAllEvents();
      emitter1.emitEvent(new TypeA());
      emitter2.emitEvent(new TypeB());
      Timer.run(expectAsync((){
        expect(eventADetectedCount, equals(0));
        expect(eventBDetectedCount, equals(0));
      }));
    });

    test('.ignoreAllEventsOfType(eventType) unhooks all EventActions of the specified type.', (){
      detector.ignoreAllEventsOfType(TypeA);
      emitter1.emitEvent(new TypeA());
      emitter2.emitEvent(new TypeB());
      Timer.run(expectAsync((){
        expect(eventADetectedCount, equals(0));
        expect(eventBDetectedCount, equals(1));
      }));
    });

    test('.ignoreAllEventsFrom(emitter) unhooks all EventActions from the specified emitter.', (){
      detector.ignoreAllEventsFrom(emitter1);
      emitter1.emitEvent(new TypeA());
      emitter2.emitEvent(new TypeB());
      Timer.run(expectAsync((){
        expect(eventADetectedCount, equals(0));
        expect(eventBDetectedCount, equals(1));
      }));
    });

    test('throws a DuplicateEventSettingError if it attempts to listen to the same emitter/event_type combination more than once.', (){
      try{
        detector.listen(emitter1, TypeA, (event){});
      }catch(error){
        expect(error is DuplicateEventSettingError, equals(true));
      }
    });

  });

}<commit_msg>add unit test to cover previous checkin fix<commit_after>/**
 * author: <NAME>  http://github.com/0xor1
 */

part of EventableTest;

void runEventDetectorTests(){

  group('EventDetector', (){

    setUp(setUpTestObjects);

    tearDown(tearDownTestObjects);

    test('.ignoreAllEvents() unhooks all EventActions.', (){
      detector.ignoreAllEvents();
      emitter1.emitEvent(new TypeA());
      emitter2.emitEvent(new TypeB());
      Timer.run(expectAsync((){
        expect(eventADetectedCount, equals(0));
        expect(eventBDetectedCount, equals(0));
      }));
    });

    test('calling ignore methods doesn\'t throw errors when no events are currently being listened for.', (){
      var detector = new EventDetector();
      var emitter = new EventEmitter();
      detector.ignoreAllEvents();
      detector.ignoreAllEventsFrom(emitter);
      detector.ignoreAllEventsOfType(Object);
      expect(true, equals(true));
    });

    test('.ignoreAllEventsOfType(eventType) unhooks all EventActions of the specified type.', (){
      detector.ignoreAllEventsOfType(TypeA);
      emitter1.emitEvent(new TypeA());
      emitter2.emitEvent(new TypeB());
      Timer.run(expectAsync((){
        expect(eventADetectedCount, equals(0));
        expect(eventBDetectedCount, equals(1));
      }));
    });

    test('.ignoreAllEventsFrom(emitter) unhooks all EventActions from the specified emitter.', (){
      detector.ignoreAllEventsFrom(emitter1);
      emitter1.emitEvent(new TypeA());
      emitter2.emitEvent(new TypeB());
      Timer.run(expectAsync((){
        expect(eventADetectedCount, equals(0));
        expect(eventBDetectedCount, equals(1));
      }));
    });

    test('throws a DuplicateEventSettingError if it attempts to listen to the same emitter/event_type combination more than once.', (){
      try{
        detector.listen(emitter1, TypeA, (event){});
      }catch(error){
        expect(error is DuplicateEventSettingError, equals(true));
      }
    });

  });

}
{'fraction_non_alphanumeric': 0.13757643135075043, 'fraction_numerical': 0.008893829905503057, 'mean_word_length': 3.4487021013597032, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6700467', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1046, 'n_words': 208}