-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Console time/timeEnd label conversion
- Loading branch information
1 parent
3822eee
commit 80b0f65
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
@domenic | ||
@pwnall | ||
@domfarolino |
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,46 @@ | ||
"use strict"; | ||
// https://console.spec.whatwg.org/#timing | ||
|
||
test(() => { | ||
let timeLabelToStringCalled = false; | ||
|
||
console.time({ | ||
toString() { | ||
timeLabelToStringCalled = true; | ||
} | ||
}); | ||
|
||
assert_true(timeLabelToStringCalled, "toString() must be called on time()'s label when label is an object"); | ||
}, "console.time()'s label gets converted to string via label.toString() when label is an object"); | ||
|
||
test(() => { | ||
let timeEndLabelToStringCalled = false; | ||
|
||
console.timeEnd({ | ||
toString() { | ||
timeEndLabelToStringCalled = true; | ||
} | ||
}); | ||
|
||
assert_true(timeEndLabelToStringCalled, "toString() must be called on timeEnd()'s label when label is an object"); | ||
}, "console.timeEnd()'s label gets converted to string via label.toString() when label is an object"); | ||
|
||
test(() => { | ||
assert_throws({name: "Error"}, () => { | ||
console.time({ | ||
toString() { | ||
throw new Error("conversion error"); | ||
} | ||
}); | ||
}, "time() must re-throw any exceptions thrown by label.toString() conversion"); | ||
}, "console.time() throws exceptions generated by erroneous label.toString() conversion"); | ||
|
||
test(() => { | ||
assert_throws({name: "Error"}, () => { | ||
console.timeEnd({ | ||
toString() { | ||
throw new Error("conversion error"); | ||
} | ||
}); | ||
}, "timeEnd() must re-throw any exceptions thrown by label.toString() conversion"); | ||
}, "console.timeEnd() throws exceptions generated by erroneous label.toString() conversion"); |
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