<commit_before>class TestEvents {
  final EventHandle<String> _testEventHandle;
  
  TestEvents(): _testEventHandle = new EventHandle<String>();

  IEvent<String> get testEvent(){
    return _testEventHandle.event;
  }
  
  void fireTestEvent(String value){
    _testEventHandle.fireEvent(this, value);
  }

  static void run(){
    test('test basic event subscribe, fire, unsubscribe', () {

      var target = new TestEvents();

      String lastValue = null;
      expect(lastValue).equals(null);

      // before an event is registered, the value should still be null
      target.fireTestEvent('bar');
      expect(lastValue).equals(null);

      var handler = (String args) => lastValue = args;

      var eventId = target.testEvent.add(handler);

      // after registration, event should change value
      target.fireTestEvent('bar');
      expect(lastValue).equals('bar');

      // dispatching another event shouldn't change value
      target.fireTestEvent('foo');
      expect(lastValue).equals('foo');

      var didRemove = target.testEvent.remove(eventId);
      expect(didRemove).equals(true);

      // removing a second time should fail
      didRemove = target.testEvent.remove(eventId);
      expect(didRemove).equals(false);

      // after removing, event should not change value
      target.fireTestEvent('bar');
      expect(lastValue).equals('foo');
    });

  }
}
<commit_msg>use EventWatcher test class in test_events<commit_after>class TestEvents {
  final EventHandle<String> _testEventHandle;
  
  TestEvents(): _testEventHandle = new EventHandle<String>();

  IEvent<String> get testEvent(){
    return _testEventHandle.event;
  }
  
  void fireTestEvent(String value){
    _testEventHandle.fireEvent(this, value);
  }

  static void run(){
    test('test basic event subscribe, fire, unsubscribe', () {

      var target = new TestEvents();
      
      var watcher = new EventWatcher<String>();

      expect(watcher.lastArgs).equals(null);

      // before an event is registered, the value should still be null
      target.fireTestEvent('bar');
      expect(watcher.lastArgs).equals(null);

      var eventId = target.testEvent.add(watcher.handler);

      // after registration, event should change value
      target.fireTestEvent('bar');
      expect(watcher.lastArgs).equals('bar');

      // dispatching another event shouldn't change value
      target.fireTestEvent('foo');
      expect(watcher.lastArgs).equals('foo');

      var didRemove = target.testEvent.remove(eventId);
      expect(didRemove).equals(true);

      // removing a second time should fail
      didRemove = target.testEvent.remove(eventId);
      expect(didRemove).equals(false);

      // after removing, event should not change value
      target.fireTestEvent('bar');
      expect(watcher.lastArgs).equals('foo');
    });

  }
}

{'fraction_non_alphanumeric': 0.11832865168539326, 'fraction_numerical': 0.0, 'mean_word_length': 3.2906626506024095, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 11, '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': '2187464', 'n_tokens_mistral': 805, 'n_tokens_neox': 775, 'n_words': 192}