mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-24 18:43:33 +03:00
Add binding for String.prototype.toUpperCase
This commit is contained in:
parent
58560f1408
commit
d5d451b94b
@ -1078,6 +1078,14 @@ extern "C" {
|
||||
#[wasm_bindgen(method, js_class = "String", js_name = toString)]
|
||||
pub fn to_string(this: &JsString) -> JsString;
|
||||
|
||||
/// The toUpperCase() method returns the calling string value
|
||||
/// converted to uppercase (the value will be converted to a
|
||||
/// string if it isn't one).
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase
|
||||
#[wasm_bindgen(method, js_class = "String", js_name = toUpperCase)]
|
||||
pub fn to_upper_case(this: &JsString) -> JsString;
|
||||
|
||||
/// The trim() method removes whitespace from both ends of a string.
|
||||
/// Whitespace in this context is all the whitespace characters
|
||||
/// (space, tab, no-break space, etc.) and all the line terminator characters (LF, CR, etc.).
|
||||
|
@ -455,6 +455,32 @@ fn to_string() {
|
||||
.test()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn to_upper_case() {
|
||||
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 string_to_upper_case(this: &js::JsString) -> js::JsString {
|
||||
this.to_upper_case()
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
export function test() {
|
||||
assert.equal(wasm.string_to_upper_case("Mozilla"), "MOZILLA");
|
||||
}
|
||||
"#)
|
||||
.test()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn trim() {
|
||||
project()
|
||||
|
Loading…
Reference in New Issue
Block a user