-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(ses-ava): use causal console (#2109)
- Loading branch information
Showing
14 changed files
with
484 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,26 @@ | ||
// This file does not start with "test-" because it is useful as an | ||
// This file is not really useful as an | ||
// automated test. Rather, its purpose is just to run it to see what a | ||
// deep stack looks like. | ||
|
||
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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Avoid importing from @endo/errors to avoid more dependence cycles | ||
const { error: makeError, details: X, quote: q } = assert; | ||
|
||
const { freeze } = Object; | ||
|
||
export const exampleProblem = label => { | ||
const subError = makeError(X`nested ${q(label)} ${'REDACTED'}`); | ||
|
||
return makeError(X`${q(label)} ${'NOTICE ME'} nest ${subError}`); | ||
}; | ||
freeze(exampleProblem); |
Oops, something went wrong.