Add basic support for String.prototype.charAt() (#306)

* String - charAt() implementation

* String - charAt() - add js_class
This commit is contained in:
Lachezar Lechev
2018-06-25 20:24:44 +02:00
committed by Nick Fitzgerald
parent 245f0f0eea
commit d28d81f38d
2 changed files with 36 additions and 0 deletions

View File

@ -2,6 +2,35 @@
use project;
#[test]
fn char_at() {
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_char_at(this: &js::JsString, index: u32) -> js::JsString {
this.char_at(index)
}
"#)
.file("test.ts", r#"
import * as assert from "assert";
import * as wasm from "./out";
var anyString = 'Brave new world';
export function test() {
assert.equal(wasm.string_char_at(anyString, 0), "B");
assert.equal(wasm.string_char_at(anyString, 999), "");
}
"#)
.test()
}
#[test]
fn slice() {
project()