Skip to content

Commit 8b28c38

Browse files
committed
ICU-22927 Duplicate (back) the MF2 test data between icu4c and icu4j
The C++ and Java implementations are done by two different people different companies. With different time constraints and availability. The spec is still not final (although it is close), and the implementations are still quite a bit behind. Sharing these test files slows down development, by forcing any C++ and Java changes to happen in the same time. There are other components that share test files that are not shared yet, even if they are more stable. So I don't know why we would force this on MF2 only. This is temporary, and the data files will be de-duplicated again at a later time, when the two implementations are more stable. That de-duplication will include other shared files, and in a slightly different structure (we have a doc and a discution on this topic).
1 parent 0b9eb9c commit 8b28c38

34 files changed

+3855
-16
lines changed

icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/TestUtils.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -200,20 +200,5 @@ private static Path getTestFile(Class<?> cls, String fileName) throws URISyntaxE
200200
URI getPath = cls.getClassLoader().getResource(packageName).toURI();
201201
Path filePath = Paths.get(getPath);
202202
Path json = Paths.get(fileName);
203-
// First, check the top level of the source directory,
204-
// in case we're in a source tarball
205-
Path icuTestdataInSourceDir = filePath.resolve("../../../../../../../../../../../testdata/message2/").normalize();
206-
Path icuTestdataDir = icuTestdataInSourceDir;
207-
if (!Files.isDirectory(icuTestdataInSourceDir)) {
208-
// If that doesn't exist, check one directory higher, in case we're
209-
// in a checked-out repo
210-
Path icuTestdataInRepo = Paths.get("../").resolve(icuTestdataInSourceDir).normalize();
211-
if (!Files.isDirectory(icuTestdataInRepo)) {
212-
throw new java.io.FileNotFoundException("Test data directory does not exist: tried "
213-
+ icuTestdataInSourceDir + " and "
214-
+ icuTestdataInRepo);
215-
}
216-
icuTestdataDir = icuTestdataInSourceDir;
217-
}
218-
return icuTestdataDir.resolve(json);
203+
return filePath.resolve(json);
219204
}}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
© 2024 and later: Unicode, Inc. and others.
2+
License & terms of use: http://www.unicode.org/copyright.html
3+
4+
The format of the JSON files in this directory and subdirectories
5+
follow the test schema defined in the Conformance repository:
6+
7+
https://github.com/unicode-org/conformance/blob/main/schema/message_fmt2/testgen_schema.json
8+
9+
(as of https://github.com/unicode-org/conformance/pull/255 or later).
10+
11+
# JSON notes
12+
13+
In the "params" field, a date parameter can be expressed as:
14+
{ "date": n }
15+
where n is a number representing a Unix timestamp.
16+
17+
In the "params" field, a decimal string parameter can be expressed as:
18+
{ "decimal": s }
19+
where s is a string.
20+
21+
Optional fields, "ignoreJava" and "ignoreCpp" can be used
22+
for tests currently expected to fail in the respective language.
23+
The field may have any value; if it's
24+
present, the test is ignored. (The value can be a comment explaining
25+
why it's expected to fail.)
26+
27+
Tests in the `spec/` subdirectory are taken from https://github.com/unicode-org/message-format-wg/blob/main/test .
28+
If the contents change upstream, then the corresponding tests in CLDR
29+
need to be updated (also see https://unicode-org.atlassian.net/browse/ICU-22812 ).
30+
31+
## ICU4J only
32+
33+
The `cleanSrc` fields is used to represent normalized input (ICU4C has its
34+
own function for normalizing input).
35+
36+
## ICU4C only
37+
38+
Additional "char" and "line" fields may be present with integer values,
39+
used for tests expected to trigger a syntax error.
40+
If present, "char" reflects the expected character offset and "line"
41+
reflects the expected line number in the parse error.
42+
The files with "diagnostics" in the name have these fields filled in.
43+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"scenario": "Selector annotations",
3+
"description": "Tests for indirectly annotated selectors",
4+
"defaultTestProperties": {
5+
"locale": "en-US"
6+
},
7+
"tests": [
8+
{
9+
"src": ".local $one = {|The one| :string}\n .match {$one}\n 1 {{Value is one}}\n * {{Value is not one}}",
10+
"exp": "Value is not one"
11+
},
12+
{
13+
"src": ".local $one = {|The one| :string}\n .local $two = {$one}\n .match {$two}\n 1 {{Value is one}}\n * {{Value is not one}}",
14+
"exp": "Value is not one"
15+
}
16+
]
17+
}
18+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"scenario": "Duplicate declaration errors",
3+
"description": "Tests that should trigger a duplicate declaration error",
4+
"defaultTestProperties": {
5+
"locale": "en-US",
6+
"expErrors": [
7+
{
8+
"type": "duplicate-declaration"
9+
}
10+
]
11+
},
12+
"tests": [
13+
{
14+
"src": ".local $foo = {$foo} .local $foo = {42} {{bar {$foo}}}",
15+
"params": [{ "name": "foo", "value": "foo" }],
16+
"exp": "bar 42"
17+
},
18+
{
19+
"src": ".local $foo = {42} .local $foo = {42} {{bar {$foo}}}",
20+
"params": [{ "name": "foo", "value": "foo" }],
21+
"exp": "bar 42"
22+
},
23+
{
24+
"src": ".local $foo = {:unknown} .local $foo = {42} {{bar {$foo}}}",
25+
"params": [{ "name": "foo", "value": "foo" }],
26+
"exp": "bar 42"
27+
},
28+
{
29+
"src": ".local $x = {42} .local $y = {$x} .local $x = {13} {{{$x} {$y}}}",
30+
"exp": "13 42"
31+
},
32+
{
33+
"src": ".local $foo = {$foo} {{bar {$foo}}}",
34+
"params": [{ "name": "foo", "value": "foo" }],
35+
"exp": "bar foo"
36+
},
37+
{
38+
"src": ".local $foo = {$bar} .local $bar = {$baz} {{bar {$foo}}}",
39+
"params": [{ "name": "baz", "value": "foo" }],
40+
"exp": "bar {$bar}"
41+
}
42+
]
43+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"scenario": "Valid tests",
3+
"description": "Additional valid tests",
4+
"defaultTestProperties": {
5+
"locale": "en-US"
6+
},
7+
"tests": [
8+
{ "src": "" },
9+
{ "src": "Hello" },
10+
{ "src": "Hello world!" },
11+
{ "src": "Hello \t \n \r \\{ world!" },
12+
{ "src": "Hello world {:datetime}" },
13+
{ "src": "Hello world {foo}" },
14+
{ "src": "Hello {0} world" },
15+
{ "src": "Hello {123} world" },
16+
{ "src": "Hello {-123} world" },
17+
{ "src": "Hello {3.1416} world" },
18+
{ "src": "Hello {-3.1416} world" },
19+
{ "src": "Hello {123E+2} world" },
20+
{ "src": "Hello {123E-2} world" },
21+
{ "src": "Hello {123.456E+2} world" },
22+
{ "src": "Hello {123.456E-2} world" },
23+
{ "src": "Hello {-123.456E+2} world" },
24+
{ "src": "Hello {-123.456E-2} world" },
25+
{ "src": "Hello {-123E+2} world" },
26+
{ "src": "Hello {-123E-2} world" },
27+
{ "src": "Hello world {$exp}" },
28+
{ "src": "Hello world {$exp :datetime}" },
29+
{ "src": "Hello world {|2024-02-27| :datetime}" },
30+
{ "src": "Hello world {$exp :datetime style=long} and more" },
31+
{ "src": "Hello world {$exp :function number=1234} and more" },
32+
{ "src": "Hello world {$exp :function unquoted=left } and more" },
33+
{ "src": "Hello world {$exp :function quoted=|Something| } and more" },
34+
{ "src": "Hello world {$exp :function quoted=|Something with spaces| } and more" },
35+
{ "src": "Hello world {$exp :function quoted=|Something with \\| spaces and \\| escapes| } and more" },
36+
{ "src": "Hello world {$exp :function number=1234 unquoted=left quoted=|Something|}" },
37+
{ "src": "Hello world {$exp :function number=1234 unquoted=left quoted=|Something longer|}" },
38+
{ "src": "Hello world {$exp :function number=1234 unquoted=left quoted=|Something \\| longer|}" },
39+
{ "src": "Hello world {$exp}" },
40+
{ "src": "Hello world {$exp @attr}" },
41+
{ "src": "Hello world {$exp @valid @attr=a @attrb=123 @atrn=|foo bar|}" },
42+
{ "src": "Hello world {$exp :date @valid @attr=aaaa @attrb=123 @atrn=|foo bar|}" },
43+
{ "src": "Hello world {$exp :date year=numeric month=long day=numeric int=12 @valid @attr=a @attrb=123 @atrn=|foo bar|}" },
44+
{ "src": "{{.starting with dot is OK here}}" },
45+
{ "src": "{{Some string pattern \\}, with {$foo} and {$exp :date style=long}!}}" },
46+
{ "src": ".input {$pi :number} {{}}" },
47+
{ "src": ".input {$exp :date} {{}}" },
48+
{ "src": ".local $foo = {$exp} {{}}" },
49+
{ "src": ".local $foo = {$exp :date} {{}}" },
50+
{ "src": ".local $foo = {$exp :date year=numeric month=long day=numeric} {{}}" },
51+
{ "src": ".local $bar = {$foo :date month=medium} {{}}" },
52+
{ "src": ".input {$a :date} .local $exp = {$a :date style=full} {{Your card expires on {$exp}!}}" },
53+
{ "src": ".input {$a :date} .local $b = {$a :date year=numeric month=long day=numeric} .local $c = {$b :date month=medium} {{}}" },
54+
{ "src": ".input {$x :number} {{_}}" },
55+
{ "src": ".local $foo = {|1|} {{_}}" }
56+
]
57+
}

0 commit comments

Comments
 (0)