<commit_before>// Copyright (c) 2011, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

#library('util_tests');

#import('dart:html');
#import('../../../testing/unittest/unittest.dart');
#import('../../../util/utilslib.dart');

main() {
  new UtilsTests().run();
}

class UtilsTests extends UnitTestSuite {

  UtilsTests() : super() {}

  void setUpTestSuite() {
    addTest(void testInsertAt() {
      List a = new List();
      CollectionUtils.insertAt(a, 0, 1);
      Expect.listEquals([1], a);

      CollectionUtils.insertAt(a, 0, 2);
      Expect.listEquals([2, 1], a);

      CollectionUtils.insertAt(a, 0, 5);
      CollectionUtils.insertAt(a, 0, 4);
      CollectionUtils.insertAt(a, 0, 3);
      Expect.listEquals([3, 4, 5, 2, 1], a);

      a = new List();
      CollectionUtils.insertAt(a, 0, 1);
      Expect.listEquals([1], a);

      CollectionUtils.insertAt(a, 1, 2);
      Expect.listEquals([1, 2], a);

      CollectionUtils.insertAt(a, 1, 3);
      CollectionUtils.insertAt(a, 3, 4);
      CollectionUtils.insertAt(a, 3, 5);
      Expect.listEquals([1, 3, 2, 5, 4], a);
    });

    addTest(void testDefaultString() {
      Expect.equals('', StringUtils.defaultString(null));
      Expect.equals('', StringUtils.defaultString(''));
      Expect.equals('test', StringUtils.defaultString('test'));
    });
  }
}<commit_msg>Clean up util tests to use new style.<commit_after>// Copyright (c) 2011, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

#library('util_tests');

#import('dart:html'); // TODO(rnystrom): Only needed to tell architecture.py
                      // that this is a web test. Come up with cleaner solution.
#import('../../../testing/unittest/unittest.dart');
#import('../../../util/utilslib.dart');

main() {
  test('insertAt', () {
    var a = [];
    CollectionUtils.insertAt(a, 0, 1);
    expect(a).equalsCollection([1]);

    CollectionUtils.insertAt(a, 0, 2);
    expect(a).equalsCollection([2, 1]);

    CollectionUtils.insertAt(a, 0, 5);
    CollectionUtils.insertAt(a, 0, 4);
    CollectionUtils.insertAt(a, 0, 3);
    expect(a).equalsCollection([3, 4, 5, 2, 1]);

    a = [];
    CollectionUtils.insertAt(a, 0, 1);
    expect(a).equalsCollection([1]);

    CollectionUtils.insertAt(a, 1, 2);
    expect(a).equalsCollection([1, 2]);

    CollectionUtils.insertAt(a, 1, 3);
    CollectionUtils.insertAt(a, 3, 4);
    CollectionUtils.insertAt(a, 3, 5);
    expect(a).equalsCollection([1, 3, 2, 5, 4]);
  });

  test('defaultString', () {
    expect(StringUtils.defaultString(null)).equals('');
    expect(StringUtils.defaultString('')).equals('');
    expect(StringUtils.defaultString('test')).equals('test');
  });
}
{'fraction_non_alphanumeric': 0.17587258556421553, 'fraction_numerical': 0.027109454422229753, 'mean_word_length': 3.3411764705882354, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1069942', 'n_tokens_mistral': 1024, 'n_tokens_neox': 935, 'n_words': 241}