-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
594 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 |
---|---|---|
@@ -0,0 +1,134 @@ | ||
// Generated by ReScript, PLEASE EDIT WITH CARE | ||
|
||
import * as Js_exn from "rescript/lib/es6/js_exn.js"; | ||
import * as Caml_option from "rescript/lib/es6/caml_option.js"; | ||
import * as Core__Option from "../../src/Core__Option.mjs"; | ||
import * as Intl__LocaleTest from "./Intl__LocaleTest.mjs"; | ||
import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js"; | ||
import * as Intl__CollatorTest from "./Intl__CollatorTest.mjs"; | ||
import * as Intl__SegmenterTest from "./Intl__SegmenterTest.mjs"; | ||
import * as Intl__ListFormatTest from "./Intl__ListFormatTest.mjs"; | ||
import * as Intl__PluralRulesTest from "./Intl__PluralRulesTest.mjs"; | ||
import * as Intl__NumberFormatTest from "./Intl__NumberFormatTest.mjs"; | ||
import * as Intl__DateTimeFormatTest from "./Intl__DateTimeFormatTest.mjs"; | ||
import * as Intl__RelativeTimeFormatTest from "./Intl__RelativeTimeFormatTest.mjs"; | ||
|
||
console.log("---"); | ||
|
||
console.log("Intl"); | ||
|
||
console.log(Intl.getCanonicalLocales("EN-US")); | ||
|
||
console.log(Intl.getCanonicalLocales([ | ||
"EN-US", | ||
"Fr" | ||
])); | ||
|
||
try { | ||
console.log(Intl.getCanonicalLocales("bloop")); | ||
} | ||
catch (raw_e){ | ||
var e = Caml_js_exceptions.internalToOCamlException(raw_e); | ||
if (e.RE_EXN_ID === Js_exn.$$Error) { | ||
console.error(e._1); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
|
||
try { | ||
console.log(Intl.supportedValuesOf("calendar")); | ||
console.log(Intl.supportedValuesOf("collation")); | ||
console.log(Intl.supportedValuesOf("currency")); | ||
console.log(Intl.supportedValuesOf("numberingSystem")); | ||
console.log(Intl.supportedValuesOf("timeZone")); | ||
console.log(Intl.supportedValuesOf("unit")); | ||
} | ||
catch (raw_e$1){ | ||
var e$1 = Caml_js_exceptions.internalToOCamlException(raw_e$1); | ||
if (e$1.RE_EXN_ID === Js_exn.$$Error) { | ||
console.error(e$1._1); | ||
} else { | ||
throw e$1; | ||
} | ||
} | ||
|
||
try { | ||
Intl.supportedValuesOf("someInvalidKey"); | ||
console.error("Shouldn't have been hit"); | ||
} | ||
catch (raw_e$2){ | ||
var e$2 = Caml_js_exceptions.internalToOCamlException(raw_e$2); | ||
if (e$2.RE_EXN_ID === Js_exn.$$Error) { | ||
var e$3 = e$2._1; | ||
var message = Core__Option.map(e$3.message, (function (prim) { | ||
return prim.toLowerCase(); | ||
})); | ||
var exit = 0; | ||
if (message === "invalid key : someinvalidkey") { | ||
console.log("Caught expected error"); | ||
} else { | ||
exit = 1; | ||
} | ||
if (exit === 1) { | ||
console.warn("Unexpected error message: \"" + message + "\""); | ||
throw e$3; | ||
} | ||
|
||
} else { | ||
var e$4 = Caml_js_exceptions.as_js_exn(e$2); | ||
if (e$4 !== undefined) { | ||
throw Caml_option.valFromOption(e$4); | ||
} | ||
console.error("Unexpected error"); | ||
} | ||
} | ||
|
||
var _collator = Intl__CollatorTest._collator; | ||
|
||
var collator = Intl__CollatorTest.collator; | ||
|
||
var resolvedOptions = Intl__DateTimeFormatTest.resolvedOptions; | ||
|
||
var timeZone = Intl__DateTimeFormatTest.timeZone; | ||
|
||
var _locale = Intl__LocaleTest._locale; | ||
|
||
var locale = Intl__LocaleTest.locale; | ||
|
||
var currencyFormatter = Intl__NumberFormatTest.currencyFormatter; | ||
|
||
var roundingFormatter = Intl__NumberFormatTest.roundingFormatter; | ||
|
||
var groupingFormatter1 = Intl__NumberFormatTest.groupingFormatter1; | ||
|
||
var groupingFormatter2 = Intl__NumberFormatTest.groupingFormatter2; | ||
|
||
var sigFormatter = Intl__NumberFormatTest.sigFormatter; | ||
|
||
var options = Intl__NumberFormatTest.options; | ||
|
||
var _formatter = Intl__SegmenterTest._formatter; | ||
|
||
var formatter = Intl__SegmenterTest.formatter; | ||
|
||
var segments = Intl__SegmenterTest.segments; | ||
|
||
export { | ||
_collator , | ||
collator , | ||
resolvedOptions , | ||
timeZone , | ||
_locale , | ||
locale , | ||
currencyFormatter , | ||
roundingFormatter , | ||
groupingFormatter1 , | ||
groupingFormatter2 , | ||
sigFormatter , | ||
options , | ||
_formatter , | ||
formatter , | ||
segments , | ||
} | ||
/* Not a pure module */ |
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 @@ | ||
// Generated by ReScript, PLEASE EDIT WITH CARE | ||
|
||
|
||
console.log("---"); | ||
|
||
console.log("Intl.Collator"); | ||
|
||
new Intl.Collator(); | ||
|
||
new Intl.Collator("en-US"); | ||
|
||
var _collator = new Intl.Collator([ | ||
"en-US", | ||
"en-GB" | ||
]); | ||
|
||
var collator = new Intl.Collator("en-US", { | ||
sensitivity: "base", | ||
ignorePunctuation: true, | ||
numeric: true, | ||
caseFirst: "upper" | ||
}); | ||
|
||
Intl.Collator.supportedLocalesOf([ | ||
"en-US", | ||
"en-GB" | ||
]); | ||
|
||
Intl.Collator.supportedLocalesOf([ | ||
"en-US", | ||
"en-GB" | ||
], { | ||
localeMatcher: "lookup" | ||
}); | ||
|
||
console.log(collator.resolvedOptions()); | ||
|
||
console.log(collator.compare("hi", "hï")); | ||
|
||
console.log(Intl.Collator.supportedLocalesOf(["hi"])); | ||
|
||
export { | ||
_collator , | ||
collator , | ||
} | ||
/* Not a pure module */ |
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,90 @@ | ||
// Generated by ReScript, PLEASE EDIT WITH CARE | ||
|
||
import * as Caml_obj from "rescript/lib/es6/caml_obj.js"; | ||
|
||
console.log("---"); | ||
|
||
console.log("Intl.DateTimeFormat"); | ||
|
||
Intl.DateTimeFormat.supportedLocalesOf([ | ||
"en-US", | ||
"en-GB" | ||
]); | ||
|
||
Intl.DateTimeFormat.supportedLocalesOf([ | ||
"en-US", | ||
"en-GB" | ||
], { | ||
localeMatcher: "lookup" | ||
}); | ||
|
||
var formatter = new Intl.DateTimeFormat(undefined, { | ||
dateStyle: "full", | ||
timeStyle: "full" | ||
}); | ||
|
||
console.log(formatter.format(new Date(Date.now()))); | ||
|
||
console.log(formatter.formatRange(new Date(2023, 1, 1), new Date(2023, 12, 31))); | ||
|
||
var options = { | ||
timeZone: "UTC", | ||
hour12: false, | ||
hourCycle: "h24", | ||
weekday: "narrow", | ||
era: "narrow", | ||
year: "2-digit", | ||
month: "2-digit", | ||
day: "2-digit", | ||
hour: "2-digit", | ||
minute: "2-digit", | ||
second: "2-digit", | ||
fractionalSecondDigits: 3, | ||
timeZoneName: "longGeneric" | ||
}; | ||
|
||
var formatter$1 = new Intl.DateTimeFormat(undefined, options); | ||
|
||
console.log(formatter$1.format(new Date(Date.now()))); | ||
|
||
var newrecord = Caml_obj.obj_dup(options); | ||
|
||
var formatter$2 = new Intl.DateTimeFormat(undefined, (newrecord.timeZoneName = "long", newrecord)); | ||
|
||
console.log(formatter$2.format(new Date(Date.now()))); | ||
|
||
var newrecord$1 = Caml_obj.obj_dup(options); | ||
|
||
var formatter$3 = new Intl.DateTimeFormat(undefined, (newrecord$1.timeZoneName = "longOffset", newrecord$1)); | ||
|
||
console.log(formatter$3.format(new Date(Date.now()))); | ||
|
||
var newrecord$2 = Caml_obj.obj_dup(options); | ||
|
||
var formatter$4 = new Intl.DateTimeFormat(undefined, (newrecord$2.timeZoneName = "short", newrecord$2)); | ||
|
||
console.log(formatter$4.format(new Date(Date.now()))); | ||
|
||
var newrecord$3 = Caml_obj.obj_dup(options); | ||
|
||
var formatter$5 = new Intl.DateTimeFormat(undefined, (newrecord$3.timeZoneName = "shortGeneric", newrecord$3)); | ||
|
||
console.log(formatter$5.format(new Date(Date.now()))); | ||
|
||
var newrecord$4 = Caml_obj.obj_dup(options); | ||
|
||
var formatter$6 = new Intl.DateTimeFormat(undefined, (newrecord$4.timeZoneName = "shortOffset", newrecord$4)); | ||
|
||
console.log(formatter$6.format(new Date(Date.now()))); | ||
|
||
var resolvedOptions = new Intl.DateTimeFormat().resolvedOptions(); | ||
|
||
var timeZone = resolvedOptions.timeZone; | ||
|
||
export { | ||
options , | ||
formatter$6 as formatter, | ||
resolvedOptions , | ||
timeZone , | ||
} | ||
/* Not a pure module */ |
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,65 @@ | ||
// Generated by ReScript, PLEASE EDIT WITH CARE | ||
|
||
|
||
console.log("---"); | ||
|
||
console.log("Intl.ListFormat"); | ||
|
||
new Intl.ListFormat(); | ||
|
||
new Intl.ListFormat("en-US"); | ||
|
||
new Intl.ListFormat([ | ||
"en-US", | ||
"en-GB" | ||
]); | ||
|
||
new Intl.ListFormat("en-US", { | ||
type: "conjunction", | ||
style: "long" | ||
}); | ||
|
||
var _formatter = new Intl.ListFormat([ | ||
"en-US", | ||
"en-GB" | ||
], { | ||
type: "conjunction", | ||
style: "long" | ||
}); | ||
|
||
Intl.ListFormat.supportedLocalesOf([ | ||
"en-US", | ||
"en-GB" | ||
]); | ||
|
||
Intl.ListFormat.supportedLocalesOf([ | ||
"en-US", | ||
"en-GB" | ||
], { | ||
localeMatcher: "lookup" | ||
}); | ||
|
||
var formatter = new Intl.ListFormat(undefined, { | ||
type: "conjunction", | ||
style: "long" | ||
}); | ||
|
||
console.log(formatter.resolvedOptions()); | ||
|
||
console.log(formatter.format([ | ||
"one", | ||
"two", | ||
"three" | ||
])); | ||
|
||
console.log(formatter.formatToParts([ | ||
"one", | ||
"two", | ||
"three" | ||
])); | ||
|
||
export { | ||
_formatter , | ||
formatter , | ||
} | ||
/* Not a pure module */ |
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 @@ | ||
// Generated by ReScript, PLEASE EDIT WITH CARE | ||
|
||
|
||
console.log("---"); | ||
|
||
console.log("Intl.Locale"); | ||
|
||
var _locale = new Intl.Locale("en-US"); | ||
|
||
var locale = new Intl.Locale("en-US", { | ||
calendar: "hebrew", | ||
collation: "compat", | ||
hourCycle: "h24", | ||
caseFirst: "upper", | ||
numeric: true | ||
}); | ||
|
||
console.log(locale.baseName); | ||
|
||
console.log(locale.calendar); | ||
|
||
console.log(locale.caseFirst); | ||
|
||
console.log(locale.collation); | ||
|
||
console.log(locale.hourCycle); | ||
|
||
console.log(locale.language); | ||
|
||
console.log(locale.numberingSystem); | ||
|
||
console.log(locale.numeric); | ||
|
||
console.log(locale.region); | ||
|
||
console.log(locale.script); | ||
|
||
console.log(locale.maximize()); | ||
|
||
console.log(locale.minimize()); | ||
|
||
export { | ||
_locale , | ||
locale , | ||
} | ||
/* Not a pure module */ |
Oops, something went wrong.