Skip to content

Commit 21e77dd

Browse files
Ertanicalerque
authored andcommitted
refactor(fluent-syntax): Use pre-formatted messages for roundtrip_unnormalized_fixtures()
...and compare with expected span data.
1 parent 10aea85 commit 21e77dd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1480
-18
lines changed

.gitattributes

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
*.ftl eol=lf
22

3-
fluent-syntax/tests/fixtures/crlf.ftl eol=crlf
43
fluent-syntax/tests/fixtures/cr.ftl eol=cr
4+
fluent-syntax/tests/fixtures/crlf.ftl eol=crlf
5+
fluent-syntax/tests/fixtures/formatted/cr.ftl eol=cr
6+
fluent-syntax/tests/fixtures/formatted/junked/cr.ftl eol=cr
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# ↓ BEL, U+0007
2+
control0 = abcdef
3+
# ↓ DEL, U+007F
4+
delete = abcdef
5+
# ↓ BPM, U+0082
6+
control1 = abc‚def
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
face-with-tears-of-joy = 😂
2+
tetragram-for-centre = 𝌆
3+
surrogates-in-text = \uD83D\uDE02
4+
surrogates-in-string = { "\uD83D\uDE02" }
5+
surrogates-in-adjacent-strings = { "\uD83D" }{ "\uDE02" }
6+
emoji-in-text = A face 😂 with tears of joy.
7+
emoji-in-string = { "A face 😂 with tears of joy." }
8+
9+
# ERROR Invalid identifier
10+
11+
# ERROR Invalid expression
12+
13+
# ERROR Invalid variant key
14+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
## Function names
2+
3+
valid-func-name-01 = { FUN1() }
4+
valid-func-name-02 = { FUN_FUN() }
5+
valid-func-name-03 = { FUN-FUN() }
6+
7+
# JUNK 0 is not a valid Identifier start
8+
9+
# JUNK Function names may not be lowercase
10+
11+
# JUNK Function names may not contain lowercase character
12+
13+
# JUNK ? is not a valid Identifier character
14+
15+
## Arguments
16+
17+
positional-args = { FUN(1, "a", msg) }
18+
named-args = { FUN(x: 1, y: "Y") }
19+
dense-named-args = { FUN(x: 1, y: "Y") }
20+
mixed-args = { FUN(1, "a", msg, x: 1, y: "Y") }
21+
22+
# ERROR Positional arg must not follow keyword args
23+
24+
# ERROR Named arguments must be unique
25+
26+
## Whitespace around arguments
27+
28+
sparse-inline-call = { FUN("a", msg, x: 1) }
29+
empty-inline-call = { FUN() }
30+
multiline-call = { FUN("a", msg, x: 1) }
31+
sparse-multiline-call = { FUN("a", msg, x: 1) }
32+
empty-multiline-call = { FUN() }
33+
unindented-arg-number = { FUN(1) }
34+
unindented-arg-string = { FUN("a") }
35+
unindented-arg-msg-ref = { FUN(msg) }
36+
unindented-arg-term-ref = { FUN(-msg) }
37+
unindented-arg-var-ref = { FUN($var) }
38+
unindented-arg-call = { FUN(OTHER()) }
39+
unindented-named-arg = { FUN(x: 1) }
40+
unindented-closing-paren = { FUN(x) }
41+
42+
## Optional trailing comma
43+
44+
one-argument = { FUN(1) }
45+
many-arguments = { FUN(1, 2, 3) }
46+
inline-sparse-args = { FUN(1, 2, 3) }
47+
mulitline-args = { FUN(1, 2) }
48+
mulitline-sparse-args = { FUN(1, 2) }
49+
50+
## Syntax errors for trailing comma
51+
52+
## Whitespace in named arguments
53+
54+
sparse-named-arg = { FUN(x: 1, y: 2, z: 3) }
55+
unindented-colon = { FUN(x: 1) }
56+
unindented-value = { FUN(x: 1) }
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## Callees in placeables.
2+
3+
function-callee-placeable = { FUNCTION() }
4+
term-callee-placeable = { -term() }
5+
6+
# ERROR Messages cannot be parameterized.
7+
8+
# ERROR Equivalent to a MessageReference callee.
9+
10+
# ERROR Message attributes cannot be parameterized.
11+
12+
# ERROR Term attributes may not be used in Placeables.
13+
14+
# ERROR Variables cannot be parameterized.
15+
16+
## Callees in selectors.
17+
18+
function-callee-selector =
19+
{ FUNCTION() ->
20+
*[key] Value
21+
}
22+
term-attr-callee-selector =
23+
{ -term.attr() ->
24+
*[key] Value
25+
}
26+
27+
# ERROR Messages cannot be parameterized.
28+
29+
# ERROR Equivalent to a MessageReference callee.
30+
31+
# ERROR Message attributes cannot be parameterized.
32+
33+
# ERROR Term values may not be used as selectors.
34+
35+
# ERROR Variables cannot be parameterized.
36+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Standalone Comment
2+
3+
# Message Comment
4+
foo = Foo
5+
# Term Comment
6+
# with a blank last line.
7+
#
8+
-term = Term
9+
10+
# Another standalone
11+
#
12+
# with indent
13+
14+
15+
## Group Comment
16+
17+
18+
### Resource Comment
19+
20+
21+
# Errors
22+

