-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
intl: Don't crash if v8BreakIterator not available
If the undocumented v8BreakIterator does not have data available, monkeypatch it to throw an error instead of crashing. Fixes: #3111 Ref: #9008 PR-URL: #4253 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
- Loading branch information
Showing
3 changed files
with
38 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
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
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,15 @@ | ||
'use strict'; | ||
require('../common'); | ||
const assert = require('assert'); | ||
|
||
if (global.Intl === undefined || Intl.v8BreakIterator === undefined) { | ||
return console.log('1..0 # Skipped: no Intl'); | ||
} | ||
|
||
try { | ||
new Intl.v8BreakIterator(); | ||
// May succeed if data is available - OK | ||
} catch (e) { | ||
// May throw this error if ICU data is not available - OK | ||
assert.throws(() => new Intl.v8BreakIterator(), /ICU data/); | ||
} |