diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:25 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:25 +0000 |
commit | 5363f350887b1e5b5dd21a86f88c8af9d7fea6da (patch) | |
tree | 35ca005eb6e0e9a1ba3bb5dbc033209ad445dc17 /vendor/unic-langid-impl | |
parent | Adding debian version 1.66.0+dfsg1-1. (diff) | |
download | rustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.tar.xz rustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.zip |
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/unic-langid-impl')
-rw-r--r-- | vendor/unic-langid-impl/.cargo-checksum.json | 2 | ||||
-rw-r--r-- | vendor/unic-langid-impl/Cargo.lock | 341 | ||||
-rw-r--r-- | vendor/unic-langid-impl/Cargo.toml | 28 | ||||
-rw-r--r-- | vendor/unic-langid-impl/benches/likely_subtags.rs | 51 | ||||
-rw-r--r-- | vendor/unic-langid-impl/benches/parser.rs | 14 | ||||
-rw-r--r-- | vendor/unic-langid-impl/src/bin/generate_likelysubtags.rs | 3 | ||||
-rw-r--r-- | vendor/unic-langid-impl/src/subtags/language.rs | 6 | ||||
-rw-r--r-- | vendor/unic-langid-impl/src/subtags/region.rs | 4 | ||||
-rw-r--r-- | vendor/unic-langid-impl/src/subtags/script.rs | 4 | ||||
-rw-r--r-- | vendor/unic-langid-impl/src/subtags/variant.rs | 6 | ||||
-rw-r--r-- | vendor/unic-langid-impl/tests/canonicalize_test.rs | 13 | ||||
-rw-r--r-- | vendor/unic-langid-impl/tests/fixtures.rs | 75 | ||||
-rw-r--r-- | vendor/unic-langid-impl/tests/language_identifier_test.rs | 192 | ||||
-rw-r--r-- | vendor/unic-langid-impl/tests/likelysubtags.rs | 113 |
14 files changed, 634 insertions, 218 deletions
diff --git a/vendor/unic-langid-impl/.cargo-checksum.json b/vendor/unic-langid-impl/.cargo-checksum.json index df7e26b58..b3315aaa1 100644 --- a/vendor/unic-langid-impl/.cargo-checksum.json +++ b/vendor/unic-langid-impl/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.lock":"7a6bb71d558693114436f11f7089237447a936cc8365f8afe0305e0b68dae07b","Cargo.toml":"0495636d8071b0d804764190a2daa3f6f780336d80bd8712ef7c197963fd5ce4","README.md":"1ce686b1ba46e7fff771db934d1e8905e3d96c73d9e6712ca85011cf63cf4157","benches/canonicalize.rs":"1bc9db6454ed711c1c1d58a9236d1ed02c40645782338697812dc21b26c2295f","benches/langid.rs":"46dc68e1ee1c998fe957035c11c373cc5d2c2993dd3058aeb36014028618a46e","benches/likely_subtags.rs":"672b47687d20d4294e2de78dc6eb1d36400a4b4c672082d15415fb18faf2e508","benches/parser.rs":"f9cf158bf5d146ef413e63e952c0a866269ba2be0db44a0aa88a5e61fdf53b4a","data/cldr-misc-full/README.md":"b4bbc8e56b8c9f5d482d2dd211e53720cdca27b0e98eec274e56577d41906b92","src/bin/generate_layout.rs":"e1df742c318ba4de09a25edad082a398da1d5591ac24074f9eadf3f40d677a9a","src/bin/generate_likelysubtags.rs":"c38ef8e59044578e51681723dbaf7f9669ccb7c7487f24ef6a430aad194f160f","src/errors.rs":"091525fd3d704cc4698bab82af9fff1f2e6fc793910700790ec3ef943b3eddfe","src/layout_table.rs":"c311b5399a22efd69f14decb00aee7dfb2943a090832e2aef127e2853ad1ce0b","src/lib.rs":"75b5e8958ba0139ef60139e61441d29c80bde8552d1adead3905165c11ed97cd","src/likelysubtags/mod.rs":"66889568b883675465faa445e257b4b70e9dcba98c6c523eb34a08ebb50377c0","src/likelysubtags/tables.rs":"47ab40497145adc553f9f585d1ec79d01028495a57b1907392642afd26986e89","src/parser/errors.rs":"2dacf5bf388499c9fbecf64ef950038f123335e87b6691bcdb88d185678f38d5","src/parser/mod.rs":"30f9ff487ab7b023ec7e6cfbfe4f4ebc41ca524cef0eba96a6b77ad624c9f6b8","src/serde.rs":"2ce1fdea1217c4f72b2c8e00f333902ff496c54eef5b4534adb289375c50aef0","src/subtags/language.rs":"1f7dbc4a10b58a6d1b729dc986a20396ce75558dfb1f9be223d5723a5e241e73","src/subtags/mod.rs":"ba23712d7ce5e0fa896c97ddc91d7eacbf21a99d62c15f5cf19a6653876bf56b","src/subtags/region.rs":"8cfd794f41f48fdf9742c9149b7360ea7cbd84c93abd13fe5a5317c46b4c48fc","src/subtags/script.rs":"94760b06f50f8f32c45af4f238b66e32428e5710ce4eabab4c943b5ebda3b0fe","src/subtags/variant.rs":"a8647d82c49df0d8df7fda33033d0df7a235beecfb35f459122675ab16b2dd8e"},"package":"1a4a8eeaf0494862c1404c95ec2f4c33a2acff5076f64314b465e3ddae1b934d"}
\ No newline at end of file +{"files":{"Cargo.lock":"da3d5fabc92472ac1f45fa321f1e188fd3fff22b3234d3f74e78a8f79503aac9","Cargo.toml":"67560e144c925cdb1467085067b51138da8461c4babd170777e90082a1664d61","README.md":"1ce686b1ba46e7fff771db934d1e8905e3d96c73d9e6712ca85011cf63cf4157","benches/canonicalize.rs":"1bc9db6454ed711c1c1d58a9236d1ed02c40645782338697812dc21b26c2295f","benches/langid.rs":"46dc68e1ee1c998fe957035c11c373cc5d2c2993dd3058aeb36014028618a46e","benches/likely_subtags.rs":"33debb6db4eabd0166525c7c06868f86e35958c2d0d9e5e7668f28b1aff3da23","benches/parser.rs":"bc5460589125aca2ca4c4cf475fde81e7de6aa70c7bf8443996b6246b44110a3","data/cldr-misc-full/README.md":"b4bbc8e56b8c9f5d482d2dd211e53720cdca27b0e98eec274e56577d41906b92","src/bin/generate_layout.rs":"e1df742c318ba4de09a25edad082a398da1d5591ac24074f9eadf3f40d677a9a","src/bin/generate_likelysubtags.rs":"9b0df3a008d0f6090ee441e4c649f00f9b78c7d23434f389fe3de2288951cf72","src/errors.rs":"091525fd3d704cc4698bab82af9fff1f2e6fc793910700790ec3ef943b3eddfe","src/layout_table.rs":"c311b5399a22efd69f14decb00aee7dfb2943a090832e2aef127e2853ad1ce0b","src/lib.rs":"75b5e8958ba0139ef60139e61441d29c80bde8552d1adead3905165c11ed97cd","src/likelysubtags/mod.rs":"66889568b883675465faa445e257b4b70e9dcba98c6c523eb34a08ebb50377c0","src/likelysubtags/tables.rs":"47ab40497145adc553f9f585d1ec79d01028495a57b1907392642afd26986e89","src/parser/errors.rs":"2dacf5bf388499c9fbecf64ef950038f123335e87b6691bcdb88d185678f38d5","src/parser/mod.rs":"30f9ff487ab7b023ec7e6cfbfe4f4ebc41ca524cef0eba96a6b77ad624c9f6b8","src/serde.rs":"2ce1fdea1217c4f72b2c8e00f333902ff496c54eef5b4534adb289375c50aef0","src/subtags/language.rs":"ea198788c10a9b24a88d2316d516a1b6325b20c57c1d05586edc7c50acc1e27d","src/subtags/mod.rs":"ba23712d7ce5e0fa896c97ddc91d7eacbf21a99d62c15f5cf19a6653876bf56b","src/subtags/region.rs":"f3455679067ed0da9103d5433586cb4809628847e923bbcf35cc2d2b25a0d35e","src/subtags/script.rs":"c5ca9a2ab6d8b3a1dc3f52a73665223f0dd30901b8e5d722dd93e58a69710f5d","src/subtags/variant.rs":"a0feec8b44933ff04a3d3f91e9e69f7537468e7c813c3780eb87e51512f6d1dd","tests/canonicalize_test.rs":"5ca005223ae159c15f8809c28c1cc950dc4d69063d9de70b885f18ef8e6cca28","tests/fixtures.rs":"d03a280b67080dac1bc333255e89d8903164688a6dfaed5adbea68efd65ef1bc","tests/language_identifier_test.rs":"90a4d7ac4961c1e214de166036c1b5cae21f3a99f157fe00d149d8b9106cb7b9","tests/likelysubtags.rs":"f5db0c3ec9f545eef148914486c7a74f1bbc629f4dcff3077242c174c0c1c6a3"},"package":"e35bfd2f2b8796545b55d7d3fd3e89a0613f68a0d1c8bc28cb7ff96b411a35ff"}
\ No newline at end of file diff --git a/vendor/unic-langid-impl/Cargo.lock b/vendor/unic-langid-impl/Cargo.lock index 55cc35bac..bd8b6c575 100644 --- a/vendor/unic-langid-impl/Cargo.lock +++ b/vendor/unic-langid-impl/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "atty" version = "0.2.14" @@ -13,21 +15,21 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bstr" -version = "0.2.12" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2889e6d50f394968c8bf4240dc3f2a7eb4680844d27308f798229ac9d4725f41" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" dependencies = [ "lazy_static", "memchr", @@ -37,36 +39,27 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187" - -[[package]] -name = "byteorder" -version = "1.3.4" +version = "3.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" [[package]] name = "cast" -version = "0.2.3" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0" -dependencies = [ - "rustc_version", -] +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cfg-if" -version = "0.1.10" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "2.33.0" +version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "bitflags", "textwrap", @@ -75,9 +68,9 @@ dependencies = [ [[package]] name = "criterion" -version = "0.3.2" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63f696897c88b57f4ffe3c69d8e1a0613c7d0e6c4833363c8560fbde9c47b966" +checksum = "b01d6de93b2b6c65e17c634a26653a29d107b3c98c607c765bf38d041531cd8f" dependencies = [ "atty", "cast", @@ -92,6 +85,7 @@ dependencies = [ "rayon", "regex", "serde", + "serde_cbor", "serde_derive", "serde_json", "tinytemplate", @@ -100,70 +94,66 @@ dependencies = [ [[package]] name = "criterion-plot" -version = "0.4.2" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddeaf7989f00f2e1d871a26a110f3ed713632feac17f65f03ca938c542618b60" +checksum = "2673cc8207403546f45f5fd319a974b1e6983ad1a3ee7e6041650013be041876" dependencies = [ "cast", "itertools", ] [[package]] -name = "crossbeam-deque" -version = "0.7.3" +name = "crossbeam-channel" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" +checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" dependencies = [ - "crossbeam-epoch", + "cfg-if", "crossbeam-utils", - "maybe-uninit", ] [[package]] -name = "crossbeam-epoch" +name = "crossbeam-deque" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" +checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" dependencies = [ - "autocfg", "cfg-if", + "crossbeam-epoch", "crossbeam-utils", - "lazy_static", - "maybe-uninit", - "memoffset", - "scopeguard", ] [[package]] -name = "crossbeam-queue" -version = "0.2.1" +name = "crossbeam-epoch" +version = "0.9.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db" +checksum = "f916dfc5d356b0ed9dae65f1db9fc9770aa2851d2662b988ccf4fe3516e86348" dependencies = [ + "autocfg", "cfg-if", "crossbeam-utils", + "memoffset", + "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.7.2" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac" dependencies = [ - "autocfg", "cfg-if", - "lazy_static", ] [[package]] name = "csv" -version = "1.1.3" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00affe7f6ab566df61b4be3ce8cf16bc2576bca0963ceb0955e45d514bf9a279" +checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" dependencies = [ "bstr", "csv-core", - "itoa", + "itoa 0.4.8", "ryu", "serde", ] @@ -178,40 +168,63 @@ dependencies = [ ] [[package]] +name = "displaydoc" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bf95dc3f046b9da4f2d51833c0d3547d8564ef6910f5c1ed130306a75b92886" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] name = "either" -version = "1.5.3" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" + +[[package]] +name = "half" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" +checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" [[package]] name = "hermit-abi" -version = "0.1.12" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61565ff7aaace3525556587bd2dc31d4a07071957be715e63ce7b1eccf51a8f4" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" dependencies = [ "libc", ] [[package]] name = "itertools" -version = "0.9.0" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ "either", ] [[package]] name = "itoa" -version = "0.4.5" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" + +[[package]] +name = "itoa" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" [[package]] name = "js-sys" -version = "0.3.39" +version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa5a448de267e7358beaf4a5d849518fe9a0c13fce7afd44b06e68550e5562a7" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" dependencies = [ "wasm-bindgen", ] @@ -224,101 +237,118 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.69" +version = "0.2.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005" +checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c" [[package]] name = "log" -version = "0.4.8" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ "cfg-if", ] [[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - -[[package]] name = "memchr" -version = "2.3.3" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memoffset" -version = "0.5.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4fc2c02a7e374099d4ee95a193111f72d2110197fe200272371758f6c3643d8" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" dependencies = [ "autocfg", ] [[package]] name = "num-traits" -version = "0.2.11" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", ] [[package]] name = "num_cpus" -version = "1.13.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" dependencies = [ "hermit-abi", "libc", ] [[package]] +name = "once_cell" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" + +[[package]] name = "oorandom" -version = "11.1.1" +version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94af325bc33c7f60191be4e2c984d48aaa21e2854f473b85398344b60c9b6358" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] name = "plotters" -version = "0.2.14" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9b1d9ca091d370ea3a78d5619145d1b59426ab0c9eedbad2514a4cee08bf389" +checksum = "2538b639e642295546c50fcd545198c9d64ee2a38620a628724a3b266d5fbf97" dependencies = [ - "js-sys", "num-traits", + "plotters-backend", + "plotters-svg", "wasm-bindgen", "web-sys", ] [[package]] +name = "plotters-backend" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142" + +[[package]] +name = "plotters-svg" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f" +dependencies = [ + "plotters-backend", +] + +[[package]] name = "proc-macro2" -version = "1.0.12" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8872cf6f48eee44265156c111456a700ab3483686b3f96df4cf5481c89157319" +checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "quote" -version = "1.0.4" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c1f4b0efa5fc5e8ceb705136bfee52cfdb6a4e3509f770b478cd6ed434232a7" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" dependencies = [ "proc-macro2", ] [[package]] name = "rayon" -version = "1.3.0" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db6ce3297f9c85e16621bb8cca38a06779ffc31bb8184e1be4bed2be4678a098" +checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" dependencies = [ + "autocfg", "crossbeam-deque", "either", "rayon-core", @@ -326,55 +356,42 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.7.0" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08a89b46efaf957e52b18062fb2f4660f8b8a4dde1807ca002690868ef2c85a9" +checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" dependencies = [ + "crossbeam-channel", "crossbeam-deque", - "crossbeam-queue", "crossbeam-utils", - "lazy_static", "num_cpus", ] [[package]] name = "regex" -version = "1.3.7" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6020f034922e3194c711b82a627453881bc4682166cabb07134a10c26ba7692" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" dependencies = [ "regex-syntax", ] [[package]] name = "regex-automata" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" -dependencies = [ - "byteorder", -] +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" [[package]] name = "regex-syntax" -version = "0.6.17" +version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae" - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" [[package]] name = "ryu" -version = "1.0.4" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed3d612bc64430efeb3f7ee6ef26d590dce0c43249217bddc62112540c7941e1" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" [[package]] name = "same-file" @@ -392,34 +409,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] -name = "semver" -version = "0.9.0" +name = "serde" +version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" dependencies = [ - "semver-parser", + "serde_derive", ] [[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - -[[package]] -name = "serde" -version = "1.0.106" +name = "serde_cbor" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399" +checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" dependencies = [ - "serde_derive", + "half", + "serde", ] [[package]] name = "serde_derive" -version = "1.0.106" +version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" +checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" dependencies = [ "proc-macro2", "quote", @@ -428,24 +440,24 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.52" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7894c8ed05b7a3a279aeb79025fdec1d3158080b75b98a08faf2806bb799edd" +checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" dependencies = [ - "itoa", + "itoa 1.0.4", "ryu", "serde", ] [[package]] name = "syn" -version = "1.0.18" +version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "410a7488c0a728c7ceb4ad59b9567eb4053d02e8cc7f5c0e0eeeb39518369213" +checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] @@ -459,15 +471,18 @@ dependencies = [ [[package]] name = "tinystr" -version = "0.3.2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bac79c4b51eda1b090b1edebfb667821bbb51f713855164dc7cec2cb8ac2ba3" +checksum = "f8aeafdfd935e4a7fe16a91ab711fa52d54df84f9c8f7ca5837a9d1d902ef4c2" +dependencies = [ + "displaydoc", +] [[package]] name = "tinytemplate" -version = "1.0.4" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45e4bc5ac99433e0dcb8b9f309dd271a165ae37dde129b9e0ce1bfdd8bfe4891" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" dependencies = [ "serde", "serde_json", @@ -475,7 +490,7 @@ dependencies = [ [[package]] name = "unic-langid-impl" -version = "0.9.0" +version = "0.9.1" dependencies = [ "criterion", "serde", @@ -484,22 +499,22 @@ dependencies = [ ] [[package]] -name = "unicode-width" -version = "0.1.7" +name = "unicode-ident" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" [[package]] -name = "unicode-xid" -version = "0.2.0" +name = "unicode-width" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] name = "walkdir" -version = "2.3.1" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" dependencies = [ "same-file", "winapi", @@ -508,9 +523,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.62" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3c7d40d09cdbf0f4895ae58cf57d92e1e57a9dd8ed2e8390514b54a47cc5551" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -518,13 +533,13 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.62" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3972e137ebf830900db522d6c8fd74d1900dcfc733462e9a12e942b00b4ac94" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" dependencies = [ "bumpalo", - "lazy_static", "log", + "once_cell", "proc-macro2", "quote", "syn", @@ -533,9 +548,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.62" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cd85aa2c579e8892442954685f0d801f9129de24fa2136b2c6a539c76b65776" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -543,9 +558,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.62" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eb197bd3a47553334907ffd2f16507b4f4f01bbec3ac921a7719e0decdfe72a" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" dependencies = [ "proc-macro2", "quote", @@ -556,15 +571,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.62" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a91c2916119c17a8e316507afaaa2dd94b47646048014bbdf6bef098c1bb58ad" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" [[package]] name = "web-sys" -version = "0.3.39" +version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bc359e5dd3b46cb9687a051d50a2fdd228e4ba7cf6fcf861a5365c3d671a642" +checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" dependencies = [ "js-sys", "wasm-bindgen", @@ -572,9 +587,9 @@ dependencies = [ [[package]] name = "winapi" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", diff --git a/vendor/unic-langid-impl/Cargo.toml b/vendor/unic-langid-impl/Cargo.toml index 6431f4c58..eab3f743e 100644 --- a/vendor/unic-langid-impl/Cargo.toml +++ b/vendor/unic-langid-impl/Cargo.toml @@ -3,19 +3,24 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "unic-langid-impl" -version = "0.9.0" +version = "0.9.1" authors = ["Zibi Braniecki <gandalf@mozilla.com>"] -include = ["src/**/*", "benches/*.rs", "Cargo.toml", "README.md"] +include = [ + "src/**/*", + "benches/*.rs", + "tests/*.rs", + "Cargo.toml", + "README.md", +] description = "API for managing Unicode Language Identifiers" readme = "README.md" categories = ["internationalization"] @@ -51,6 +56,7 @@ harness = false name = "likely_subtags" harness = false required-features = ["likelysubtags"] + [dependencies.serde] version = "1.0" optional = true @@ -60,7 +66,8 @@ version = "1.0" optional = true [dependencies.tinystr] -version = "0.3.2" +version = "0.7.0" + [dev-dependencies.criterion] version = "0.3" @@ -72,5 +79,8 @@ features = ["derive"] version = "1.0" [features] -binary = ["serde", "serde_json"] +binary = [ + "serde", + "serde_json", +] likelysubtags = [] diff --git a/vendor/unic-langid-impl/benches/likely_subtags.rs b/vendor/unic-langid-impl/benches/likely_subtags.rs index a01666597..3b7f8746e 100644 --- a/vendor/unic-langid-impl/benches/likely_subtags.rs +++ b/vendor/unic-langid-impl/benches/likely_subtags.rs @@ -1,9 +1,8 @@ -use criterion::black_box; use criterion::criterion_group; use criterion::criterion_main; use criterion::Criterion; -use tinystr::{TinyStr4, TinyStr8}; +use unic_langid_impl::subtags; use unic_langid_impl::LanguageIdentifier; static STRINGS: &[&str] = &[ @@ -49,51 +48,37 @@ static STRINGS: &[&str] = &[ ]; fn maximize_bench(c: &mut Criterion) { + let langids: Vec<LanguageIdentifier> = STRINGS + .iter() + .map(|s| -> LanguageIdentifier { s.parse().unwrap() }) + .collect(); c.bench_function("maximize", move |b| { b.iter(|| { - let langids: Vec<LanguageIdentifier> = STRINGS - .iter() - .map(|s| -> LanguageIdentifier { s.parse().unwrap() }) - .collect(); - for mut s in langids { + for mut s in langids.clone().into_iter() { s.maximize(); - let _ = black_box(s.to_string()); } }) }); } -fn extract_input(s: &str) -> (Option<TinyStr8>, Option<TinyStr4>, Option<TinyStr4>) { - let chunks: Vec<&str> = s.split("-").collect(); - let mut lang: Option<TinyStr8> = chunks.get(0).map(|s| s.parse().unwrap()); - let mut script: Option<TinyStr4> = chunks.get(1).map(|s| s.parse().unwrap()); - let mut region: Option<TinyStr4> = chunks.get(2).map(|s| s.parse().unwrap()); - if let Some(l) = lang { - if l.as_str() == "und" { - lang = None; - } - } - if let Some(s) = script { - if s.as_str().chars().count() == 2 { - region = script; - script = None; - } - } - (lang, script, region) +fn extract_input( + s: &str, +) -> ( + subtags::Language, + Option<subtags::Script>, + Option<subtags::Region>, +) { + let langid: LanguageIdentifier = s.parse().unwrap(); + (langid.language, langid.script, langid.region) } fn raw_maximize_bench(c: &mut Criterion) { - let entries: Vec<(Option<TinyStr8>, Option<TinyStr4>, Option<TinyStr4>)> = - STRINGS.iter().map(|s| extract_input(s)).collect(); + let entries: Vec<_> = STRINGS.iter().map(|s| extract_input(s)).collect(); c.bench_function("raw_maximize", move |b| { b.iter(|| { - for (lang, script, region) in &entries { - let _ = unic_langid_impl::likelysubtags::maximize( - lang.clone(), - script.clone(), - region.clone(), - ); + for (lang, script, region) in entries.clone().into_iter() { + let _ = unic_langid_impl::likelysubtags::maximize(lang, script, region); } }) }); diff --git a/vendor/unic-langid-impl/benches/parser.rs b/vendor/unic-langid-impl/benches/parser.rs index 43c7a3282..97abe833f 100644 --- a/vendor/unic-langid-impl/benches/parser.rs +++ b/vendor/unic-langid-impl/benches/parser.rs @@ -21,6 +21,13 @@ fn language_identifier_parser_bench(c: &mut Criterion) { "fr-FR", "mk", "uk", + "en-US", + "en-GB", + "es-AR", + "th", + "de", + "zh-Cyrl-HN", + "en-Latn-US", ]; c.bench_function("language_identifier_parser", |b| { @@ -49,6 +56,13 @@ fn language_identifier_parser_casing_bench(c: &mut Criterion) { "fr_fr", "Mk", "uK", + "en-us", + "en_gb", + "ES-AR", + "tH", + "DE", + "ZH_cyrl_hN", + "eN-lAtN-uS", ]; c.bench_function("language_identifier_parser_casing", |b| { let slices: Vec<&[u8]> = strings.iter().map(|s| s.as_bytes()).collect(); diff --git a/vendor/unic-langid-impl/src/bin/generate_likelysubtags.rs b/vendor/unic-langid-impl/src/bin/generate_likelysubtags.rs index 4fec79939..a86ffa80d 100644 --- a/vendor/unic-langid-impl/src/bin/generate_likelysubtags.rs +++ b/vendor/unic-langid-impl/src/bin/generate_likelysubtags.rs @@ -1,6 +1,5 @@ use serde_json::Value; use std::fs; -use std::str::FromStr; use tinystr::TinyStr8; use unic_langid_impl::{subtags, LanguageIdentifier}; @@ -77,7 +76,7 @@ fn main() { match (lang, script, region) { (None, None, None) => lang_only.push(( - TinyStr8::from_str("und").unwrap().into(), + u64::from_le_bytes(*TinyStr8::from_str("und").unwrap().all_bytes()), (val_lang, val_script, val_region), )), (Some(l), None, None) => lang_only.push(( diff --git a/vendor/unic-langid-impl/src/subtags/language.rs b/vendor/unic-langid-impl/src/subtags/language.rs index 3703475e2..8b25bb609 100644 --- a/vendor/unic-langid-impl/src/subtags/language.rs +++ b/vendor/unic-langid-impl/src/subtags/language.rs @@ -34,7 +34,7 @@ impl Language { /// This function accepts any u64 that is exected to be a valid /// `TinyStr8` and a valid `Language` subtag. pub const unsafe fn from_raw_unchecked(v: u64) -> Self { - Self(Some(TinyStr8::new_unchecked(v))) + Self(Some(TinyStr8::from_bytes_unchecked(v.to_le_bytes()))) } pub fn matches<O: Borrow<Self>>( @@ -59,13 +59,13 @@ impl Language { impl From<Language> for Option<u64> { fn from(input: Language) -> Self { - input.0.map(|i| i.into()) + input.0.map(|i| u64::from_le_bytes(*i.all_bytes())) } } impl From<&Language> for Option<u64> { fn from(input: &Language) -> Self { - input.0.map(|i| i.into()) + input.0.map(|i| u64::from_le_bytes(*i.all_bytes())) } } diff --git a/vendor/unic-langid-impl/src/subtags/region.rs b/vendor/unic-langid-impl/src/subtags/region.rs index f14ac21bf..b7febe202 100644 --- a/vendor/unic-langid-impl/src/subtags/region.rs +++ b/vendor/unic-langid-impl/src/subtags/region.rs @@ -37,13 +37,13 @@ impl Region { /// This function accepts any u64 that is exected to be a valid /// `TinyStr4` and a valid `Region` subtag. pub const unsafe fn from_raw_unchecked(v: u32) -> Self { - Self(TinyStr4::new_unchecked(v)) + Self(TinyStr4::from_bytes_unchecked(v.to_le_bytes())) } } impl From<Region> for u32 { fn from(input: Region) -> Self { - input.0.into() + u32::from_le_bytes(*input.0.all_bytes()) } } diff --git a/vendor/unic-langid-impl/src/subtags/script.rs b/vendor/unic-langid-impl/src/subtags/script.rs index 63780e510..8cb38c8d5 100644 --- a/vendor/unic-langid-impl/src/subtags/script.rs +++ b/vendor/unic-langid-impl/src/subtags/script.rs @@ -25,13 +25,13 @@ impl Script { /// This function accepts any u64 that is exected to be a valid /// `TinyStr4` and a valid `Script` subtag. pub const unsafe fn from_raw_unchecked(v: u32) -> Self { - Self(TinyStr4::new_unchecked(v)) + Self(TinyStr4::from_bytes_unchecked(v.to_le_bytes())) } } impl From<Script> for u32 { fn from(input: Script) -> Self { - input.0.into() + u32::from_le_bytes(*input.0.all_bytes()) } } diff --git a/vendor/unic-langid-impl/src/subtags/variant.rs b/vendor/unic-langid-impl/src/subtags/variant.rs index 064ff3bb9..8b29a458e 100644 --- a/vendor/unic-langid-impl/src/subtags/variant.rs +++ b/vendor/unic-langid-impl/src/subtags/variant.rs @@ -35,19 +35,19 @@ impl Variant { /// This function accepts any u64 that is exected to be a valid /// `TinyStr8` and a valid `Variant` subtag. pub const unsafe fn from_raw_unchecked(v: u64) -> Self { - Self(TinyStr8::new_unchecked(v)) + Self(TinyStr8::from_bytes_unchecked(v.to_le_bytes())) } } impl From<Variant> for u64 { fn from(input: Variant) -> Self { - input.0.into() + u64::from_le_bytes(*input.0.all_bytes()) } } impl From<&Variant> for u64 { fn from(input: &Variant) -> Self { - input.0.into() + u64::from_le_bytes(*input.0.all_bytes()) } } diff --git a/vendor/unic-langid-impl/tests/canonicalize_test.rs b/vendor/unic-langid-impl/tests/canonicalize_test.rs new file mode 100644 index 000000000..b0195828b --- /dev/null +++ b/vendor/unic-langid-impl/tests/canonicalize_test.rs @@ -0,0 +1,13 @@ +use unic_langid_impl::canonicalize; + +fn assert_canonicalize(input: &str, output: &str) { + assert_eq!(&canonicalize(input).unwrap(), output); +} + +#[test] +fn test_canonicalize() { + assert_canonicalize("Pl", "pl"); + assert_canonicalize("eN-uS", "en-US"); + assert_canonicalize("ZH_hans_hK", "zh-Hans-HK"); + assert_canonicalize("en-scouse-fonipa", "en-fonipa-scouse"); +} diff --git a/vendor/unic-langid-impl/tests/fixtures.rs b/vendor/unic-langid-impl/tests/fixtures.rs new file mode 100644 index 000000000..27cd29b33 --- /dev/null +++ b/vendor/unic-langid-impl/tests/fixtures.rs @@ -0,0 +1,75 @@ +use std::convert::TryInto; +use std::error::Error; +use std::fs::File; +use std::path::Path; + +use unic_langid_impl::LanguageIdentifier; + +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize)] +struct LangIdTestInputData { + string: String, +} + +#[derive(Serialize, Deserialize, Debug)] +struct LangIdTestOutputObject { + language: Option<String>, + script: Option<String>, + region: Option<String>, + #[serde(default)] + variants: Vec<String>, +} + +#[derive(Serialize, Deserialize, Debug)] +#[serde(untagged)] +enum LangIdTestOutput { + String(String), + Object(LangIdTestOutputObject), +} + +#[derive(Serialize, Deserialize)] +struct LangIdTestSet { + input: LangIdTestInputData, + output: LangIdTestOutput, +} + +fn read_langid_testsets<P: AsRef<Path>>(path: P) -> Result<Vec<LangIdTestSet>, Box<dyn Error>> { + let file = File::open(path)?; + let sets = serde_json::from_reader(file)?; + Ok(sets) +} + +fn test_langid_fixtures(path: &str) { + let tests = read_langid_testsets(path).unwrap(); + + for test in tests { + let s = test.input.string; + + let langid: LanguageIdentifier = s.parse().expect("Parsing failed."); + + match test.output { + LangIdTestOutput::Object(o) => { + let expected = LanguageIdentifier::from_parts( + o.language.try_into().unwrap(), + o.script.as_ref().map(|s| s.parse().unwrap()), + o.region.as_ref().map(|r| r.parse().unwrap()), + o.variants + .iter() + .map(|s| s.parse().unwrap()) + .collect::<Vec<_>>() + .as_ref(), + ); + assert_eq!(langid, expected); + } + LangIdTestOutput::String(s) => { + assert_eq!(langid.to_string(), s); + } + } + } +} + +#[test] +fn parse() { + test_langid_fixtures("./tests/fixtures/parsing.json"); +} diff --git a/vendor/unic-langid-impl/tests/language_identifier_test.rs b/vendor/unic-langid-impl/tests/language_identifier_test.rs new file mode 100644 index 000000000..79b81fb4f --- /dev/null +++ b/vendor/unic-langid-impl/tests/language_identifier_test.rs @@ -0,0 +1,192 @@ +use unic_langid_impl::parser::parse_language_identifier; +use unic_langid_impl::subtags; +use unic_langid_impl::CharacterDirection; +use unic_langid_impl::LanguageIdentifier; + +fn assert_language_identifier( + loc: &LanguageIdentifier, + language: Option<&str>, + script: Option<&str>, + region: Option<&str>, + variants: Option<&[&str]>, +) { + assert_eq!( + loc.language, + language.map_or(subtags::Language::default(), |l| { + subtags::Language::from_bytes(l.as_bytes()).unwrap() + }) + ); + assert_eq!(loc.script, script.map(|s| s.parse().unwrap())); + assert_eq!(loc.region, region.map(|r| r.parse().unwrap())); + let v = variants + .unwrap_or(&[]) + .iter() + .map(|v| -> subtags::Variant { v.parse().unwrap() }) + .collect::<Vec<_>>(); + assert_eq!( + loc.variants().collect::<Vec<_>>(), + v.iter().collect::<Vec<_>>(), + ); +} + +fn assert_parsed_language_identifier( + input: &str, + language: Option<&str>, + script: Option<&str>, + region: Option<&str>, + variants: Option<&[&str]>, +) { + let langid = parse_language_identifier(input.as_bytes()).unwrap(); + assert_language_identifier(&langid, language, script, region, variants); +} + +#[test] +fn test_language_identifier_parser() { + assert_parsed_language_identifier("pl", Some("pl"), None, None, None); + assert_parsed_language_identifier("und", None, None, None, None); + assert_parsed_language_identifier("en-US", Some("en"), None, Some("US"), None); + assert_parsed_language_identifier("en-Latn-US", Some("en"), Some("Latn"), Some("US"), None); + assert_parsed_language_identifier("sl-nedis", Some("sl"), None, None, Some(&["nedis"])); +} + +#[test] +fn test_language_casing() { + assert_parsed_language_identifier("Pl", Some("pl"), None, None, None); + assert_parsed_language_identifier("En-uS", Some("en"), None, Some("US"), None); + assert_parsed_language_identifier("eN-lAtN-uS", Some("en"), Some("Latn"), Some("US"), None); + assert_parsed_language_identifier("ZH_cyrl_hN", Some("zh"), Some("Cyrl"), Some("HN"), None); +} + +#[test] +fn test_serialize_langid() { + let langid: LanguageIdentifier = "en-Latn-US".parse().unwrap(); + assert_eq!(&langid.to_string(), "en-Latn-US"); +} + +#[test] +fn test_sorted_variants() { + let langid: LanguageIdentifier = "en-nedis-macos".parse().unwrap(); + assert_eq!(&langid.to_string(), "en-macos-nedis"); + + let langid = LanguageIdentifier::from_parts( + "en".parse().unwrap(), + None, + None, + &["nedis".parse().unwrap(), "macos".parse().unwrap()], + ); + assert_eq!(&langid.to_string(), "en-macos-nedis"); +} + +#[test] +fn test_from_parts_unchecked() { + let langid: LanguageIdentifier = "en-nedis-macos".parse().unwrap(); + let (lang, script, region, variants) = langid.into_parts(); + let langid = LanguageIdentifier::from_raw_parts_unchecked( + lang, + script, + region, + Some(variants.into_boxed_slice()), + ); + assert_eq!(&langid.to_string(), "en-macos-nedis"); +} + +#[test] +fn test_matches() { + let langid_en: LanguageIdentifier = "en".parse().unwrap(); + let langid_en_us: LanguageIdentifier = "en-US".parse().unwrap(); + let langid_en_us2: LanguageIdentifier = "en-US".parse().unwrap(); + let langid_pl: LanguageIdentifier = "pl".parse().unwrap(); + assert_eq!(langid_en.matches(&langid_en_us, false, false), false); + assert_eq!(langid_en_us.matches(&langid_en_us2, false, false), true); + assert_eq!(langid_en.matches(&langid_pl, false, false), false); + assert_eq!(langid_en.matches(&langid_en_us, true, false), true); +} + +#[test] +fn test_set_fields() { + let mut langid = LanguageIdentifier::default(); + assert_eq!(&langid.to_string(), "und"); + + langid.language = "pl".parse().expect("Setting language failed"); + assert_eq!(&langid.to_string(), "pl"); + + langid.language = "de".parse().expect("Setting language failed"); + assert_eq!(&langid.to_string(), "de"); + langid.region = Some("AT".parse().expect("Setting region failed")); + assert_eq!(&langid.to_string(), "de-AT"); + langid.script = Some("Latn".parse().expect("Setting script failed")); + assert_eq!(&langid.to_string(), "de-Latn-AT"); + langid.set_variants(&["macos".parse().expect("Setting variants failed")]); + assert_eq!(&langid.to_string(), "de-Latn-AT-macos"); + + assert_eq!(langid.has_variant("macos".parse().unwrap()), true); + assert_eq!(langid.has_variant("windows".parse().unwrap()), false); + + langid.language.clear(); + assert_eq!(&langid.to_string(), "und-Latn-AT-macos"); + langid.region = None; + assert_eq!(&langid.to_string(), "und-Latn-macos"); + langid.script = None; + assert_eq!(&langid.to_string(), "und-macos"); + langid.clear_variants(); + assert_eq!(&langid.to_string(), "und"); + + assert_eq!(langid.has_variant("macos".parse().unwrap()), false); +} + +#[test] +fn test_matches_as_range() { + let langid: LanguageIdentifier = "en-US".parse().unwrap(); + let langid2: LanguageIdentifier = "en-US-windows".parse().unwrap(); + assert_eq!(langid.matches(&langid2, false, false), false); + assert_eq!(langid.matches(&langid2, true, false), true); + assert_eq!(langid.matches(&langid2, false, true), false); + assert_eq!(langid.matches(&langid2, true, true), true); +} + +#[test] +fn test_character_direction() { + let langid: LanguageIdentifier = "en-US".parse().unwrap(); + let langid2: LanguageIdentifier = "ar-AF".parse().unwrap(); + assert_eq!(langid.character_direction(), CharacterDirection::LTR); + assert_eq!(langid2.character_direction(), CharacterDirection::RTL); +} + +#[test] +fn test_langid_ord() { + let input = &[ + "en-US-macos-zarab", + "en-US-macos-nedis", + "en-US-macos", + "en-GB", + "en", + "en-US", + "ar", + "fr", + "de", + ]; + + let mut langids = input + .iter() + .map(|l| -> LanguageIdentifier { l.parse().unwrap() }) + .collect::<Vec<_>>(); + + langids.sort(); + + let result = langids.iter().map(|l| l.to_string()).collect::<Vec<_>>(); + + assert_eq!( + &result, + &[ + "ar", + "de", + "en", + "en-GB", + "en-US", + "en-US-macos", + "en-US-macos-nedis", + "en-US-macos-zarab", + "fr" + ] + ); +} diff --git a/vendor/unic-langid-impl/tests/likelysubtags.rs b/vendor/unic-langid-impl/tests/likelysubtags.rs new file mode 100644 index 000000000..a378274f3 --- /dev/null +++ b/vendor/unic-langid-impl/tests/likelysubtags.rs @@ -0,0 +1,113 @@ +use unic_langid_impl::likelysubtags::{maximize, minimize, CLDR_VERSION}; +use unic_langid_impl::subtags; + +static STRINGS: &[(&str, Option<&str>)] = &[ + ("en-US", Some("en-Latn-US")), + ("en-GB", Some("en-Latn-GB")), + ("es-AR", Some("es-Latn-AR")), + ("it", Some("it-Latn-IT")), + ("zh-Hans-CN", None), + ("de-AT", Some("de-Latn-AT")), + ("pl", Some("pl-Latn-PL")), + ("fr-FR", Some("fr-Latn-FR")), + ("de-AT", Some("de-Latn-AT")), + ("sr-Cyrl-SR", None), + ("nb-NO", Some("nb-Latn-NO")), + ("fr-FR", Some("fr-Latn-FR")), + ("mk", Some("mk-Cyrl-MK")), + ("uk", Some("uk-Cyrl-UA")), + ("und-PL", Some("pl-Latn-PL")), + ("und-Latn-AM", Some("ku-Latn-AM")), + ("ug-Cyrl", Some("ug-Cyrl-KZ")), + ("sr-ME", Some("sr-Latn-ME")), + ("mn-Mong", Some("mn-Mong-CN")), + ("lif-Limb", Some("lif-Limb-IN")), + ("gan", Some("gan-Hans-CN")), + ("zh-Hant", Some("zh-Hant-TW")), + ("yue-Hans", Some("yue-Hans-CN")), + ("unr", Some("unr-Beng-IN")), + ("unr-Deva", Some("unr-Deva-NP")), + ("und-Thai-CN", Some("lcp-Thai-CN")), + ("ug-Cyrl", Some("ug-Cyrl-KZ")), + ("en-Latn-DE", None), + ("pl-FR", Some("pl-Latn-FR")), + ("de-CH", Some("de-Latn-CH")), + ("tuq", Some("tuq-Latn")), + ("sr-ME", Some("sr-Latn-ME")), + ("ng", Some("ng-Latn-NA")), + ("klx", Some("klx-Latn")), + ("kk-Arab", Some("kk-Arab-CN")), + ("en-Cyrl", Some("en-Cyrl-US")), + ("und-Cyrl-UK", Some("ru-Cyrl-UK")), + ("und-Arab", Some("ar-Arab-EG")), + ("und-Arab-FO", Some("ar-Arab-FO")), + ("zh-TW", Some("zh-Hant-TW")), +]; + +fn extract_input( + s: &str, +) -> ( + subtags::Language, + Option<subtags::Script>, + Option<subtags::Region>, +) { + let chunks: Vec<&str> = s.split("-").collect(); + let lang: subtags::Language = chunks[0].parse().unwrap(); + let (script, region) = if let Some(s) = chunks.get(1) { + if let Ok(script) = s.parse() { + let region = chunks.get(2).map(|r| r.parse().unwrap()); + (Some(script), region) + } else { + let region = s.parse().unwrap(); + (None, Some(region)) + } + } else { + (None, None) + }; + (lang, script, region) +} + +fn extract_output( + s: Option<&str>, +) -> Option<( + subtags::Language, + Option<subtags::Script>, + Option<subtags::Region>, +)> { + s.map(|s| { + let chunks: Vec<&str> = s.split("-").collect(); + ( + chunks[0].parse().unwrap(), + chunks.get(1).map(|s| s.parse().unwrap()), + chunks.get(2).map(|s| s.parse().unwrap()), + ) + }) +} + +#[test] +fn maximize_test() { + for i in STRINGS { + let chunks = extract_input(i.0); + let result = maximize(chunks.0, chunks.1, chunks.2); + assert_eq!(extract_output(i.1), result); + } +} + +#[test] +fn version_works() { + assert_eq!(CLDR_VERSION, "36"); +} + +#[test] +fn minimize_test() { + let lang = "zh".parse().unwrap(); + let script = "Hant".parse().unwrap(); + let result = minimize(lang, Some(script), None); + assert_eq!(result, Some(extract_input("zh-TW"))); + + let lang = "en".parse().unwrap(); + let script = "Latn".parse().unwrap(); + let region = "US".parse().unwrap(); + let result = minimize(lang, Some(script), Some(region)); + assert_eq!(result, Some(extract_input("en"))); +} |