fluent-syntax/tests/fixtures/formatted/cr.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### This entire file uses CR as EOL.err01 = Value 01err02 = Value 02err03 = Value 03 Continued .title = Titleerr04 = { "strerr05 = { $sel -> }
2+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### NOTE: Disable final newline insertion when editing this file.
2+
3+
4+
# No EOL
5+

fluent-syntax/tests/fixtures/formatted/eof_empty.ftl

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### NOTE: Disable final newline insertion when editing this file.
2+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### NOTE: Disable final newline insertion when editing this file.
2+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### NOTE: Disable final newline insertion when editing this file.
2+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### NOTE: Disable final newline insertion when editing this file.
2+
3+
no-eol = No EOL
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## Literal text
2+
3+
text-backslash-one = Value with \ a backslash
4+
text-backslash-two = Value with \\ two backslashes
5+
text-backslash-brace = Value with \{ placeable }
6+
text-backslash-u = \u0041
7+
text-backslash-backslash-u = \\u0041
8+
9+
## String literals
10+
11+
quote-in-string = { "\"" }
12+
backslash-in-string = { "\\" }
13+
14+
# ERROR Mismatched quote
15+
16+
# ERROR Unknown escape
17+
18+
# ERROR Multiline literal
19+
20+
## Unicode escapes
21+
22+
string-unicode-4digits = { "\u0041" }
23+
escape-unicode-4digits = { "\\u0041" }
24+
string-unicode-6digits = { "\U01F602" }
25+
escape-unicode-6digits = { "\\U01F602" }
26+
# OK The trailing "00" is part of the literal value.
27+
string-too-many-4digits = { "\u004100" }
28+
# OK The trailing "00" is part of the literal value.
29+
string-too-many-6digits = { "\U01F60200" }
30+
31+
# ERROR Too few hex digits after \u.
32+
33+
# ERROR Too few hex digits after \U.
34+
35+
## Literal braces
36+
37+
brace-open = An opening { "{" } brace.
38+
brace-close = A closing { "}" } brace.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## Two adjacent Junks.
2+
3+
# A single Junk.
4+
5+
# A single Junk.
6+
7+
# The COMMENT ends this junk.
8+
9+
# COMMENT
10+
11+
12+
# The COMMENT ends this junk.
13+
# The closing brace is a separate Junk.
14+
15+
# COMMENT
16+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# ↓ BEL, U+0007
2+
control0 = abcdef
3+
# ↓ DEL, U+007F
4+
delete = abcdef
5+
# ↓ BPM, U+0082
6+
control1 = abc‚def
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
face-with-tears-of-joy = 😂
2+
tetragram-for-centre = 𝌆
3+
surrogates-in-text = \uD83D\uDE02
4+
surrogates-in-string = { "\uD83D\uDE02" }
5+
surrogates-in-adjacent-strings = { "\uD83D" }{ "\uDE02" }
6+
emoji-in-text = A face 😂 with tears of joy.
7+
emoji-in-string = { "A face 😂 with tears of joy." }
8+
9+
# ERROR Invalid identifier
10+
11+
err-😂 = Value
12+
13+
# ERROR Invalid expression
14+
15+
err-invalid-expression = { 😂 }
16+
17+
# ERROR Invalid variant key
18+
19+
err-invalid-variant-key = { $sel ->
20+
*[😂] Value
21+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
## Function names
2+
3+
valid-func-name-01 = { FUN1() }
4+
valid-func-name-02 = { FUN_FUN() }
5+
valid-func-name-03 = { FUN-FUN() }
6+
7+
# JUNK 0 is not a valid Identifier start
8+
9+
invalid-func-name-01 = {0FUN()}
10+
# JUNK Function names may not be lowercase
11+
12+
invalid-func-name-02 = {fun()}
13+
# JUNK Function names may not contain lowercase character
14+
15+
invalid-func-name-03 = {Fun()}
16+
# JUNK ? is not a valid Identifier character
17+
18+
invalid-func-name-04 = {FUN?()}
19+
20+
## Arguments
21+
22+
positional-args = { FUN(1, "a", msg) }
23+
named-args = { FUN(x: 1, y: "Y") }
24+
dense-named-args = { FUN(x: 1, y: "Y") }
25+
mixed-args = { FUN(1, "a", msg, x: 1, y: "Y") }
26+
27+
# ERROR Positional arg must not follow keyword args
28+
29+
shuffled-args = {FUN(1, x: 1, "a", y: "Y", msg)}
30+
31+
# ERROR Named arguments must be unique
32+
33+
duplicate-named-args = {FUN(x: 1, x: "X")}
34+
35+
36+
## Whitespace around arguments
37+
38+
sparse-inline-call = { FUN("a", msg, x: 1) }
39+
empty-inline-call = { FUN() }
40+
multiline-call = { FUN("a", msg, x: 1) }
41+
sparse-multiline-call = { FUN("a", msg, x: 1) }
42+
empty-multiline-call = { FUN() }
43+
unindented-arg-number = { FUN(1) }
44+
unindented-arg-string = { FUN("a") }
45+
unindented-arg-msg-ref = { FUN(msg) }
46+
unindented-arg-term-ref = { FUN(-msg) }
47+
unindented-arg-var-ref = { FUN($var) }
48+
unindented-arg-call = { FUN(OTHER()) }
49+
unindented-named-arg = { FUN(x: 1) }
50+
unindented-closing-paren = { FUN(x) }
51+
52+
## Optional trailing comma
53+
54+
one-argument = { FUN(1) }
55+
many-arguments = { FUN(1, 2, 3) }
56+
inline-sparse-args = { FUN(1, 2, 3) }
57+
mulitline-args = { FUN(1, 2) }
58+
mulitline-sparse-args = { FUN(1, 2) }
59+
60+
## Syntax errors for trailing comma
61+
62+
one-argument = {FUN(1,,)}
63+
missing-arg = {FUN(,)}
64+
missing-sparse-arg = {FUN( , )}
65+
66+
67+
## Whitespace in named arguments
68+
69+
sparse-named-arg = { FUN(x: 1, y: 2, z: 3) }
70+
unindented-colon = { FUN(x: 1) }
71+
unindented-value = { FUN(x: 1) }
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
## Callees in placeables.
2+
3+
function-callee-placeable = { FUNCTION() }
4+
term-callee-placeable = { -term() }
5+
6+
# ERROR Messages cannot be parameterized.
7+
8+
message-callee-placeable = {message()}
9+
# ERROR Equivalent to a MessageReference callee.
10+
11+
mixed-case-callee-placeable = {Function()}
12+
# ERROR Message attributes cannot be parameterized.
13+
14+
message-attr-callee-placeable = {message.attr()}
15+
# ERROR Term attributes may not be used in Placeables.
16+
17+
term-attr-callee-placeable = {-term.attr()}
18+
# ERROR Variables cannot be parameterized.
19+
20+
variable-callee-placeable = {$variable()}
21+
22+
23+
## Callees in selectors.
24+
25+
function-callee-selector =
26+
{ FUNCTION() ->
27+
*[key] Value
28+
}
29+
term-attr-callee-selector =
30+
{ -term.attr() ->
31+
*[key] Value
32+
}
33+
34+
# ERROR Messages cannot be parameterized.
35+
36+
message-callee-selector = {message() ->
37+
*[key] Value
38+
}
39+
# ERROR Equivalent to a MessageReference callee.
40+
41+
mixed-case-callee-selector = {Function() ->
42+
*[key] Value
43+
}
44+
# ERROR Message attributes cannot be parameterized.
45+
46+
message-attr-callee-selector = {message.attr() ->
47+
*[key] Value
48+
}
49+
# ERROR Term values may not be used as selectors.
50+
51+
term-callee-selector = {-term() ->
52+
*[key] Value
53+
}
54+
# ERROR Variables cannot be parameterized.
55+
56+
variable-callee-selector = {$variable() ->
57+
*[key] Value
58+
}

0 commit comments

Comments
 (0)