Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate label conversion tests + add timeLog #11401

Merged
merged 2 commits into from
Jun 18, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 0 additions & 55 deletions console/console-counting-label-conversion.any.js

This file was deleted.

37 changes: 37 additions & 0 deletions console/console-label-conversion.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"use strict";
// https://console.spec.whatwg/org/#counting
// https://console.spec.whatwg/org/#timing

// toString() console label test strings
const toStringAssertionEnding = 'must call toString() on label when label is an object';
const toStringTestNameEnding = 'label gets converted to string via label.toString() when label is an object';

// toString error re-throwing console test strings
const toStringRethrowAssertionEnding = 'must re-throw any exceptions thrown by label.toString() conversion';
const toStringRethrowTestNameEnding = 'throws exceptions generated by erroneous label.toString() conversion';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why these test strings are factored out instead of inlined; it makes things a big harder to read.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I think before using the for loop I had factored them out to avoid duplication, but that's not an issue at all now.


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}() ${toStringAssertionEnding}`);
}, `console.${method}()'s ${toStringTestNameEnding}`);

test(() => {
assert_throws({name: 'Error'}, () => {
console[method]({
toString() {
throw new Error('conversion error');
}
});
}, `${method} ${toStringRethrowAssertionEnding}`);
}, `console.${method}() ${toStringRethrowTestNameEnding}`);
}
46 changes: 0 additions & 46 deletions console/console-time-label-conversion.any.js

This file was deleted.