-
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.
Merge branch 'master' into leotm-versioned-lockdown-bundle
- Loading branch information
Showing
19 changed files
with
848 additions
and
56 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 @@ | ||
export { getMethodNames } from './src/local.js'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* eslint-disable max-classes-per-file */ | ||
/* eslint-disable class-methods-use-this */ | ||
// eslint-disable-next-line import/order | ||
import { test } from './prepare-test-env-ava.js'; | ||
|
||
import { passStyleOf } from '@endo/pass-style'; | ||
import { M, getInterfaceGuardPayload } from '@endo/patterns'; | ||
import { makeExo, defineExoClass } from '../src/exo-makers.js'; | ||
|
||
// Based on FarSubclass1 in test-far-class-instances.js | ||
class DoublerBehaviorClass { | ||
double(x) { | ||
return x + x; | ||
} | ||
} | ||
|
||
const DoublerI = M.interface('Doubler', { | ||
double: M.call(M.lte(10)).returns(M.number()), | ||
}); | ||
|
||
const doubler = makeExo('doubler', DoublerI, DoublerBehaviorClass.prototype); | ||
|
||
test('exo doubler using js classes', t => { | ||
t.is(passStyleOf(doubler), 'remotable'); | ||
t.is(doubler.double(3), 6); | ||
t.throws(() => doubler.double('x'), { | ||
message: 'In "double" method of (doubler): arg 0: "x" - Must be <= 10', | ||
}); | ||
t.throws(() => doubler.double(), { | ||
message: | ||
'In "double" method of (doubler): Expected at least 1 arguments: []', | ||
}); | ||
t.throws(() => doubler.double(12), { | ||
message: 'In "double" method of (doubler): arg 0: 12 - Must be <= 10', | ||
}); | ||
}); | ||
|
||
// Based on FarSubclass2 in test-far-class-instances.js | ||
class DoubleAdderBehaviorClass extends DoublerBehaviorClass { | ||
doubleAddSelfCall(x) { | ||
const { | ||
state: { y }, | ||
self, | ||
} = this; | ||
return self.double(x) + y; | ||
} | ||
|
||
doubleAddSuperCall(x) { | ||
const { | ||
state: { y }, | ||
} = this; | ||
return super.double(x) + y; | ||
} | ||
} | ||
|
||
const DoubleAdderI = M.interface('DoubleAdder', { | ||
...getInterfaceGuardPayload(DoublerI).methodGuards, | ||
doubleAddSelfCall: M.call(M.number()).returns(M.number()), | ||
doubleAddSuperCall: M.call(M.number()).returns(M.number()), | ||
}); | ||
|
||
const makeDoubleAdder = defineExoClass( | ||
'doubleAdderClass', | ||
DoubleAdderI, | ||
y => ({ y }), | ||
DoubleAdderBehaviorClass.prototype, | ||
); | ||
|
||
test('exo inheritance self vs super call', t => { | ||
const da = makeDoubleAdder(5); | ||
t.is(da.doubleAddSelfCall(3), 11); | ||
t.throws(() => da.doubleAddSelfCall(12), { | ||
message: | ||
'In "double" method of (doubleAdderClass): arg 0: 12 - Must be <= 10', | ||
}); | ||
t.is(da.doubleAddSuperCall(12), 29); | ||
}); |
Oops, something went wrong.