<commit_before>/// <reference path='../third_party/DefinitelyTyped/jasmine/jasmine.d.ts' />

module Handler {

  // Simple testing class
  class NumberSumAggregator implements Aggregator<number,string> {
    public sum :number;
    constructor(public min :number) { this.sum = 0; }
    public input = (n:number) => {
      this.sum += n;
    }
    public check = () => {
      if (this.sum < this.min) { return null; }
      var result = 'SUM_AT_OUTPUT:' + this.sum.toString();
      this.sum = 0;
      return result;
    }
  }

  describe('Handler Queue', function() {
    var queue :Queue<string, number>;
    var ncallbacks :number;
    function lenHandler(s:string) : number { return s.length; };
    function promiseLenHandler(s:string) : Promise<number> {
      return new Promise<number>((F,R) => {
        setTimeout(F(s.length), 1);
      });
    }

    beforeEach(() => {
      queue = new Queue<string, number>();
      ncallbacks = 0;
    });

    it('New queue has no events (length = 0)', function() {
      expect(queue.getLength()).toBe(0);
    });

    it('3 events makes length = 3', function() {
      queue.handle('A');
      queue.handle('BB');
      queue.handle('CCC');
      expect(queue.getLength()).toBe(3);
    });

    it('3 events and then clearing makes length = 0', function() {<commit_msg>removed unneeded type param<commit_after>/// <reference path='../third_party/DefinitelyTyped/jasmine/jasmine.d.ts' />

module Handler {

  // Simple testing class
  class NumberSumAggregator implements Aggregator<number,string> {
    public sum :number;
    constructor(public min :number) { this.sum = 0; }
    public input = (n:number) => {
      this.sum += n;
    }
    public check = () => {
      if (this.sum < this.min) { return null; }
      var result = 'SUM_AT_OUTPUT:' + this.sum.toString();
      this.sum = 0;
      return result;
    }
  }

  describe('Handler Queue', function() {
    var queue :Queue<string, number>;
    var ncallbacks :number;
    function lenHandler(s:string) : number { return s.length; };
    function promiseLenHandler(s:string) : Promise<number> {
      return new Promise((F,R) => {
        setTimeout(F(s.length), 1);
      });
    }

    beforeEach(() => {
      queue = new Queue<string, number>();
      ncallbacks = 0;
    });

    it('New queue has no events (length = 0)', function() {
      expect(queue.getLength()).toBe(0);
    });

    it('3 events makes length = 3', function() {
      queue.handle('A');
      queue.handle('BB');
      queue.handle('CCC');
      expect(queue.getLength()).toBe(3);
    });

    it('3 events and then clearing makes length = 0', function() {
{'fraction_non_alphanumeric': 0.16150943396226414, 'fraction_numerical': 0.00830188679245283, 'mean_word_length': 2.7338028169014086, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 22, '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': '1266576', 'n_tokens_mistral': 849, 'n_tokens_neox': 818, 'n_words': 199}