<commit_before>#import "assertions.js";
#import "lang-ext.js";

extend(UIATableView.prototype, {
  /**
   * A shortcut for:
   *  this.cells().firstWithName(name)
   */
  cellNamed: function (name) {
    return this.cells().firstWithName(name);
  },

  /**
   * Asserts that this table has a cell with the name (accessibility label)
   * matching the given +name+ argument.
   */
  assertCellNamed: function (name) {
    assertNotNull(this.cellNamed(name), "No table cell found named '" + name + "'");
  }
});

var isNotNil = function () {
  var ret = undefined !== this && null != this && this.toString() != "[object UIAElementNil]";
  return ret;
};

extend(UIAElementArray.prototype, {
  /**
   * Same as withName, but takes a regular expression
   */
  withNameRegex: function(pattern) {
    var ret = [];
    for (var i = 0; i < this.length; ++i) {
      var elem = this[i];
      if (elem.isNotNil() && elem.name().match(pattern) !== null) {
        ret.push(elem);
      }
    }
    return ret;
  },

  /**
   * Same as firstWithName, but takes a regular expression
   */
  firstWithNameRegex: function(pattern) {
    for (var i = 0; i < this.length; ++i) {
      var elem = this[i];
      if (elem.isNotNil() && elem.name().match(pattern) !== null) return elem;
    }
    return new UIAElementNil();<commit_msg>Add check for non-UIAElement objects<commit_after>#import "assertions.js";
#import "lang-ext.js";

extend(UIATableView.prototype, {
  /**
   * A shortcut for:
   *  this.cells().firstWithName(name)
   */
  cellNamed: function (name) {
    return this.cells().firstWithName(name);
  },

  /**
   * Asserts that this table has a cell with the name (accessibility label)
   * matching the given +name+ argument.
   */
  assertCellNamed: function (name) {
    assertNotNull(this.cellNamed(name), "No table cell found named '" + name + "'");
  }
});

var isNotNil = function () {
  var ret = undefined !== this && null != this && this.toString() != "[object UIAElementNil]";
  return ret;
};

extend(UIAElementArray.prototype, {
  /**
   * Same as withName, but takes a regular expression
   */
  withNameRegex: function(pattern) {
    var ret = [];
    for (var i = 0; i < this.length; ++i) {
      var elem = this[i];
      if (elem.isNotNil && elem.isNotNil() && elem.name().match(pattern) !== null) {
        ret.push(elem);
      }
    }
    return ret;
  },

  /**
   * Same as firstWithName, but takes a regular expression
   */
  firstWithNameRegex: function(pattern) {
    for (var i = 0; i < this.length; ++i) {
      var elem = this[i];
      if (elem.isNotNil && elem.isNotNil() && elem.name().match(pattern) !== null) return elem;
    }
    return new UIAElementNil();
{'fraction_non_alphanumeric': 0.15992578849721706, 'fraction_numerical': 0.001484230055658627, 'mean_word_length': 2.9647058823529413, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6095419', 'n_tokens_mistral': 891, 'n_tokens_neox': 874, 'n_words': 233}