<commit_before>var divRendersTo = function (test, div, html) {
  Deps.flush({_throwFirstError: true});
  var actual = canonicalizeHtml(div.innerHTML);
  test.equal(actual, html);
};

var nodesToArray = function (array) {
  // Starting in underscore 1.4, _.toArray does not work right on a node
  // list in IE8. This is a workaround to support IE8.
  return _.map(array, _.identity);
};

var clickIt = function (elem) {
  // jQuery's bubbling change event polyfill for IE 8 seems
  // to require that the element in question have focus when
  // it receives a simulated click.
  if (elem.focus)
    elem.focus();
  clickElement(elem);
};

Tinytest.add("spacebars-tests - template_tests - simple helper", function (test) {
  var tmpl = Template.spacebars_template_test_simple_helper;
  var R = ReactiveVar(1);
  tmpl.foo = function (x) {
    return x + R.get();
  };
  tmpl.bar = function () {
    return 123;
  };
  var div = renderToDiv(tmpl);

  test.equal(canonicalizeHtml(div.innerHTML), "124");
  R.set(2);
  Deps.flush();
  test.equal(canonicalizeHtml(div.innerHTML), "125");

  // Test that `{{foo bar}}` throws if `foo` is missing or not a function.
  tmpl.foo = 3;
  test.throws(function () {
    renderToDiv(tmpl);
  }, /Can't call non-function/);

  delete tmpl.foo;
  test.throws(function () {
    renderToDiv(tmpl);
  }, /No such function/);

  tmpl.foo = function () {};
  // doesn't throw
  div = renderToDiv(tmpl);
  test.equal(canonicalizeHtml(div.innerHTML), '');

  // now "foo" is a function in the data context
  delete tmpl.foo;
  R.set(1);
  div = renderToDiv(tmpl, { foo: function (x) {
    return x + R.get();
  } });
  test.equal(canonicalizeHtml(div.innerHTML), "124");
  R.set(2);
  Deps.flush();
  test.equal(canonicalizeHtml(div.innerHTML), "125");

  test.throws(function () {
    renderToDiv(tmpl, {foo: 3});<commit_msg>Prevent error in console when running tests<commit_after>var divRendersTo = function (test, div, html) {
  Deps.flush({_throwFirstError: true});
  var actual = canonicalizeHtml(div.innerHTML);
  test.equal(actual, html);
};

var nodesToArray = function (array) {
  // Starting in underscore 1.4, _.toArray does not work right on a node
  // list in IE8. This is a workaround to support IE8.
  return _.map(array, _.identity);
};

var clickIt = function (elem) {
  // jQuery's bubbling change event polyfill for IE 8 seems
  // to require that the element in question have focus when
  // it receives a simulated click.
  if (elem.focus)
    elem.focus();
  clickElement(elem);
};

Tinytest.add("spacebars-tests - template_tests - simple helper", function (test) {
  var tmpl = Template.spacebars_template_test_simple_helper;
  var R = ReactiveVar(1);
  tmpl.foo = function (x) {
    return x + R.get();
  };
  tmpl.bar = function () {
    return 123;
  };
  var div = renderToDiv(tmpl);

  test.equal(canonicalizeHtml(div.innerHTML), "124");
  R.set(2);
  Deps.flush();
  test.equal(canonicalizeHtml(div.innerHTML), "125");

  // Test that `{{foo bar}}` throws if `foo` is missing or not a function.
  tmpl.foo = 3;
  test.throws(function () {
    renderToDiv(tmpl);
  }, /Can't call non-function/);

  delete tmpl.foo;
  test.throws(function () {
    renderToDiv(tmpl);
  }, /No such function/);

  tmpl.foo = function () {};
  // doesn't throw
  div = renderToDiv(tmpl);
  test.equal(canonicalizeHtml(div.innerHTML), '');

  // now "foo" is a function in the data context
  delete tmpl.foo;

  R = ReactiveVar(1);
  div = renderToDiv(tmpl, { foo: function (x) {
    return x + R.get();
  } });
  test.equal(canonicalizeHtml(div.innerHTML), "124");
  R.set(2);
  Deps.flush();
  test.equal(canonicalizeHtml(div.innerHTML), "125");

  test.throws(function () {
    renderToDiv(tmpl, {foo: 3});
{'fraction_non_alphanumeric': 0.14953271028037382, 'fraction_numerical': 0.013885180240320427, 'mean_word_length': 3.5406060606060605, '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': '6427893', 'n_tokens_mistral': 1329, 'n_tokens_neox': 1267, 'n_words': 344}