From 45aae6aab0c1ca61fbfcb3de80bc3ec376b9cc15 Mon Sep 17 00:00:00 2001 From: Zibi Braniecki Date: Thu, 8 Oct 2020 19:20:44 -0700 Subject: [PATCH 1/5] Use testdata everywhere --- components/datetime/benches/datetime.rs | 2 +- .../benches/fixtures/tests/styles.json | 24 +++++++++---------- components/datetime/examples/work_log.rs | 2 +- components/datetime/tests/datetime.rs | 2 +- .../data/icu4x/dates/gregory@1/en.json | 1 - .../data/icu4x/dates/gregory@1/pl.json | 1 - .../fixtures/data/icu4x/dates/manifest.json | 4 ---- .../tests/fixtures/data/icu4x/manifest.json | 5 ---- .../datetime/tests/fixtures/tests/styles.json | 4 ++-- .../fs-data-provider/tests/test_file_io.rs | 8 +++---- .../testdata/json_plurals_37/manifest.json | 5 ---- .../plurals/cardinal@1/ar.json | 7 ------ .../plurals/cardinal@1/de.json | 7 ------ .../plurals/cardinal@1/en.json | 7 ------ .../plurals/cardinal@1/iw.json | 7 ------ .../plurals/cardinal@1/sr.json | 7 ------ .../plurals/cardinal@1/und.json | 7 ------ .../plurals/cardinal@1/zh.json | 7 ------ .../json_plurals_37/plurals/ordinal@1/ar.json | 7 ------ .../json_plurals_37/plurals/ordinal@1/en.json | 7 ------ .../json_plurals_37/plurals/ordinal@1/es.json | 7 ------ .../json_plurals_37/plurals/ordinal@1/he.json | 7 ------ .../json_plurals_37/plurals/ordinal@1/sr.json | 7 ------ .../plurals/ordinal@1/und.json | 7 ------ .../plurals/ordinal@1/yue.json | 7 ------ .../pluralrules/benches/fixtures/plurals.json | 2 +- components/pluralrules/benches/parser.rs | 2 +- components/pluralrules/benches/pluralrules.rs | 2 +- .../pluralrules/examples/elevator_floors.rs | 2 +- .../pluralrules/examples/unread_emails.rs | 2 +- .../tests/data/json_plurals_37/manifest.json | 5 ---- .../plurals/cardinal@1/ar.json | 1 - .../plurals/cardinal@1/cs.json | 1 - .../plurals/cardinal@1/de.json | 1 - .../plurals/cardinal@1/en.json | 1 - .../plurals/cardinal@1/es.json | 1 - .../plurals/cardinal@1/fr.json | 1 - .../plurals/cardinal@1/it.json | 1 - .../plurals/cardinal@1/pl.json | 1 - .../plurals/cardinal@1/sk.json | 1 - .../plurals/cardinal@1/uk.json | 1 - .../plurals/cardinal@1/zh.json | 1 - .../json_plurals_37/plurals/ordinal@1/ar.json | 1 - .../json_plurals_37/plurals/ordinal@1/cs.json | 1 - .../json_plurals_37/plurals/ordinal@1/de.json | 1 - .../json_plurals_37/plurals/ordinal@1/en.json | 1 - .../json_plurals_37/plurals/ordinal@1/es.json | 1 - .../json_plurals_37/plurals/ordinal@1/fr.json | 1 - .../json_plurals_37/plurals/ordinal@1/it.json | 1 - .../json_plurals_37/plurals/ordinal@1/pl.json | 1 - .../json_plurals_37/plurals/ordinal@1/sk.json | 1 - .../json_plurals_37/plurals/ordinal@1/uk.json | 1 - .../json_plurals_37/plurals/ordinal@1/zh.json | 1 - components/pluralrules/tests/plurals.rs | 4 ++-- 54 files changed, 28 insertions(+), 169 deletions(-) delete mode 100644 components/datetime/tests/fixtures/data/icu4x/dates/gregory@1/en.json delete mode 100644 components/datetime/tests/fixtures/data/icu4x/dates/gregory@1/pl.json delete mode 100644 components/datetime/tests/fixtures/data/icu4x/dates/manifest.json delete mode 100644 components/datetime/tests/fixtures/data/icu4x/manifest.json delete mode 100644 components/fs-data-provider/tests/testdata/json_plurals_37/manifest.json delete mode 100644 components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/ar.json delete mode 100644 components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/de.json delete mode 100644 components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/en.json delete mode 100644 components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/iw.json delete mode 100644 components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/sr.json delete mode 100644 components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/und.json delete mode 100644 components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/zh.json delete mode 100644 components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/ar.json delete mode 100644 components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/en.json delete mode 100644 components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/es.json delete mode 100644 components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/he.json delete mode 100644 components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/sr.json delete mode 100644 components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/und.json delete mode 100644 components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/yue.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/manifest.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/ar.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/cs.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/de.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/en.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/es.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/fr.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/it.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/pl.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/sk.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/uk.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/zh.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/ar.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/cs.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/de.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/en.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/es.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/fr.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/it.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/pl.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/sk.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/uk.json delete mode 100644 components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/zh.json diff --git a/components/datetime/benches/datetime.rs b/components/datetime/benches/datetime.rs index db780e3a3c4..f006d92293b 100644 --- a/components/datetime/benches/datetime.rs +++ b/components/datetime/benches/datetime.rs @@ -10,7 +10,7 @@ use icu_fs_data_provider::FsDataProvider; fn datetime_benches(c: &mut Criterion) { let fxs = fixtures::get_fixture("styles").unwrap(); - let provider = FsDataProvider::try_new("./tests/fixtures/data/icu4x") + let provider = FsDataProvider::try_new("../../resources/testdata/data/json") .expect("Loading file from testdata directory"); { diff --git a/components/datetime/benches/fixtures/tests/styles.json b/components/datetime/benches/fixtures/tests/styles.json index a11da1a8b92..15b4bd99374 100644 --- a/components/datetime/benches/fixtures/tests/styles.json +++ b/components/datetime/benches/fixtures/tests/styles.json @@ -2,7 +2,7 @@ { "setups": [ { - "locale": "pl", + "locale": "be", "options": { "style": { "date": "full", @@ -11,7 +11,7 @@ } }, { - "locale": "pl", + "locale": "be", "options": { "style": { "date": "long", @@ -20,7 +20,7 @@ } }, { - "locale": "pl", + "locale": "be", "options": { "style": { "date": "medium", @@ -29,7 +29,7 @@ } }, { - "locale": "pl", + "locale": "be", "options": { "style": { "date": "short", @@ -38,7 +38,7 @@ } }, { - "locale": "pl", + "locale": "be", "options": { "style": { "date": null, @@ -47,7 +47,7 @@ } }, { - "locale": "pl", + "locale": "be", "options": { "style": { "date": null, @@ -56,7 +56,7 @@ } }, { - "locale": "pl", + "locale": "be", "options": { "style": { "date": null, @@ -65,7 +65,7 @@ } }, { - "locale": "pl", + "locale": "be", "options": { "style": { "date": null, @@ -74,7 +74,7 @@ } }, { - "locale": "pl", + "locale": "be", "options": { "style": { "date": "full", @@ -83,7 +83,7 @@ } }, { - "locale": "pl", + "locale": "be", "options": { "style": { "date": "long", @@ -92,7 +92,7 @@ } }, { - "locale": "pl", + "locale": "be", "options": { "style": { "date": "medium", @@ -101,7 +101,7 @@ } }, { - "locale": "pl", + "locale": "be", "options": { "style": { "date": "short", diff --git a/components/datetime/examples/work_log.rs b/components/datetime/examples/work_log.rs index eb27d9fb1c2..45f75c4ff0a 100644 --- a/components/datetime/examples/work_log.rs +++ b/components/datetime/examples/work_log.rs @@ -30,7 +30,7 @@ fn print(_input: &str, _value: Option) { fn main() { let langid: LanguageIdentifier = "en".parse().expect("Failed to parse Language Identifier."); - let provider = FsDataProvider::try_new("./tests/fixtures/data/icu4x") + let provider = FsDataProvider::try_new("../../resources/testdata/data/json") .expect("Loading file from testdata directory"); let dates = DATES_ISO diff --git a/components/datetime/tests/datetime.rs b/components/datetime/tests/datetime.rs index c7c90b5a906..75888a953ab 100644 --- a/components/datetime/tests/datetime.rs +++ b/components/datetime/tests/datetime.rs @@ -7,7 +7,7 @@ use std::fmt::Write; #[test] fn test_fixtures() { - let provider = FsDataProvider::try_new("./tests/fixtures/data/icu4x") + let provider = FsDataProvider::try_new("../../resources/testdata/data/json") .expect("Loading file from testdata directory"); for fx in fixtures::get_fixture("styles").unwrap().0 { diff --git a/components/datetime/tests/fixtures/data/icu4x/dates/gregory@1/en.json b/components/datetime/tests/fixtures/data/icu4x/dates/gregory@1/en.json deleted file mode 100644 index 62b3151792c..00000000000 --- a/components/datetime/tests/fixtures/data/icu4x/dates/gregory@1/en.json +++ /dev/null @@ -1 +0,0 @@ -{"symbols":{"months":{"format":{"abbreviated":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"narrow":["J","F","M","A","M","J","J","A","S","O","N","D"],"wide":["January","February","March","April","May","June","July","August","September","October","November","December"]}},"weekdays":{"format":{"abbreviated":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"narrow":["S","M","T","W","T","F","S"],"short":["Su","Mo","Tu","We","Th","Fr","Sa"],"wide":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]}},"day_periods":{"format":{"abbreviated":{"am":"AM","pm":"PM"},"narrow":{"am":"a","pm":"p"},"wide":{"am":"AM","pm":"PM"}},"stand_alone":{"narrow":{"am":"AM","pm":"PM"}}}},"patterns":{"date":{"full":"EEEE, MMMM d, y","long":"MMMM d, y","medium":"MMM d, y","short":"M/d/yy"},"time":{"full":"h:mm:ss a zzzz","long":"h:mm:ss a z","medium":"h:mm:ss a","short":"h:mm a"},"date_time":{"full":"{1} 'at' {0}","long":"{1} 'at' {0}","medium":"{1}, {0}","short":"{1}, {0}"}}} diff --git a/components/datetime/tests/fixtures/data/icu4x/dates/gregory@1/pl.json b/components/datetime/tests/fixtures/data/icu4x/dates/gregory@1/pl.json deleted file mode 100644 index f5c69ba1236..00000000000 --- a/components/datetime/tests/fixtures/data/icu4x/dates/gregory@1/pl.json +++ /dev/null @@ -1 +0,0 @@ -{"symbols":{"months":{"format":{"abbreviated":["sty","lut","mar","kwi","maj","cze","lip","sie","wrz","paź","lis","gru"],"narrow":["s","l","m","k","m","c","l","s","w","p","l","g"],"wide":["stycznia","lutego","marca","kwietnia","maja","czerwca","lipca","sierpnia","września","października","listopada","grudnia"]},"stand_alone":{"narrow":["S","L","M","K","M","C","L","S","W","P","L","G"],"wide":["styczeń","luty","marzec","kwiecień","maj","czerwiec","lipiec","sierpień","wrzesień","październik","listopad","grudzień"]}},"weekdays":{"format":{"abbreviated":["niedz.","pon.","wt.","śr.","czw.","pt.","sob."],"narrow":["n","p","w","ś","c","p","s"],"short":["nie","pon","wto","śro","czw","pią","sob"],"wide":["niedziela","poniedziałek","wtorek","środa","czwartek","piątek","sobota"]},"stand_alone":{"narrow":["N","P","W","Ś","C","P","S"]}},"day_periods":{"format":{"abbreviated":{"am":"AM","pm":"PM"},"narrow":{"am":"a","pm":"p"},"wide":{"am":"AM","pm":"PM"}}}},"patterns":{"date":{"full":"EEEE, d MMMM y","long":"d MMMM y","medium":"d MMM y","short":"dd.MM.y"},"time":{"full":"HH:mm:ss zzzz","long":"HH:mm:ss z","medium":"HH:mm:ss","short":"HH:mm"},"date_time":{"full":"{1} {0}","long":"{1} {0}","medium":"{1}, {0}","short":"{1}, {0}"}}} diff --git a/components/datetime/tests/fixtures/data/icu4x/dates/manifest.json b/components/datetime/tests/fixtures/data/icu4x/dates/manifest.json deleted file mode 100644 index a68a792a8e3..00000000000 --- a/components/datetime/tests/fixtures/data/icu4x/dates/manifest.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "aliasing": "NoAliases", - "syntax": "Json" -} diff --git a/components/datetime/tests/fixtures/data/icu4x/manifest.json b/components/datetime/tests/fixtures/data/icu4x/manifest.json deleted file mode 100644 index c0f2b714d99..00000000000 --- a/components/datetime/tests/fixtures/data/icu4x/manifest.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "aliasing": "NoAliases", - "locales": "IncludeAll", - "syntax": "Json" -} diff --git a/components/datetime/tests/fixtures/tests/styles.json b/components/datetime/tests/fixtures/tests/styles.json index d33a0047c8f..a3d2481e2da 100644 --- a/components/datetime/tests/fixtures/tests/styles.json +++ b/components/datetime/tests/fixtures/tests/styles.json @@ -91,7 +91,7 @@ }, { "input": { - "locale": "pl", + "locale": "be", "value": "2020-03-21T08:25:07.000", "options": { "style": { @@ -101,7 +101,7 @@ } }, "output": { - "value": "sobota, 21 marca 2020 08:25:07 zzzz" + "value": "субота, 21 сакавіка 2020 'г'. 'у' 08:25:07, zzzz" } } ] diff --git a/components/fs-data-provider/tests/test_file_io.rs b/components/fs-data-provider/tests/test_file_io.rs index b7a0b74fd20..82d67382a4b 100644 --- a/components/fs-data-provider/tests/test_file_io.rs +++ b/components/fs-data-provider/tests/test_file_io.rs @@ -5,7 +5,7 @@ use std::borrow::Cow; #[test] fn test_read_json() { - let provider = FsDataProvider::try_new("tests/testdata/json_plurals_37") + let provider = FsDataProvider::try_new("../../resources/testdata/data/json") .expect("Loading file from testdata directory"); let response = provider .load(&DataRequest { @@ -13,7 +13,7 @@ fn test_read_json() { data_entry: DataEntry { variant: None, // TODO: Migrate to LanguageIdentifier macro - langid: "sr".parse().expect("Valid language tag"), + langid: "en".parse().expect("Valid language tag"), }, }) .expect("The key should be present in the testdata"); @@ -24,9 +24,9 @@ fn test_read_json() { plurals_data, &structs::plurals::PluralRuleStringsV1 { zero: None, - one: Some(Cow::Borrowed("v = 0 and i % 10 = 1 and i % 100 != 11 or f % 10 = 1 and f % 100 != 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, … @decimal 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 10.1, 100.1, 1000.1, …")), + one: Some(Cow::Borrowed("i = 1 and v = 0")), two: None, - few: Some(Cow::Borrowed("v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14 @integer 2~4, 22~24, 32~34, 42~44, 52~54, 62, 102, 1002, … @decimal 0.2~0.4, 1.2~1.4, 2.2~2.4, 3.2~3.4, 4.2~4.4, 5.2, 10.2, 100.2, 1000.2, …")), + few: None, many: None, } ); diff --git a/components/fs-data-provider/tests/testdata/json_plurals_37/manifest.json b/components/fs-data-provider/tests/testdata/json_plurals_37/manifest.json deleted file mode 100644 index c0f2b714d99..00000000000 --- a/components/fs-data-provider/tests/testdata/json_plurals_37/manifest.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "aliasing": "NoAliases", - "locales": "IncludeAll", - "syntax": "Json" -} diff --git a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/ar.json b/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/ar.json deleted file mode 100644 index bfb875aea5e..00000000000 --- a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/ar.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "zero": "n = 0 @integer 0 @decimal 0.0, 0.00, 0.000, 0.0000", - "one": "n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000", - "two": "n = 2 @integer 2 @decimal 2.0, 2.00, 2.000, 2.0000", - "few": "n % 100 = 3..10 @integer 3~10, 103~110, 1003, … @decimal 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 103.0, 1003.0, …", - "many": "n % 100 = 11..99 @integer 11~26, 111, 1011, … @decimal 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 111.0, 1011.0, …" -} diff --git a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/de.json b/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/de.json deleted file mode 100644 index 53ff26df1b5..00000000000 --- a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/de.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "zero": null, - "one": "i = 1 and v = 0 @integer 1", - "two": null, - "few": null, - "many": null -} diff --git a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/en.json b/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/en.json deleted file mode 100644 index 53ff26df1b5..00000000000 --- a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/en.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "zero": null, - "one": "i = 1 and v = 0 @integer 1", - "two": null, - "few": null, - "many": null -} diff --git a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/iw.json b/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/iw.json deleted file mode 100644 index 99613c0d10f..00000000000 --- a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/iw.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "zero": null, - "one": "i = 1 and v = 0 @integer 1", - "two": "i = 2 and v = 0 @integer 2", - "few": null, - "many": "v = 0 and n != 0..10 and n % 10 = 0 @integer 20, 30, 40, 50, 60, 70, 80, 90, 100, 1000, 10000, 100000, 1000000, …" -} diff --git a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/sr.json b/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/sr.json deleted file mode 100644 index 5b20b081ddc..00000000000 --- a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/sr.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "zero": null, - "one": "v = 0 and i % 10 = 1 and i % 100 != 11 or f % 10 = 1 and f % 100 != 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, … @decimal 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 10.1, 100.1, 1000.1, …", - "two": null, - "few": "v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14 @integer 2~4, 22~24, 32~34, 42~44, 52~54, 62, 102, 1002, … @decimal 0.2~0.4, 1.2~1.4, 2.2~2.4, 3.2~3.4, 4.2~4.4, 5.2, 10.2, 100.2, 1000.2, …", - "many": null -} diff --git a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/und.json b/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/und.json deleted file mode 100644 index 09656a23d93..00000000000 --- a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/und.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "zero": null, - "one": null, - "two": null, - "few": null, - "many": null -} diff --git a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/zh.json b/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/zh.json deleted file mode 100644 index 09656a23d93..00000000000 --- a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/cardinal@1/zh.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "zero": null, - "one": null, - "two": null, - "few": null, - "many": null -} diff --git a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/ar.json b/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/ar.json deleted file mode 100644 index 09656a23d93..00000000000 --- a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/ar.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "zero": null, - "one": null, - "two": null, - "few": null, - "many": null -} diff --git a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/en.json b/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/en.json deleted file mode 100644 index 70718946ebc..00000000000 --- a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/en.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "zero": null, - "one": "n % 10 = 1 and n % 100 != 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, …", - "two": "n % 10 = 2 and n % 100 != 12 @integer 2, 22, 32, 42, 52, 62, 72, 82, 102, 1002, …", - "few": "n % 10 = 3 and n % 100 != 13 @integer 3, 23, 33, 43, 53, 63, 73, 83, 103, 1003, …", - "many": null -} diff --git a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/es.json b/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/es.json deleted file mode 100644 index 09656a23d93..00000000000 --- a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/es.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "zero": null, - "one": null, - "two": null, - "few": null, - "many": null -} diff --git a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/he.json b/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/he.json deleted file mode 100644 index 09656a23d93..00000000000 --- a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/he.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "zero": null, - "one": null, - "two": null, - "few": null, - "many": null -} diff --git a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/sr.json b/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/sr.json deleted file mode 100644 index 09656a23d93..00000000000 --- a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/sr.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "zero": null, - "one": null, - "two": null, - "few": null, - "many": null -} diff --git a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/und.json b/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/und.json deleted file mode 100644 index 09656a23d93..00000000000 --- a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/und.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "zero": null, - "one": null, - "two": null, - "few": null, - "many": null -} diff --git a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/yue.json b/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/yue.json deleted file mode 100644 index 09656a23d93..00000000000 --- a/components/fs-data-provider/tests/testdata/json_plurals_37/plurals/ordinal@1/yue.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "zero": null, - "one": null, - "two": null, - "few": null, - "many": null -} diff --git a/components/pluralrules/benches/fixtures/plurals.json b/components/pluralrules/benches/fixtures/plurals.json index 26043549570..1386332f6b3 100644 --- a/components/pluralrules/benches/fixtures/plurals.json +++ b/components/pluralrules/benches/fixtures/plurals.json @@ -1,3 +1,3 @@ { - "langs": ["uk", "de", "sk", "ar", "fr", "it", "en", "cs", "es", "zh"] + "langs": ["be", "bn", "en", "fa", "fr", "und", "zh"] } diff --git a/components/pluralrules/benches/parser.rs b/components/pluralrules/benches/parser.rs index 38545fc9830..6225cde8f9c 100644 --- a/components/pluralrules/benches/parser.rs +++ b/components/pluralrules/benches/parser.rs @@ -12,7 +12,7 @@ fn parser(c: &mut Criterion) { let plurals_data = helpers::get_plurals_data(); - let provider = FsDataProvider::try_new("./tests/data/json_plurals_37") + let provider = FsDataProvider::try_new("../../resources/testdata/data/json") .expect("Loading file from testdata directory"); let mut rules = vec![]; diff --git a/components/pluralrules/benches/pluralrules.rs b/components/pluralrules/benches/pluralrules.rs index e9e365a7bfb..dbc14e9e3c6 100644 --- a/components/pluralrules/benches/pluralrules.rs +++ b/components/pluralrules/benches/pluralrules.rs @@ -10,7 +10,7 @@ fn pluralrules(c: &mut Criterion) { let plurals_data = helpers::get_plurals_data(); let numbers_data = helpers::get_numbers_data(); - let provider = FsDataProvider::try_new("./tests/data/json_plurals_37") + let provider = FsDataProvider::try_new("../../resources/testdata/data/json") .expect("Loading file from testdata directory"); c.bench_function("pluralrules/overview", |b| { diff --git a/components/pluralrules/examples/elevator_floors.rs b/components/pluralrules/examples/elevator_floors.rs index c678c62c810..4ce5a91bcb2 100644 --- a/components/pluralrules/examples/elevator_floors.rs +++ b/components/pluralrules/examples/elevator_floors.rs @@ -17,7 +17,7 @@ fn print(_input: &str, _value: Option) { fn main() { let langid: LanguageIdentifier = "en".parse().expect("Failed to parse Language Identifier."); - let dtp = FsDataProvider::try_new("./tests/data/json_plurals_37") + let dtp = FsDataProvider::try_new("../../resources/testdata/data/json") .expect("Loading file from testdata directory"); { diff --git a/components/pluralrules/examples/unread_emails.rs b/components/pluralrules/examples/unread_emails.rs index 2054f1dc443..42cb6724a92 100644 --- a/components/pluralrules/examples/unread_emails.rs +++ b/components/pluralrules/examples/unread_emails.rs @@ -17,7 +17,7 @@ fn print(_input: &str, _value: Option) { fn main() { let langid: LanguageIdentifier = "en".parse().expect("Failed to parse Language Identifier."); - let dtp = FsDataProvider::try_new("./tests/data/json_plurals_37") + let dtp = FsDataProvider::try_new("../../resources/testdata/data/json") .expect("Loading file from testdata directory"); { diff --git a/components/pluralrules/tests/data/json_plurals_37/manifest.json b/components/pluralrules/tests/data/json_plurals_37/manifest.json deleted file mode 100644 index c0f2b714d99..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/manifest.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "aliasing": "NoAliases", - "locales": "IncludeAll", - "syntax": "Json" -} diff --git a/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/ar.json b/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/ar.json deleted file mode 100644 index 7b3c120389e..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/ar.json +++ /dev/null @@ -1 +0,0 @@ -{"zero":"n = 0","one":"n = 1","two":"n = 2","few":"n % 100 = 3..10","many":"n % 100 = 11..99"} diff --git a/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/cs.json b/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/cs.json deleted file mode 100644 index 68bb8dda2b9..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/cs.json +++ /dev/null @@ -1 +0,0 @@ -{"one":"i = 1 and v = 0","few":"i = 2..4 and v = 0","many":"v != 0"} diff --git a/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/de.json b/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/de.json deleted file mode 100644 index 4ce936fa8e6..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/de.json +++ /dev/null @@ -1 +0,0 @@ -{"one":"i = 1 and v = 0"} diff --git a/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/en.json b/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/en.json deleted file mode 100644 index 4ce936fa8e6..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/en.json +++ /dev/null @@ -1 +0,0 @@ -{"one":"i = 1 and v = 0"} diff --git a/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/es.json b/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/es.json deleted file mode 100644 index a6f90482493..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/es.json +++ /dev/null @@ -1 +0,0 @@ -{"one":"n = 1"} diff --git a/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/fr.json b/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/fr.json deleted file mode 100644 index 51be304b297..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/fr.json +++ /dev/null @@ -1 +0,0 @@ -{"one":"i = 0,1"} diff --git a/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/it.json b/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/it.json deleted file mode 100644 index 4ce936fa8e6..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/it.json +++ /dev/null @@ -1 +0,0 @@ -{"one":"i = 1 and v = 0"} diff --git a/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/pl.json b/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/pl.json deleted file mode 100644 index 8ef0fdc5b44..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/pl.json +++ /dev/null @@ -1 +0,0 @@ -{"one":"i = 1 and v = 0","few":"v = 0 and i % 10 = 2..4 and i % 100 != 12..14","many":"v = 0 and i != 1 and i % 10 = 0..1 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 12..14"} diff --git a/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/sk.json b/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/sk.json deleted file mode 100644 index 68bb8dda2b9..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/sk.json +++ /dev/null @@ -1 +0,0 @@ -{"one":"i = 1 and v = 0","few":"i = 2..4 and v = 0","many":"v != 0"} diff --git a/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/uk.json b/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/uk.json deleted file mode 100644 index 7a63d744146..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/uk.json +++ /dev/null @@ -1 +0,0 @@ -{"one":"v = 0 and i % 10 = 1 and i % 100 != 11","few":"v = 0 and i % 10 = 2..4 and i % 100 != 12..14","many":"v = 0 and i % 10 = 0 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 11..14"} diff --git a/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/zh.json b/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/zh.json deleted file mode 100644 index 0967ef424bc..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/plurals/cardinal@1/zh.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/ar.json b/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/ar.json deleted file mode 100644 index 0967ef424bc..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/ar.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/cs.json b/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/cs.json deleted file mode 100644 index 0967ef424bc..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/cs.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/de.json b/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/de.json deleted file mode 100644 index 0967ef424bc..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/de.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/en.json b/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/en.json deleted file mode 100644 index 62555fbefbd..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/en.json +++ /dev/null @@ -1 +0,0 @@ -{"one":"n % 10 = 1 and n % 100 != 11","two":"n % 10 = 2 and n % 100 != 12","few":"n % 10 = 3 and n % 100 != 13"} diff --git a/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/es.json b/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/es.json deleted file mode 100644 index 0967ef424bc..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/es.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/fr.json b/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/fr.json deleted file mode 100644 index a6f90482493..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/fr.json +++ /dev/null @@ -1 +0,0 @@ -{"one":"n = 1"} diff --git a/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/it.json b/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/it.json deleted file mode 100644 index 75b1e4e10a3..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/it.json +++ /dev/null @@ -1 +0,0 @@ -{"many":"n = 11,8,80,800"} diff --git a/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/pl.json b/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/pl.json deleted file mode 100644 index 0967ef424bc..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/pl.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/sk.json b/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/sk.json deleted file mode 100644 index 0967ef424bc..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/sk.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/uk.json b/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/uk.json deleted file mode 100644 index 22830f0e248..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/uk.json +++ /dev/null @@ -1 +0,0 @@ -{"few":"n % 10 = 3 and n % 100 != 13"} diff --git a/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/zh.json b/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/zh.json deleted file mode 100644 index 0967ef424bc..00000000000 --- a/components/pluralrules/tests/data/json_plurals_37/plurals/ordinal@1/zh.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/components/pluralrules/tests/plurals.rs b/components/pluralrules/tests/plurals.rs index 271f65e4cc3..750dc4b8f1d 100644 --- a/components/pluralrules/tests/plurals.rs +++ b/components/pluralrules/tests/plurals.rs @@ -4,7 +4,7 @@ use icu_pluralrules::{PluralCategory, PluralRuleType, PluralRules}; #[test] fn test_plural_rules() { - let dp = FsDataProvider::try_new("./tests/data/json_plurals_37") + let dp = FsDataProvider::try_new("../../resources/testdata/data/json") .expect("Loading file from testdata directory"); let lang: LanguageIdentifier = "en".parse().unwrap(); @@ -16,7 +16,7 @@ fn test_plural_rules() { #[test] fn test_plural_rules_missing() { - let dp = FsDataProvider::try_new("./tests/data/json_plurals_37") + let dp = FsDataProvider::try_new("../../resources/testdata/data/json") .expect("Loading file from testdata directory"); let lang: LanguageIdentifier = "xx".parse().unwrap(); From b4c68ec1c9be877be7cde6344024e79d5b15763c Mon Sep 17 00:00:00 2001 From: Zibi Braniecki Date: Fri, 9 Oct 2020 11:46:56 -0700 Subject: [PATCH 2/5] Use icu_testdata --- components/datetime/Cargo.toml | 2 +- components/datetime/benches/datetime.rs | 4 +--- components/datetime/examples/work_log.rs | 4 +--- components/datetime/tests/datetime.rs | 4 +--- components/icu/src/lib.rs | 4 +--- components/pluralrules/Cargo.toml | 2 +- components/pluralrules/benches/fixtures/plurals.json | 2 +- components/pluralrules/benches/parser.rs | 4 +--- components/pluralrules/benches/pluralrules.rs | 4 +--- components/pluralrules/examples/elevator_floors.rs | 7 +++---- components/pluralrules/examples/unread_emails.rs | 6 ++---- components/pluralrules/tests/plurals.rs | 11 ++++------- 12 files changed, 18 insertions(+), 36 deletions(-) diff --git a/components/datetime/Cargo.toml b/components/datetime/Cargo.toml index bdaa31352e1..de3d32122e9 100644 --- a/components/datetime/Cargo.toml +++ b/components/datetime/Cargo.toml @@ -21,7 +21,7 @@ icu-data-provider = { path = "../data-provider" } [dev-dependencies] criterion = "0.3" icu-data-provider = { path = "../data-provider", features = ["invariant"] } -icu-fs-data-provider = { path = "../fs-data-provider" } +icu-testdata = { path = "../../resources/testdata" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/components/datetime/benches/datetime.rs b/components/datetime/benches/datetime.rs index f006d92293b..1915035cec7 100644 --- a/components/datetime/benches/datetime.rs +++ b/components/datetime/benches/datetime.rs @@ -5,13 +5,11 @@ use std::fmt::Write; use icu_datetime::DateTimeFormat; use icu_datetime::MockDateTime; -use icu_fs_data_provider::FsDataProvider; fn datetime_benches(c: &mut Criterion) { let fxs = fixtures::get_fixture("styles").unwrap(); - let provider = FsDataProvider::try_new("../../resources/testdata/data/json") - .expect("Loading file from testdata directory"); + let provider = icu_testdata::get_provider(); { let mut group = c.benchmark_group("datetime"); diff --git a/components/datetime/examples/work_log.rs b/components/datetime/examples/work_log.rs index 45f75c4ff0a..4e81314ba54 100644 --- a/components/datetime/examples/work_log.rs +++ b/components/datetime/examples/work_log.rs @@ -2,7 +2,6 @@ // from a work log into human readable dates and times. use icu_datetime::date::MockDateTime; use icu_datetime::{options::style, DateTimeFormat}; -use icu_fs_data_provider::FsDataProvider; use icu_locale::LanguageIdentifier; const DATES_ISO: &[&str] = &[ @@ -30,8 +29,7 @@ fn print(_input: &str, _value: Option) { fn main() { let langid: LanguageIdentifier = "en".parse().expect("Failed to parse Language Identifier."); - let provider = FsDataProvider::try_new("../../resources/testdata/data/json") - .expect("Loading file from testdata directory"); + let provider = icu_testdata::get_provider(); let dates = DATES_ISO .iter() diff --git a/components/datetime/tests/datetime.rs b/components/datetime/tests/datetime.rs index 75888a953ab..0725e1c055b 100644 --- a/components/datetime/tests/datetime.rs +++ b/components/datetime/tests/datetime.rs @@ -2,13 +2,11 @@ mod fixtures; use icu_datetime::DateTimeFormat; use icu_datetime::MockDateTime; -use icu_fs_data_provider::FsDataProvider; use std::fmt::Write; #[test] fn test_fixtures() { - let provider = FsDataProvider::try_new("../../resources/testdata/data/json") - .expect("Loading file from testdata directory"); + let provider = icu_testdata::get_provider(); for fx in fixtures::get_fixture("styles").unwrap().0 { let langid = fx.input.locale.parse().unwrap(); diff --git a/components/icu/src/lib.rs b/components/icu/src/lib.rs index 522104c87ba..248d0f78cee 100644 --- a/components/icu/src/lib.rs +++ b/components/icu/src/lib.rs @@ -33,10 +33,8 @@ //! ``` //! use icu::locale::LanguageIdentifier; //! use icu::datetime::{DateTimeFormat, date::MockDateTime, options::style}; -//! use icu_fs_data_provider::FsDataProvider; //! -//! let provider = FsDataProvider::try_new("./tests/fixtures/data/icu4x") -//! .expect("Loading file from testdata directory"); +//! let provider = icu_testdata::get_provider(); //! //! let langid: LanguageIdentifier = "en".parse() //! .expect("Failed to parse a Language Identifier."); diff --git a/components/pluralrules/Cargo.toml b/components/pluralrules/Cargo.toml index 54d9479a613..93e22ae8501 100644 --- a/components/pluralrules/Cargo.toml +++ b/components/pluralrules/Cargo.toml @@ -25,7 +25,7 @@ serde = { version = "1.0", features = ["derive"] } serde_json = {version = "1.0" } icu-locale = { path = "../locale", features = ["serde"] } icu-data-provider = { path = "../data-provider", features = ["invariant"] } -icu-fs-data-provider = { path = "../fs-data-provider" } +icu-testdata = { path = "../../resources/testdata" } [features] default = [] diff --git a/components/pluralrules/benches/fixtures/plurals.json b/components/pluralrules/benches/fixtures/plurals.json index 1386332f6b3..3673f4283fe 100644 --- a/components/pluralrules/benches/fixtures/plurals.json +++ b/components/pluralrules/benches/fixtures/plurals.json @@ -1,3 +1,3 @@ { - "langs": ["be", "bn", "en", "fa", "fr", "und", "zh"] + "langs": ["ar", "be", "bn", "en", "es", "fr", "ja", "sr", "th", "tr"] } diff --git a/components/pluralrules/benches/parser.rs b/components/pluralrules/benches/parser.rs index 6225cde8f9c..0ed9a02e949 100644 --- a/components/pluralrules/benches/parser.rs +++ b/components/pluralrules/benches/parser.rs @@ -4,7 +4,6 @@ mod helpers; use criterion::{black_box, criterion_group, criterion_main, Criterion}; use icu_data_provider::{icu_data_key, structs, DataEntry, DataProvider, DataRequest}; -use icu_fs_data_provider::FsDataProvider; use std::borrow::Cow; fn parser(c: &mut Criterion) { @@ -12,8 +11,7 @@ fn parser(c: &mut Criterion) { let plurals_data = helpers::get_plurals_data(); - let provider = FsDataProvider::try_new("../../resources/testdata/data/json") - .expect("Loading file from testdata directory"); + let provider = icu_testdata::get_provider(); let mut rules = vec![]; diff --git a/components/pluralrules/benches/pluralrules.rs b/components/pluralrules/benches/pluralrules.rs index dbc14e9e3c6..e85ed2b790f 100644 --- a/components/pluralrules/benches/pluralrules.rs +++ b/components/pluralrules/benches/pluralrules.rs @@ -3,15 +3,13 @@ mod helpers; use criterion::{criterion_group, criterion_main, Criterion}; -use icu_fs_data_provider::FsDataProvider; use icu_pluralrules::{PluralRuleType, PluralRules}; fn pluralrules(c: &mut Criterion) { let plurals_data = helpers::get_plurals_data(); let numbers_data = helpers::get_numbers_data(); - let provider = FsDataProvider::try_new("../../resources/testdata/data/json") - .expect("Loading file from testdata directory"); + let provider = icu_testdata::get_provider(); c.bench_function("pluralrules/overview", |b| { b.iter(|| { diff --git a/components/pluralrules/examples/elevator_floors.rs b/components/pluralrules/examples/elevator_floors.rs index 4ce5a91bcb2..a9cf340a4ca 100644 --- a/components/pluralrules/examples/elevator_floors.rs +++ b/components/pluralrules/examples/elevator_floors.rs @@ -1,6 +1,5 @@ // An example application which uses icu_pluralrules to construct a correct // sentence for English based on the numerical value in Ordinal category. -use icu_fs_data_provider::FsDataProvider; use icu_locale::LanguageIdentifier; use icu_pluralrules::{PluralCategory, PluralRuleType, PluralRules}; @@ -17,12 +16,12 @@ fn print(_input: &str, _value: Option) { fn main() { let langid: LanguageIdentifier = "en".parse().expect("Failed to parse Language Identifier."); - let dtp = FsDataProvider::try_new("../../resources/testdata/data/json") - .expect("Loading file from testdata directory"); + + let provider = icu_testdata::get_provider(); { print("\n====== Elevator Floor (en) example ============", None); - let pr = PluralRules::try_new(langid, &dtp, PluralRuleType::Ordinal) + let pr = PluralRules::try_new(langid, &provider, PluralRuleType::Ordinal) .expect("Failed to create a PluralRules instance."); for value in VALUES { diff --git a/components/pluralrules/examples/unread_emails.rs b/components/pluralrules/examples/unread_emails.rs index 42cb6724a92..e048aab4a27 100644 --- a/components/pluralrules/examples/unread_emails.rs +++ b/components/pluralrules/examples/unread_emails.rs @@ -1,6 +1,5 @@ // An example application which uses icu_pluralrules to construct a correct // sentence for English based on the numerical value in Cardinal category. -use icu_fs_data_provider::FsDataProvider; use icu_locale::LanguageIdentifier; use icu_pluralrules::{PluralCategory, PluralRuleType, PluralRules}; @@ -17,12 +16,11 @@ fn print(_input: &str, _value: Option) { fn main() { let langid: LanguageIdentifier = "en".parse().expect("Failed to parse Language Identifier."); - let dtp = FsDataProvider::try_new("../../resources/testdata/data/json") - .expect("Loading file from testdata directory"); + let provider = icu_testdata::get_provider(); { print("\n====== Unread Emails (en) example ============", None); - let pr = PluralRules::try_new(langid, &dtp, PluralRuleType::Cardinal) + let pr = PluralRules::try_new(langid, &provider, PluralRuleType::Cardinal) .expect("Failed to create a PluralRules instance."); for value in VALUES { diff --git a/components/pluralrules/tests/plurals.rs b/components/pluralrules/tests/plurals.rs index 750dc4b8f1d..4be5ad0f424 100644 --- a/components/pluralrules/tests/plurals.rs +++ b/components/pluralrules/tests/plurals.rs @@ -1,27 +1,24 @@ -use icu_fs_data_provider::FsDataProvider; use icu_locale::LanguageIdentifier; use icu_pluralrules::{PluralCategory, PluralRuleType, PluralRules}; #[test] fn test_plural_rules() { - let dp = FsDataProvider::try_new("../../resources/testdata/data/json") - .expect("Loading file from testdata directory"); + let provider = icu_testdata::get_provider(); let lang: LanguageIdentifier = "en".parse().unwrap(); - let pr = PluralRules::try_new(lang, &dp, PluralRuleType::Cardinal).unwrap(); + let pr = PluralRules::try_new(lang, &provider, PluralRuleType::Cardinal).unwrap(); assert_eq!(pr.select(5_usize), PluralCategory::Other); } #[test] fn test_plural_rules_missing() { - let dp = FsDataProvider::try_new("../../resources/testdata/data/json") - .expect("Loading file from testdata directory"); + let provider = icu_testdata::get_provider(); let lang: LanguageIdentifier = "xx".parse().unwrap(); - let pr = PluralRules::try_new(lang, &dp, PluralRuleType::Cardinal); + let pr = PluralRules::try_new(lang, &provider, PluralRuleType::Cardinal); assert!(pr.is_err()); } From 343335d84471d8deaedbe48916fa66409480407e Mon Sep 17 00:00:00 2001 From: Zibi Braniecki Date: Fri, 9 Oct 2020 12:53:52 -0700 Subject: [PATCH 3/5] Apply feedback --- components/datetime/tests/fixtures/tests/styles.json | 2 +- components/fs-data-provider/tests/test_file_io.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/components/datetime/tests/fixtures/tests/styles.json b/components/datetime/tests/fixtures/tests/styles.json index a3d2481e2da..fedd7d62a2a 100644 --- a/components/datetime/tests/fixtures/tests/styles.json +++ b/components/datetime/tests/fixtures/tests/styles.json @@ -101,7 +101,7 @@ } }, "output": { - "value": "субота, 21 сакавіка 2020 'г'. 'у' 08:25:07, zzzz" + "value": "субота, 21 сакавіка 2020 'г'. 'у' 08:25:07, zzzz" } } ] diff --git a/components/fs-data-provider/tests/test_file_io.rs b/components/fs-data-provider/tests/test_file_io.rs index 82d67382a4b..0e97fd33035 100644 --- a/components/fs-data-provider/tests/test_file_io.rs +++ b/components/fs-data-provider/tests/test_file_io.rs @@ -6,14 +6,13 @@ use std::borrow::Cow; #[test] fn test_read_json() { let provider = FsDataProvider::try_new("../../resources/testdata/data/json") - .expect("Loading file from testdata directory"); let response = provider .load(&DataRequest { data_key: icu_data_key!(plurals: cardinal@1), data_entry: DataEntry { variant: None, // TODO: Migrate to LanguageIdentifier macro - langid: "en".parse().expect("Valid language tag"), + langid: "sr".parse().expect("Valid language tag"), }, }) .expect("The key should be present in the testdata"); @@ -24,9 +23,9 @@ fn test_read_json() { plurals_data, &structs::plurals::PluralRuleStringsV1 { zero: None, - one: Some(Cow::Borrowed("i = 1 and v = 0")), + one: Some(Cow::Borrowed("v = 0 and i % 10 = 1 and i % 100 != 11 or f % 10 = 1 and f % 100 != 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, … @decimal 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 10.1, 100.1, 1000.1, …")), two: None, - few: None, + few: Some(Cow::Borrowed("v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14 @integer 2~4, 22~24, 32~34, 42~44, 52~54, 62, 102, 1002, … @decimal 0.2~0.4, 1.2~1.4, 2.2~2.4, 3.2~3.4, 4.2~4.4, 5.2, 10.2, 100.2, 1000.2, …")), many: None, } ); From f44e2153b143042c991a965073d88ef564d7eb89 Mon Sep 17 00:00:00 2001 From: Zibi Braniecki Date: Fri, 9 Oct 2020 12:56:36 -0700 Subject: [PATCH 4/5] Fix missing semicolon --- components/fs-data-provider/tests/test_file_io.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/fs-data-provider/tests/test_file_io.rs b/components/fs-data-provider/tests/test_file_io.rs index 0e97fd33035..23146382674 100644 --- a/components/fs-data-provider/tests/test_file_io.rs +++ b/components/fs-data-provider/tests/test_file_io.rs @@ -5,7 +5,8 @@ use std::borrow::Cow; #[test] fn test_read_json() { - let provider = FsDataProvider::try_new("../../resources/testdata/data/json") + let provider = FsDataProvider::try_new("../../resources/testdata/data/json"); + let response = provider .load(&DataRequest { data_key: icu_data_key!(plurals: cardinal@1), From 5aeb63b455542ad8ddfb721024f93a0a9890d6be Mon Sep 17 00:00:00 2001 From: Zibi Braniecki Date: Fri, 9 Oct 2020 13:02:06 -0700 Subject: [PATCH 5/5] Fix fs-data-provider test --- components/fs-data-provider/tests/test_file_io.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/fs-data-provider/tests/test_file_io.rs b/components/fs-data-provider/tests/test_file_io.rs index 23146382674..4171c2cf496 100644 --- a/components/fs-data-provider/tests/test_file_io.rs +++ b/components/fs-data-provider/tests/test_file_io.rs @@ -5,7 +5,8 @@ use std::borrow::Cow; #[test] fn test_read_json() { - let provider = FsDataProvider::try_new("../../resources/testdata/data/json"); + let provider = FsDataProvider::try_new("../../resources/testdata/data/json") + .expect("Loading file from testdata directory"); let response = provider .load(&DataRequest { @@ -24,9 +25,9 @@ fn test_read_json() { plurals_data, &structs::plurals::PluralRuleStringsV1 { zero: None, - one: Some(Cow::Borrowed("v = 0 and i % 10 = 1 and i % 100 != 11 or f % 10 = 1 and f % 100 != 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, … @decimal 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 10.1, 100.1, 1000.1, …")), + one: Some(Cow::Borrowed("v = 0 and i % 10 = 1 and i % 100 != 11 or f % 10 = 1 and f % 100 != 11")), two: None, - few: Some(Cow::Borrowed("v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14 @integer 2~4, 22~24, 32~34, 42~44, 52~54, 62, 102, 1002, … @decimal 0.2~0.4, 1.2~1.4, 2.2~2.4, 3.2~3.4, 4.2~4.4, 5.2, 10.2, 100.2, 1000.2, …")), + few: Some(Cow::Borrowed("v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14")), many: None, } );