forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consolidate label conversion tests + add timeLog
- Loading branch information
1 parent
5133c54
commit 70c9654
Showing
3 changed files
with
37 additions
and
101 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
|
||
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}`); | ||
} |
This file was deleted.
Oops, something went wrong.