mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-25 11:02:11 +03:00
Merge branch 'expose-bindings/object-to-locale-string' of https://github.com/belfz/wasm-bindgen into rollup
This commit is contained in:
commit
7825122feb
@ -220,6 +220,14 @@ extern {
|
||||
#[wasm_bindgen(method, js_name = hasOwnProperty)]
|
||||
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.
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString
|
||||
|
@ -157,3 +157,30 @@ fn property_is_enumerable() {
|
||||
"#)
|
||||
.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()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user