@@ -40,73 +40,85 @@ Some examples of test harnesses using these tests, from the source repository:
4040
4141As the behaviour of ` :number ` , ` :datetime ` , and other default message functions
4242is dependent on locale-specific data and may vary between implementations,
43- the following functions are defined for test use only:
43+ the following functions are defined for ** test use only** :
4444
45- ### ` test:number `
45+ ### ` test:func `
4646
4747This function is valid both as a selector and as a formatter.
48- The only option it recognizes is ` fractionDigits ` ,
48+ The only option it recognizes is ` fd ` ,
4949all other option values passed to it are ignored.
5050
51- When resolving a ` test:number ` expression,
52- its internal _ input_ and _ fractionDigits_ values are determined as follows:
53- 1 . If the expression argument resolves to a numerical value
51+ When resolving a ` test:func ` expression,
52+ its _ Input_ and _ FD_ values are determined as follows:
53+
54+ 1 . Let _ FD_ be ` 0 ` .
55+ 1 . Let _ arg_ be the resolved value of the expression argument.
56+ 1 . If _ arg_ is the resolved value of an expression
57+ with a ` test:func ` , ` test:select ` , or ` test:format ` annotation
58+ for which resolution has succeeded, then
59+ 1 . Let _ Input_ be the _ Input_ value of _ arg_ .
60+ 1 . Set _ FD_ to be _ FD_ value of _ arg_ .
61+ 1 . Else if _ arg_ is a numerical value
5462 or a string matching the ` number-literal ` production, then
55- 1 . Let _ input_ be the numerical value of the argument.
56- 2 . Else,
57- 1 . Emit "bad-input" error.
58- 1 . Use a fallback representation is used as the resolved value of the expression.
59- The _ fractionDigits_ value is not determined.
60- 3 . If the ` fractionDigits ` option is set, then
61- 1 . If its value resolves to a numerical integer value ` 0 ` , ` 1 ` or ` 2 ` ,
62- or their corresponding string representations ` '0' ` , ` '1' ` , or ` '2' ` , then
63- 1 . Let _ fractionDigits_ be the numerical value of the option.
64- 2 . Else,
65- 1 . Emit "bad-option" error.
66- 2 . Let _ fractionDigits_ be ` 0 ` .
67- 4 . Else,
68- 1 . Let _ fractionDigits_ be ` 0 ` .
69-
70- When ` test:number ` is used as a selector,
63+ 1 . Let _ Input_ be the numerical value of _ arg_ .
64+ 1 . Else,
65+ 1 . Emit "bad-input" Resolution Error.
66+ 1 . Use a fallback representation as the resolved value of the expression.
67+ Further steps of this algorithm are not followed.
68+ 1 . If the ` fd ` option is set, then
69+ 1 . If its value resolves to a numerical integer value ` 0 ` or ` 1 `
70+ or their corresponding string representations ` '0' ` or ` '1' ` , then
71+ 1 . Set _ FD_ to be the numerical value of the option.
72+ 1 . Else if its value is not an unresolved value set by [ Option Resolution] ( /spec/formatting.md#option-resolution ) ,
73+ 1 . Emit "bad-option" Resolution Error.
74+ 1 . Use a fallback representation as the resolved value of the expression.
75+
76+ When ` test:func ` is used as a selector,
7177the behaviour of calling it as the ` rv ` value of MatchSelectorKeys(` rv ` , ` keys ` )
7278(see [ Resolve Preferences] ( /spec/formatting.md#resolve-preferences ) for more information)
73- depends on its _ input_ and _ fractionDigits_ values.
74- - If the _ input_ is ` 1 ` and _ fractionDigits_ is ` 0 ` ,
75- the method will return some slice of the list « ` '1' ` , ` 'one' ` »,
79+ depends on its _ Input_ and _ FD_ values.
80+
81+ - If the _ Input_ is ` 1 ` and _ FD_ is ` 1 ` ,
82+ the method will return some slice of the list « ` '1.0' ` , ` '1' ` »,
7683 depending on whether those values are included in ` keys ` .
77- - If the _ input _ is ` 1 ` and _ fractionDigits _ is not ` 0 ` ,
84+ - If the _ Input _ is ` 1 ` and _ FD _ is ` 0 ` ,
7885 the method will return the list « ` '1' ` » if ` keys ` includes ` '1' ` , or an empty list otherwise.
79- - If the _ input _ is any other value, the method will return an empty list.
86+ - If the _ Input _ is any other value, the method will return an empty list.
8087
81- When an expression with a ` test:number ` annotation is assigned to a variable by a declaration
82- and that variable is used as an argument or option value,
83- its resolved value is the _ input _ value.
88+ When an expression with a ` test:func ` annotation is assigned to a variable by a declaration
89+ and that variable is used as an option value,
90+ its resolved value is the _ Input _ value.
8491
85- When ` test:number ` is used as a formatter,
86- a placeholder resolving to a value with a ` test:number ` expression
92+ When ` test:func ` is used as a formatter,
93+ a placeholder resolving to a value with a ` test:func ` expression
8794is formatted as a concatenation of the following parts:
88- 1 . If _ input_ is less than ` 0 ` , the character ` - ` U+002D Hyphen-Minus.
89- 2 . The truncated absolute integer value of _ input_ , i.e. floor(abs(_ input_ )),
95+
96+ 1 . If _ Input_ is less than ` 0 ` , the character ` - ` U+002D Hyphen-Minus.
97+ 1 . The truncated absolute integer value of _ Input_ , i.e. floor(abs(_ Input_ )),
9098 formatted as a sequence of decimal digit caharacters.
91- 3 . If _ fractionDigits_ is ` 1 ` , then
92- 1 . The character ` . ` U+002E Full Stop.
93- 2 . The single decimal digit character representing the value floor((abs(_ input_ ) - floor(abs(_ input_ ))) * 10)
94- 4 . Else if _ fractionDigits_ is ` 2 ` , then
99+ 1 . If _ FD_ is ` 1 ` , then
95100 1 . The character ` . ` U+002E Full Stop.
96- 2 . The two decimal digit character string representing the value floor((abs(_ input_ ) - floor(abs(_ input_ ))) * 100),
97- with a ` 0 ` U+0030 Digit Zero padding at start if the result is less than ` 10 ` .
101+ 1 . The single decimal digit character representing the value floor((abs(_ Input_ ) - floor(abs(_ Input_ ))) \* 10)
98102
99103If the formatting target is a sequence of parts,
100104each of the above parts will be emitted separately
101105rather than being concatenated into a single string.
102106
103- Note that for purposes of clarity, the formatting of ` test:number ` does not perform any rounding.
107+ Note that for purposes of clarity, the formatting of ` test:func ` does not perform any rounding.
104108
105- ### ` test:plural `
109+ ### ` test:select `
106110
107- This function behaves exactly the same as ` test:number ` ,
111+ This function behaves exactly the same as ` test:func ` ,
108112except that it cannot be used for formatting.
109113
110- When ` test:plural ` is used as a formatter,
114+ When ` test:select ` is used as a formatter,
111115a "not-formattable" error is emitted and the placeholder is formatted with
112116a fallback representation.
117+
118+ ### ` test:format `
119+
120+ This function behaves exactly the same as ` test:func ` ,
121+ except that it cannot be used for selection.
122+
123+ When ` test:format ` is used as a selector,
124+ the steps under 2.iii. of [ Resolve Selectors] ( /spec/formatting.md#resolve-selectors ) are followed.
0 commit comments