<commit_before>import fs from 'fs';
import {parse, transform, traverse} from 'babel-core';

if (process.env.NODE_WATCH) {
  var typecheck = require('../src').default;
}
else if (process.env.TYPECHECK_USE_LIBCHECKED) {
  var typecheck = require('../lib-checked').default;
}
else {
  var typecheck = require('../lib').default;
}

describe('Typecheck', function () {
  ok('class-annotation', class Thing {});
  failWith(`Value of argument "input" violates contract, expected Class got boolean`, 'class-annotation', false);
  ok('bug-83-spread-object', {a: 1, b: 2, c: 3});
  ok('bug-82-too-much-inference');
  ok('bug-xxx-assignment-expression');
  ok('bug-78-not-type-checked-array');
  ok('bug-76-cannot-read-property-name-of-undefined');
  ok('bug-71-cannot-iterate-void');
  ok('iterable', [1, 2, 3]);
  failWith(`Value of variable "item" violates contract, expected number got string`, 'iterable', ['a', 'b', 'c']);
  failStatic('bad-iterable', [1, 2, 3]);
  failStatic('bad-iterable-type', 123);

  ok('bug-68-return-string-literal');
  ok('indexers', foo => null);
  ok('object-pattern', {a: 'foo', b: 34});
  ok('object-pattern-complex', {a: 'foo', b: 34, d: {e: 'bar', g: false, a: 123}});
  ok('generators', 'foo');
  failWith(`Function "gen"  yielded an invalid value, expected number | string got boolean`, 'generators', false);
  ok('generators-with-next', 12);
  failWith(`Generator "gen" received an invalid next value, expected number got string`, 'generators-with-next', 'foo');
  failWith(`Generator "gen" received an invalid next value, expected number got boolean`, 'generators-with-next', false);
  failStatic('bad-generators', 'foo');<commit_msg>add conditional test for spec compliant arrow functions<commit_after>import fs from 'fs';
import {parse, transform, traverse} from 'babel-core';

if (process.env.NODE_WATCH) {
  var typecheck = require('../src').default;
}
else if (process.env.TYPECHECK_USE_LIBCHECKED) {
  var typecheck = require('../lib-checked').default;
}
else {
  var typecheck = require('../lib').default;
}

describe('Typecheck', function () {
  ok('class-annotation', class Thing {});
  failWith(`Value of argument "input" violates contract, expected Class got boolean`, 'class-annotation', false);

  if (!(() => true).prototype) {
    failWith(`Value of argument "input" violates contract, expected Class got function`, 'class-annotation', () => true);
  }
  else {
    // environment does not support spec compliant arrow functions.
    it.skip(`Value of argument "input" violates contract, expected Class got function`);
  }

  ok('bug-83-spread-object', {a: 1, b: 2, c: 3});
  ok('bug-82-too-much-inference');
  ok('bug-xxx-assignment-expression');
  ok('bug-78-not-type-checked-array');
  ok('bug-76-cannot-read-property-name-of-undefined');
  ok('bug-71-cannot-iterate-void');
  ok('iterable', [1, 2, 3]);
  failWith(`Value of variable "item" violates contract, expected number got string`, 'iterable', ['a', 'b', 'c']);
  failStatic('bad-iterable', [1, 2, 3]);
  failStatic('bad-iterable-type', 123);

  ok('bug-68-return-string-literal');
  ok('indexers', foo => null);
  ok('object-pattern', {a: 'foo', b: 34});
  ok('object-pattern-complex', {a: 'foo', b: 34, d: {e: 'bar', g: false, a: 123}});
  ok('generators', 'foo');
  failWith(`Function "gen"  yielded an invalid value, expected number | string got boolean`, 'generators', false);
  ok('generators-with-next', 12);
  failWith(`Generator "gen" received an invalid next value, expected number got string`, 'generators-with-next', 'foo');
  failWith(`Generator "gen" received an invalid next value, expected number got boolean`, 'generators-with-next', false);
  failStatic('bad-generators', 'foo');
{'fraction_non_alphanumeric': 0.18876586551444774, 'fraction_numerical': 0.017823386443424252, 'mean_word_length': 4.916932907348243, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1945154', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1185, 'n_words': 327}