File
Blob: src/workerd/server/tests/unsafe-eval/unsafe-eval-test.js
| 1 | // Copyright (c) 2023 Cloudflare, Inc. |
| 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: |
| 3 | // https://opensource.org/licenses/Apache-2.0 |
| 4 | |
| 5 | import * as assert from 'node:assert'; |
| 6 | import { doEval } from 'test:module'; |
| 7 | |
| 8 | export const test_can_use_eval_via_proxy = { |
| 9 | async test() { |
| 10 | assert.equal(doEval(), 2); |
| 11 | }, |
| 12 | }; |
| 13 | |
| 14 | // internal modules can't be imported |
| 15 | export const test_cannot_import_unsafe_eval = { |
| 16 | async test() { |
| 17 | await assert.rejects(import('internal:unsafe-eval')); |
| 18 | }, |
| 19 | }; |