<commit_before>import {assertEqual, I, B, K} from '../util/util.js';
import {
  any,
  anyFuture,
  anyRejectedFuture,
  anyResolvedFuture,
  constant,
  f,
  g,
  oneof,
  property,
} from '../util/props.js';
import {
  after,
  and,
  bichain,
  bimap,
  chain,
  chainRej,
  coalesce,
  go,
  map,
  mapRej,
  reject,
  rejectAfter,
  resolve,
  swap,
} from '../../index.js';

var make = oneof(constant(resolve), constant(reject));

function eq (a){
  return function (b){
    return assertEqual(a, b);
  };
}

property('swap(m) = bichain(resolve)(reject)(m)', anyFuture, function (m){
  return eq(swap(m))(bichain(resolve)(reject)(m));
});

property('reject(x) = swap(resolve(x))', any, function (x){
  return eq(reject(x))(swap(resolve(x)));
});

property('swap(reject(x)) = resolve(x)', any, function (x){
  return eq(swap(reject(x)))(resolve(x));
});

property('Resolved m => chainRej(B(mk)(f))(m) = m', make, anyResolvedFuture, function (mk, m){
  return eq(chainRej(B(mk)(f))(m))(m);
});

property('Rejected m => chainRej(B(mk)(f))(m) = chain(B(mk)(f))(swap(m))', make, anyRejectedFuture, function (mk, m){
  return eq(chainRej(B(mk)(f))(m))(chain(B(mk)(f))(swap(m)));
});

property('Resolved m => chain(B(mk)(f))(m) = chainRej(B(mk)(f))(swap(m))', make, anyResolvedFuture, function (mk, m){
  return eq(chain(B(mk)(f))(m))(chainRej(B(mk)(f))(swap(m)));
});

property('after(1)(x) = resolve(x)', any, function (n, x){
  return eq(after(1)(x))(resolve(x));
});

property('and(a)(b) = chain(K(a))(b)', anyFuture, anyFuture, function (a, b){
  return eq(and(a)(b))(chain(K(a))(b));
});

property('coalesce(f)(g)(m) = chainRej(B(resolve)(f))(map(g)(m))', anyFuture, function (m){
  return eq(coalesce(f)(g)(m))(chainRej(B(resolve)(f))(map(g)(m)));<commit_msg>Improve phasing of a property test for swap<commit_after>import {assertEqual, I, B, K} from '../util/util.js';
import {
  any,
  anyFuture,
  anyRejectedFuture,
  anyResolvedFuture,
  constant,
  f,
  g,
  oneof,
  property,
} from '../util/props.js';
import {
  after,
  and,
  bichain,
  bimap,
  chain,
  chainRej,
  coalesce,
  go,
  map,
  mapRej,
  reject,
  rejectAfter,
  resolve,
  swap,
} from '../../index.js';

var make = oneof(constant(resolve), constant(reject));

function eq (a){
  return function (b){
    return assertEqual(a, b);
  };
}

property('swap(m) = bichain(resolve)(reject)(m)', anyFuture, function (m){
  return eq(swap(m))(bichain(resolve)(reject)(m));
});

property('swap(resolve(x)) = reject(x)', any, function (x){
  return eq(swap(resolve(x)))(reject(x));
});

property('swap(reject(x)) = resolve(x)', any, function (x){
  return eq(swap(reject(x)))(resolve(x));
});

property('Resolved m => chainRej(B(mk)(f))(m) = m', make, anyResolvedFuture, function (mk, m){
  return eq(chainRej(B(mk)(f))(m))(m);
});

property('Rejected m => chainRej(B(mk)(f))(m) = chain(B(mk)(f))(swap(m))', make, anyRejectedFuture, function (mk, m){
  return eq(chainRej(B(mk)(f))(m))(chain(B(mk)(f))(swap(m)));
});

property('Resolved m => chain(B(mk)(f))(m) = chainRej(B(mk)(f))(swap(m))', make, anyResolvedFuture, function (mk, m){
  return eq(chain(B(mk)(f))(m))(chainRej(B(mk)(f))(swap(m)));
});

property('after(1)(x) = resolve(x)', any, function (n, x){
  return eq(after(1)(x))(resolve(x));
});

property('and(a)(b) = chain(K(a))(b)', anyFuture, anyFuture, function (a, b){
  return eq(and(a)(b))(chain(K(a))(b));
});

property('coalesce(f)(g)(m) = chainRej(B(resolve)(f))(map(g)(m))', anyFuture, function (m){
  return eq(coalesce(f)(g)(m))(chainRej(B(resolve)(f))(map(g)(m)));
{'fraction_non_alphanumeric': 0.24943820224719102, 'fraction_numerical': 0.0011235955056179776, 'mean_word_length': 5.928015564202335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1518823', 'n_tokens_mistral': 1472, 'n_tokens_neox': 1466, 'n_words': 260}