<commit_before>import {
  assertThat, equalTo, not,
} from 'hamjest';

describe('The matcher `equalTo()`, matches equality', () => {
  describe('for simple types', () => {
    it('`null`', () =>
      assertThat(null, equalTo(null)));
    it('`undefined`', () =>
      assertThat(undefined, equalTo(undefined)));

    it('a (integer) number', () =>
      assertThat(1, equalTo(1)));
    it('a (decimal) number', () =>
      assertThat(1.23, equalTo(1.23)));
    it('a number and a `Number(x)`', () =>
      assertThat(1, equalTo(Number(1))));

    it('a string', () =>
      assertThat('a string', equalTo('a string')));
    it('a string and a String(x)', () =>
      assertThat('a string', equalTo(String('a string'))));

    it('`NaN`', () =>
      assertThat(NaN, equalTo(NaN)));
  });
  describe('for complex types', () => {
    it('empty []', () =>
      assertThat([], equalTo([])));
    it('empty Array()', () =>
      assertThat(new Array(3), equalTo([undefined, undefined, undefined])));
    it('empty {}', () =>
      assertThat({}, equalTo({})));
    it('empty Object()', () =>
      assertThat(new Object(), equalTo({})));
    it('function', () => {
      const fn = () => {};
      assertThat(fn, equalTo(fn));
    });
    it('class', () => {
      class X {}
      assertThat(X, equalTo(X));
    });
    it('the same instance of a class', () => {
      class X {}
      const instance = new X();
      assertThat(instance, equalTo(instance));
    });
    it('another instance of a class (will fail with `strictlyEqualTo()`)', () => {
      class X {}
      const instance = new X();
      assertThat(instance, equalTo(new X()));
    });
  });
  describe('and does a deep compare', () => {
    it('of an array', () =>
      assertThat([1, 2, 3], equalTo([1, 2, 3])));
    it('fails for differing arrays', () =>
      assertThat([1, 'two', 3], not(equalTo([1, 2, 3]))));
    it('of an object', () =>
      assertThat({attr: 'value'}, equalTo({attr: 'value'})));
    it('fails for differing objects', () =>
      assertThat({no: ''}, not(equalTo({attr: 'value'}))));
  });
});
<commit_msg>Make the `equalTo()` test cases so that they better compare better to `strictlyEqualTo`.<commit_after>import {
  assertThat, equalTo, not,
} from 'hamjest';

describe('The matcher `equalTo()`, matches equality', () => {
  describe('for simple types', () => {
    it('`null`', () =>
      assertThat(null, equalTo(null)));
    it('`undefined`', () =>
      assertThat(undefined, equalTo(undefined)));

    it('a (integer) number', () =>
      assertThat(1, equalTo(1)));
    it('a (decimal) number', () =>
      assertThat(1.23, equalTo(1.23)));
    it('a number and a `Number(x)`', () =>
      assertThat(1, equalTo(Number(1))));

    it('a string', () =>
      assertThat('a string', equalTo('a string')));
    it('a string and a String(x)', () =>
      assertThat('a string', equalTo(String('a string'))));

    it('`NaN`', () =>
      assertThat(NaN, equalTo(NaN)));
  });
  describe('for complex types', () => {
    it('empty []', () =>
      assertThat([], equalTo([])));
    it('empty Array()', () =>
      assertThat(new Array(3), equalTo([undefined, undefined, undefined])));
    it('empty {}', () =>
      assertThat({}, equalTo({})));
    it('empty Object()', () =>
      assertThat(new Object(), equalTo({})));
    it('function', () => {
      const fn = () => {};
      assertThat(fn, equalTo(fn));
    });
    it('class', () => {
      class X {}
      assertThat(X, equalTo(X));
    });
    it('the same instance of a class', () => {
      class X {}
      const instance = new X();
      assertThat(instance, equalTo(instance));
    });
    it('another instance of a class (will fail with `strictlyEqualTo()`)', () => {
      class X {}
      const instance = new X();
      assertThat(instance, equalTo(new X()));
    });
  });
  describe('deep compares', () => {
    describe('two different arrays', () => {
      it('successfully, WHEN both have the same values', () =>
        assertThat([1, 2, 3], equalTo([1, 2, 3])));
      it('NOT successfully, WHEN the values differ', () =>
        assertThat(['x', 'y', 'z'], not(equalTo([1, 2, 3]))));
    });
    it('successfully, WHEN it`s the same array', () => {
      const arr = [1, 2, 3];
      assertThat(arr, equalTo(arr))
    });

    describe('two different objects', () => {
      it('successfully, WHEN both have the same values', () =>
        assertThat({attr: 'value'}, equalTo({attr: 'value'})));
      it('NOT successfully, WHEN the values differ', () =>
        assertThat({one: 'two'}, not(equalTo({attr: 'value'}))));
    });
    it('successfully, WHEN it`s the same object', () => {
      const obj = {attr: 'value'};
      assertThat(obj, equalTo(obj))
    });
  });
});

{'fraction_non_alphanumeric': 0.23096339924274295, 'fraction_numerical': 0.009465713083718973, 'mean_word_length': 3.1097666378565254, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 57, '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': '5440341', 'n_tokens_mistral': 1499, 'n_tokens_neox': 1503, 'n_words': 365}