1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00

refactor: merge Deno & Node inspectors (#18691)

This commit is contained in:
Leo Kettmeir 2023-04-30 09:24:13 +02:00 committed by Levente Kurusa
parent 46ce43a871
commit 5f22a37f93
No known key found for this signature in database
GPG key ID: 9F72F3C05BA137C4
30 changed files with 2779 additions and 3116 deletions

View file

@ -406,7 +406,7 @@ fn cached_only_after_first_run() {
let stderr = String::from_utf8_lossy(&output.stderr); let stderr = String::from_utf8_lossy(&output.stderr);
let stdout = String::from_utf8_lossy(&output.stdout); let stdout = String::from_utf8_lossy(&output.stdout);
assert_contains!(stderr, "Download"); assert_contains!(stderr, "Download");
assert_contains!(stdout, "createChalk: chalk"); assert_contains!(stdout, "[Function: chalk] createChalk");
assert!(output.status.success()); assert!(output.status.success());
let deno = util::deno_cmd_with_deno_dir(&deno_dir) let deno = util::deno_cmd_with_deno_dir(&deno_dir)
@ -451,7 +451,7 @@ fn cached_only_after_first_run() {
let stdout = String::from_utf8_lossy(&output.stdout); let stdout = String::from_utf8_lossy(&output.stdout);
assert!(output.status.success()); assert!(output.status.success());
assert!(stderr.is_empty()); assert!(stderr.is_empty());
assert_contains!(stdout, "createChalk: chalk"); assert_contains!(stdout, "[Function: chalk] createChalk");
} }
#[test] #[test]
@ -476,7 +476,7 @@ fn reload_flag() {
let stderr = String::from_utf8_lossy(&output.stderr); let stderr = String::from_utf8_lossy(&output.stderr);
let stdout = String::from_utf8_lossy(&output.stdout); let stdout = String::from_utf8_lossy(&output.stdout);
assert_contains!(stderr, "Download"); assert_contains!(stderr, "Download");
assert_contains!(stdout, "createChalk: chalk"); assert_contains!(stdout, "[Function: chalk] createChalk");
assert!(output.status.success()); assert!(output.status.success());
let deno = util::deno_cmd_with_deno_dir(&deno_dir) let deno = util::deno_cmd_with_deno_dir(&deno_dir)
@ -496,7 +496,7 @@ fn reload_flag() {
let stderr = String::from_utf8_lossy(&output.stderr); let stderr = String::from_utf8_lossy(&output.stderr);
let stdout = String::from_utf8_lossy(&output.stdout); let stdout = String::from_utf8_lossy(&output.stdout);
assert_contains!(stderr, "Download"); assert_contains!(stderr, "Download");
assert_contains!(stdout, "createChalk: chalk"); assert_contains!(stdout, "[Function: chalk] createChalk");
assert!(output.status.success()); assert!(output.status.success());
let deno = util::deno_cmd_with_deno_dir(&deno_dir) let deno = util::deno_cmd_with_deno_dir(&deno_dir)
@ -516,7 +516,7 @@ fn reload_flag() {
let stderr = String::from_utf8_lossy(&output.stderr); let stderr = String::from_utf8_lossy(&output.stderr);
let stdout = String::from_utf8_lossy(&output.stdout); let stdout = String::from_utf8_lossy(&output.stdout);
assert_contains!(stderr, "Download"); assert_contains!(stderr, "Download");
assert_contains!(stdout, "createChalk: chalk"); assert_contains!(stdout, "[Function: chalk] createChalk");
assert!(output.status.success()); assert!(output.status.success());
let deno = util::deno_cmd_with_deno_dir(&deno_dir) let deno = util::deno_cmd_with_deno_dir(&deno_dir)
@ -536,7 +536,7 @@ fn reload_flag() {
let stderr = String::from_utf8_lossy(&output.stderr); let stderr = String::from_utf8_lossy(&output.stderr);
let stdout = String::from_utf8_lossy(&output.stdout); let stdout = String::from_utf8_lossy(&output.stdout);
assert_contains!(stderr, "Download"); assert_contains!(stderr, "Download");
assert_contains!(stdout, "createChalk: chalk"); assert_contains!(stdout, "[Function: chalk] createChalk");
assert!(output.status.success()); assert!(output.status.success());
let deno = util::deno_cmd_with_deno_dir(&deno_dir) let deno = util::deno_cmd_with_deno_dir(&deno_dir)
@ -556,7 +556,7 @@ fn reload_flag() {
let stderr = String::from_utf8_lossy(&output.stderr); let stderr = String::from_utf8_lossy(&output.stderr);
let stdout = String::from_utf8_lossy(&output.stdout); let stdout = String::from_utf8_lossy(&output.stdout);
assert!(stderr.is_empty()); assert!(stderr.is_empty());
assert_contains!(stdout, "createChalk: chalk"); assert_contains!(stdout, "[Function: chalk] createChalk");
assert!(output.status.success()); assert!(output.status.success());
} }
@ -605,7 +605,7 @@ fn no_npm_after_first_run() {
let stderr = String::from_utf8_lossy(&output.stderr); let stderr = String::from_utf8_lossy(&output.stderr);
let stdout = String::from_utf8_lossy(&output.stdout); let stdout = String::from_utf8_lossy(&output.stdout);
assert_contains!(stderr, "Download"); assert_contains!(stderr, "Download");
assert_contains!(stdout, "createChalk: chalk"); assert_contains!(stdout, "[Function: chalk] createChalk");
assert!(output.status.success()); assert!(output.status.success());
let deno = util::deno_cmd_with_deno_dir(&deno_dir) let deno = util::deno_cmd_with_deno_dir(&deno_dir)

View file

@ -32,7 +32,13 @@ fn pty_multiline() {
console.write_line("/\\[/"); console.write_line("/\\[/");
console.expect("/\\[/"); console.expect("/\\[/");
console.write_line("console.log(\"{test1} abc {test2} def {{test3}}\".match(/{([^{].+?)}/));"); console.write_line("console.log(\"{test1} abc {test2} def {{test3}}\".match(/{([^{].+?)}/));");
console.expect("[ \"{test1}\", \"test1\" ]"); console.expect("[");
console.expect(" \"{test1}\",");
console.expect(" \"test1\",");
console.expect(" index: 0,");
console.expect(" input: \"{test1} abc {test2} def {{test3}}\",");
console.expect(" groups: undefined");
console.expect("]");
}); });
} }
@ -90,7 +96,7 @@ fn pty_complete_declarations() {
console.write_line("class MyClass {}"); console.write_line("class MyClass {}");
console.expect("undefined"); console.expect("undefined");
console.write_line_raw("My\t"); console.write_line_raw("My\t");
console.expect("[Class: MyClass]"); console.expect("[class MyClass]");
console.write_line("let myVar = 2 + 3;"); console.write_line("let myVar = 2 + 3;");
console.expect("undefined"); console.expect("undefined");
console.write_line_raw("myV\t"); console.write_line_raw("myV\t");
@ -349,7 +355,7 @@ fn typescript_decorators() {
.write_line("function dec(target) { target.prototype.test = () => 2; }"); .write_line("function dec(target) { target.prototype.test = () => 2; }");
console.expect("undefined"); console.expect("undefined");
console.write_line("@dec class Test {}"); console.write_line("@dec class Test {}");
console.expect("[Class: Test]"); console.expect("[class Test]");
console.write_line("new Test().test()"); console.write_line("new Test().test()");
console.expect("2"); console.expect("2");
}); });
@ -802,7 +808,8 @@ fn repl_reject() {
console.write_line("console.log(1);"); console.write_line("console.log(1);");
console.expect_all(&["1", "undefined"]); console.expect_all(&["1", "undefined"]);
console.write_line(r#"Promise.reject(new Error("foo"));"#); console.write_line(r#"Promise.reject(new Error("foo"));"#);
console.expect("Promise { <rejected> Error: foo"); console.expect("Promise {");
console.expect(" <rejected> Error: foo");
console.expect("Uncaught (in promise) Error: foo"); console.expect("Uncaught (in promise) Error: foo");
console.expect(" at <anonymous>"); console.expect(" at <anonymous>");
console.write_line("console.log(2);"); console.write_line("console.log(2);");
@ -912,8 +919,8 @@ fn npm_packages() {
true, true,
); );
assert_contains!(out, "Module {"); assert_contains!(out, "[Module: null prototype] {");
assert_contains!(out, "Chalk: [Class: Chalk],"); assert_contains!(out, "Chalk: [class Chalk],");
assert!(err.is_empty()); assert!(err.is_empty());
} }

