mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-11-24 06:33:33 +03:00
Move the js
module to a js_sys
crate (#512)
* Move the `js` module to a `js_sys` crate * Update js-sys tests to pass again * Update binding_to_unimplemented_apis_doesnt_break_everything Remove its dependency on the `js` module * Update metadata for js-sys * Fix the `closures` example
This commit is contained in:
parent
3e2d1e6519
commit
6eef5f7b52
10
.travis.yml
10
.travis.yml
@ -68,6 +68,16 @@ matrix:
|
||||
addons:
|
||||
firefox: latest
|
||||
|
||||
# The `js-sys` crate's tests pass on nightly.
|
||||
- rust: nightly
|
||||
env: JOB=test-js-sys
|
||||
before_install: *INSTALL_NODE_VIA_NVM
|
||||
install:
|
||||
- npm ci
|
||||
script: cargo test --manifest-path crates/js-sys/Cargo.toml
|
||||
addons:
|
||||
firefox: latest
|
||||
|
||||
# Tests pass on nightly using yarn
|
||||
- rust: nightly
|
||||
env: JOB=test-yarn-smoke
|
||||
|
@ -17,8 +17,7 @@ test = false
|
||||
doctest = false
|
||||
|
||||
[features]
|
||||
default = ["spans", "std", "js_globals"]
|
||||
js_globals = []
|
||||
default = ["spans", "std"]
|
||||
spans = ["wasm-bindgen-macro/spans"]
|
||||
std = []
|
||||
serde-serialize = ["serde", "serde_json", "std"]
|
||||
@ -38,9 +37,10 @@ wasm-bindgen-test-project-builder = { path = "crates/test-project-builder", vers
|
||||
[workspace]
|
||||
members = [
|
||||
"crates/cli",
|
||||
"crates/js-sys",
|
||||
"crates/typescript",
|
||||
"crates/webidl",
|
||||
"crates/web-sys",
|
||||
"crates/webidl",
|
||||
"examples/hello_world",
|
||||
"examples/smorgasboard",
|
||||
"examples/console_log",
|
||||
|
23
crates/js-sys/Cargo.toml
Normal file
23
crates/js-sys/Cargo.toml
Normal file
@ -0,0 +1,23 @@
|
||||
[package]
|
||||
name = "js-sys"
|
||||
version = "0.2.11"
|
||||
authors = ["Alex Crichton <alex@alexcrichton.com>"]
|
||||
readme = "./README.md"
|
||||
categories = ["wasm"]
|
||||
repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/js-sys"
|
||||
homepage = "https://rustwasm.github.io/wasm-bindgen/"
|
||||
documentation = "https://docs.rs/wasm-bindgen"
|
||||
description = """
|
||||
Bindings for all JS global objects and functions in all JS environments like
|
||||
Node.js and browsers, built on `#[wasm_bindgen]` using the `wasm-bindgen` crate.
|
||||
"""
|
||||
|
||||
[lib]
|
||||
test = false
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
wasm-bindgen = { path = "../..", version = "0.2.11" }
|
||||
|
||||
[dev-dependencies]
|
||||
wasm-bindgen-test-project-builder = { path = "../test-project-builder" }
|
8
crates/js-sys/README.md
Normal file
8
crates/js-sys/README.md
Normal file
@ -0,0 +1,8 @@
|
||||
# `js-sys`
|
||||
|
||||
Raw bindings to JS global APIs for projects using `wasm-bindgen`. This crate is
|
||||
handwritten and intended to work in *all* JS environments like browsers and
|
||||
Node.js.
|
||||
|
||||
Progress for this crate can be tracked at
|
||||
[#275](https://github.com/rustwasm/wasm-bindgen/issues/275).
|
@ -16,14 +16,13 @@
|
||||
//! example, `decodeURI` in JavaScript is exposed as `decode_uri` in these
|
||||
//! bindings.
|
||||
|
||||
use wasm_bindgen_macro::*;
|
||||
use JsValue;
|
||||
#![feature(use_extern_macros, wasm_import_module)]
|
||||
|
||||
use core::mem;
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
if_std! {
|
||||
use std::prelude::v1::*;
|
||||
}
|
||||
use std::mem;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
// When adding new imports:
|
||||
//
|
||||
@ -662,15 +661,15 @@ extern "C" {
|
||||
pub fn to_string(this: &Function) -> JsString;
|
||||
}
|
||||
|
||||
impl JsValue {
|
||||
impl Function {
|
||||
/// Returns the `Function` value of this JS value if it's an instance of a
|
||||
/// function.
|
||||
///
|
||||
/// If this JS value is not an instance of a function then this returns
|
||||
/// `None`.
|
||||
pub fn as_function(&self) -> Option<&Function> {
|
||||
if self.is_function() {
|
||||
Some(unsafe { mem::transmute(self) })
|
||||
pub fn try_from(val: &JsValue) -> Option<&Function> {
|
||||
if val.is_function() {
|
||||
Some(unsafe { mem::transmute(val) })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -1013,13 +1012,13 @@ extern "C" {
|
||||
#[wasm_bindgen(static_method_of = Math)]
|
||||
pub fn pow(base: f64, exponent: f64) -> f64;
|
||||
|
||||
/// The Math.random() function returns a floating-point, pseudo-random number
|
||||
/// in the range 0–1 (inclusive of 0, but not 1) with approximately uniform distribution
|
||||
/// over that range — which you can then scale to your desired range.
|
||||
/// The implementation selects the initial seed to the random number generation algorithm;
|
||||
/// The Math.random() function returns a floating-point, pseudo-random number
|
||||
/// in the range 0–1 (inclusive of 0, but not 1) with approximately uniform distribution
|
||||
/// over that range — which you can then scale to your desired range.
|
||||
/// The implementation selects the initial seed to the random number generation algorithm;
|
||||
/// it cannot be chosen or reset by the user.
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random
|
||||
#[wasm_bindgen(static_method_of = Math)]
|
||||
pub fn random() -> f64;
|
||||
|
||||
@ -1619,15 +1618,15 @@ extern "C" {
|
||||
pub fn values(object: &Object) -> Array;
|
||||
}
|
||||
|
||||
impl JsValue {
|
||||
impl Object {
|
||||
/// Returns the `Object` value of this JS value if it's an instance of an
|
||||
/// object.
|
||||
///
|
||||
/// If this JS value is not an instance of an object then this returns
|
||||
/// `None`.
|
||||
pub fn as_object(&self) -> Option<&Object> {
|
||||
if self.is_object() {
|
||||
Some(unsafe { mem::transmute(self) })
|
||||
pub fn try_from(val: &JsValue) -> Option<&Object> {
|
||||
if val.is_object() {
|
||||
Some(unsafe { mem::transmute(val) })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -2065,7 +2064,7 @@ extern "C" {
|
||||
#[wasm_bindgen(method, js_class = "String")]
|
||||
pub fn concat(this: &JsString, string_2: &JsString) -> JsString;
|
||||
|
||||
/// The endsWith() method determines whether a string ends with the characters of a
|
||||
/// The endsWith() method determines whether a string ends with the characters of a
|
||||
/// specified string, returning true or false as appropriate.
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
|
||||
@ -2095,7 +2094,7 @@ extern "C" {
|
||||
#[wasm_bindgen(method, js_class = "String", js_name = lastIndexOf)]
|
||||
pub fn last_index_of(this: &JsString, search_value: &JsString, from_index: i32) -> i32;
|
||||
|
||||
/// The normalize() method returns the Unicode Normalization Form
|
||||
/// The normalize() method returns the Unicode Normalization Form
|
||||
/// of a given string (if the value isn't a string, it will be converted to one first).
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
|
||||
@ -2120,7 +2119,7 @@ extern "C" {
|
||||
#[wasm_bindgen(method, js_class = "String", js_name = padStart)]
|
||||
pub fn pad_start(this: &JsString, target_length: u32, pad_string: &JsString) -> JsString;
|
||||
|
||||
/// The repeat() method constructs and returns a new string which contains the specified
|
||||
/// The repeat() method constructs and returns a new string which contains the specified
|
||||
/// number of copies of the string on which it was called, concatenated together.
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat
|
||||
@ -2221,15 +2220,15 @@ extern "C" {
|
||||
pub fn value_of(this: &JsString) -> JsString;
|
||||
}
|
||||
|
||||
impl JsValue {
|
||||
impl JsString {
|
||||
/// Returns the `JsString` value of this JS value if it's an instance of a
|
||||
/// string.
|
||||
///
|
||||
/// If this JS value is not an instance of a string then this returns
|
||||
/// `None`.
|
||||
pub fn as_js_string(&self) -> Option<&JsString> {
|
||||
if self.is_string() {
|
||||
Some(unsafe { mem::transmute(self) })
|
||||
pub fn try_from(val: &JsValue) -> Option<&JsString> {
|
||||
if val.is_string() {
|
||||
Some(unsafe { mem::transmute(val) })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -2244,23 +2243,21 @@ impl<'a> From<&'a str> for JsString {
|
||||
}
|
||||
}
|
||||
|
||||
if_std! {
|
||||
impl From<String> for JsString {
|
||||
fn from(s: String) -> Self {
|
||||
From::from(&*s)
|
||||
}
|
||||
impl From<String> for JsString {
|
||||
fn from(s: String) -> Self {
|
||||
From::from(&*s)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a JsString> for String {
|
||||
fn from(s: &'a JsString) -> Self {
|
||||
s.obj.as_string().unwrap()
|
||||
}
|
||||
impl<'a> From<&'a JsString> for String {
|
||||
fn from(s: &'a JsString) -> Self {
|
||||
s.obj.as_string().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<JsString> for String {
|
||||
fn from(s: JsString) -> Self {
|
||||
From::from(&s)
|
||||
}
|
||||
impl From<JsString> for String {
|
||||
fn from(s: JsString) -> Self {
|
||||
From::from(&s)
|
||||
}
|
||||
}
|
||||
|
@ -11,11 +11,11 @@ fn filter() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn keep_numbers(array: &js::Array) -> js::Array {
|
||||
pub fn keep_numbers(array: &js_sys::Array) -> js_sys::Array {
|
||||
array.filter(&mut |x, _, _| x.as_f64().is_some())
|
||||
}
|
||||
|
||||
@ -50,11 +50,11 @@ fn index_of() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_index_of(this: &js::Array, value: JsValue, from_index: i32) -> i32 {
|
||||
pub fn get_index_of(this: &js_sys::Array, value: JsValue, from_index: i32) -> i32 {
|
||||
this.index_of(value, from_index)
|
||||
}
|
||||
|
||||
@ -94,12 +94,12 @@ fn is_array() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn is_array(value: &JsValue) -> bool {
|
||||
js::Array::is_array(value)
|
||||
js_sys::Array::is_array(value)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -140,11 +140,11 @@ fn sort() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn sort_array(this: &js::Array) -> js::Array {
|
||||
pub fn sort_array(this: &js_sys::Array) -> js_sys::Array {
|
||||
this.sort()
|
||||
}
|
||||
|
||||
@ -174,11 +174,11 @@ fn some() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn has_elem(array: &js::Array, arg: JsValue) -> bool {
|
||||
pub fn has_elem(array: &js_sys::Array, arg: JsValue) -> bool {
|
||||
array.some(&mut |elem| arg == elem)
|
||||
}
|
||||
|
||||
@ -207,11 +207,11 @@ fn last_index_of() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_last_index_of(this: &js::Array, value: JsValue, from_index: i32) -> i32 {
|
||||
pub fn get_last_index_of(this: &js_sys::Array, value: JsValue, from_index: i32) -> i32 {
|
||||
this.last_index_of(value, from_index)
|
||||
}
|
||||
|
||||
@ -251,11 +251,11 @@ fn join() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn join_array(this: &js::Array, delimiter: &str) -> js::JsString {
|
||||
pub fn join_array(this: &js_sys::Array, delimiter: &str) -> js_sys::JsString {
|
||||
this.join(delimiter)
|
||||
}
|
||||
|
||||
@ -289,11 +289,11 @@ fn slice() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn create_slice(this: &js::Array, start: u32, end: u32) -> js::Array {
|
||||
pub fn create_slice(this: &js_sys::Array, start: u32, end: u32) -> js_sys::Array {
|
||||
this.slice(start, end)
|
||||
}
|
||||
"#,
|
||||
@ -325,11 +325,11 @@ fn fill() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn fill_with(this: &js::Array, value: JsValue, start: u32, end: u32) -> js::Array {
|
||||
pub fn fill_with(this: &js_sys::Array, value: JsValue, start: u32, end: u32) -> js_sys::Array {
|
||||
this.fill(value, start, end)
|
||||
}
|
||||
"#,
|
||||
@ -359,11 +359,11 @@ fn copy_within() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn copy_values_within_array(this: &js::Array, target: i32, start: i32, end: i32) -> js::Array {
|
||||
pub fn copy_values_within_array(this: &js_sys::Array, target: i32, start: i32, end: i32) -> js_sys::Array {
|
||||
this.copy_within(target, start, end)
|
||||
}
|
||||
|
||||
@ -395,11 +395,11 @@ fn pop() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn pop_in_it(this: &js::Array) -> JsValue {
|
||||
pub fn pop_in_it(this: &js_sys::Array) -> JsValue {
|
||||
this.pop()
|
||||
}
|
||||
|
||||
@ -431,11 +431,11 @@ fn push() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn push_it_along(this: &js::Array, value: JsValue) -> u32 {
|
||||
pub fn push_it_along(this: &js_sys::Array, value: JsValue) -> u32 {
|
||||
this.push(value)
|
||||
}
|
||||
|
||||
@ -467,11 +467,11 @@ fn reverse() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn reverse_array(this: &js::Array) -> js::Array {
|
||||
pub fn reverse_array(this: &js_sys::Array) -> js_sys::Array {
|
||||
this.reverse()
|
||||
}
|
||||
|
||||
@ -503,11 +503,11 @@ fn shift() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn shift_item(this: &js::Array) -> JsValue {
|
||||
pub fn shift_item(this: &js_sys::Array) -> JsValue {
|
||||
this.shift()
|
||||
}
|
||||
|
||||
@ -540,11 +540,11 @@ fn unshift() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn unshift_item(this: &js::Array, value: JsValue) -> u32 {
|
||||
pub fn unshift_item(this: &js_sys::Array, value: JsValue) -> u32 {
|
||||
this.unshift(value)
|
||||
}
|
||||
|
||||
@ -577,11 +577,11 @@ fn to_string() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn array_to_string(this: &js::Array) -> js::JsString {
|
||||
pub fn array_to_string(this: &js_sys::Array) -> js_sys::JsString {
|
||||
this.to_string()
|
||||
}
|
||||
|
||||
@ -613,11 +613,11 @@ fn includes() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn array_includes(this: &js::Array, value: JsValue, from_index: i32) -> bool {
|
||||
pub fn array_includes(this: &js_sys::Array, value: JsValue, from_index: i32) -> bool {
|
||||
this.includes(value, from_index)
|
||||
}
|
||||
|
||||
@ -654,11 +654,11 @@ fn concat() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn array_concat(this: &js::Array, arr: &js::Array) -> js::Array {
|
||||
pub fn array_concat(this: &js_sys::Array, arr: &js_sys::Array) -> js_sys::Array {
|
||||
this.concat(arr)
|
||||
}
|
||||
|
||||
@ -691,11 +691,11 @@ fn length() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn array_length(this: &js::Array) -> u32 {
|
||||
pub fn array_length(this: &js_sys::Array) -> u32 {
|
||||
this.length()
|
||||
}
|
||||
|
||||
@ -730,11 +730,11 @@ fn every() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn array_every_number_is_even(array: &js::Array) -> bool {
|
||||
pub fn array_every_number_is_even(array: &js_sys::Array) -> bool {
|
||||
array.every(&mut |el, _, _| el.as_f64().unwrap() % 2f64 == 0f64)
|
||||
}
|
||||
"#,
|
||||
@ -768,11 +768,11 @@ fn find() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn array_find_first_even_number(array: &js::Array) -> JsValue {
|
||||
pub fn array_find_first_even_number(array: &js_sys::Array) -> JsValue {
|
||||
array.find(&mut |el, _, _| el.as_f64().unwrap() % 2f64 == 0f64)
|
||||
}
|
||||
"#,
|
||||
@ -806,12 +806,12 @@ fn map() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
use JsValue;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn array_map(array: &js::Array) -> js::Array {
|
||||
pub fn array_map(array: &js_sys::Array) -> js_sys::Array {
|
||||
array.map(&mut |el, _, _| JsValue::from_f64(el.as_f64().unwrap().sqrt()))
|
||||
}
|
||||
"#,
|
||||
@ -840,12 +840,12 @@ fn reduce() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
use JsValue;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn array_reduce(array: &js::Array) -> JsValue {
|
||||
pub fn array_reduce(array: &js_sys::Array) -> JsValue {
|
||||
array.reduce(&mut |ac, cr, _, _| JsValue::from_str(&format!("{}{}", &ac.as_string().unwrap(), &cr.as_string().unwrap().as_str())), JsValue::from_str(""))
|
||||
}
|
||||
"#,
|
||||
@ -873,12 +873,12 @@ fn reduce_right() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
use JsValue;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn array_reduce_right(array: &js::Array) -> JsValue {
|
||||
pub fn array_reduce_right(array: &js_sys::Array) -> JsValue {
|
||||
array.reduce_right(&mut |ac, cr, _, _| JsValue::from_str(&format!("{}{}", &ac.as_string().unwrap(), &cr.as_string().unwrap().as_str())), JsValue::from_str(""))
|
||||
}
|
||||
"#,
|
||||
@ -906,11 +906,11 @@ fn find_index() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn array_find_first_even_number_index(array: &js::Array) -> u32 {
|
||||
pub fn array_find_first_even_number_index(array: &js_sys::Array) -> u32 {
|
||||
array.find_index(&mut |el, _, _| el.as_f64().unwrap() % 2. == 0.)
|
||||
}
|
||||
"#,
|
||||
@ -944,12 +944,12 @@ fn to_locale_string() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
use JsValue;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn array_to_locale_string(array: &js::Array, locale: &JsValue, options: &JsValue) -> js::JsString {
|
||||
pub fn array_to_locale_string(array: &js_sys::Array, locale: &JsValue, options: &JsValue) -> js_sys::JsString {
|
||||
array.to_locale_string(locale, options)
|
||||
}
|
||||
"#,
|
||||
@ -977,11 +977,11 @@ fn for_each() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn sum_indices_of_evens(array: &js::Array) -> u32 {
|
||||
pub fn sum_indices_of_evens(array: &js_sys::Array) -> u32 {
|
||||
let mut res = 0;
|
||||
array.for_each(&mut |elem: JsValue, i, _| {
|
||||
match elem.as_f64() {
|
@ -9,8 +9,9 @@ fn new() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::ArrayBuffer;
|
||||
use js_sys::ArrayBuffer;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn new_arraybuffer() -> ArrayBuffer {
|
||||
@ -35,9 +36,10 @@ fn is_view() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use JsValue;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::ArrayBuffer;
|
||||
use js_sys::ArrayBuffer;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn is_view(value: JsValue) -> bool {
|
||||
@ -62,8 +64,9 @@ fn slice() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::ArrayBuffer;
|
||||
use js_sys::ArrayBuffer;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn slice(arraybuffer: &ArrayBuffer, begin: u32) -> ArrayBuffer {
|
||||
@ -89,8 +92,9 @@ fn slice_with_end() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::ArrayBuffer;
|
||||
use js_sys::ArrayBuffer;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn slice_with_end(arraybuffer: &ArrayBuffer, begin: u32, end: u32) -> ArrayBuffer {
|
12
tests/all/js_globals/ArrayIterator.rs → crates/js-sys/tests/all/ArrayIterator.rs
Executable file → Normal file
12
tests/all/js_globals/ArrayIterator.rs → crates/js-sys/tests/all/ArrayIterator.rs
Executable file → Normal file
@ -11,11 +11,11 @@ fn keys() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_keys(this: &js::Array) -> js::ArrayIterator {
|
||||
pub fn get_keys(this: &js_sys::Array) -> js_sys::ArrayIterator {
|
||||
this.keys()
|
||||
}
|
||||
|
||||
@ -49,11 +49,11 @@ fn entries() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_entries(this: &js::Array) -> js::ArrayIterator {
|
||||
pub fn get_entries(this: &js_sys::Array) -> js_sys::ArrayIterator {
|
||||
this.entries()
|
||||
}
|
||||
|
||||
@ -89,11 +89,11 @@ fn values() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_values(this: &js::Array) -> js::ArrayIterator {
|
||||
pub fn get_values(this: &js_sys::Array) -> js_sys::ArrayIterator {
|
||||
this.values()
|
||||
}
|
||||
"#,
|
@ -11,12 +11,12 @@ fn new_undefined() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn new_boolean() -> js::Boolean {
|
||||
js::Boolean::new(JsValue::undefined())
|
||||
pub fn new_boolean() -> js_sys::Boolean {
|
||||
js_sys::Boolean::new(JsValue::undefined())
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -43,12 +43,12 @@ fn new_truely() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn new_boolean() -> js::Boolean {
|
||||
js::Boolean::new(JsValue::from("foo"))
|
||||
pub fn new_boolean() -> js_sys::Boolean {
|
||||
js_sys::Boolean::new(JsValue::from("foo"))
|
||||
}
|
||||
"#,
|
||||
)
|
@ -9,8 +9,9 @@ fn test() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::{ArrayBuffer, DataView};
|
||||
use js_sys::{ArrayBuffer, DataView};
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn test_data_view(buffer: &ArrayBuffer, offset: usize, len: usize) {
|
141
tests/all/js_globals/Date.rs → crates/js-sys/tests/all/Date.rs
Executable file → Normal file
141
tests/all/js_globals/Date.rs → crates/js-sys/tests/all/Date.rs
Executable file → Normal file
@ -11,8 +11,9 @@ fn get_date() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_date(this: &Date) -> u32 {
|
||||
@ -45,8 +46,9 @@ fn get_day() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_day(this: &Date) -> u32 {
|
||||
@ -79,8 +81,9 @@ fn get_full_year() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_full_year(this: &Date) -> u32 {
|
||||
@ -115,8 +118,9 @@ fn get_hours() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_hours(this: &Date) -> u32 {
|
||||
@ -149,8 +153,9 @@ fn get_milliseconds() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_milliseconds(this: &Date) -> u32 {
|
||||
@ -185,8 +190,9 @@ fn get_minutes() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_minutes(this: &Date) -> u32 {
|
||||
@ -219,8 +225,9 @@ fn get_month() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_month(this: &Date) -> u32 {
|
||||
@ -253,8 +260,9 @@ fn get_seconds() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_seconds(this: &Date) -> u32 {
|
||||
@ -287,8 +295,9 @@ fn get_time() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_time(this: &Date) -> f64 {
|
||||
@ -321,8 +330,9 @@ fn get_timezone_offset() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_timezone_offset(this: &Date) -> f64 {
|
||||
@ -357,8 +367,9 @@ fn get_utc_date() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_utc_date(this: &Date) -> u32 {
|
||||
@ -393,8 +404,9 @@ fn get_utc_day() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_utc_day(this: &Date) -> u32 {
|
||||
@ -429,8 +441,9 @@ fn get_utc_full_year() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_utc_full_year(this: &Date) -> u32 {
|
||||
@ -465,8 +478,9 @@ fn get_utc_hours() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_utc_hours(this: &Date) -> u32 {
|
||||
@ -501,8 +515,9 @@ fn get_utc_milliseconds() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_utc_milliseconds(this: &Date) -> u32 {
|
||||
@ -535,8 +550,9 @@ fn get_utc_minutes() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_utc_minutes(this: &Date) -> u32 {
|
||||
@ -571,8 +587,9 @@ fn get_utc_month() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_utc_month(this: &Date) -> u32 {
|
||||
@ -607,8 +624,9 @@ fn get_utc_seconds() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_utc_seconds(this: &Date) -> u32 {
|
||||
@ -641,8 +659,9 @@ fn new() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn new_date() -> Date {
|
||||
@ -671,8 +690,9 @@ fn now() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn now() -> f64 {
|
||||
@ -699,8 +719,9 @@ fn parse() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::{Date, JsString};
|
||||
use js_sys::{Date, JsString};
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn parse(date: JsString) -> f64 {
|
||||
@ -735,8 +756,9 @@ fn set_date() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn set_date(this: &Date, day: u32) -> f64 {
|
||||
@ -774,8 +796,9 @@ fn set_full_year() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn set_full_year(this: &Date, year: u32) -> f64 {
|
||||
@ -813,8 +836,9 @@ fn set_hours() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn set_hours(this: &Date, hours: u32) -> f64 {
|
||||
@ -852,8 +876,9 @@ fn set_milliseconds() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn set_milliseconds(this: &Date, milliseconds: u32) -> f64 {
|
||||
@ -889,8 +914,9 @@ fn set_minutes() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn set_minutes(this: &Date, minutes: u32) -> f64 {
|
||||
@ -928,8 +954,9 @@ fn set_month() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn set_month(this: &Date, month: u32) -> f64 {
|
||||
@ -967,8 +994,9 @@ fn set_seconds() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn set_seconds(this: &Date, seconds: u32) -> f64 {
|
||||
@ -1006,8 +1034,9 @@ fn set_time() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn set_time(this: &Date, time: f64) -> f64 {
|
||||
@ -1044,8 +1073,9 @@ fn set_utc_date() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn set_utc_date(this: &Date, day: u32) -> f64 {
|
||||
@ -1083,8 +1113,9 @@ fn set_utc_full_year() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn set_utc_full_year(this: &Date, year: u32) -> f64 {
|
||||
@ -1122,8 +1153,9 @@ fn set_utc_hours() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn set_utc_hours(this: &Date, hours: u32) -> f64 {
|
||||
@ -1161,8 +1193,9 @@ fn set_utc_milliseconds() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn set_utc_milliseconds(this: &Date, milliseconds: u32) -> f64 {
|
||||
@ -1200,8 +1233,9 @@ fn set_utc_minutes() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn set_utc_minutes(this: &Date, minutes: u32) -> f64 {
|
||||
@ -1239,8 +1273,9 @@ fn set_utc_month() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn set_utc_month(this: &Date, minutes: u32) -> f64 {
|
||||
@ -1278,8 +1313,9 @@ fn set_utc_seconds() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn set_utc_seconds(this: &Date, seconds: u32) -> f64 {
|
||||
@ -1317,8 +1353,9 @@ fn to_date_string() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::{Date, JsString};
|
||||
use js_sys::{Date, JsString};
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn to_date_string(this: &Date) -> JsString {
|
||||
@ -1351,8 +1388,9 @@ fn to_iso_string() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::{Date, JsString};
|
||||
use js_sys::{Date, JsString};
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn to_iso_string(this: &Date) -> JsString {
|
||||
@ -1385,8 +1423,9 @@ fn to_json() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::{Date, JsString};
|
||||
use js_sys::{Date, JsString};
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn to_json(this: &Date) -> JsString {
|
||||
@ -1417,9 +1456,10 @@ fn to_locale_date_string() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use JsValue;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::{Date, JsString};
|
||||
use js_sys::{Date, JsString};
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn to_locale_date_string(this: &Date, locale: JsString, options: JsValue) -> JsString {
|
||||
@ -1449,9 +1489,10 @@ fn to_locale_string() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use JsValue;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::{Date, JsString};
|
||||
use js_sys::{Date, JsString};
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn to_locale_string(this: &Date, locale: JsString, options: JsValue) -> JsString {
|
||||
@ -1481,8 +1522,9 @@ fn to_locale_time_string() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::{Date, JsString};
|
||||
use js_sys::{Date, JsString};
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn to_locale_time_string(this: &Date, locale: JsString) -> JsString {
|
||||
@ -1514,8 +1556,9 @@ fn to_string() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::{Date, JsString};
|
||||
use js_sys::{Date, JsString};
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn to_string(this: &Date) -> JsString {
|
||||
@ -1547,8 +1590,9 @@ fn to_time_string() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::{Date, JsString};
|
||||
use js_sys::{Date, JsString};
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn to_time_string(this: &Date) -> JsString {
|
||||
@ -1580,8 +1624,9 @@ fn to_utc_string() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::{Date, JsString};
|
||||
use js_sys::{Date, JsString};
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn to_utc_string(this: &Date) -> JsString {
|
||||
@ -1611,8 +1656,9 @@ fn utc() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn utc() -> f64 {
|
||||
@ -1639,8 +1685,9 @@ fn value_of() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Date;
|
||||
use js_sys::Date;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn js_value_of(this: &Date) -> Date {
|
@ -9,12 +9,12 @@ fn new() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
use wasm_bindgen::js::Error;
|
||||
use js_sys::Error;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn new_error(message: &js::JsString) -> Error {
|
||||
pub fn new_error(message: &js_sys::JsString) -> Error {
|
||||
Error::new(message)
|
||||
}
|
||||
"#)
|
||||
@ -39,12 +39,12 @@ fn message() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
use wasm_bindgen::js::Error;
|
||||
use js_sys::Error;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn error_message(this: &Error) -> js::JsString {
|
||||
pub fn error_message(this: &Error) -> js_sys::JsString {
|
||||
this.message()
|
||||
}
|
||||
"#)
|
||||
@ -69,12 +69,12 @@ fn set_message() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
use wasm_bindgen::js::Error;
|
||||
use js_sys::Error;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn error_set_message(this: &Error, message: &js::JsString) {
|
||||
pub fn error_set_message(this: &Error, message: &js_sys::JsString) {
|
||||
this.set_message(message);
|
||||
}
|
||||
"#)
|
||||
@ -100,12 +100,12 @@ fn name() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
use wasm_bindgen::js::Error;
|
||||
use js_sys::Error;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn error_name(this: &Error) -> js::JsString {
|
||||
pub fn error_name(this: &Error) -> js_sys::JsString {
|
||||
this.name()
|
||||
}
|
||||
"#)
|
||||
@ -131,12 +131,12 @@ fn set_name() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
use wasm_bindgen::js::Error;
|
||||
use js_sys::Error;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn error_set_name(this: &Error, name: &js::JsString) {
|
||||
pub fn error_set_name(this: &Error, name: &js_sys::JsString) {
|
||||
this.set_name(name);
|
||||
}
|
||||
"#)
|
||||
@ -162,12 +162,12 @@ fn to_string() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
use wasm_bindgen::js::Error;
|
||||
use js_sys::Error;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn error_to_string(this: &Error) -> js::JsString {
|
||||
pub fn error_to_string(this: &Error) -> js_sys::JsString {
|
||||
this.to_string()
|
||||
}
|
||||
"#)
|
@ -11,11 +11,11 @@ fn apply() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn apply(this: &js::Function, context: &JsValue, args: &js::Array) -> js::Function {
|
||||
pub fn apply(this: &js_sys::Function, context: &JsValue, args: &js_sys::Array) -> js_sys::Function {
|
||||
this.apply(context, args)
|
||||
}
|
||||
"#,
|
||||
@ -47,11 +47,11 @@ fn bind() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn bind(this: &js::Function, context: &JsValue) -> js::Function {
|
||||
pub fn bind(this: &js_sys::Function, context: &JsValue) -> js_sys::Function {
|
||||
this.bind(context)
|
||||
}
|
||||
"#,
|
||||
@ -87,11 +87,11 @@ fn length() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn fn_length(this: &js::Function) -> u32 {
|
||||
pub fn fn_length(this: &js_sys::Function) -> u32 {
|
||||
this.length()
|
||||
}
|
||||
"#,
|
||||
@ -133,11 +133,11 @@ fn name() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn fn_name(this: &js::Function) -> js::JsString {
|
||||
pub fn fn_name(this: &js_sys::Function) -> js_sys::JsString {
|
||||
this.name()
|
||||
}
|
||||
"#,
|
||||
@ -180,11 +180,11 @@ fn to_string() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_source_code(this: &js::Function) -> js::JsString {
|
||||
pub fn get_source_code(this: &js_sys::Function) -> js_sys::JsString {
|
||||
this.to_string()
|
||||
}
|
||||
"#,
|
@ -11,11 +11,11 @@ fn return_() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn gen_return(this: &js::Generator, value: &JsValue) -> JsValue {
|
||||
pub fn gen_return(this: &js_sys::Generator, value: &JsValue) -> JsValue {
|
||||
this.return_(value)
|
||||
}
|
||||
"#,
|
||||
@ -55,18 +55,18 @@ fn next() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn next(this: &js::Generator, value: &JsValue) -> JsValue {
|
||||
pub fn next(this: &js_sys::Generator, value: &JsValue) -> JsValue {
|
||||
this.next(value)
|
||||
.ok()
|
||||
.expect("generator throws an error")
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn next_throws_error(this: &js::Generator, value: &JsValue) -> bool {
|
||||
pub fn next_throws_error(this: &js_sys::Generator, value: &JsValue) -> bool {
|
||||
this.next(value).is_err()
|
||||
}
|
||||
"#,
|
||||
@ -113,11 +113,11 @@ fn throw() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn gen_throws_error(this: &js::Generator, error: &js::Error) -> bool {
|
||||
pub fn gen_throws_error(this: &js_sys::Generator, error: &js_sys::Error) -> bool {
|
||||
this.throw(error).is_err()
|
||||
}
|
||||
"#,
|
@ -9,12 +9,12 @@ fn get_canonical_locales() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_canonical_locales(v: &JsValue) -> js::Array {
|
||||
js::Intl::get_canonical_locales(v)
|
||||
pub fn get_canonical_locales(v: &JsValue) -> js_sys::Array {
|
||||
js_sys::Intl::get_canonical_locales(v)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
108
tests/all/js_globals/JsString.rs → crates/js-sys/tests/all/JsString.rs
Executable file → Normal file
108
tests/all/js_globals/JsString.rs → crates/js-sys/tests/all/JsString.rs
Executable file → Normal file
@ -11,11 +11,11 @@ fn length() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_length(this: &js::JsString) -> u32 {
|
||||
pub fn string_length(this: &js_sys::JsString) -> u32 {
|
||||
this.length()
|
||||
}
|
||||
|
||||
@ -48,11 +48,11 @@ fn char_at() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_char_at(this: &js::JsString, index: u32) -> js::JsString {
|
||||
pub fn string_char_at(this: &js_sys::JsString, index: u32) -> js_sys::JsString {
|
||||
this.char_at(index)
|
||||
}
|
||||
"#,
|
||||
@ -83,11 +83,11 @@ fn char_code_at() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_char_code_at(this: &js::JsString, index: u32) -> f64 {
|
||||
pub fn string_char_code_at(this: &js_sys::JsString, index: u32) -> f64 {
|
||||
this.char_code_at(index)
|
||||
}
|
||||
"#,
|
||||
@ -124,11 +124,11 @@ fn code_point_at() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_code_point_at(this: &js::JsString, pos: u32) -> JsValue {
|
||||
pub fn string_code_point_at(this: &js_sys::JsString, pos: u32) -> JsValue {
|
||||
this.code_point_at(pos)
|
||||
}
|
||||
"#,
|
||||
@ -158,11 +158,11 @@ fn concat() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_concat(this: &js::JsString, string_2: &js::JsString) -> js::JsString {
|
||||
pub fn string_concat(this: &js_sys::JsString, string_2: &js_sys::JsString) -> js_sys::JsString {
|
||||
this.concat(string_2)
|
||||
}
|
||||
"#,
|
||||
@ -194,11 +194,11 @@ fn ends_with() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn ends_with(this: &js::JsString, search_value: &js::JsString, length: i32) -> bool {
|
||||
pub fn ends_with(this: &js_sys::JsString, search_value: &js_sys::JsString, length: i32) -> bool {
|
||||
this.ends_with(search_value, length)
|
||||
}
|
||||
"#)
|
||||
@ -226,11 +226,11 @@ fn includes() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_includes(this: &js::JsString, search_value: &js::JsString, position: i32) -> bool {
|
||||
pub fn string_includes(this: &js_sys::JsString, search_value: &js_sys::JsString, position: i32) -> bool {
|
||||
this.includes(search_value, position)
|
||||
}
|
||||
"#)
|
||||
@ -261,11 +261,11 @@ fn index_of() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_index_of(this: &js::JsString, search_value: &js::JsString, from_index: i32) -> i32 {
|
||||
pub fn string_index_of(this: &js_sys::JsString, search_value: &js_sys::JsString, from_index: i32) -> i32 {
|
||||
this.index_of(search_value, from_index)
|
||||
}
|
||||
"#)
|
||||
@ -300,11 +300,11 @@ fn last_index_of() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_last_index_of(this: &js::JsString, search_value: &js::JsString, from_index: i32) -> i32 {
|
||||
pub fn string_last_index_of(this: &js_sys::JsString, search_value: &js_sys::JsString, from_index: i32) -> i32 {
|
||||
this.last_index_of(search_value, from_index)
|
||||
}
|
||||
"#)
|
||||
@ -339,11 +339,11 @@ fn normalize() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_normalize(this: &js::JsString, form: &js::JsString) -> js::JsString {
|
||||
pub fn string_normalize(this: &js_sys::JsString, form: &js_sys::JsString) -> js_sys::JsString {
|
||||
this.normalize(form)
|
||||
}
|
||||
"#)
|
||||
@ -371,15 +371,15 @@ fn pad_end() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_pad_end(
|
||||
this: &js::JsString,
|
||||
this: &js_sys::JsString,
|
||||
target_length: u32,
|
||||
pad_string: &js::JsString
|
||||
) -> js::JsString
|
||||
pad_string: &js_sys::JsString
|
||||
) -> js_sys::JsString
|
||||
{
|
||||
this.pad_end(target_length, pad_string)
|
||||
}
|
||||
@ -411,15 +411,15 @@ fn pad_start() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_pad_start(
|
||||
this: &js::JsString,
|
||||
this: &js_sys::JsString,
|
||||
target_length: u32,
|
||||
pad_string: &js::JsString
|
||||
) -> js::JsString
|
||||
pad_string: &js_sys::JsString
|
||||
) -> js_sys::JsString
|
||||
{
|
||||
this.pad_start(target_length, pad_string)
|
||||
}
|
||||
@ -452,11 +452,11 @@ fn repeat() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_repeat(this: &js::JsString, count: i32) -> js::JsString {
|
||||
pub fn string_repeat(this: &js_sys::JsString, count: i32) -> js_sys::JsString {
|
||||
this.repeat(count)
|
||||
}
|
||||
"#,
|
||||
@ -485,11 +485,11 @@ fn slice() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn create_slice(this: &js::JsString, start: u32, end: u32) -> js::JsString {
|
||||
pub fn create_slice(this: &js_sys::JsString, start: u32, end: u32) -> js_sys::JsString {
|
||||
this.slice(start, end)
|
||||
}
|
||||
"#,
|
||||
@ -518,11 +518,11 @@ fn starts_with() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_starts_with(this: &js::JsString, search_string: &js::JsString, position: u32) -> bool {
|
||||
pub fn string_starts_with(this: &js_sys::JsString, search_string: &js_sys::JsString, position: u32) -> bool {
|
||||
this.starts_with(search_string, position)
|
||||
}
|
||||
"#)
|
||||
@ -549,11 +549,11 @@ fn substring() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_substring(this: &js::JsString, index_start: u32, index_end: u32) -> js::JsString {
|
||||
pub fn string_substring(this: &js_sys::JsString, index_start: u32, index_end: u32) -> js_sys::JsString {
|
||||
this.substring(index_start, index_end)
|
||||
}
|
||||
"#)
|
||||
@ -588,11 +588,11 @@ fn substr() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn create_substr(this: &js::JsString, start: i32, length: i32) -> js::JsString {
|
||||
pub fn create_substr(this: &js_sys::JsString, start: i32, length: i32) -> js_sys::JsString {
|
||||
this.substr(start, length)
|
||||
}
|
||||
"#)
|
||||
@ -624,11 +624,11 @@ fn to_lower_case() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_to_lower_case(this: &js::JsString) -> js::JsString {
|
||||
pub fn string_to_lower_case(this: &js_sys::JsString) -> js_sys::JsString {
|
||||
this.to_lower_case()
|
||||
}
|
||||
"#)
|
||||
@ -652,11 +652,11 @@ fn to_string() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_to_string(this: &js::JsString) -> js::JsString {
|
||||
pub fn string_to_string(this: &js_sys::JsString) -> js_sys::JsString {
|
||||
this.to_string()
|
||||
}
|
||||
"#,
|
||||
@ -683,11 +683,11 @@ fn to_upper_case() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_to_upper_case(this: &js::JsString) -> js::JsString {
|
||||
pub fn string_to_upper_case(this: &js_sys::JsString) -> js_sys::JsString {
|
||||
this.to_upper_case()
|
||||
}
|
||||
"#)
|
||||
@ -711,11 +711,11 @@ fn trim() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_trim(this: &js::JsString) -> js::JsString {
|
||||
pub fn string_trim(this: &js_sys::JsString) -> js_sys::JsString {
|
||||
this.trim()
|
||||
}
|
||||
"#,
|
||||
@ -745,16 +745,16 @@ fn trim_end_and_trim_right() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_trim_end(this: &js::JsString) -> js::JsString {
|
||||
pub fn string_trim_end(this: &js_sys::JsString) -> js_sys::JsString {
|
||||
this.trim_end()
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_trim_right(this: &js::JsString) -> js::JsString {
|
||||
pub fn string_trim_right(this: &js_sys::JsString) -> js_sys::JsString {
|
||||
this.trim_right()
|
||||
}
|
||||
"#,
|
||||
@ -785,16 +785,16 @@ fn trim_start_and_trim_left() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_trim_start(this: &js::JsString) -> js::JsString {
|
||||
pub fn string_trim_start(this: &js_sys::JsString) -> js_sys::JsString {
|
||||
this.trim_start()
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_trim_left(this: &js::JsString) -> js::JsString {
|
||||
pub fn string_trim_left(this: &js_sys::JsString) -> js_sys::JsString {
|
||||
this.trim_left()
|
||||
}
|
||||
"#,
|
||||
@ -825,11 +825,11 @@ fn value_of() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn string_value_of(this: &js::JsString) -> js::JsString {
|
||||
pub fn string_value_of(this: &js_sys::JsString) -> js_sys::JsString {
|
||||
this.value_of()
|
||||
}
|
||||
"#,
|
36
tests/all/js_globals/Map.rs → crates/js-sys/tests/all/Map.rs
Executable file → Normal file
36
tests/all/js_globals/Map.rs → crates/js-sys/tests/all/Map.rs
Executable file → Normal file
@ -9,11 +9,11 @@ fn clear() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn map_clear(this: &js::Map) {
|
||||
pub fn map_clear(this: &js_sys::Map) {
|
||||
this.clear();
|
||||
}
|
||||
"#)
|
||||
@ -41,11 +41,11 @@ fn delete() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn map_delete(this: &js::Map, key: &str) -> bool {
|
||||
pub fn map_delete(this: &js_sys::Map, key: &str) -> bool {
|
||||
this.delete(key)
|
||||
}
|
||||
"#)
|
||||
@ -73,12 +73,12 @@ fn for_each() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_bool_vals(this: &js::Map) -> js::Map {
|
||||
let res = js::Map::new();
|
||||
pub fn get_bool_vals(this: &js_sys::Map) -> js_sys::Map {
|
||||
let res = js_sys::Map::new();
|
||||
this.for_each(&mut |value, key| {
|
||||
if value.as_bool().is_some() {
|
||||
res.set(&key, &value);
|
||||
@ -118,11 +118,11 @@ fn get() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn map_get(this: &js::Map, key: &JsValue) -> JsValue {
|
||||
pub fn map_get(this: &js_sys::Map, key: &JsValue) -> JsValue {
|
||||
this.get(key)
|
||||
}
|
||||
"#)
|
||||
@ -149,11 +149,11 @@ fn has() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn has(this: &js::Map, key: &JsValue) -> bool {
|
||||
pub fn has(this: &js_sys::Map, key: &JsValue) -> bool {
|
||||
this.has(key)
|
||||
}
|
||||
"#)
|
||||
@ -178,12 +178,12 @@ fn new() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn new_map() -> js::Map {
|
||||
js::Map::new()
|
||||
pub fn new_map() -> js_sys::Map {
|
||||
js_sys::Map::new()
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -206,11 +206,11 @@ fn set() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn set(this: &js::Map, key: &JsValue, value: &JsValue) -> js::Map {
|
||||
pub fn set(this: &js_sys::Map, key: &JsValue, value: &JsValue) -> js_sys::Map {
|
||||
this.set(key, value)
|
||||
}
|
||||
"#)
|
||||
@ -235,11 +235,11 @@ fn size() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn map_size(this: &js::Map) -> u32 {
|
||||
pub fn map_size(this: &js_sys::Map) -> u32 {
|
||||
this.size()
|
||||
}
|
||||
"#)
|
@ -10,11 +10,11 @@ fn entries() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_entries(this: &js::Map) -> js::MapIterator {
|
||||
pub fn get_entries(this: &js_sys::Map) -> js_sys::MapIterator {
|
||||
this.entries()
|
||||
}
|
||||
"#)
|
||||
@ -42,11 +42,11 @@ fn keys() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_keys(this: &js::Map) -> js::MapIterator {
|
||||
pub fn get_keys(this: &js_sys::Map) -> js_sys::MapIterator {
|
||||
this.keys()
|
||||
}
|
||||
"#)
|
||||
@ -74,11 +74,11 @@ fn values() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_values(this: &js::Map) -> js::MapIterator {
|
||||
pub fn get_values(this: &js_sys::Map) -> js_sys::MapIterator {
|
||||
this.values()
|
||||
}
|
||||
"#)
|
128
tests/all/js_globals/Math.rs → crates/js-sys/tests/all/Math.rs
Executable file → Normal file
128
tests/all/js_globals/Math.rs → crates/js-sys/tests/all/Math.rs
Executable file → Normal file
@ -11,12 +11,12 @@ fn abs() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn abs(x: f64) -> f64 {
|
||||
js::Math::abs(x)
|
||||
js_sys::Math::abs(x)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -45,12 +45,12 @@ fn acos() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn acos(x: f64) -> f64 {
|
||||
js::Math::acos(x)
|
||||
js_sys::Math::acos(x)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -79,12 +79,12 @@ fn acosh() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn acosh(x: f64) -> f64 {
|
||||
js::Math::acosh(x)
|
||||
js_sys::Math::acosh(x)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -113,12 +113,12 @@ fn asin() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn asin(x: f64) -> f64 {
|
||||
js::Math::asin(x)
|
||||
js_sys::Math::asin(x)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -147,12 +147,12 @@ fn asinh() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn asinh(x: f64) -> f64 {
|
||||
js::Math::asinh(x)
|
||||
js_sys::Math::asinh(x)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -180,12 +180,12 @@ fn atan() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn atan(x: f64) -> f64 {
|
||||
js::Math::atan(x)
|
||||
js_sys::Math::atan(x)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -213,12 +213,12 @@ fn atan2() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn atan2(y: f64, x: f64) -> f64 {
|
||||
js::Math::atan2(y, x)
|
||||
js_sys::Math::atan2(y, x)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -246,12 +246,12 @@ fn atanh() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn atanh(x: f64) -> f64 {
|
||||
js::Math::atanh(x)
|
||||
js_sys::Math::atanh(x)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -280,12 +280,12 @@ fn cbrt() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn cbrt(x: f64) -> f64 {
|
||||
js::Math::cbrt(x)
|
||||
js_sys::Math::cbrt(x)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -313,12 +313,12 @@ fn ceil() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn ceil(x: f64) -> i32 {
|
||||
js::Math::ceil(x)
|
||||
js_sys::Math::ceil(x)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -346,12 +346,12 @@ fn clz32() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn clz32(x: i32) -> u32 {
|
||||
js::Math::clz32(x)
|
||||
js_sys::Math::clz32(x)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -377,12 +377,12 @@ fn cos() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn cos(x: f64) -> f64 {
|
||||
js::Math::cos(x)
|
||||
js_sys::Math::cos(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -404,12 +404,12 @@ fn cosh() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn cosh(x: f64) -> f64 {
|
||||
js::Math::cosh(x)
|
||||
js_sys::Math::cosh(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -431,12 +431,12 @@ fn exp() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn exp(x: f64) -> f64 {
|
||||
js::Math::exp(x)
|
||||
js_sys::Math::exp(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -459,12 +459,12 @@ fn expm1() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn expm1(x: f64) -> f64 {
|
||||
js::Math::expm1(x)
|
||||
js_sys::Math::expm1(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -490,12 +490,12 @@ fn floor() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn floor(x: f64) -> i32 {
|
||||
js::Math::floor(x)
|
||||
js_sys::Math::floor(x)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -521,12 +521,12 @@ fn fround() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn fround(x: f64) -> f32 {
|
||||
js::Math::fround(x)
|
||||
js_sys::Math::fround(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -550,12 +550,12 @@ fn imul() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn imul(x: i32, y:i32) -> i32 {
|
||||
js::Math::imul(x, y)
|
||||
js_sys::Math::imul(x, y)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -578,12 +578,12 @@ fn log() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn log(x: f64) -> f64 {
|
||||
js::Math::log(x)
|
||||
js_sys::Math::log(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -605,12 +605,12 @@ fn log10() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn log10(x: f64) -> f64 {
|
||||
js::Math::log10(x)
|
||||
js_sys::Math::log10(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -633,12 +633,12 @@ fn log1p() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn log1p(x: f64) -> f64 {
|
||||
js::Math::log1p(x)
|
||||
js_sys::Math::log1p(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -662,12 +662,12 @@ fn log2() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn log2(x: f64) -> f64 {
|
||||
js::Math::log2(x)
|
||||
js_sys::Math::log2(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -691,12 +691,12 @@ fn pow() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn pow(base: f64, exponent: f64) -> f64 {
|
||||
js::Math::pow(base, exponent)
|
||||
js_sys::Math::pow(base, exponent)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -719,12 +719,12 @@ fn random() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn random() -> f64 {
|
||||
js::Math::random()
|
||||
js_sys::Math::random()
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -746,12 +746,12 @@ fn round() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn round(x: f64) -> i32 {
|
||||
js::Math::round(x)
|
||||
js_sys::Math::round(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -776,12 +776,12 @@ fn sign() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn sign(x: f64) -> f64 {
|
||||
js::Math::sign(x)
|
||||
js_sys::Math::sign(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -806,12 +806,12 @@ fn sin() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn sin(x: f64) -> f64 {
|
||||
js::Math::sin(x)
|
||||
js_sys::Math::sin(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -834,12 +834,12 @@ fn sinh() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn sinh(x: f64) -> f64 {
|
||||
js::Math::sinh(x)
|
||||
js_sys::Math::sinh(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -862,12 +862,12 @@ fn sqrt() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn sqrt(x: f64) -> f64 {
|
||||
js::Math::sqrt(x)
|
||||
js_sys::Math::sqrt(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -892,12 +892,12 @@ fn tan() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn tan(x: f64) -> f64 {
|
||||
js::Math::tan(x)
|
||||
js_sys::Math::tan(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -920,12 +920,12 @@ fn tanh() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn tanh(x: f64) -> f64 {
|
||||
js::Math::tanh(x)
|
||||
js_sys::Math::tanh(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -948,12 +948,12 @@ fn trunc() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn trunc(x: f64) -> i32 {
|
||||
js::Math::trunc(x)
|
||||
js_sys::Math::trunc(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
42
tests/all/js_globals/Number.rs → crates/js-sys/tests/all/Number.rs
Executable file → Normal file
42
tests/all/js_globals/Number.rs → crates/js-sys/tests/all/Number.rs
Executable file → Normal file
@ -9,12 +9,12 @@ fn is_finite() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn is_finite(value: &JsValue) -> bool {
|
||||
js::Number::is_finite(value)
|
||||
js_sys::Number::is_finite(value)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -39,12 +39,12 @@ fn is_integer() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn is_integer(value: &JsValue) -> bool {
|
||||
js::Number::is_integer(value)
|
||||
js_sys::Number::is_integer(value)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -66,12 +66,12 @@ fn is_safe_integer() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn is_safe_integer(value: &JsValue) -> bool {
|
||||
js::Number::is_safe_integer(value)
|
||||
js_sys::Number::is_safe_integer(value)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -98,8 +98,9 @@ fn new() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Number;
|
||||
use js_sys::Number;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn new_number() -> Number {
|
||||
@ -126,8 +127,9 @@ fn parse_int_float() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::Number;
|
||||
use js_sys::Number;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn parse_int(text: &str, radix: u8) -> Number {
|
||||
@ -165,11 +167,11 @@ fn to_locale_string() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn to_locale_string(this: &js::Number, locale: &str) -> js::JsString {
|
||||
pub fn to_locale_string(this: &js_sys::Number, locale: &str) -> js_sys::JsString {
|
||||
this.to_locale_string(locale)
|
||||
}
|
||||
"#)
|
||||
@ -197,11 +199,11 @@ fn to_precision() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn to_precision(this: &js::Number, precision: u8) -> js::JsString {
|
||||
pub fn to_precision(this: &js_sys::Number, precision: u8) -> js_sys::JsString {
|
||||
let result = this.to_precision(precision);
|
||||
let result = match result {
|
||||
Ok(num) => num,
|
||||
@ -235,11 +237,11 @@ fn to_string() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn to_string(this: &js::Number, radix: u8) -> js::JsString {
|
||||
pub fn to_string(this: &js_sys::Number, radix: u8) -> js_sys::JsString {
|
||||
let result = this.to_string(radix);
|
||||
let result = match result {
|
||||
Ok(num) => num,
|
||||
@ -275,11 +277,11 @@ fn value_of() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn js_value_of(this: &js::Number) -> f64 {
|
||||
pub fn js_value_of(this: &js_sys::Number) -> f64 {
|
||||
this.value_of()
|
||||
}
|
||||
"#,
|
||||
@ -309,11 +311,11 @@ fn to_fixed() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn to_fixed(this: &js::Number, digits: u8) -> js::JsString {
|
||||
pub fn to_fixed(this: &js_sys::Number, digits: u8) -> js_sys::JsString {
|
||||
let result = this.to_fixed(digits);
|
||||
let result = match result {
|
||||
Ok(num) => num,
|
||||
@ -347,11 +349,11 @@ fn to_exponential() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn to_exponential(this: &js::Number, fraction_digits: u8) -> js::JsString {
|
||||
pub fn to_exponential(this: &js_sys::Number, fraction_digits: u8) -> js_sys::JsString {
|
||||
let result = this.to_exponential(fraction_digits);
|
||||
let result = match result {
|
||||
Ok(num) => num,
|
@ -11,12 +11,12 @@ fn new() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn new_object() -> js::Object {
|
||||
js::Object::new()
|
||||
pub fn new_object() -> js_sys::Object {
|
||||
js_sys::Object::new()
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -43,11 +43,11 @@ fn has_own_property() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn has_own_foo_property(obj: &js::Object, property: &JsValue) -> bool {
|
||||
pub fn has_own_foo_property(obj: &js_sys::Object, property: &JsValue) -> bool {
|
||||
obj.has_own_property(&property)
|
||||
}
|
||||
"#,
|
||||
@ -80,17 +80,17 @@ fn to_string() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn to_string(obj: &js::Object) -> js::JsString {
|
||||
pub fn to_string(obj: &js_sys::Object) -> js_sys::JsString {
|
||||
obj.to_string()
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn test() {
|
||||
let object = js::Object::new();
|
||||
let object = js_sys::Object::new();
|
||||
assert_eq!(String::from(object.to_string()), "[object Object]");
|
||||
}
|
||||
"#,
|
||||
@ -117,12 +117,12 @@ fn is_extensible() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn is_extensible(obj: &js::Object) -> bool {
|
||||
js::Object::is_extensible(&obj)
|
||||
pub fn is_extensible(obj: &js_sys::Object) -> bool {
|
||||
js_sys::Object::is_extensible(&obj)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -147,12 +147,12 @@ fn is_frozen() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn is_frozen(obj: &js::Object) -> bool {
|
||||
js::Object::is_frozen(&obj)
|
||||
pub fn is_frozen(obj: &js_sys::Object) -> bool {
|
||||
js_sys::Object::is_frozen(&obj)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -177,12 +177,12 @@ fn is_sealed() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn is_sealed(obj: &js::Object) -> bool {
|
||||
js::Object::is_sealed(&obj)
|
||||
pub fn is_sealed(obj: &js_sys::Object) -> bool {
|
||||
js_sys::Object::is_sealed(&obj)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -209,11 +209,11 @@ fn is_prototype_of() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn obj_is_prototype_of_value(obj: &js::Object, value: &JsValue) -> bool {
|
||||
pub fn obj_is_prototype_of_value(obj: &js_sys::Object, value: &JsValue) -> bool {
|
||||
obj.is_prototype_of(&value)
|
||||
}
|
||||
"#,
|
||||
@ -246,12 +246,12 @@ fn keys() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn keys(obj: &js::Object) -> js::Array {
|
||||
js::Object::keys(obj)
|
||||
pub fn keys(obj: &js_sys::Object) -> js_sys::Array {
|
||||
js_sys::Object::keys(obj)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -277,12 +277,12 @@ fn prevent_extensions() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn prevent_extensions(obj: &js::Object) {
|
||||
js::Object::prevent_extensions(obj);
|
||||
pub fn prevent_extensions(obj: &js_sys::Object) {
|
||||
js_sys::Object::prevent_extensions(obj);
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -312,11 +312,11 @@ fn property_is_enumerable() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn property_is_enumerable(obj: &js::Object, property: &JsValue) -> bool {
|
||||
pub fn property_is_enumerable(obj: &js_sys::Object, property: &JsValue) -> bool {
|
||||
obj.property_is_enumerable(&property)
|
||||
}
|
||||
"#,
|
||||
@ -351,12 +351,12 @@ fn seal() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn seal(value: &JsValue) -> JsValue {
|
||||
js::Object::seal(&value)
|
||||
js_sys::Object::seal(&value)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -402,12 +402,12 @@ fn set_prototype_of() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn set_prototype_of(object: &js::Object, prototype: &js::Object) -> js::Object {
|
||||
js::Object::set_prototype_of(&object, &prototype)
|
||||
pub fn set_prototype_of(object: &js_sys::Object, prototype: &js_sys::Object) -> js_sys::Object {
|
||||
js_sys::Object::set_prototype_of(&object, &prototype)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -434,12 +434,12 @@ fn to_locale_string() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn to_locale_string() -> js::JsString {
|
||||
let object = js::Object::new();
|
||||
pub fn to_locale_string() -> js_sys::JsString {
|
||||
let object = js_sys::Object::new();
|
||||
object.to_locale_string()
|
||||
}
|
||||
"#,
|
||||
@ -467,11 +467,11 @@ fn value_of() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn value_of(obj: &js::Object) -> js::Object {
|
||||
pub fn value_of(obj: &js_sys::Object) -> js_sys::Object {
|
||||
obj.value_of()
|
||||
}
|
||||
"#,
|
||||
@ -499,12 +499,12 @@ fn values() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn values(obj: &js::Object) -> js::Array {
|
||||
js::Object::values(&obj)
|
||||
pub fn values(obj: &js_sys::Object) -> js_sys::Array {
|
||||
js_sys::Object::values(&obj)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
@ -9,12 +9,12 @@ fn new() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn new_proxy(target: JsValue, handler: js::Object) -> js::Proxy {
|
||||
js::Proxy::new(&target, &handler)
|
||||
pub fn new_proxy(target: JsValue, handler: js_sys::Object) -> js_sys::Proxy {
|
||||
js_sys::Proxy::new(&target, &handler)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -43,12 +43,12 @@ fn revocable() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn new_revocable_proxy(target: JsValue, handler: js::Object) -> js::Object {
|
||||
js::Proxy::revocable(&target, &handler)
|
||||
pub fn new_revocable_proxy(target: JsValue, handler: js_sys::Object) -> js_sys::Object {
|
||||
js_sys::Proxy::revocable(&target, &handler)
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
@ -11,12 +11,12 @@ fn apply() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn apply(target: &js::Function, this_argument: &JsValue, arguments_list: &js::Array) -> JsValue {
|
||||
js::Reflect::apply(target, this_argument, arguments_list)
|
||||
pub fn apply(target: &js_sys::Function, this_argument: &JsValue, arguments_list: &js_sys::Array) -> JsValue {
|
||||
js_sys::Reflect::apply(target, this_argument, arguments_list)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -43,12 +43,12 @@ fn construct() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn construct(target: &js::Function, arguments_list: &js::Array) -> JsValue {
|
||||
js::Reflect::construct(target, arguments_list)
|
||||
pub fn construct(target: &js_sys::Function, arguments_list: &js_sys::Array) -> JsValue {
|
||||
js_sys::Reflect::construct(target, arguments_list)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -89,12 +89,12 @@ fn construct_with_new_target() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn construct_with_new_target(target: &js::Function, arguments_list: &js::Array, new_target: &js::Function) -> JsValue {
|
||||
js::Reflect::construct_with_new_target(target, arguments_list, new_target)
|
||||
pub fn construct_with_new_target(target: &js_sys::Function, arguments_list: &js_sys::Array, new_target: &js_sys::Function) -> JsValue {
|
||||
js_sys::Reflect::construct_with_new_target(target, arguments_list, new_target)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -147,12 +147,12 @@ fn define_property() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn define_property(target: &js::Object, property_key: &JsValue, attributes: &js::Object) -> bool {
|
||||
js::Reflect::define_property(target, property_key, attributes)
|
||||
pub fn define_property(target: &js_sys::Object, property_key: &JsValue, attributes: &js_sys::Object) -> bool {
|
||||
js_sys::Reflect::define_property(target, property_key, attributes)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -181,12 +181,12 @@ fn delete_property() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn delete_property(target: &js::Object, property_key: &JsValue) -> bool {
|
||||
js::Reflect::delete_property(target, property_key)
|
||||
pub fn delete_property(target: &js_sys::Object, property_key: &JsValue) -> bool {
|
||||
js_sys::Reflect::delete_property(target, property_key)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -224,12 +224,12 @@ fn get() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get(target: &js::Object, property_key: &JsValue) -> JsValue {
|
||||
js::Reflect::get(target, property_key)
|
||||
pub fn get(target: &js_sys::Object, property_key: &JsValue) -> JsValue {
|
||||
js_sys::Reflect::get(target, property_key)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -264,12 +264,12 @@ fn get_own_property_descriptor() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_own_property_descriptor(target: &js::Object, property_key: &JsValue) -> JsValue {
|
||||
js::Reflect::get_own_property_descriptor(target, property_key)
|
||||
pub fn get_own_property_descriptor(target: &js_sys::Object, property_key: &JsValue) -> JsValue {
|
||||
js_sys::Reflect::get_own_property_descriptor(target, property_key)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -301,12 +301,12 @@ fn get_prototype_of() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_prototype_of(target: &js::Object) -> js::Object {
|
||||
js::Reflect::get_prototype_of(target)
|
||||
pub fn get_prototype_of(target: &js_sys::Object) -> js_sys::Object {
|
||||
js_sys::Reflect::get_prototype_of(target)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -339,12 +339,12 @@ fn has() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn has(target: &js::Object, property_key: &JsValue) -> bool {
|
||||
js::Reflect::has(target, property_key)
|
||||
pub fn has(target: &js_sys::Object, property_key: &JsValue) -> bool {
|
||||
js_sys::Reflect::has(target, property_key)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -379,12 +379,12 @@ fn is_extensible() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn is_extensible(target: &js::Object) -> bool {
|
||||
js::Reflect::is_extensible(target)
|
||||
pub fn is_extensible(target: &js_sys::Object) -> bool {
|
||||
js_sys::Reflect::is_extensible(target)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -423,12 +423,12 @@ fn own_keys() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn own_keys(target: &js::Object) -> js::Array {
|
||||
js::Reflect::own_keys(target)
|
||||
pub fn own_keys(target: &js_sys::Object) -> js_sys::Array {
|
||||
js_sys::Reflect::own_keys(target)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -461,12 +461,12 @@ fn prevent_extensions() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn prevent_extensions(target: &js::Object) -> bool {
|
||||
js::Reflect::prevent_extensions(target)
|
||||
pub fn prevent_extensions(target: &js_sys::Object) -> bool {
|
||||
js_sys::Reflect::prevent_extensions(target)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -497,12 +497,12 @@ fn set() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn set(target: &js::Object, property_key: &JsValue, value: &JsValue) -> bool {
|
||||
js::Reflect::set(target, property_key, value)
|
||||
pub fn set(target: &js_sys::Object, property_key: &JsValue, value: &JsValue) -> bool {
|
||||
js_sys::Reflect::set(target, property_key, value)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -535,12 +535,12 @@ fn set_with_receiver() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn set_with_receiver(target: &js::Object, property_key: &JsValue, value: &JsValue, receiver: &js::Object) -> bool {
|
||||
js::Reflect::set_with_receiver(target, property_key, value, receiver)
|
||||
pub fn set_with_receiver(target: &js_sys::Object, property_key: &JsValue, value: &JsValue, receiver: &js_sys::Object) -> bool {
|
||||
js_sys::Reflect::set_with_receiver(target, property_key, value, receiver)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -573,12 +573,12 @@ fn set_prototype_of() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn set_prototype_of(target: &js::Object, prototype: &JsValue) -> bool {
|
||||
js::Reflect::set_prototype_of(target, prototype)
|
||||
pub fn set_prototype_of(target: &js_sys::Object, prototype: &JsValue) -> bool {
|
||||
js_sys::Reflect::set_prototype_of(target, prototype)
|
||||
}
|
||||
"#,
|
||||
)
|
30
tests/all/js_globals/Set.rs → crates/js-sys/tests/all/Set.rs
Executable file → Normal file
30
tests/all/js_globals/Set.rs → crates/js-sys/tests/all/Set.rs
Executable file → Normal file
@ -9,11 +9,11 @@ fn add() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn add(this: &js::Set, value: &JsValue) -> js::Set {
|
||||
pub fn add(this: &js_sys::Set, value: &JsValue) -> js_sys::Set {
|
||||
this.add(value)
|
||||
}
|
||||
|
||||
@ -42,11 +42,11 @@ fn clear() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn clear(this: &js::Set) {
|
||||
pub fn clear(this: &js_sys::Set) {
|
||||
this.clear();
|
||||
}
|
||||
|
||||
@ -73,11 +73,11 @@ fn delete() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn set_delete(this: &js::Set, value: &JsValue) -> bool {
|
||||
pub fn set_delete(this: &js_sys::Set, value: &JsValue) -> bool {
|
||||
this.delete(value)
|
||||
}
|
||||
"#)
|
||||
@ -102,11 +102,11 @@ fn for_each() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn count_evens(set: &js::Set) -> u32 {
|
||||
pub fn count_evens(set: &js_sys::Set) -> u32 {
|
||||
let mut res = 0;
|
||||
set.for_each(&mut |value, _, _| {
|
||||
match value.as_f64() {
|
||||
@ -148,11 +148,11 @@ fn has() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn has(this: &js::Set, value: &JsValue) -> bool {
|
||||
pub fn has(this: &js_sys::Set, value: &JsValue) -> bool {
|
||||
this.has(value)
|
||||
}
|
||||
"#)
|
||||
@ -177,12 +177,12 @@ fn new() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn new_set() -> js::Set {
|
||||
js::Set::new()
|
||||
pub fn new_set() -> js_sys::Set {
|
||||
js_sys::Set::new()
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
@ -205,11 +205,11 @@ fn size() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn size(this: &js::Set) -> u32 {
|
||||
pub fn size(this: &js_sys::Set) -> u32 {
|
||||
this.size()
|
||||
}
|
||||
|
@ -9,11 +9,11 @@ fn entries() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn entries(this: &js::Set) -> js::SetIterator {
|
||||
pub fn entries(this: &js_sys::Set) -> js_sys::SetIterator {
|
||||
this.entries()
|
||||
}
|
||||
|
||||
@ -41,11 +41,11 @@ fn keys() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn keys(this: &js::Set) -> js::SetIterator {
|
||||
pub fn keys(this: &js_sys::Set) -> js_sys::SetIterator {
|
||||
this.keys()
|
||||
}
|
||||
|
||||
@ -72,11 +72,11 @@ fn values() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn values(this: &js::Set) -> js::SetIterator {
|
||||
pub fn values(this: &js_sys::Set) -> js_sys::SetIterator {
|
||||
this.values()
|
||||
}
|
||||
|
@ -11,12 +11,12 @@ fn has_instance() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn symbol_has_instance() -> js::Symbol {
|
||||
js::Symbol::has_instance()
|
||||
pub fn symbol_has_instance() -> js_sys::Symbol {
|
||||
js_sys::Symbol::has_instance()
|
||||
}
|
||||
|
||||
"#,
|
||||
@ -50,12 +50,12 @@ fn is_concat_spreadable() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn symbol_is_cancat_spreadable() -> js::Symbol {
|
||||
js::Symbol::is_concat_spreadable()
|
||||
pub fn symbol_is_cancat_spreadable() -> js_sys::Symbol {
|
||||
js_sys::Symbol::is_concat_spreadable()
|
||||
}
|
||||
|
||||
"#,
|
||||
@ -92,12 +92,12 @@ fn iterator() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn symbol_iterator() -> js::Symbol {
|
||||
js::Symbol::iterator()
|
||||
pub fn symbol_iterator() -> js_sys::Symbol {
|
||||
js_sys::Symbol::iterator()
|
||||
}
|
||||
|
||||
"#,
|
||||
@ -133,12 +133,12 @@ fn match_() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn symbol_match() -> js::Symbol {
|
||||
js::Symbol::match_()
|
||||
pub fn symbol_match() -> js_sys::Symbol {
|
||||
js_sys::Symbol::match_()
|
||||
}
|
||||
|
||||
"#,
|
||||
@ -173,12 +173,12 @@ fn replace() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn symbol_replace() -> js::Symbol {
|
||||
js::Symbol::replace()
|
||||
pub fn symbol_replace() -> js_sys::Symbol {
|
||||
js_sys::Symbol::replace()
|
||||
}
|
||||
|
||||
"#,
|
||||
@ -215,12 +215,12 @@ fn search() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn symbol_search() -> js::Symbol {
|
||||
js::Symbol::search()
|
||||
pub fn symbol_search() -> js_sys::Symbol {
|
||||
js_sys::Symbol::search()
|
||||
}
|
||||
|
||||
"#,
|
||||
@ -258,12 +258,12 @@ fn species() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn symbol_species() -> js::Symbol {
|
||||
js::Symbol::species()
|
||||
pub fn symbol_species() -> js_sys::Symbol {
|
||||
js_sys::Symbol::species()
|
||||
}
|
||||
|
||||
"#,
|
||||
@ -300,12 +300,12 @@ fn split() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn symbol_split() -> js::Symbol {
|
||||
js::Symbol::split()
|
||||
pub fn symbol_split() -> js_sys::Symbol {
|
||||
js_sys::Symbol::split()
|
||||
}
|
||||
|
||||
"#,
|
||||
@ -345,12 +345,12 @@ fn to_primitive() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn symbol_to_primitive() -> js::Symbol {
|
||||
js::Symbol::to_primitive()
|
||||
pub fn symbol_to_primitive() -> js_sys::Symbol {
|
||||
js_sys::Symbol::to_primitive()
|
||||
}
|
||||
|
||||
"#,
|
||||
@ -387,12 +387,12 @@ fn to_string_tag() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn symbol_to_string_tag() -> js::Symbol {
|
||||
js::Symbol::to_string_tag()
|
||||
pub fn symbol_to_string_tag() -> js_sys::Symbol {
|
||||
js_sys::Symbol::to_string_tag()
|
||||
}
|
||||
|
||||
"#,
|
||||
@ -426,12 +426,12 @@ fn for_() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn symbol_for(key: &js::JsString) -> js::Symbol {
|
||||
js::Symbol::for_(key)
|
||||
pub fn symbol_for(key: &js_sys::JsString) -> js_sys::Symbol {
|
||||
js_sys::Symbol::for_(key)
|
||||
}
|
||||
|
||||
"#,
|
||||
@ -466,12 +466,12 @@ fn key_for() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn symbol_key_for(sym: &js::Symbol) -> js::JsString {
|
||||
js::Symbol::key_for(sym)
|
||||
pub fn symbol_key_for(sym: &js_sys::Symbol) -> js_sys::JsString {
|
||||
js_sys::Symbol::key_for(sym)
|
||||
}
|
||||
|
||||
"#,
|
||||
@ -505,12 +505,12 @@ fn to_string() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn symbol_to_string(this: &js::Symbol) -> js::JsString {
|
||||
js::Symbol::to_string(this)
|
||||
pub fn symbol_to_string(this: &js_sys::Symbol) -> js_sys::JsString {
|
||||
js_sys::Symbol::to_string(this)
|
||||
}
|
||||
|
||||
"#,
|
||||
@ -542,12 +542,12 @@ fn value_of() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn symbol_value_of(this: &js::Symbol) -> js::Symbol {
|
||||
js::Symbol::value_of(this)
|
||||
pub fn symbol_value_of(this: &js_sys::Symbol) -> js_sys::Symbol {
|
||||
js_sys::Symbol::value_of(this)
|
||||
}
|
||||
|
||||
"#,
|
@ -8,12 +8,12 @@ fn new_undefined_lib(array_type: &str) -> String {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn new_array() -> js::{} {{
|
||||
js::{}::new(JsValue::undefined())
|
||||
pub fn new_array() -> js_sys::{} {{
|
||||
js_sys::{}::new(JsValue::undefined())
|
||||
}}
|
||||
"#, array_type, array_type)
|
||||
}
|
||||
@ -106,12 +106,12 @@ fn new_length_lib(array_type: &str) -> String {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn new_array() -> js::{} {{
|
||||
js::{}::new(JsValue::from_f64(4.0))
|
||||
pub fn new_array() -> js_sys::{} {{
|
||||
js_sys::{}::new(JsValue::from_f64(4.0))
|
||||
}}
|
||||
"#, array_type, array_type)
|
||||
}
|
||||
@ -204,11 +204,11 @@ fn fill_lib(array_type: &str, el_type: &str) -> String {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn fill_with(this: &js::{}, value: {}, start: u32, end: u32) -> js::{} {{
|
||||
pub fn fill_with(this: &js_sys::{}, value: {}, start: u32, end: u32) -> js_sys::{} {{
|
||||
this.fill(value, start, end)
|
||||
}}
|
||||
"#, array_type, el_type, array_type)
|
@ -11,12 +11,12 @@ fn new() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn new_weak_map() -> js::WeakMap {
|
||||
js::WeakMap::new()
|
||||
pub fn new_weak_map() -> js_sys::WeakMap {
|
||||
js_sys::WeakMap::new()
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -43,11 +43,11 @@ fn get() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_value(this: &js::WeakMap, key: js::Object) -> JsValue {
|
||||
pub fn get_value(this: &js_sys::WeakMap, key: js_sys::Object) -> JsValue {
|
||||
this.get(key)
|
||||
}
|
||||
"#,
|
||||
@ -81,11 +81,11 @@ fn set() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn set_value(this: &js::WeakMap, key: js::Object, value: JsValue) -> js::WeakMap {
|
||||
pub fn set_value(this: &js_sys::WeakMap, key: js_sys::Object, value: JsValue) -> js_sys::WeakMap {
|
||||
this.set(key, value)
|
||||
}
|
||||
"#,
|
||||
@ -116,11 +116,11 @@ fn has() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn has_value(this: &js::WeakMap, key: js::Object) -> bool {
|
||||
pub fn has_value(this: &js_sys::WeakMap, key: js_sys::Object) -> bool {
|
||||
this.has(key)
|
||||
}
|
||||
"#,
|
||||
@ -154,11 +154,11 @@ fn delete() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn delete_key(this: &js::WeakMap, key: js::Object) -> bool {
|
||||
pub fn delete_key(this: &js_sys::WeakMap, key: js_sys::Object) -> bool {
|
||||
this.delete(key)
|
||||
}
|
||||
"#,
|
@ -11,12 +11,12 @@ fn new() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn new_weak_set() -> js::WeakSet {
|
||||
js::WeakSet::new()
|
||||
pub fn new_weak_set() -> js_sys::WeakSet {
|
||||
js_sys::WeakSet::new()
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -43,11 +43,11 @@ fn has() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn has_value(this: &js::WeakSet, value: js::Object) -> bool {
|
||||
pub fn has_value(this: &js_sys::WeakSet, value: js_sys::Object) -> bool {
|
||||
this.has(value)
|
||||
}
|
||||
"#,
|
||||
@ -81,11 +81,11 @@ fn add() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn add_value(this: &js::WeakSet, value: js::Object) -> js::WeakSet {
|
||||
pub fn add_value(this: &js_sys::WeakSet, value: js_sys::Object) -> js_sys::WeakSet {
|
||||
this.add(value)
|
||||
}
|
||||
"#,
|
||||
@ -122,11 +122,11 @@ fn delete() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn delete_value(this: &js::WeakSet, value: js::Object) -> bool {
|
||||
pub fn delete_value(this: &js_sys::WeakSet, value: js_sys::Object) -> bool {
|
||||
this.delete(value)
|
||||
}
|
||||
"#,
|
@ -9,9 +9,10 @@ fn validate() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use JsValue;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::WebAssembly;
|
||||
use js_sys::WebAssembly;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn validate_wasm(wasm: JsValue) -> JsValue {
|
||||
@ -39,9 +40,10 @@ fn validate_with_invalid_input() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use JsValue;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::WebAssembly;
|
||||
use js_sys::WebAssembly;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn validate_wasm(wasm: JsValue) -> JsValue {
|
@ -1,6 +1,12 @@
|
||||
// Keep these tests in alphabetical order, just like the imports in `src/js.rs`.
|
||||
extern crate wasm_bindgen_test_project_builder as project_builder;
|
||||
|
||||
use super::project;
|
||||
fn project() -> project_builder::Project {
|
||||
let mut p = project_builder::project();
|
||||
p.add_local_dependency("js-sys", env!("CARGO_MANIFEST_DIR"));
|
||||
return p
|
||||
}
|
||||
|
||||
// Keep these tests in alphabetical order, just like the imports in `src/js.rs`.
|
||||
|
||||
mod Array;
|
||||
mod ArrayBuffer;
|
||||
@ -29,7 +35,6 @@ mod WeakSet;
|
||||
mod WebAssembly;
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "std")]
|
||||
fn decode_uri() {
|
||||
project()
|
||||
.file(
|
||||
@ -38,17 +43,17 @@ fn decode_uri() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn test() {
|
||||
let x = js::decode_uri("https://mozilla.org/?x=%D1%88%D0%B5%D0%BB%D0%BB%D1%8B")
|
||||
let x = js_sys::decode_uri("https://mozilla.org/?x=%D1%88%D0%B5%D0%BB%D0%BB%D1%8B")
|
||||
.ok()
|
||||
.expect("should decode URI OK");
|
||||
assert_eq!(String::from(x), "https://mozilla.org/?x=шеллы");
|
||||
|
||||
assert!(js::decode_uri("%E0%A4%A").is_err());
|
||||
assert!(js_sys::decode_uri("%E0%A4%A").is_err());
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -64,17 +69,17 @@ fn decode_uri_component() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn test() {
|
||||
let x = js::decode_uri_component("%3Fx%3Dtest")
|
||||
let x = js_sys::decode_uri_component("%3Fx%3Dtest")
|
||||
.ok()
|
||||
.expect("should decode URI OK");
|
||||
assert_eq!(String::from(x), "?x=test");
|
||||
|
||||
assert!(js::decode_uri_component("%E0%A4%A").is_err());
|
||||
assert!(js_sys::decode_uri_component("%E0%A4%A").is_err());
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -82,7 +87,6 @@ fn decode_uri_component() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "std")]
|
||||
fn encode_uri() {
|
||||
project()
|
||||
.file(
|
||||
@ -91,12 +95,12 @@ fn encode_uri() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn test() {
|
||||
let x = js::encode_uri("ABC abc 123");
|
||||
let x = js_sys::encode_uri("ABC abc 123");
|
||||
assert_eq!(String::from(x), "ABC%20abc%20123");
|
||||
}
|
||||
"#,
|
||||
@ -113,12 +117,12 @@ fn encode_uri_component() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn test() {
|
||||
let x = js::encode_uri_component("?x=шеллы");
|
||||
let x = js_sys::encode_uri_component("?x=шеллы");
|
||||
assert_eq!(String::from(x), "%3Fx%3D%D1%88%D0%B5%D0%BB%D0%BB%D1%8B");
|
||||
}
|
||||
"#,
|
||||
@ -135,15 +139,15 @@ fn eval() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn test() {
|
||||
let x = js::eval("42").ok().expect("should eval OK");
|
||||
let x = js_sys::eval("42").ok().expect("should eval OK");
|
||||
assert_eq!(x.as_f64().unwrap(), 42.0);
|
||||
|
||||
let err = js::eval("(function () { throw 42; }())")
|
||||
let err = js_sys::eval("(function () { throw 42; }())")
|
||||
.err()
|
||||
.expect("eval should throw");
|
||||
assert_eq!(err.as_f64().unwrap(), 42.0);
|
||||
@ -162,12 +166,12 @@ fn is_finite() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn is_finite(value: &JsValue) -> bool {
|
||||
js::is_finite(value)
|
||||
js_sys::is_finite(value)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -196,24 +200,24 @@ fn parse_int_float() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn test() {
|
||||
let i = js::parse_int("42", 10);
|
||||
let i = js_sys::parse_int("42", 10);
|
||||
assert_eq!(i as i64, 42);
|
||||
|
||||
let i = js::parse_int("42", 16);
|
||||
let i = js_sys::parse_int("42", 16);
|
||||
assert_eq!(i as i64, 66); // 0x42 == 66
|
||||
|
||||
let i = js::parse_int("invalid int", 10);
|
||||
let i = js_sys::parse_int("invalid int", 10);
|
||||
assert!(i.is_nan());
|
||||
|
||||
let f = js::parse_float("123456.789");
|
||||
let f = js_sys::parse_float("123456.789");
|
||||
assert_eq!(f, 123456.789);
|
||||
|
||||
let f = js::parse_float("invalid float");
|
||||
let f = js_sys::parse_float("invalid float");
|
||||
assert!(f.is_nan());
|
||||
}
|
||||
"#)
|
||||
@ -227,16 +231,16 @@ fn escape() {
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn test() {
|
||||
assert_eq!(String::from(js::escape("test")), "test");
|
||||
assert_eq!(String::from(js::escape("äöü")), "%E4%F6%FC");
|
||||
assert_eq!(String::from(js::escape("ć")), "%u0107");
|
||||
assert_eq!(String::from(js::escape("@*_+-./")), "@*_+-./");
|
||||
assert_eq!(String::from(js_sys::escape("test")), "test");
|
||||
assert_eq!(String::from(js_sys::escape("äöü")), "%E4%F6%FC");
|
||||
assert_eq!(String::from(js_sys::escape("ć")), "%u0107");
|
||||
assert_eq!(String::from(js_sys::escape("@*_+-./")), "@*_+-./");
|
||||
}
|
||||
"#)
|
||||
.test();
|
||||
}
|
||||
}
|
@ -8,3 +8,4 @@ crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
wasm-bindgen = { path = "../.." }
|
||||
js-sys = { path = "../../crates/js-sys" }
|
||||
|
@ -1,9 +1,10 @@
|
||||
#![feature(use_extern_macros, wasm_import_module)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate js_sys;
|
||||
|
||||
use wasm_bindgen::js::Date;
|
||||
use wasm_bindgen::js::JsString;
|
||||
use js_sys::Date;
|
||||
use js_sys::JsString;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
|
@ -6,7 +6,6 @@
|
||||
//! interface.
|
||||
|
||||
#![feature(use_extern_macros, wasm_import_module, unsize)]
|
||||
#![cfg_attr(feature = "js_globals", feature(use_extern_macros))]
|
||||
#![no_std]
|
||||
|
||||
#[cfg(feature = "serde-serialize")]
|
||||
@ -45,13 +44,6 @@ pub mod prelude {
|
||||
|
||||
pub mod convert;
|
||||
pub mod describe;
|
||||
#[cfg(feature = "js_globals")]
|
||||
pub mod js;
|
||||
|
||||
#[cfg(feature = "js_globals")]
|
||||
mod wasm_bindgen {
|
||||
pub use super::*;
|
||||
}
|
||||
|
||||
if_std! {
|
||||
extern crate std;
|
||||
|
@ -11,8 +11,6 @@ mod dependencies;
|
||||
mod enums;
|
||||
mod import_class;
|
||||
mod imports;
|
||||
#[cfg(feature = "js_globals")]
|
||||
mod js_globals;
|
||||
mod jsobjects;
|
||||
mod math;
|
||||
mod node;
|
||||
|
@ -423,7 +423,6 @@ fn binding_to_unimplemented_apis_doesnt_break_everything() {
|
||||
#![feature(use_extern_macros, wasm_import_module)]
|
||||
extern crate wasm_bindgen;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::js::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
extern {
|
||||
@ -433,27 +432,16 @@ fn binding_to_unimplemented_apis_doesnt_break_everything() {
|
||||
#[wasm_bindgen(constructor)]
|
||||
fn new() -> Array;
|
||||
|
||||
#[wasm_bindgen(method)]
|
||||
fn standardized_method_this_js_runtime_doesnt_implement_yet(this: &Array);
|
||||
#[wasm_bindgen(method, catch)]
|
||||
fn standardized_method_this_js_runtime_doesnt_implement_yet(this: &Array)
|
||||
-> Result<(), JsValue>;
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn test() {
|
||||
let array = Array::new();
|
||||
|
||||
let array_obj: JsValue = array.clone().into();
|
||||
let array_obj = array_obj.as_object().unwrap();
|
||||
|
||||
let array_proto = Reflect::get_prototype_of(&array_obj);
|
||||
|
||||
let unimplemented = Reflect::get(
|
||||
&array_proto,
|
||||
&JsValue::from_str("standardized_method_this_js_runtime_doesnt_implement_yet")
|
||||
);
|
||||
|
||||
if unimplemented.is_function() {
|
||||
array.standardized_method_this_js_runtime_doesnt_implement_yet();
|
||||
}
|
||||
let res = array.standardized_method_this_js_runtime_doesnt_implement_yet();
|
||||
assert!(res.is_err());
|
||||
}
|
||||
"#,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user