@@ -5,6 +5,7 @@ import ftl from "@fluent/dedent";
5
5
6
6
import { FluentBundle } from "../esm/bundle.js" ;
7
7
import { FluentResource } from "../esm/resource.js" ;
8
+ import { FluentNumber } from "../esm/types.js" ;
8
9
9
10
suite ( "Runtime-specific functions" , function ( ) {
10
11
let bundle , args , errs ;
@@ -19,13 +20,20 @@ suite("Runtime-specific functions", function () {
19
20
useIsolating : false ,
20
21
functions : {
21
22
CONCAT : ( args , kwargs ) => args . reduce ( ( a , b ) => `${ a } ${ b } ` , "" ) ,
22
- SUM : ( args , kwargs ) => args . reduce ( ( a , b ) => a + b , 0 ) ,
23
+ SUM : ( args , kwargs ) =>
24
+ new FluentNumber ( args . reduce ( ( a , b ) => a + b , 0 ) ) ,
25
+ PLATFORM : ( ) => "windows" ,
23
26
} ,
24
27
} ) ;
25
28
bundle . addResource (
26
29
new FluentResource ( ftl `
27
30
foo = { CONCAT("Foo", "Bar") }
28
31
bar = { SUM(1, 2) }
32
+ pref =
33
+ { PLATFORM() ->
34
+ [windows] Options
35
+ *[other] Preferences
36
+ }
29
37
` )
30
38
) ;
31
39
} ) ;
@@ -37,9 +45,14 @@ suite("Runtime-specific functions", function () {
37
45
assert . strictEqual ( errs . length , 0 ) ;
38
46
} ) ;
39
47
40
- // XXX When they are passed as variables, convert JS types to FTL types
41
- // https://bugzil.la/1307116
42
- test . skip ( "works for numbers" , function ( ) {
48
+ test ( "works for selectors" , function ( ) {
49
+ const msg = bundle . getMessage ( "pref" ) ;
50
+ const val = bundle . formatPattern ( msg . value , args , errs ) ;
51
+ assert . strictEqual ( val , "Options" ) ;
52
+ assert . strictEqual ( errs . length , 0 ) ;
53
+ } ) ;
54
+
55
+ test ( "works for numbers" , function ( ) {
43
56
const msg = bundle . getMessage ( "bar" ) ;
44
57
const val = bundle . formatPattern ( msg . value , args , errs ) ;
45
58
assert . strictEqual ( val , "3" ) ;
0 commit comments