diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2023-02-17 23:58:52 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-17 23:58:52 +0900 |
commit | a01af067d79e78ea8e2c21cf0ef92d86d425f8eb (patch) | |
tree | b6345e86f04b61effd2be9b5dfd8c48507de7d65 /cli/tests/node_compat/test/parallel/test-assert-fail.js | |
parent | 1a7666a6ca63b3dc6872d8f4631a2799af534159 (diff) |
test: add node compat tests (#17805)
Diffstat (limited to 'cli/tests/node_compat/test/parallel/test-assert-fail.js')
-rw-r--r-- | cli/tests/node_compat/test/parallel/test-assert-fail.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/cli/tests/node_compat/test/parallel/test-assert-fail.js b/cli/tests/node_compat/test/parallel/test-assert-fail.js new file mode 100644 index 000000000..2aad9766d --- /dev/null +++ b/cli/tests/node_compat/test/parallel/test-assert-fail.js @@ -0,0 +1,51 @@ +// deno-fmt-ignore-file +// deno-lint-ignore-file + +// Copyright Joyent and Node contributors. All rights reserved. MIT license. +// Taken from Node 18.12.1 +// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually + +'use strict'; + +const common = require('../common'); +const assert = require('assert'); + +// No args +assert.throws( + () => { assert.fail(); }, + { + code: 'ERR_ASSERTION', + name: 'AssertionError', + message: 'Failed', + operator: 'fail', + actual: undefined, + expected: undefined, + generatedMessage: true, + stack: /Failed/ + } +); + +// One arg = message +assert.throws(() => { + assert.fail('custom message'); +}, { + code: 'ERR_ASSERTION', + name: 'AssertionError', + message: 'custom message', + operator: 'fail', + actual: undefined, + expected: undefined, + generatedMessage: false +}); + +// One arg = Error +assert.throws(() => { + assert.fail(new TypeError('custom message')); +}, { + name: 'TypeError', + message: 'custom message' +}); + +Object.prototype.get = common.mustNotCall(); +assert.throws(() => assert.fail(''), { code: 'ERR_ASSERTION' }); +delete Object.prototype.get; |