Skip to content

Commit

Permalink
fixup! review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Mar 8, 2024
1 parent 3359608 commit 2b4f0ce
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 66 deletions.
30 changes: 0 additions & 30 deletions packages/eventual-send/test/test-deep-send-ses-ava.js

This file was deleted.

27 changes: 18 additions & 9 deletions packages/eventual-send/test/test-deep-send.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,30 @@ import { E } from './get-hp.js';
const { freeze } = Object;

const carol = freeze({
bar: () => assert.fail('Wut?'),
// Throw an error with redacted contents (here, a string and a number).
bar: label => assert.Fail`[${assert.quote(label)}] ${'blue'} is not ${42}`,
});

const bob = freeze({
foo: carolP => E(carolP).bar(),
foo: (label, carolP) => E(carolP).bar(label),
});

const alice = freeze({
test: () => E(bob).foo(carol),
test: label => E(bob).foo(label, carol),
});

test('deep-stacks E', t => {
const q = alice.test();
return q.catch(reason => {
t.assert(reason instanceof Error);
console.log('expected failure', reason);
});
const testDeepStacksE = test.macro({
title: (title, loggerDescription, _getLogger) =>
`deep-stacks E with ${loggerDescription}${title ? ` (${title})` : ''}`,
exec: (t, loggerDescription, getLogger) => {
const p = alice.test(loggerDescription);
return p.catch(reason => {
t.true(reason instanceof Error);
const log = getLogger(t);
log('expected failure', reason);
});
},
});

test(testDeepStacksE, 'console.log', _t => console.log.bind(console));
test(testDeepStacksE, 'ses-ava t.log', t => t.log.bind(t));
18 changes: 0 additions & 18 deletions packages/eventual-send/test/test-deep-stacks-ses-ava.js

This file was deleted.

26 changes: 17 additions & 9 deletions packages/eventual-send/test/test-deep-stacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@ import { test } from './prepare-test-env-ava.js';

import { E } from './get-hp.js';

test('deep-stacks when', t => {
let r;
const p = new Promise(res => (r = res));
const q = E.when(p, v1 => E.when(v1 + 1, v2 => assert.equal(v2, 22)));
r(33);
return q.catch(reason => {
t.assert(reason instanceof Error);
console.log('expected failure', reason);
});
const testDeepStacksWhen = test.macro({
title: (title, loggerDescription, _getLogger) =>
`deep-stacks E.when with ${loggerDescription}${title ? ` (${title})` : ''}`,
exec: (t, _loggerDescription, getLogger) => {
let r;
const p = new Promise(res => (r = res));
const q = E.when(p, v1 => E.when(v1 + 1, v2 => assert.equal(v2, 22)));
r(33);
return q.catch(reason => {
t.assert(reason instanceof Error);
const log = getLogger(t);
log('expected failure', reason);
});
},
});

test(testDeepStacksWhen, 'console.log', _t => console.log.bind(console));
test(testDeepStacksWhen, 'ses-ava t.log', t => t.log.bind(t));

0 comments on commit 2b4f0ce

Please sign in to comment.