Bindings for Array.prototype.toLocaleString()

This commit is contained in:
Tomohide Takao
2018-07-14 19:39:15 +09:00
parent f5035c3841
commit 7a7bc6d22e
2 changed files with 41 additions and 0 deletions

View File

@ -934,4 +934,37 @@ fn find_index() {
"#,
)
.test()
}
#[test]
fn to_locale_string() {
project()
.file(
"src/lib.rs",
r#"
#![feature(proc_macro, wasm_custom_section)]
extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;
use wasm_bindgen::js;
use JsValue;
#[wasm_bindgen]
pub fn array_to_locale_string(array: &js::Array, locale: &JsValue, options: &JsValue) -> js::JsString {
array.to_locale_string(locale, options)
}
"#,
)
.file(
"test.js",
r#"
import * as assert from "assert";
import * as wasm from "./out";
export function test() {
assert.equal(wasm.array_to_locale_string([1, 'a', new Date('21 Dec 1997 14:12:00 UTC')], 'en', {timeZone: 'UTC'}), '1,a,12/21/1997, 2:12:00 PM');
}
"#,
)
.test()
}