File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -213,6 +213,13 @@ extern {
213
213
extern {
214
214
pub type Number ;
215
215
216
+ /// The toLocaleString() method returns a string with a language sensitive
217
+ /// representation of this number.
218
+ ///
219
+ /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString
220
+ #[ wasm_bindgen( method, js_name = toLocaleString) ]
221
+ pub fn to_locale_string ( this : & Number , locale : String ) -> String ;
222
+
216
223
/// The toPrecision() method returns a string representing the Number
217
224
/// object to the specified precision.
218
225
///
Original file line number Diff line number Diff line change 2
2
3
3
use super :: project;
4
4
5
+
6
+ #[ test]
7
+ fn to_locale_string ( ) {
8
+ project ( )
9
+ . file ( "src/lib.rs" , r#"
10
+ #![feature(proc_macro, wasm_custom_section)]
11
+
12
+ extern crate wasm_bindgen;
13
+ use wasm_bindgen::prelude::*;
14
+ use wasm_bindgen::js;
15
+
16
+ #[wasm_bindgen]
17
+ pub fn to_locale_string(this: &js::Number, locale: String) -> String {
18
+ this.to_locale_string(locale)
19
+ }
20
+ "# )
21
+ . file ( "test.ts" , r#"
22
+ import * as assert from "assert";
23
+ import * as wasm from "./out";
24
+
25
+ export function test() {
26
+ let number = 1234.45;
27
+ assert.equal(wasm.to_locale_string(number, "de-DE"), "1,234.45");
28
+ assert.equal(wasm.to_locale_string(number, "en-US"), "1,234.45");
29
+ assert.equal(wasm.to_locale_string(number, "zh-Hans-CN-u-nu-hanidec"), "1,234.45");
30
+ }
31
+ "# )
32
+ . test ( )
33
+ }
34
+
5
35
#[ test]
6
36
fn to_precision ( ) {
7
37
project ( )
You can’t perform that action at this time.
0 commit comments