<commit_before>/**
 * maryamyriameliamurphies.js
 * A library of Haskell-style morphisms ported to ES2015 JavaScript.
 *
 * test/ord-test.js
 *
 * @file Tests for Ord type class.
 * @license ISC
 */

/* global describe, it */

import {
  EQ,
  LT,
  GT,
  compare,
  lessThan,
  lessThanOrEqual,
  greaterThan,
  greaterThanOrEqual,
  max,
  min,
  just,
  tuple,
  list
} from '../source';

describe(`Ord type class`, function() {
  const a = 1;
  const b = 2;
  const c = 2;
  const d = 2;
  const mb1 = just(1);
  const mb2 = just(2);
  const tup1 = tuple(1,2);
  const tup2 = tuple(2,1);
  const lst1 = list(1,2,3);
  const lst2 = list(3,2,1);
  describe(`compare()`, function() {
    it(`should return the Ordering of two values if they are the same type`, function() {
      compare(a, b).should.equal(LT);
      compare(b, a).should.equal(GT);
      compare(b, c).should.equal(EQ);
      compare(mb1, mb2).should.equal(LT);
      compare(mb2, mb1).should.equal(GT);
      compare(mb1, just(1)).should.equal(EQ);
      compare(tup1, tup2).should.equal(LT);
      compare(tup2, tup1).should.equal(GT);
      compare(tup1, tuple(1,2)).should.equal(EQ);
      compare(lst1, lst2).should.equal(LT);
      compare(lst2, lst1).should.equal(GT);
      compare(lst1, list(1,2,3)).should.equal(EQ);
    });
    it(`should throw a type error if two tuples are not the same type`, function() {
      compare.bind(null, c, `text`).should.throw();
    });
  });
  describe(`lessThan()`, function() {
    it(`should return true if the first argument is less than the second argument`, function() {
      lessThan(a, b).should.be.true;
      lessThan(mb1, mb2).should.be.true;
      lessThan(tup1, tup2).should.be.true;
      lessThan(lst1, lst2).should.be.true;
    });
    it(`should return false if the first argument is not less than the second argument`, function() {
      lessThan(c, d).should.be.false;
      lessThan(b, a).should.be.false;
      lessThan(mb2, mb1).should.be.false;
      lessThan(tup2, tup1).should.be.false;
      lessThan(lst2, lst1).should.be.false;
    });
  });
  describe(`lessThanOrEqual()`, function() {
    it(`should return true if the first argument is less than or equal to the second argument`, function() {
      lessThanOrEqual(a, b).should.be.true;
      lessThanOrEqual(c, d).should.be.true;
      lessThanOrEqual(mb1, mb2).should.be.true;
      lessThanOrEqual(mb1, just(1)).should.be.true;
      lessThanOrEqual(tup1, tup2).should.be.true;<commit_msg>Add a test for ternary tuples to make coverage of Tuple 100%<commit_after>/**
 * maryamyriameliamurphies.js
 * A library of Haskell-style morphisms ported to ES2015 JavaScript.
 *
 * test/ord-test.js
 *
 * @file Tests for Ord type class.
 * @license ISC
 */

/* global describe, it */

import {
  EQ,
  LT,
  GT,
  compare,
  lessThan,
  lessThanOrEqual,
  greaterThan,
  greaterThanOrEqual,
  max,
  min,
  just,
  tuple,
  list
} from '../source';

describe(`Ord type class`, function() {
  const a = 1;
  const b = 2;
  const c = 2;
  const d = 2;
  const mb1 = just(1);
  const mb2 = just(2);
  const tup1 = tuple(1,2);
  const tup2 = tuple(2,1);
  const tup3 = tuple(2,2,1);
  const tup4 = tuple(2,2,2);
  const lst1 = list(1,2,3);
  const lst2 = list(3,2,1);
  describe(`compare()`, function() {
    it(`should return the Ordering of two values if they are the same type`, function() {
      compare(a, b).should.equal(LT);
      compare(b, a).should.equal(GT);
      compare(b, c).should.equal(EQ);
      compare(mb1, mb2).should.equal(LT);
      compare(mb2, mb1).should.equal(GT);
      compare(mb1, just(1)).should.equal(EQ);
      compare(tup1, tup2).should.equal(LT);
      compare(tup2, tup1).should.equal(GT);
      compare(tup3, tup4).should.equal(LT);
      compare(tup4, tup3).should.equal(GT);
      compare(tup1, tuple(1,2)).should.equal(EQ);
      compare(lst1, lst2).should.equal(LT);
      compare(lst2, lst1).should.equal(GT);
      compare(lst1, list(1,2,3)).should.equal(EQ);
    });
    it(`should throw a type error if two tuples are not the same type`, function() {
      compare.bind(null, c, `text`).should.throw();
    });
  });
  describe(`lessThan()`, function() {
    it(`should return true if the first argument is less than the second argument`, function() {
      lessThan(a, b).should.be.true;
      lessThan(mb1, mb2).should.be.true;
      lessThan(tup1, tup2).should.be.true;
      lessThan(lst1, lst2).should.be.true;
    });
    it(`should return false if the first argument is not less than the second argument`, function() {
      lessThan(c, d).should.be.false;
      lessThan(b, a).should.be.false;
      lessThan(mb2, mb1).should.be.false;
      lessThan(tup2, tup1).should.be.false;
      lessThan(lst2, lst1).should.be.false;
    });
  });
  describe(`lessThanOrEqual()`, function() {
    it(`should return true if the first argument is less than or equal to the second argument`, function() {
      lessThanOrEqual(a, b).should.be.true;
      lessThanOrEqual(c, d).should.be.true;
      lessThanOrEqual(mb1, mb2).should.be.true;
      lessThanOrEqual(mb1, just(1)).should.be.true;
      lessThanOrEqual(tup1, tup2).should.be.true;
{'fraction_non_alphanumeric': 0.1569576156377008, 'fraction_numerical': 0.028062705631894717, 'mean_word_length': 3.208469055374593, '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': '4963776', 'n_tokens_mistral': 1896, 'n_tokens_neox': 1864, 'n_words': 436}