-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pass-style,exo): exo boundary only throws throwables
- Loading branch information
Showing
7 changed files
with
224 additions
and
27 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
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,51 @@ | ||
import test from '@endo/ses-ava/prepare-endo.js'; | ||
|
||
import { makeError } from '@endo/errors'; | ||
import { Far, isPassable } from '@endo/pass-style'; | ||
import { M } from '@endo/patterns'; | ||
import { makeExo } from '../src/exo-makers.js'; | ||
|
||
const { defineProperty } = Object; | ||
|
||
const thrower = makeExo( | ||
'Thrower', | ||
M.interface('Thrower', { | ||
throw: M.call(M.raw()).returns(M.any()), | ||
reject: M.callWhen(M.raw()).returns(M.any()), | ||
}), | ||
{ | ||
throw(val) { | ||
throw val; | ||
}, | ||
reject(val) { | ||
throw val; | ||
}, | ||
}, | ||
); | ||
|
||
test('exo only throwables', async t => { | ||
const e = makeError('test error', undefined, { | ||
sanitize: false, | ||
}); | ||
|
||
// Remotables cannot be in passable errors or throwables | ||
defineProperty(e, 'foo', { value: Far('Foo', {}) }); | ||
|
||
let caught; | ||
try { | ||
thrower.throw(e); | ||
} catch (thrown) { | ||
caught = thrown; | ||
} | ||
t.false(isPassable(e)); | ||
t.true(isPassable(caught)); | ||
t.log('throw caught', caught); | ||
|
||
try { | ||
await thrower.reject(e); | ||
} catch (thrown) { | ||
caught = thrown; | ||
} | ||
t.true(isPassable(caught)); | ||
t.log('reject caught', caught); | ||
}); |
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
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