File tree 3 files changed +51
-0
lines changed
3 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -86,3 +86,24 @@ extern {
86
86
#[ wasm_bindgen( method, js_name = hasOwnProperty) ]
87
87
pub fn has_own_property ( this : & Object , property : & str ) -> bool ;
88
88
}
89
+
90
+
91
+ // String
92
+ #[ wasm_bindgen]
93
+ extern {
94
+ pub type String ;
95
+
96
+ /// The String global object is a constructor for strings or a sequence
97
+ /// of characters.
98
+ ///
99
+ /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
100
+ #[ wasm_bindgen( constructor) ]
101
+ pub fn new ( ) -> String ;
102
+
103
+ /// The length property of a String object indicates the length of a
104
+ /// string, in UTF-16 code units.
105
+ ///
106
+ /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length
107
+ #[ wasm_bindgen( method, js_name = length) ]
108
+ pub fn length ( this : & String ) -> i32 ;
109
+ }
Original file line number Diff line number Diff line change
1
+ #![ allow( non_snake_case) ]
2
+
3
+ use project;
4
+
5
+ #[ test]
6
+ fn new ( ) {
7
+ project ( )
8
+ . file ( "src/lib.rs" , r#"
9
+ #![feature(proc_macro, wasm_custom_section)]
10
+
11
+ extern crate wasm_bindgen;
12
+ use wasm_bindgen::prelude::*;
13
+ use wasm_bindgen::js;
14
+
15
+ #[wasm_bindgen]
16
+ pub fn new_string() -> js::String {
17
+ js::String::new()
18
+ }
19
+ "# )
20
+ . file ( "test.ts" , r#"
21
+ import * as assert from "assert";
22
+ import * as wasm from "./out";
23
+
24
+ export function test() {
25
+ assert.equal(typeof wasm.new_string(), "string");
26
+ }
27
+ "# )
28
+ . test ( )
29
+ }
Original file line number Diff line number Diff line change 3
3
use super :: project;
4
4
5
5
mod Object ;
6
+ mod String ;
6
7
7
8
#[ test]
8
9
#[ cfg( feature = "std" ) ]
You can’t perform that action at this time.
0 commit comments