Improve testing repair functions
MODIFY
shim/src/functions.js
shim/src/functions.js
@@ -33,8 +33,6 @@ export function repairFunctions() {
function repairFunction(name, declaration) {
let FunctionInstance;
try {
- // Use Function() because eval() has issues with serializing functions under the esm module.
- // TODO: investigate esm distortion of source code.
// eslint-disable-next-line no-new-func
FunctionInstance = (0, eval)(declaration);
} catch (e) {

MODIFY
shim/src/unsafeRec.js
shim/src/unsafeRec.js
@@ -77,9 +77,7 @@ function strip(src) {
src = src.replace(/\(0,[^)]+\)/g, '(0, eval)');
// Remove code coverage.
- if (typeof __coverage__ !== 'undefined') {
src = src.replace(/cov_[^+]+\+\+[;,]/g, '');
- }
/* END_TESTS_ONLY */
return src;

MODIFY
shim/test/realm/functions.js
shim/test/realm/functions.js
import test from 'tape';
import { repairFunctions } from '../../src/functions';
-/* eslint-disable no-restricted-properties, no-underscore-dangle */
-
repairFunctions();
test('Function.prototype.constructor', t => {
- t.plan(3);
+ t.plan(4);
+
+ // eslint-disable-next-line no-new-func
+ t.doesNotThrow(() => Function(''));
// eslint-disable-next-line no-proto
t.throws(() => Error.__proto__.constructor(''), TypeError);

Improve testing repair functions