compartment-mapper: Add program transform test
ADD
packages/compartment-mapper/test/node_modules/evaluator/evaluator.js
+/* global code */
+// eslint-disable-next-line no-eval
+export default (0, eval)(code);

ADD
packages/compartment-mapper/test/node_modules/evaluator/package.json
+{
+ "name": "evaluator",
+ "type": "module"
+}

ADD
packages/compartment-mapper/test/transform.test.js
+// import "./ses-lockdown.js";
+import "ses";
+import fs from "fs";
+import tape from "tape";
+import { loadLocation } from "../src/main.js";
+
+const { test } = tape;
+
+test("transforms applied to evaluation", async t => {
+ t.plan(1);
+
+ const fixture = new URL(
+ "node_modules/evaluator/evaluator.js",
+ import.meta.url
+ ).toString();
+ const read = async location =>
+ fs.promises.readFile(new URL(location).pathname);
+
+ const application = await loadLocation(read, fixture);
+ const { namespace } = await application.import({
+ globals: {
+ code: `"hello"`
+ },
+ transforms: [
+ function transform(source) {
+ return source.replace(/ll/g, "y");
+ }
+ ]
+ });
+ const { default: value } = namespace;
+ t.equal(value, "heyo", "code evaluated in compartment is transforemd");
+});

compartment-mapper: Add program transform test