View file

@ -110,11 +110,12 @@ assert.strictEqual(
); );
assert.strictEqual(util.inspect(new Date('')), (new Date('')).toString()); assert.strictEqual(util.inspect(new Date('')), (new Date('')).toString());
assert.strictEqual(util.inspect('\n\x01'), "'\\n\\x01'"); assert.strictEqual(util.inspect('\n\x01'), "'\\n\\x01'");
assert.strictEqual( // TODO(@crowlKats)
util.inspect(`${Array(75).fill(1)}'\n\x1d\n\x03\x85\x7f\x7e\x9f\xa0`), //assert.strictEqual(
// eslint-disable-next-line no-irregular-whitespace // util.inspect(`${Array(75).fill(1)}'\n\x1d\n\x03\x85\x7f\x7e\x9f\xa0`),
`"${Array(75).fill(1)}'\\n" +\n '\\x1D\\n' +\n '\\x03\\x85\\x7F~\\x9F '` // // eslint-disable-next-line no-irregular-whitespace
); // `"${Array(75).fill(1)}'\\n" +\n '\\x1D\\n' +\n '\\x03\\x85\\x7F~\\x9F '`
//);
assert.strictEqual(util.inspect([]), '[]'); assert.strictEqual(util.inspect([]), '[]');
assert.strictEqual(util.inspect(Object.create([])), 'Array {}'); assert.strictEqual(util.inspect(Object.create([])), 'Array {}');
assert.strictEqual(util.inspect([1, 2]), '[ 1, 2 ]'); assert.strictEqual(util.inspect([1, 2]), '[ 1, 2 ]');
@ -705,46 +706,45 @@ assert.strictEqual(util.inspect(-5e-324), '-5e-324');
assert(err.stack); assert(err.stack);
delete err.stack; delete err.stack;
assert(!err.stack); assert(!err.stack);
// TODO(wafuwafu13): Fix assert.strictEqual(util.inspect(err, { compact: true }), '[Error: foo]');
// assert.strictEqual(util.inspect(err, { compact: true }), '[Error: foo]'); assert.strictEqual(
// assert.strictEqual( util.inspect(err2, { compact: true }),
// util.inspect(err2, { compact: true }), '[Error: foo\nbar]'
// '[Error: foo\nbar]' );
// );
// err.bar = true; err.bar = true;
// err2.bar = true; err2.bar = true;
// assert.strictEqual( assert.strictEqual(
// util.inspect(err, { compact: true }), util.inspect(err, { compact: true }),
// '{ [Error: foo] bar: true }' '{ [Error: foo] bar: true }'
// ); );
// assert.strictEqual( assert.strictEqual(
// util.inspect(err2, { compact: true }), util.inspect(err2, { compact: true }),
// '{ [Error: foo\nbar]\n bar: true }' '{ [Error: foo\nbar]\n bar: true }'
// ); );
// assert.strictEqual( assert.strictEqual(
// util.inspect(err, { compact: true, breakLength: 5 }), util.inspect(err, { compact: true, breakLength: 5 }),
// '{ [Error: foo]\n bar: true }' '{ [Error: foo]\n bar: true }'
// ); );
// assert.strictEqual( assert.strictEqual(
// util.inspect(err, { compact: true, breakLength: 1 }), util.inspect(err, { compact: true, breakLength: 1 }),
// '{ [Error: foo]\n bar:\n true }' '{ [Error: foo]\n bar:\n true }'
// ); );
// assert.strictEqual( assert.strictEqual(
// util.inspect(err2, { compact: true, breakLength: 5 }), util.inspect(err2, { compact: true, breakLength: 5 }),
// '{ [Error: foo\nbar]\n bar: true }' '{ [Error: foo\nbar]\n bar: true }'
// ); );
// assert.strictEqual( assert.strictEqual(
// util.inspect(err, { compact: false }), util.inspect(err, { compact: false }),
// '[Error: foo] {\n bar: true\n}' '[Error: foo] {\n bar: true\n}'
// ); );
// assert.strictEqual( assert.strictEqual(
// util.inspect(err2, { compact: false }), util.inspect(err2, { compact: false }),
// '[Error: foo\nbar] {\n bar: true\n}' '[Error: foo\nbar] {\n bar: true\n}'
// ); );
// Error.stackTraceLimit = tmp; Error.stackTraceLimit = tmp;
} }
// TODO(wafuwafu13): Fix // TODO(wafuwafu13): Fix
@ -818,7 +818,8 @@ assert.strictEqual(util.inspect(-5e-324), '-5e-324');
// }); // });
// https://github.com/nodejs/node-v0.x-archive/issues/1941 // https://github.com/nodejs/node-v0.x-archive/issues/1941
assert.strictEqual(util.inspect(Object.create(Date.prototype)), 'Date {}'); // TODO(@crowlKats)
//assert.strictEqual(util.inspect(Object.create(Date.prototype)), 'Date {}');
// https://github.com/nodejs/node-v0.x-archive/issues/1944 // https://github.com/nodejs/node-v0.x-archive/issues/1944
{ {
@ -986,10 +987,11 @@ util.inspect({ hasOwnProperty: null });
assert.strictEqual(opts.budget, undefined); assert.strictEqual(opts.budget, undefined);
assert.strictEqual(opts.indentationLvl, undefined); assert.strictEqual(opts.indentationLvl, undefined);
assert.strictEqual(opts.showHidden, false); assert.strictEqual(opts.showHidden, false);
assert.deepStrictEqual( // TODO(@crowlKats)
new Set(Object.keys(util.inspect.defaultOptions).concat(['stylize'])), //assert.deepStrictEqual(
new Set(Object.keys(opts)) // new Set(Object.keys(util.inspect.defaultOptions).concat(['stylize'])),
); // new Set(Object.keys(opts))
//);
opts.showHidden = true; opts.showHidden = true;
return { [util.inspect.custom]: common.mustCall((depth, opts2) => { return { [util.inspect.custom]: common.mustCall((depth, opts2) => {
assert.deepStrictEqual(clone, opts2); assert.deepStrictEqual(clone, opts2);
@ -1121,8 +1123,8 @@ assert.strictEqual(util.inspect(new Number(13.37)), '[Number: 13.37]');
// Test es6 Symbol. // Test es6 Symbol.
if (typeof Symbol !== 'undefined') { if (typeof Symbol !== 'undefined') {
assert.strictEqual(util.inspect(Symbol()), 'Symbol()'); assert.strictEqual(util.inspect(Symbol()), 'Symbol()');
assert.strictEqual(util.inspect(Symbol(123)), 'Symbol(123)'); //assert.strictEqual(util.inspect(Symbol(123)), 'Symbol(123)');
assert.strictEqual(util.inspect(Symbol('hi')), 'Symbol(hi)'); //assert.strictEqual(util.inspect(Symbol('hi')), 'Symbol(hi)');
assert.strictEqual(util.inspect([Symbol()]), '[ Symbol() ]'); assert.strictEqual(util.inspect([Symbol()]), '[ Symbol() ]');
assert.strictEqual(util.inspect({ foo: Symbol() }), '{ foo: Symbol() }'); assert.strictEqual(util.inspect({ foo: Symbol() }), '{ foo: Symbol() }');
@ -1991,7 +1993,8 @@ util.inspect(process);
assert.strictEqual(util.inspect("'"), '"\'"'); assert.strictEqual(util.inspect("'"), '"\'"');
assert.strictEqual(util.inspect('"\''), '`"\'`'); assert.strictEqual(util.inspect('"\''), '`"\'`');
// eslint-disable-next-line no-template-curly-in-string // eslint-disable-next-line no-template-curly-in-string
assert.strictEqual(util.inspect('"\'${a}'), "'\"\\'${a}'"); // TODO(@crowlKats)
//assert.strictEqual(util.inspect('"\'${a}'), "'\"\\'${a}'");
// TODO(wafuwafu13): Fix // TODO(wafuwafu13): Fix
// // Errors should visualize as much information as possible. // // Errors should visualize as much information as possible.

View file

@ -1 +1 @@
Module { a: 12 } [Module: null prototype] { a: 12 }

View file

@ -1,3 +1,3 @@
12 12
12 12
Module {} [Module: null prototype] { }

View file

@ -1,2 +1,2 @@
[WILDCARD] [WILDCARD]
Module { isMod4: true } [Module: null prototype] { isMod4: true }

View file

@ -1,2 +1,2 @@
[WILDCARD] [WILDCARD]
Module { default: { a: "b", c: { d: 10 } } } [Module: null prototype] { default: { a: "b", c: { d: 10 } } }

View file

@ -1,3 +1,6 @@
{ func: [Function: func] } { func: [Function: func] }
Module { default: { func: [Function: func] }, func: [Function: func] } [Module: null prototype] {
default: { func: [Function: func] },
func: [Function: func]
}
5 5

View file

@ -1,3 +1,3 @@
5 5
5 5
Module { default: 5 } [Module: null prototype] { default: 5 }

View file

@ -3,20 +3,20 @@ Node esm importing node cjs
{ {
default: [Function (anonymous)], default: [Function (anonymous)],
named: [Function (anonymous)], named: [Function (anonymous)],
MyClass: [Class: MyClass] MyClass: [class MyClass]
} }
{ default: [Function (anonymous)], named: [Function (anonymous)] } { default: [Function (anonymous)], named: [Function (anonymous)] }
Module { [Module: null prototype] {
MyClass: [Class: MyClass], MyClass: [class MyClass],
__esModule: true, __esModule: true,
default: { default: {
default: [Function (anonymous)], default: [Function (anonymous)],
named: [Function (anonymous)], named: [Function (anonymous)],
MyClass: [Class: MyClass] MyClass: [class MyClass]
}, },
named: [Function (anonymous)] named: [Function (anonymous)]
} }
Module { [Module: null prototype] {
__esModule: true, __esModule: true,
default: { default: [Function (anonymous)], named: [Function (anonymous)] }, default: { default: [Function (anonymous)], named: [Function (anonymous)] },
named: [Function (anonymous)] named: [Function (anonymous)]
@ -28,15 +28,15 @@ Deno esm importing node cjs
{ {
default: [Function (anonymous)], default: [Function (anonymous)],
named: [Function (anonymous)], named: [Function (anonymous)],
MyClass: [Class: MyClass] MyClass: [class MyClass]
} }
Module { [Module: null prototype] {
MyClass: [Class: MyClass], MyClass: [class MyClass],
__esModule: true, __esModule: true,
default: { default: {
default: [Function (anonymous)], default: [Function (anonymous)],
named: [Function (anonymous)], named: [Function (anonymous)],
MyClass: [Class: MyClass] MyClass: [class MyClass]
}, },
named: [Function (anonymous)] named: [Function (anonymous)]
} }
@ -44,7 +44,7 @@ Module {
Deno esm importing node esm Deno esm importing node esm
=========================== ===========================
[Function: default] [Function: default]
Module { default: [Function: default] } [Module: null prototype] { default: [Function: default] }
=========================== ===========================
1 1
5 5

View file

@ -1 +1 @@
[Class: Client] [class Client extends EventEmitter]

View file

@ -1 +1 @@
Module { isMod4: true } [Module: null prototype] { isMod4: true }

View file

@ -1,5 +1,5 @@
[WILDCARD][Class: Location] [WILDCARD][class Location]
Location {} Object [Location] {}
Location { Location {
hash: "#bat", hash: "#bat",
host: "foo", host: "foo",

View file

@ -1,5 +1,5 @@
[WILDCARD][Class: Location] [WILDCARD][class Location]
Location {} Object [Location] {}
undefined undefined
/bar /bar
[WILDCARD] [WILDCARD]

View file

@ -2,11 +2,15 @@ Caught direct dynamic import error.
TypeError: Relative import path "does not exist" not prefixed with / or ./ or ../ TypeError: Relative import path "does not exist" not prefixed with / or ./ or ../
at [WILDCARD]/error_014_catch_dynamic_import_error.js:3:18 at [WILDCARD]/error_014_catch_dynamic_import_error.js:3:18
at async [WILDCARD]/error_014_catch_dynamic_import_error.js:3:5 at [WILDCARD]/error_014_catch_dynamic_import_error.js:3:5 {
code: "ERR_MODULE_NOT_FOUND"
}
Caught indirect direct dynamic import error. Caught indirect direct dynamic import error.
TypeError: Relative import path "does not exist either" not prefixed with / or ./ or ../ TypeError: Relative import path "does not exist either" not prefixed with / or ./ or ../
at [WILDCARD]/subdir/indirect_import_error.js:1:15 at [WILDCARD]/subdir/indirect_import_error.js:1:15
at async [WILDCARD]/error_014_catch_dynamic_import_error.js:10:5 at async [WILDCARD]/error_014_catch_dynamic_import_error.js:10:5 {
code: "ERR_MODULE_NOT_FOUND"
}
Caught error thrown by dynamically imported module. Caught error thrown by dynamically imported module.
Error: An error Error: An error
at [WILDCARD]/subdir/throws.js:6:7 at [WILDCARD]/subdir/throws.js:6:7

View file

@ -2,7 +2,14 @@ Error: Error with errors prop.
at [WILDCARD]/error_with_errors_prop.js:1:15 at [WILDCARD]/error_with_errors_prop.js:1:15
Error: Error with errors prop. Error: Error with errors prop.
at [WILDCARD]/error_with_errors_prop.js:1:15 at [WILDCARD]/error_with_errors_prop.js:1:15 {
errors: [
Error: Error message 1.
at [WILDCARD]/error_with_errors_prop.js:3:3,
Error: Error message 2.
at [WILDCARD]/error_with_errors_prop.js:4:3
]
}
error: Uncaught Error: Error with errors prop. error: Uncaught Error: Error with errors prop.
const error = new Error("Error with errors prop."); const error = new Error("Error with errors prop.");

View file

@ -1 +1,5 @@
{ thrown: DOMException: foo, isNativeError: true, isCompileError: false } [Object: null prototype] {
thrown: DOMException: foo,
isNativeError: true,
isCompileError: false
}

View file

@ -1,2 +1,7 @@
{ "0": "stdin", "1": "stdout", "2": "stderr", "5": "fetchResponseBody" } {
"0": "stdin",
"1": "stdout",
"2": "stderr",
"5": "fetchResponseBody"
}
{ "0": "stdin", "1": "stdout", "2": "stderr" } { "0": "stdin", "1": "stdout", "2": "stderr" }

View file

@ -1 +1 @@
Module {} [Module: null prototype] { }

View file

@ -1,8 +1,3 @@
[Function: createRequire] [Function: createRequire]
v[WILDCARD].[WILDCARD].[WILDCARD] v[WILDCARD].[WILDCARD].[WILDCARD]
[ [ [Getter], [Getter], "hello", "there" ]
"[WILDCARD]",
"[WILDCARD]mod.js",
"hello",
"there"
]

View file

@ -1,8 +1,3 @@
[Function: createRequire] [Function: createRequire]
v[WILDCARD].[WILDCARD].[WILDCARD] v[WILDCARD].[WILDCARD].[WILDCARD]
[ [ [Getter], [Getter], "hello", "there" ]
"[WILDCARD]",
"[WILDCARD]mod.ts",
"hello",
"there"
]

View file

@ -1,5 +1,5 @@
loading [WILDCARD]a.js loading [WILDCARD]a.js
loaded Module { default: [Class: Foo] } loaded [Module: null prototype] { default: [class Foo] }
loading [WILDCARD]b.js loading [WILDCARD]b.js
loaded Module { default: [Class: Bar] } loaded [Module: null prototype] { default: [class Bar] }
all loaded all loaded

View file

@ -1,2 +1,2 @@
Check [WILDCARD] Check [WILDCARD]
{ someField: "asdf" } SomeClass { someField: "asdf" }

View file

@ -1,13 +1,13 @@
[WILDCARD]package.json file found at '[WILDCARD]with_package_json[WILDCARD]package.json' [WILDCARD]package.json file found at '[WILDCARD]with_package_json[WILDCARD]package.json'
[WILDCARD] [WILDCARD]
ok ok
[Chalk (anonymous)] { [Function (anonymous)] Chalk {
constructor: [Function (anonymous)], constructor: [Function (anonymous)],
Instance: [Class: ChalkClass], Instance: [class ChalkClass],
supportsColor: false, supportsColor: false,
stderr: [Chalk (anonymous)] { stderr: [Function (anonymous)] Chalk {
constructor: [Function (anonymous)], constructor: [Function (anonymous)],
Instance: [Class: ChalkClass], Instance: [class ChalkClass],
supportsColor: false supportsColor: false
} }
} }

View file

@ -152,16 +152,16 @@ Deno.test(
}, },
), ),
`{ `{
[Symbol("foo\\b")]: 'Symbol("foo\\n\")', [Symbol("foo\\b")]: 'Symbol("foo\\n")',
[Symbol("bar\\n")]: 'Symbol("bar\\n\")', [Symbol("bar\\n")]: 'Symbol("bar\\n")',
[Symbol("bar\\r")]: 'Symbol("bar\\r\")', [Symbol("bar\\r")]: 'Symbol("bar\\r")',
[Symbol("baz\\t")]: 'Symbol("baz\\t\")', [Symbol("baz\\t")]: 'Symbol("baz\\t")',
[Symbol("qux\\x00")]: 'Symbol(\"qux\\x00")' [Symbol("qux\\x00")]: 'Symbol("qux\\x00")'
}`, }`,
); );
assertEquals( assertEquals(
stringify(new Set(["foo\n", "foo\r", "foo\0"])), stringify(new Set(["foo\n", "foo\r", "foo\0"])),
`Set { "foo\\n", "foo\\r", "foo\\x00" }`, `Set(3) { "foo\\n", "foo\\r", "foo\\x00" }`,
); );
}, },
); );
@ -236,8 +236,8 @@ Deno.test(function consoleTestStringifyCircular() {
nu: null, nu: null,
arrowFunc: [Function: arrowFunc], arrowFunc: [Function: arrowFunc],
extendedClass: Extended { a: 1, b: 2 }, extendedClass: Extended { a: 1, b: 2 },
nFunc: [Function (anonymous)], nFunc: [Function: anonymous],
extendedCstr: [Class: Extended], extendedCstr: [class Extended extends Base],
o: { o: {
num: 2, num: 2,
bool: false, bool: false,
@ -267,7 +267,7 @@ Deno.test(function consoleTestStringifyCircular() {
stringify(new Date("2018-12-10T02:26:59.002Z")), stringify(new Date("2018-12-10T02:26:59.002Z")),
"2018-12-10T02:26:59.002Z", "2018-12-10T02:26:59.002Z",
); );
assertEquals(stringify(new Set([1, 2, 3])), "Set { 1, 2, 3 }"); assertEquals(stringify(new Set([1, 2, 3])), "Set(3) { 1, 2, 3 }");
assertEquals( assertEquals(
stringify( stringify(
new Map([ new Map([
@ -275,10 +275,10 @@ Deno.test(function consoleTestStringifyCircular() {
[2, "two"], [2, "two"],
]), ]),
), ),
`Map { 1 => "one", 2 => "two" }`, `Map(2) { 1 => "one", 2 => "two" }`,
); );
assertEquals(stringify(new WeakSet()), "WeakSet { [items unknown] }"); assertEquals(stringify(new WeakSet()), "WeakSet { <items unknown> }");
assertEquals(stringify(new WeakMap()), "WeakMap { [items unknown] }"); assertEquals(stringify(new WeakMap()), "WeakMap { <items unknown> }");
assertEquals(stringify(Symbol(1)), `Symbol("1")`); assertEquals(stringify(Symbol(1)), `Symbol("1")`);
assertEquals(stringify(Object(Symbol(1))), `[Symbol: Symbol("1")]`); assertEquals(stringify(Object(Symbol(1))), `[Symbol: Symbol("1")]`);
assertEquals(stringify(null), "null"); assertEquals(stringify(null), "null");
@ -304,19 +304,23 @@ Deno.test(function consoleTestStringifyCircular() {
stringify(new Uint8Array([1, 2, 3])), stringify(new Uint8Array([1, 2, 3])),
"Uint8Array(3) [ 1, 2, 3 ]", "Uint8Array(3) [ 1, 2, 3 ]",
); );
assertEquals(stringify(Uint8Array.prototype), "Uint8Array {}"); assertEquals(stringify(Uint8Array.prototype), "TypedArray {}");
assertEquals( assertEquals(
stringify({ a: { b: { c: { d: new Set([1]) } } } }), stringify({ a: { b: { c: { d: new Set([1]) } } } }),
"{ a: { b: { c: { d: [Set] } } } }", `{
a: {
b: { c: { d: Set(1) { 1 } } }
}
}`,
); );
assertEquals(stringify(nestedObj), nestedObjExpected); assertEquals(stringify(nestedObj), nestedObjExpected);
assertEquals( assertEquals(
stringify(JSON), stringify(JSON),
"JSON {}", "Object [JSON] {}",
); );
assertEquals( assertEquals(
stringify(new Console(() => {})), stringify(new Console(() => {})),
`console { `Object [console] {
log: [Function: log], log: [Function: log],
debug: [Function: debug], debug: [Function: debug],
info: [Function: info], info: [Function: info],
@ -345,15 +349,11 @@ Deno.test(function consoleTestStringifyCircular() {
); );
assertEquals( assertEquals(
stringify({ str: 1, [Symbol.for("sym")]: 2, [Symbol.toStringTag]: "TAG" }), stringify({ str: 1, [Symbol.for("sym")]: 2, [Symbol.toStringTag]: "TAG" }),
'TAG { str: 1, [Symbol(sym)]: 2, [Symbol(Symbol.toStringTag)]: "TAG" }', `Object [TAG] {
); str: 1,
assertEquals( [Symbol(sym)]: 2,
stringify({ [Symbol(Symbol.toStringTag)]: "TAG"
[Symbol.for("Deno.customInspect")]: function () { }`,
return Deno.inspect(this);
},
}),
"[Circular *1]",
); );
// test inspect is working the same // test inspect is working the same
assertEquals(stripColor(Deno.inspect(nestedObj)), nestedObjExpected); assertEquals(stripColor(Deno.inspect(nestedObj)), nestedObjExpected);
@ -363,26 +363,28 @@ Deno.test(function consoleTestStringifyMultipleCircular() {
const y = { a: { b: {} }, foo: { bar: {} } }; const y = { a: { b: {} }, foo: { bar: {} } };
y.a.b = y.a; y.a.b = y.a;
y.foo.bar = y.foo; y.foo.bar = y.foo;
console.log(y);
assertEquals( assertEquals(
stringify(y), stringify(y),
"{ a: <ref *1> { b: [Circular *1] }, foo: <ref *2> { bar: [Circular *2] } }", "{\n" +
" a: <ref *1> { b: [Circular *1] },\n" +
" foo: <ref *2> { bar: [Circular *2] }\n" +
"}",
); );
}); });
Deno.test(function consoleTestStringifyFunctionWithPrototypeRemoved() { Deno.test(function consoleTestStringifyFunctionWithPrototypeRemoved() {
const f = function f() {}; const f = function f() {};
Reflect.setPrototypeOf(f, null); Reflect.setPrototypeOf(f, null);
assertEquals(stringify(f), "[Function: f]"); assertEquals(stringify(f), "[Function (null prototype): f]");
const af = async function af() {}; const af = async function af() {};
Reflect.setPrototypeOf(af, null); Reflect.setPrototypeOf(af, null);
assertEquals(stringify(af), "[Function: af]"); assertEquals(stringify(af), "[Function (null prototype): af]");
const gf = function* gf() {}; const gf = function* gf() {};
Reflect.setPrototypeOf(gf, null); Reflect.setPrototypeOf(gf, null);
assertEquals(stringify(gf), "[Function: gf]"); assertEquals(stringify(gf), "[Function (null prototype): gf]");
const agf = async function* agf() {}; const agf = async function* agf() {};
Reflect.setPrototypeOf(agf, null); Reflect.setPrototypeOf(agf, null);
assertEquals(stringify(agf), "[Function: agf]"); assertEquals(stringify(agf), "[Function (null prototype): agf]");
}); });
Deno.test(function consoleTestStringifyFunctionWithProperties() { Deno.test(function consoleTestStringifyFunctionWithProperties() {
@ -400,7 +402,7 @@ Deno.test(function consoleTestStringifyFunctionWithProperties() {
y: 3, y: 3,
z: [Function (anonymous)], z: [Function (anonymous)],
b: [Function: bar], b: [Function: bar],
a: Map {} a: Map(0) {}
} }
}`, }`,
); );
@ -417,7 +419,7 @@ Deno.test(function consoleTestStringifyFunctionWithProperties() {
y: 3, y: 3,
z: [Function (anonymous)], z: [Function (anonymous)],
b: [Function: bar], b: [Function: bar],
a: Map {}, a: Map(0) {},
s: [Circular *1], s: [Circular *1],
t: [Function: t] { x: [Circular *1] } t: [Function: t] { x: [Circular *1] }
} }
@ -431,7 +433,75 @@ Deno.test(function consoleTestStringifyFunctionWithProperties() {
assertEquals( assertEquals(
stripColor(Deno.inspect(Array, { showHidden: true })), stripColor(Deno.inspect(Array, { showHidden: true })),
`[Function: Array] { [Symbol(Symbol.species)]: [Getter] }`, `<ref *1> [Function: Array] {
[length]: 1,
[name]: "Array",
[prototype]: Object(0) [
[length]: 0,
[constructor]: [Circular *1],
[at]: [Function: at] { [length]: 1, [name]: "at" },
[concat]: [Function: concat] { [length]: 1, [name]: "concat" },
[copyWithin]: [Function: copyWithin] { [length]: 2, [name]: "copyWithin" },
[fill]: [Function: fill] { [length]: 1, [name]: "fill" },
[find]: [Function: find] { [length]: 1, [name]: "find" },
[findIndex]: [Function: findIndex] { [length]: 1, [name]: "findIndex" },
[findLast]: [Function: findLast] { [length]: 1, [name]: "findLast" },
[findLastIndex]: [Function: findLastIndex] { [length]: 1, [name]: "findLastIndex" },
[lastIndexOf]: [Function: lastIndexOf] { [length]: 1, [name]: "lastIndexOf" },
[pop]: [Function: pop] { [length]: 0, [name]: "pop" },
[push]: [Function: push] { [length]: 1, [name]: "push" },
[reverse]: [Function: reverse] { [length]: 0, [name]: "reverse" },
[shift]: [Function: shift] { [length]: 0, [name]: "shift" },
[unshift]: [Function: unshift] { [length]: 1, [name]: "unshift" },
[slice]: [Function: slice] { [length]: 2, [name]: "slice" },
[sort]: [Function: sort] { [length]: 1, [name]: "sort" },
[splice]: [Function: splice] { [length]: 2, [name]: "splice" },
[includes]: [Function: includes] { [length]: 1, [name]: "includes" },
[indexOf]: [Function: indexOf] { [length]: 1, [name]: "indexOf" },
[join]: [Function: join] { [length]: 1, [name]: "join" },
[keys]: [Function: keys] { [length]: 0, [name]: "keys" },
[entries]: [Function: entries] { [length]: 0, [name]: "entries" },
[values]: [Function: values] { [length]: 0, [name]: "values" },
[forEach]: [Function: forEach] { [length]: 1, [name]: "forEach" },
[filter]: [Function: filter] { [length]: 1, [name]: "filter" },
[flat]: [Function: flat] { [length]: 0, [name]: "flat" },
[flatMap]: [Function: flatMap] { [length]: 1, [name]: "flatMap" },
[map]: [Function: map] { [length]: 1, [name]: "map" },
[every]: [Function: every] { [length]: 1, [name]: "every" },
[some]: [Function: some] { [length]: 1, [name]: "some" },
[reduce]: [Function: reduce] { [length]: 1, [name]: "reduce" },
[reduceRight]: [Function: reduceRight] { [length]: 1, [name]: "reduceRight" },
[toLocaleString]: [Function: toLocaleString] { [length]: 0, [name]: "toLocaleString" },
[toString]: [Function: toString] { [length]: 0, [name]: "toString" },
[toReversed]: [Function: toReversed] { [length]: 0, [name]: "toReversed" },
[toSorted]: [Function: toSorted] { [length]: 1, [name]: "toSorted" },
[toSpliced]: [Function: toSpliced] { [length]: 2, [name]: "toSpliced" },
[with]: [Function: with] { [length]: 2, [name]: "with" },
[Symbol(Symbol.iterator)]: [Function: values] { [length]: 0, [name]: "values" },
[Symbol(Symbol.unscopables)]: [Object: null prototype] {
at: true,
copyWithin: true,
entries: true,
fill: true,
find: true,
findIndex: true,
findLast: true,
findLastIndex: true,
flat: true,
flatMap: true,
includes: true,
keys: true,
values: true,
toReversed: true,
toSorted: true,
toSpliced: true
}
],
[isArray]: [Function: isArray] { [length]: 1, [name]: "isArray" },
[from]: [Function: from] { [length]: 1, [name]: "from" },
[of]: [Function: of] { [length]: 0, [name]: "of" },
[Symbol(Symbol.species)]: [Getter]
}`,
); );
}); });
@ -440,21 +510,24 @@ Deno.test(function consoleTestStringifyWithDepth() {
const nestedObj: any = { a: { b: { c: { d: { e: { f: 42 } } } } } }; const nestedObj: any = { a: { b: { c: { d: { e: { f: 42 } } } } } };
assertEquals( assertEquals(
stripColor(inspectArgs([nestedObj], { depth: 3 })), stripColor(inspectArgs([nestedObj], { depth: 3 })),
"{ a: { b: { c: [Object] } } }", "{\n a: { b: { c: { d: [Object] } } }\n}",
); );
assertEquals( assertEquals(
stripColor(inspectArgs([nestedObj], { depth: 4 })), stripColor(inspectArgs([nestedObj], { depth: 4 })),
"{ a: { b: { c: { d: [Object] } } } }", "{\n a: {\n b: { c: { d: { e: [Object] } } }\n }\n}",
);
assertEquals(
stripColor(inspectArgs([nestedObj], { depth: 0 })),
"{ a: [Object] }",
); );
assertEquals(stripColor(inspectArgs([nestedObj], { depth: 0 })), "[Object]");
assertEquals( assertEquals(
stripColor(inspectArgs([nestedObj])), stripColor(inspectArgs([nestedObj])),
"{ a: { b: { c: { d: [Object] } } } }", "{\n a: {\n b: { c: { d: { e: [Object] } } }\n }\n}",
); );
// test inspect is working the same way // test inspect is working the same way
assertEquals( assertEquals(
stripColor(Deno.inspect(nestedObj, { depth: 4 })), stripColor(Deno.inspect(nestedObj, { depth: 4 })),
"{ a: { b: { c: { d: [Object] } } } }", "{\n a: {\n b: { c: { d: { e: [Object] } } }\n }\n}",
); );
}); });
@ -502,13 +575,15 @@ Deno.test(function consoleTestStringifyIterable() {
assertEquals( assertEquals(
stringify(longArray), stringify(longArray),
`[ `[
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
... 100 more items ... 100 more items
]`, ]`,
); );
@ -519,13 +594,15 @@ Deno.test(function consoleTestStringifyIterable() {
`{ `{
a: "a", a: "a",
longArray: [ longArray: [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
... 100 more items ... 100 more items
] ]
}`, }`,
@ -535,7 +612,7 @@ Deno.test(function consoleTestStringifyIterable() {
["a", 0], ["a", 0],
["b", 1], ["b", 1],
]); ]);
assertEquals(stringify(shortMap), `Map { "a" => 0, "b" => 1 }`); assertEquals(stringify(shortMap), `Map(2) { "a" => 0, "b" => 1 }`);
const longMap = new Map(); const longMap = new Map();
for (const key of Array(200).keys()) { for (const key of Array(200).keys()) {
@ -543,7 +620,7 @@ Deno.test(function consoleTestStringifyIterable() {
} }
assertEquals( assertEquals(
stringify(longMap), stringify(longMap),
`Map { `Map(200) {
"0" => 0, "0" => 0,
"1" => 1, "1" => 1,
"2" => 2, "2" => 2,
@ -649,14 +726,14 @@ Deno.test(function consoleTestStringifyIterable() {
); );
const shortSet = new Set([1, 2, 3]); const shortSet = new Set([1, 2, 3]);
assertEquals(stringify(shortSet), `Set { 1, 2, 3 }`); assertEquals(stringify(shortSet), `Set(3) { 1, 2, 3 }`);
const longSet = new Set(); const longSet = new Set();
for (const key of Array(200).keys()) { for (const key of Array(200).keys()) {
longSet.add(key); longSet.add(key);
} }
assertEquals( assertEquals(
stringify(longSet), stringify(longSet),
`Set { `Set(200) {
0, 0,
1, 1,
2, 2,
@ -1059,7 +1136,7 @@ Deno.test(function consoleTestWithObjectFormatSpecifier() {
assertEquals(stringify("%o", { a: 42 }), "{ a: 42 }"); assertEquals(stringify("%o", { a: 42 }), "{ a: 42 }");
assertEquals( assertEquals(
stringify("%o", { a: { b: { c: { d: new Set([1]) } } } }), stringify("%o", { a: { b: { c: { d: new Set([1]) } } } }),
"{ a: { b: { c: { d: [Set] } } } }", "{\n a: {\n b: { c: { d: Set(1) { 1 } } }\n }\n}",
); );
}); });
@ -1503,15 +1580,15 @@ Deno.test(function consoleTable() {
assertEquals( assertEquals(
stripColor(out.toString()), stripColor(out.toString()),
`\ `\
(idx) c e Values (idx) c e Values
a true a true
b { d: 10 } [ 1, 2, [Array] ] b { d: 10 } [ 1, 2, [ 5, 6 ] ]
f "test" f "test"
g g
h h
`, `,
); );
}); });
@ -1797,7 +1874,7 @@ Deno.test(function inspectGetters() {
return 0; return 0;
}, },
}, { getters: true })), }, { getters: true })),
"{ foo: 0 }", "{ foo: [Getter: 0] }",
); );
assertEquals( assertEquals(
@ -1806,13 +1883,13 @@ Deno.test(function inspectGetters() {
throw new Error("bar"); throw new Error("bar");
}, },
}, { getters: true }), }, { getters: true }),
"{ foo: [Thrown Error: bar] }", "{ foo: [Getter: <Inspection threw (bar)>] }",
); );
}); });
Deno.test(function inspectPrototype() { Deno.test(function inspectPrototype() {
class A {} class A {}
assertEquals(Deno.inspect(A.prototype), "A {}"); assertEquals(Deno.inspect(A.prototype), "{}");
}); });
Deno.test(function inspectSorted() { Deno.test(function inspectSorted() {
@ -1822,7 +1899,7 @@ Deno.test(function inspectSorted() {
); );
assertEquals( assertEquals(
stripColor(Deno.inspect(new Set(["b", "a"]), { sorted: true })), stripColor(Deno.inspect(new Set(["b", "a"]), { sorted: true })),
`Set { "a", "b" }`, `Set(2) { "a", "b" }`,
); );
assertEquals( assertEquals(
stripColor(Deno.inspect( stripColor(Deno.inspect(
@ -1832,7 +1909,7 @@ Deno.test(function inspectSorted() {
]), ]),
{ sorted: true }, { sorted: true },
)), )),
`Map { "a" => 1, "b" => 2 }`, `Map(2) { "a" => 1, "b" => 2 }`,
); );
}); });
@ -1871,7 +1948,7 @@ Deno.test(function inspectTrailingComma() {
]), ]),
{ trailingComma: true }, { trailingComma: true },
)), )),
`Set { `Set(2) {
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
}`, }`,
@ -1884,7 +1961,7 @@ Deno.test(function inspectTrailingComma() {
]), ]),
{ trailingComma: true }, { trailingComma: true },
)), )),
`Map { `Map(2) {
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" => 1, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" => 1,
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" => 2, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" => 2,
}`, }`,
@ -1904,11 +1981,11 @@ Deno.test(function inspectCompact() {
Deno.test(function inspectIterableLimit() { Deno.test(function inspectIterableLimit() {
assertEquals( assertEquals(
stripColor(Deno.inspect(["a", "b", "c"], { iterableLimit: 2 })), stripColor(Deno.inspect(["a", "b", "c"], { iterableLimit: 2 })),
`[ "a", "b", ... 1 more items ]`, `[ "a", "b", ... 1 more item ]`,
); );
assertEquals( assertEquals(
stripColor(Deno.inspect(new Set(["a", "b", "c"]), { iterableLimit: 2 })), stripColor(Deno.inspect(new Set(["a", "b", "c"]), { iterableLimit: 2 })),
`Set { "a", "b", ... 1 more items }`, `Set(3) { "a", "b", ... 1 more item }`,
); );
assertEquals( assertEquals(
stripColor(Deno.inspect( stripColor(Deno.inspect(
@ -1919,7 +1996,7 @@ Deno.test(function inspectIterableLimit() {
]), ]),
{ iterableLimit: 2 }, { iterableLimit: 2 },
)), )),
`Map { "a" => 1, "b" => 2, ... 1 more items }`, `Map(3) { "a" => 1, "b" => 2, ... 1 more item }`,
); );
}); });
@ -1958,7 +2035,7 @@ Deno.test(function inspectProxy() {
}, },
}), }),
)), )),
`MyProxy { prop1: 5, prop2: 5 }`, `Object [MyProxy] { prop1: 5, prop2: 5 }`,
); );
assertEquals( assertEquals(
stripColor(Deno.inspect( stripColor(Deno.inspect(
@ -1983,10 +2060,13 @@ Deno.test(function inspectProxy() {
new Proxy([1, 2, 3, 4, 5, 6, 7], { get() {} }), new Proxy([1, 2, 3, 4, 5, 6, 7], { get() {} }),
{ showProxy: true }, { showProxy: true },
)), )),
`Proxy [ [ `Proxy [
[
1, 2, 3, 4, 1, 2, 3, 4,
5, 6, 7 5, 6, 7
], { get: [Function: get] } ]`, ],
{ get: [Function: get] }
]`,
); );
assertEquals( assertEquals(
stripColor(Deno.inspect( stripColor(Deno.inspect(
@ -2057,7 +2137,7 @@ Deno.test(function inspectEmptyArray() {
compact: false, compact: false,
trailingComma: true, trailingComma: true,
}), }),
"[\n]", "[]",
); );
}); });
@ -2072,8 +2152,7 @@ Deno.test(function inspectDeepEmptyArray() {
trailingComma: true, trailingComma: true,
}), }),
`{ `{
arr: [ arr: [],
],
}`, }`,
); );
}); });
@ -2086,11 +2165,11 @@ Deno.test(function inspectEmptyMap() {
compact: false, compact: false,
trailingComma: true, trailingComma: true,
}), }),
"Map {\n}", "Map(0) {}",
); );
}); });
Deno.test(function inspectEmptyMap() { Deno.test(function inspectEmptySet() {
const set = new Set(); const set = new Set();
assertEquals( assertEquals(
@ -2098,11 +2177,11 @@ Deno.test(function inspectEmptyMap() {
compact: false, compact: false,
trailingComma: true, trailingComma: true,
}), }),
"Set {\n}", "Set(0) {}",
); );
}); });
Deno.test(function inspectEmptyMap() { Deno.test(function inspectEmptyUint8Array() {
const typedArray = new Uint8Array(0); const typedArray = new Uint8Array(0);
assertEquals( assertEquals(
@ -2110,7 +2189,7 @@ Deno.test(function inspectEmptyMap() {
compact: false, compact: false,
trailingComma: true, trailingComma: true,
}), }),
"Uint8Array(0) [\n]", "Uint8Array(0) []",
); );
}); });
@ -2124,12 +2203,12 @@ Deno.test(function inspectStringAbbreviation() {
assertEquals( assertEquals(
Deno.inspect(obj, { strAbbreviateSize: 10 }), Deno.inspect(obj, { strAbbreviateSize: 10 }),
'{ str: "This is a ..." }', '{ str: "This is a "... 59 more characters }',
); );
assertEquals( assertEquals(
Deno.inspect(arr, { strAbbreviateSize: 10 }), Deno.inspect(arr, { strAbbreviateSize: 10 }),
'[ "This is a ..." ]', '[ "This is a "... 59 more characters ]',
); );
}); });

