-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1320 from Agoric/mfig/bundle-source-errors
fix(bundle-source): fix comment misparse, make require optional
- Loading branch information
Showing
9 changed files
with
109 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* global success */ | ||
// */ [not executed] | ||
success(); |
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,4 @@ | ||
/* global success */ | ||
// /* | ||
success(); | ||
// */ |
File renamed without changes.
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 @@ | ||
import 'fs'; |
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,85 @@ | ||
/* global Compartment */ | ||
import '@agoric/install-ses'; | ||
import { test } from 'tape-promise/tape'; | ||
import bundleSource from '..'; | ||
|
||
function evaluate(src, endowments) { | ||
const c = new Compartment(endowments, {}, {}); | ||
return c.evaluate(src); | ||
} | ||
|
||
test('trailing comment', async t => { | ||
try { | ||
const { source: src1 } = await bundleSource( | ||
`${__dirname}/../demo/comments/trailing-comment.js`, | ||
'nestedEvaluate', | ||
); | ||
|
||
const nestedEvaluate = src => { | ||
// console.log('========== evaluating', src); | ||
return evaluate(src, { nestedEvaluate }); | ||
}; | ||
// console.log(src1); | ||
const srcMap1 = `(${src1})`; | ||
const ex1 = nestedEvaluate(srcMap1)(); | ||
|
||
// console.log(err.stack); | ||
t.equals( | ||
typeof ex1.buildRootObject, | ||
'function', | ||
`buildRootObject is exported`, | ||
); | ||
} catch (e) { | ||
t.isNot(e, e, 'unexpected exception'); | ||
} finally { | ||
t.end(); | ||
} | ||
}); | ||
|
||
test('comment block opener', async t => { | ||
try { | ||
t.plan(1); | ||
const { source: src1 } = await bundleSource( | ||
`${__dirname}/../demo/comments/block-opener.js`, | ||
'nestedEvaluate', | ||
); | ||
|
||
const success = () => t.pass('body runs correctly'); | ||
|
||
const nestedEvaluate = src => { | ||
// console.log('========== evaluating', src); | ||
return evaluate(src, { nestedEvaluate, success }); | ||
}; | ||
// console.log(src1); | ||
const srcMap1 = `(${src1})`; | ||
nestedEvaluate(srcMap1)(); | ||
} catch (e) { | ||
t.isNot(e, e, 'unexpected exception'); | ||
} finally { | ||
t.end(); | ||
} | ||
}); | ||
|
||
test('comment block closer', async t => { | ||
try { | ||
t.plan(1); | ||
const { source: src1 } = await bundleSource( | ||
`${__dirname}/../demo/comments/block-closer.js`, | ||
'nestedEvaluate', | ||
); | ||
|
||
const success = () => t.pass('body runs correctly'); | ||
|
||
const nestedEvaluate = src => { | ||
// console.log('========== evaluating', src); | ||
return evaluate(src, { nestedEvaluate, success }); | ||
}; | ||
// console.log(src1); | ||
const srcMap1 = `(${src1})`; | ||
nestedEvaluate(srcMap1)(); | ||
} catch (e) { | ||
t.isNot(e, e, 'unexpected exception'); | ||
} finally { | ||
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