Merge branch 'expose-bindings/object-to-locale-string' of https://github.com/belfz/wasm-bindgen into rollup

This commit is contained in:
Nick Fitzgerald 2018-06-22 10:51:17 -07:00
commit 7825122feb
2 changed files with 35 additions and 0 deletions

View File

@ -220,6 +220,14 @@ extern {
#[wasm_bindgen(method, js_name = hasOwnProperty)] #[wasm_bindgen(method, js_name = hasOwnProperty)]
pub fn has_own_property(this: &Object, property: &JsValue) -> bool; pub fn has_own_property(this: &Object, property: &JsValue) -> bool;
/// The toLocaleString() method returns a string representing the object.
/// This method is meant to be overridden by derived objects for locale-specific
/// purposes.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toLocaleString
#[wasm_bindgen(method, js_name = toLocaleString)]
pub fn to_locale_string(this: &Object) -> String;
/// The toString() method returns a string representing the object. /// The toString() method returns a string representing the object.
/// ///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString

View File

@ -157,3 +157,30 @@ fn property_is_enumerable() {
"#) "#)
.test() .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;
#[wasm_bindgen]
pub fn to_locale_string() -> String {
let object = js::Object::new();
object.to_locale_string()
}
"#)
.file("test.ts", r#"
import * as assert from "assert";
import * as wasm from "./out";
export function test() {
assert.equal(wasm.to_locale_string(), "[object Object]");
}
"#)
.test()
}