Browse Source

fix testcase to deal with non-writable require.id

pull/20/head
Sami Vaarala 11 years ago
parent
commit
3345845d0e
  1. 4
      ecmascript-testcases/test-commonjs-require-tweaked-id.js

4
ecmascript-testcases/test-commonjs-require-tweaked-id.js

@ -24,9 +24,11 @@ testModule: Error
Duktape.find = function (id) { Duktape.find = function (id) {
print('Duktape.find', id); print('Duktape.find', id);
if (id == 'testModule') { if (id == 'testModule') {
// require.id is non-writable but is configurable, so its value must
// be changed with Object.defineProperty().
return 'var mod;\n' + return 'var mod;\n' +
'exports.name = "testModule";\n' + 'exports.name = "testModule";\n' +
'require.id = "./././testModule/foo/../../test";\n' + // same as 'test' but non-canonical 'Object.defineProperty(require, "id", { value: "./././testModule/foo/../../test" });\n' + // same as 'test' but non-canonical
'mod = require("./innerRequire");\n'; 'mod = require("./innerRequire");\n';
} }
throw new Error('cannot find module'); throw new Error('cannot find module');

Loading…
Cancel
Save