-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ses): Add ModuleStaticRecord (#279)
- Loading branch information
Showing
8 changed files
with
133 additions
and
4 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
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 |
---|---|---|
|
@@ -94,6 +94,7 @@ const globalIntrinsicNames = [ | |
|
||
'globalThis', | ||
'Compartment', | ||
'ModuleStaticRecord', | ||
'harden', | ||
]; | ||
|
||
|
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,56 @@ | ||
import tap from 'tap'; | ||
import { ModuleStaticRecord } from '../src/main.js'; | ||
|
||
const { test } = tap; | ||
|
||
test('module static record constructor', t => { | ||
const msr = new ModuleStaticRecord(` | ||
import foo from 'import-default-export-from-me.js'; | ||
import oof from 'import-default-export-from-me.js'; | ||
import * as bar from 'import-all-from-me.js'; | ||
import { fizz, buzz } from 'import-named-exports-from-me.js'; | ||
import { color as colour } from 'import-named-export-and-rename.js'; | ||
export let quuux = null; | ||
export { qux } from 'import-and-reexport-name-from-me.js'; | ||
export * from 'import-and-export-all.js'; | ||
export default 42; | ||
export const quux = 'Hello, World!'; | ||
// Late binding of an exported variable. | ||
quuux = 'Hello, World!'; | ||
`); | ||
|
||
t.equal( | ||
'[object ModuleStaticRecord]', | ||
msr.toString(), | ||
'instance string representation should be fixed', | ||
); | ||
t.equal( | ||
'function ModuleStaticRecord() { [shim code] }', | ||
ModuleStaticRecord.toString(), | ||
'constructor string representation should be fixed', | ||
); | ||
|
||
t.deepEquals( | ||
msr.imports, | ||
[ | ||
'import-all-from-me.js', | ||
'import-and-export-all.js', | ||
'import-and-reexport-name-from-me.js', | ||
'import-default-export-from-me.js', | ||
'import-named-export-and-rename.js', | ||
'import-named-exports-from-me.js', | ||
], | ||
'should capture sorted unique imports', | ||
); | ||
|
||
t.ok(Object.isFrozen(msr), 'ModuleStaticRecords should be frozen'); | ||
t.ok( | ||
Object.isFrozen(msr.imports), | ||
'ModuleStaticRecord imports should be frozen', | ||
); | ||
|
||
t.end(); | ||
}); |
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