<commit_before>import { expect } from 'chai'
import { List, Map, Set, Stack } from 'immutable'
import { Maybe, Just, Nothing } from '../../src/core/Maybe'
import { Left, Right } from '../../src/core/Either'
import { Record } from '../../src/core/Record'
import { deepEqual } from '../../src/utils/deepEqual'

describe('deepEqual', () => {

  describe('JS object', () => {
    it('should compare primitive datatype correctly (number)', () => {
      expect(deepEqual(1, 1)).to.be.true
      expect(deepEqual(1, 0)).to.be.false
    })
    it('should compare primitive datatype correctly (string)', () => {
      expect(deepEqual('foo', 'foo')).to.be.true
      expect(deepEqual('foo', 'bar')).to.be.false
    })
    it('should compare primitive datatype correctly (boolean)', () => {
      expect(deepEqual(false, false)).to.be.true
      expect(deepEqual(true, false)).to.false
    })
    it('should compare native JS object correctly', () => {
      const newJS = () => { return { a: 1, b: 'foo' }}
      expect(deepEqual(newJS(), newJS())).to.be.true
    })
  })

  describe('immutable iterable', () => {
    it('should compare collections correctly', () => {
      expect(deepEqual(List([1, 2]), List([1, 2]))).to.be.true
      expect(deepEqual(Set([1, 2]), Set([1, 2]))).to.be.true
      expect(deepEqual(Stack([1, 2]), Stack([1, 2]))).to.be.true
      expect(deepEqual(Map({ x: 'foo' }), Map({ x: 'foo' }))).to.be.true
    })
  })

  describe('Record', () => {

    class Foo extends Record {
      constructor(public x: any, public y?: any) { super() }
    }

    class Bar extends Record {
      constructor(public m: any, public n?: any) { super() }
    }

    it('should compare Record with primitive datatype correctly (number)', () => {
      expect(deepEqual(new Foo(0, 1), new Foo(0, 1))).to.be.true
      expect(deepEqual(new Foo(0, 0), new Foo(0, 1))).to.be.false
    })
    it('should compare Record with primitive datatype correctly (string)', () => {
      expect(deepEqual(new Foo('foo', 'bar'), new Foo('foo', 'bar'))).to.be.true
      expect(deepEqual(new Foo('foo', 'baz'), new Foo('foo', 'bar'))).to.be.false
    })
    it('should compare Record with primitive datatype correctly (boolean)', () => {
      expect(deepEqual(new Foo(true, false), new Foo(true, false))).to.be.true
      expect(deepEqual(new Foo(true, true), new Foo(true, false))).to.be.false
    })
    it('should compare Record with native JS object correctly', () => {
      expect(deepEqual(
        new Foo({ x: 'foo' }, { y: 'bar' }),
        new Foo({ x: 'foo' }, { y: 'bar' })
      )).to.be.true
      expect(deepEqual(
        new Foo({ x: 'foo' }, { y: 'bar' }),
        new Foo({ x: 'foo' }, { y: 'baz' })
      )).to.be.false
    })
    it('should compare Record with immutable object correctly', () => {
      expect(deepEqual(
        new Foo(List([1, 2]), Stack(['foo', 'bar'])),
        new Foo(List([1, 2]), Stack(['foo', 'bar']))
      )).to.be.true
      expect(deepEqual(
        new Foo(List([1, 2]), Stack(['foo', 'bar'])),
        new Foo(List([1, 3]), Stack(['foo', 'baz']))
      )).to.be.false
    })
    it('should compare nested Record correctly', () => {
      expect(deepEqual(new Foo(new Bar('baz')), new Foo(new Bar('baz')))).to.be.true
      expect(deepEqual(new Foo(new Bar('baz')), new Foo(new Bar('qux')))).to.be.false
    })
    it('should compare nested Record and immutable object (2 layer)', () => {
      expect(deepEqual(new Foo(List([1, 2])), new Foo(List([1, 2])))).to.be.true
      expect(deepEqual(new Foo(List([1, 2])), new Foo(List([1, 3])))).to.be.false
    })
    it('should compare nested Record and immutable object (3 layer)', () => {
      expect(deepEqual(
        new Foo(List([new Bar(1, 'foo')])),
        new Foo(List([new Bar(1, 'foo')]))
      )).to.be.true
      expect(deepEqual(<commit_msg>Adds ImmutableJS compatibility guard<commit_after>import { expect } from 'chai'
import { List, Map, Set, Stack } from 'immutable'
import { Maybe, Just, Nothing } from '../../src/core/Maybe'
import { Left, Right } from '../../src/core/Either'
import { Record } from '../../src/core/Record'
import { deepEqual } from '../../src/utils/deepEqual'

describe('deepEqual', () => {

  describe('JS object', () => {
    it('should compare primitive datatype correctly (number)', () => {
      expect(deepEqual(1, 1)).to.be.true
      expect(deepEqual(1, 0)).to.be.false
    })
    it('should compare primitive datatype correctly (string)', () => {
      expect(deepEqual('foo', 'foo')).to.be.true
      expect(deepEqual('foo', 'bar')).to.be.false
    })
    it('should compare primitive datatype correctly (boolean)', () => {
      expect(deepEqual(false, false)).to.be.true
      expect(deepEqual(true, false)).to.false
    })
    it('should compare native JS object correctly', () => {
      const newJS = () => { return { a: 1, b: 'foo' }}
      expect(deepEqual(newJS(), newJS())).to.be.true
    })
  })

  describe('immutable iterable', () => {
    it('should compare collections correctly', () => {
      expect(deepEqual(List([1, 2]), List([1, 2]))).to.be.true
      expect(deepEqual(Set([1, 2]), Set([1, 2]))).to.be.true
      expect(deepEqual(Stack([1, 2]), Stack([1, 2]))).to.be.true
      expect(deepEqual(Map({ x: 'foo' }), Map({ x: 'foo' }))).to.be.true
    })
  })

  describe('Record', () => {

    class Foo extends Record {
      constructor(public x: any, public y?: any) { super() }
    }

    class Bar extends Record {
      constructor(public m: any, public n?: any) { super() }
    }

    it('should compare Record with primitive datatype correctly (number)', () => {
      expect(deepEqual(new Foo(0, 1), new Foo(0, 1))).to.be.true
      expect(deepEqual(new Foo(0, 0), new Foo(0, 1))).to.be.false
    })
    it('should compare Record with primitive datatype correctly (string)', () => {
      expect(deepEqual(new Foo('foo', 'bar'), new Foo('foo', 'bar'))).to.be.true
      expect(deepEqual(new Foo('foo', 'baz'), new Foo('foo', 'bar'))).to.be.false
    })
    it('should compare Record with primitive datatype correctly (boolean)', () => {
      expect(deepEqual(new Foo(true, false), new Foo(true, false))).to.be.true
      expect(deepEqual(new Foo(true, true), new Foo(true, false))).to.be.false
    })
    it('should compare Record with native JS object correctly', () => {
      expect(deepEqual(
        new Foo({ x: 'foo' }, { y: 'bar' }),
        new Foo({ x: 'foo' }, { y: 'bar' })
      )).to.be.true
      expect(deepEqual(
        new Foo({ x: 'foo' }, { y: 'bar' }),
        new Foo({ x: 'foo' }, { y: 'baz' })
      )).to.be.false
    })
    it('should compare Record with immutable object correctly', () => {
      expect(deepEqual(
        new Foo(List([1, 2]), Stack(['foo', 'bar'])),
        new Foo(List([1, 2]), Stack(['foo', 'bar']))
      )).to.be.true
      expect(deepEqual(
        new Foo(List([1, 2]), Stack(['foo', 'bar'])),
        new Foo(List([1, 3]), Stack(['foo', 'baz']))
      )).to.be.false
    })
    it('should compare nested Record correctly', () => {
      expect(deepEqual(new Foo(new Bar('baz')), new Foo(new Bar('baz')))).to.be.true
      expect(deepEqual(new Foo(new Bar('baz')), new Foo(new Bar('qux')))).to.be.false
    })
    // Note: this is a guard for compatibility with ImmutableJS, if this
    //       test case failed then you should check if the comparison
    //       logic for Iterable in ImmutableJS is changed.
    it('should compare nested immutable collection of Records', () => {
      expect(deepEqual(List([new Foo(1)]), List([new Foo(1)]))).to.be.true
      expect(deepEqual(List([new Foo(1)]), List([new Foo(0)]))).to.be.false
    })
    it('should compare nested Record and immutable object (2 layer)', () => {
      expect(deepEqual(new Foo(List([1, 2])), new Foo(List([1, 2])))).to.be.true
      expect(deepEqual(new Foo(List([1, 2])), new Foo(List([1, 3])))).to.be.false
    })
    it('should compare nested Record and immutable object (3 layer)', () => {
      expect(deepEqual(
        new Foo(List([new Bar(1, 'foo')])),
        new Foo(List([new Bar(1, 'foo')]))
      )).to.be.true
      expect(deepEqual(
{'fraction_non_alphanumeric': 0.20665929475365524, 'fraction_numerical': 0.011549330384568129, 'mean_word_length': 3.0639041437843235, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 40, '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': '4124559', 'n_tokens_mistral': 2757, 'n_tokens_neox': 2611, 'n_words': 667}