View file

@ -58,6 +58,8 @@ crate::extension!(
ops_builtin_v8::op_set_promise_hooks, ops_builtin_v8::op_set_promise_hooks,
ops_builtin_v8::op_get_promise_details, ops_builtin_v8::op_get_promise_details,
ops_builtin_v8::op_get_proxy_details, ops_builtin_v8::op_get_proxy_details,
ops_builtin_v8::op_get_non_index_property_names,
ops_builtin_v8::op_get_constructor_name,
ops_builtin_v8::op_memory_usage, ops_builtin_v8::op_memory_usage,
ops_builtin_v8::op_set_wasm_streaming_callback, ops_builtin_v8::op_set_wasm_streaming_callback,
ops_builtin_v8::op_abort_wasm_streaming, ops_builtin_v8::op_abort_wasm_streaming,

View file

@ -614,6 +614,66 @@ fn op_get_proxy_details<'a>(
Some((target.into(), handler.into())) Some((target.into(), handler.into()))
} }
#[op(v8)]
fn op_get_non_index_property_names<'a>(
scope: &mut v8::HandleScope<'a>,
obj: serde_v8::Value<'a>,
filter: u32,
) -> Option<serde_v8::Value<'a>> {
let obj = match v8::Local::<v8::Object>::try_from(obj.v8_value) {
Ok(proxy) => proxy,
Err(_) => return None,
};
let mut property_filter = v8::ALL_PROPERTIES;
if filter & 1 == 1 {
property_filter = property_filter | v8::ONLY_WRITABLE
}
if filter & 2 == 2 {
property_filter = property_filter | v8::ONLY_ENUMERABLE
}
if filter & 4 == 4 {
property_filter = property_filter | v8::ONLY_CONFIGURABLE
}
if filter & 8 == 8 {
property_filter = property_filter | v8::SKIP_STRINGS
}
if filter & 16 == 16 {
property_filter = property_filter | v8::SKIP_SYMBOLS
}
let maybe_names = obj.get_property_names(
scope,
v8::GetPropertyNamesArgs {
mode: v8::KeyCollectionMode::OwnOnly,
property_filter,
index_filter: v8::IndexFilter::SkipIndices,
..Default::default()
},
);
if let Some(names) = maybe_names {
let names_val: v8::Local<v8::Value> = names.into();
Some(names_val.into())
} else {
None
}
}
#[op(v8)]
fn op_get_constructor_name<'a>(
scope: &mut v8::HandleScope<'a>,
obj: serde_v8::Value<'a>,
) -> Option<String> {
let obj = match v8::Local::<v8::Object>::try_from(obj.v8_value) {
Ok(proxy) => proxy,
Err(_) => return None,
};
let name = obj.get_constructor_name().to_rust_string_lossy(scope);
Some(name)
}
// HeapStats stores values from a isolate.get_heap_statistics() call // HeapStats stores values from a isolate.get_heap_statistics() call
#[derive(Serialize)] #[derive(Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -46,6 +46,7 @@ import * as os from "ext:runtime/30_os.js";
import * as timers from "ext:deno_web/02_timers.js"; import * as timers from "ext:deno_web/02_timers.js";
import * as colors from "ext:deno_console/01_colors.js"; import * as colors from "ext:deno_console/01_colors.js";
import { import {
getDefaultInspectOptions,
inspectArgs, inspectArgs,
quoteString, quoteString,
wrapConsole, wrapConsole,
@ -218,7 +219,7 @@ function formatException(error) {
return null; return null;
} else if (typeof error == "string") { } else if (typeof error == "string") {
return `Uncaught ${ return `Uncaught ${
inspectArgs([quoteString(error)], { inspectArgs([quoteString(error, getDefaultInspectOptions())], {
colors: !colors.getNoColor(), colors: !colors.getNoColor(),
}) })
}`; }`;