forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest-whatwg-console-label-conversion.js
More file actions
45 lines (34 loc) · 1.39 KB
/
test-whatwg-console-label-conversion.js
File metadata and controls
45 lines (34 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict';
require('../common');
const { test, assert_true, assert_throws } =
require('../common/wpt');
/* eslint-disable max-len, object-curly-spacing */
/* The following tests should not be modified as they are copied */
/* WPT Refs:
https://github.com/web-platform-tests/wpt/blob/6f0a96ed650935b17b6e5d277889cfbe0ccc103e/console/console-label-conversion.any.js
License: https://github.com/web-platform-tests/wpt/blob/6f0a96ed650935b17b6e5d277889cfbe0ccc103e/LICENSE.md
*/
// https://console.spec.whatwg/org/#counting
// https://console.spec.whatwg/org/#timing
const methods = ['count', 'countReset', 'time', 'timeLog', 'timeEnd'];
for (const method of methods) {
test(() => {
let labelToStringCalled = false;
console[method]({
toString() {
labelToStringCalled = true;
}
});
assert_true(labelToStringCalled, `${method}() must call toString() on label when label is an object`);
}, `console.${method}()'s label gets converted to string via label.toString() when label is an object`);
test(() => {
assert_throws({name: 'Error'}, () => {
console[method]({
toString() {
throw new Error('conversion error');
}
});
}, `${method} must re-throw any exceptions thrown by label.toString() conversion`);
}, `console.${method}() throws exceptions generated by erroneous label.toString() conversion`);
}
/* eslint-enable */