diff options
Diffstat (limited to 'vendor/wasm-bindgen/tests/wasm')
-rw-r--r-- | vendor/wasm-bindgen/tests/wasm/api.rs | 9 | ||||
-rw-r--r-- | vendor/wasm-bindgen/tests/wasm/classes.js | 2 | ||||
-rw-r--r-- | vendor/wasm-bindgen/tests/wasm/classes.rs | 4 | ||||
-rw-r--r-- | vendor/wasm-bindgen/tests/wasm/closures.rs | 2 | ||||
-rw-r--r-- | vendor/wasm-bindgen/tests/wasm/futures.rs | 6 | ||||
-rw-r--r-- | vendor/wasm-bindgen/tests/wasm/import_class.rs | 8 | ||||
-rw-r--r-- | vendor/wasm-bindgen/tests/wasm/imports.rs | 1 | ||||
-rw-r--r-- | vendor/wasm-bindgen/tests/wasm/js_keywords.rs | 4 | ||||
-rw-r--r-- | vendor/wasm-bindgen/tests/wasm/js_objects.rs | 13 | ||||
-rw-r--r-- | vendor/wasm-bindgen/tests/wasm/main.rs | 2 | ||||
-rw-r--r-- | vendor/wasm-bindgen/tests/wasm/no_shims.rs | 28 | ||||
-rw-r--r-- | vendor/wasm-bindgen/tests/wasm/owned.rs | 1 | ||||
-rw-r--r-- | vendor/wasm-bindgen/tests/wasm/result.rs | 8 | ||||
-rw-r--r-- | vendor/wasm-bindgen/tests/wasm/result_jserror.rs | 2 | ||||
-rw-r--r-- | vendor/wasm-bindgen/tests/wasm/should_panic.rs | 17 | ||||
-rw-r--r-- | vendor/wasm-bindgen/tests/wasm/simple.rs | 9 | ||||
-rw-r--r-- | vendor/wasm-bindgen/tests/wasm/slice.rs | 1 | ||||
-rw-r--r-- | vendor/wasm-bindgen/tests/wasm/truthy_falsy.rs | 32 |
18 files changed, 86 insertions, 63 deletions
diff --git a/vendor/wasm-bindgen/tests/wasm/api.rs b/vendor/wasm-bindgen/tests/wasm/api.rs index 26da4fc9a..b3c578706 100644 --- a/vendor/wasm-bindgen/tests/wasm/api.rs +++ b/vendor/wasm-bindgen/tests/wasm/api.rs @@ -82,14 +82,14 @@ pub fn api_mk_symbol() -> JsValue { let a = JsValue::symbol(None); assert!(a.is_symbol()); assert_eq!(format!("{:?}", a), "JsValue(Symbol)"); - return a; + a } #[wasm_bindgen] pub fn api_mk_symbol2(s: &str) -> JsValue { let a = JsValue::symbol(Some(s)); assert!(a.is_symbol()); - return a; + a } #[wasm_bindgen] @@ -121,6 +121,7 @@ pub fn eq_test(a: &JsValue, b: &JsValue) -> bool { } #[wasm_bindgen] +#[allow(clippy::eq_op)] pub fn eq_test1(a: &JsValue) -> bool { a == a } @@ -132,8 +133,8 @@ pub fn api_completely_variadic(args: &JsValue) -> JsValue { #[wasm_bindgen(variadic)] pub fn api_variadic_with_prefixed_params( - first: &JsValue, - second: &JsValue, + _first: &JsValue, + _second: &JsValue, args: &JsValue, ) -> JsValue { args.into() diff --git a/vendor/wasm-bindgen/tests/wasm/classes.js b/vendor/wasm-bindgen/tests/wasm/classes.js index bcb61e054..8e503c658 100644 --- a/vendor/wasm-bindgen/tests/wasm/classes.js +++ b/vendor/wasm-bindgen/tests/wasm/classes.js @@ -228,7 +228,7 @@ exports.js_test_inspectable_classes = () => { assert.strictEqual(not_inspectable.toJSON, undefined); assert.strictEqual(not_inspectable.toString(), '[object Object]'); // Non-inspectable classes in Node.js have no special console.log formatting - assert.strictEqual(console_log_to_string(not_inspectable), `NotInspectable { ptr: ${not_inspectable.ptr} }`); + assert.strictEqual(console_log_to_string(not_inspectable), `NotInspectable { __wbg_ptr: ${not_inspectable.__wbg_ptr} }`); inspectable.free(); not_inspectable.free(); }; diff --git a/vendor/wasm-bindgen/tests/wasm/classes.rs b/vendor/wasm-bindgen/tests/wasm/classes.rs index 3588bb74c..9321ff92d 100644 --- a/vendor/wasm-bindgen/tests/wasm/classes.rs +++ b/vendor/wasm-bindgen/tests/wasm/classes.rs @@ -599,12 +599,12 @@ impl OverriddenInspectable { } #[wasm_bindgen(js_name = toJSON)] - pub fn to_json(&self) -> String { + pub fn js_to_json(&self) -> String { String::from("JSON was overwritten") } #[wasm_bindgen(js_name = toString)] - pub fn to_string(&self) -> String { + pub fn js_to_string(&self) -> String { String::from("string was overwritten") } } diff --git a/vendor/wasm-bindgen/tests/wasm/closures.rs b/vendor/wasm-bindgen/tests/wasm/closures.rs index e94ed2427..1061dab5a 100644 --- a/vendor/wasm-bindgen/tests/wasm/closures.rs +++ b/vendor/wasm-bindgen/tests/wasm/closures.rs @@ -510,7 +510,7 @@ fn test_closure_returner() { Reflect::set( &o, &JsValue::from("someKey"), - &some_fn.as_ref().unchecked_ref(), + some_fn.as_ref().unchecked_ref(), ) .unwrap(); Reflect::set( diff --git a/vendor/wasm-bindgen/tests/wasm/futures.rs b/vendor/wasm-bindgen/tests/wasm/futures.rs index 7dfddf209..3679a0d48 100644 --- a/vendor/wasm-bindgen/tests/wasm/futures.rs +++ b/vendor/wasm-bindgen/tests/wasm/futures.rs @@ -93,9 +93,9 @@ pub struct AsyncCustomError { pub val: JsValue, } -impl Into<JsValue> for AsyncCustomError { - fn into(self) -> JsValue { - self.val +impl From<AsyncCustomError> for JsValue { + fn from(e: AsyncCustomError) -> Self { + e.val } } diff --git a/vendor/wasm-bindgen/tests/wasm/import_class.rs b/vendor/wasm-bindgen/tests/wasm/import_class.rs index 55cc1d1be..cd9b4cfb7 100644 --- a/vendor/wasm-bindgen/tests/wasm/import_class.rs +++ b/vendor/wasm-bindgen/tests/wasm/import_class.rs @@ -1,6 +1,7 @@ //! dox #![deny(missing_docs)] // test that documenting public bindings is enough +#![allow(clippy::redundant_clone)] // test specifically with cloned objects use wasm_bindgen::prelude::*; use wasm_bindgen_test::*; @@ -124,11 +125,11 @@ extern "C" { fn assert_internal_int(this: &InnerClass, i: u32); } -#[wasm_bindgen] +#[wasm_bindgen(js_namespace = Math)] extern "C" { - #[wasm_bindgen(js_namespace = Math)] + #[wasm_bindgen] fn random() -> f64; - #[wasm_bindgen(js_namespace = Math)] + #[wasm_bindgen] fn log(a: f64) -> f64; } @@ -173,7 +174,6 @@ fn rename_type() { } #[wasm_bindgen_test] -#[cfg(ignored)] // TODO: fix this before landing fn switch_methods() { assert!(!switch_methods_called()); SwitchMethods::a(); diff --git a/vendor/wasm-bindgen/tests/wasm/imports.rs b/vendor/wasm-bindgen/tests/wasm/imports.rs index 27e4a67dc..a9fbb33b7 100644 --- a/vendor/wasm-bindgen/tests/wasm/imports.rs +++ b/vendor/wasm-bindgen/tests/wasm/imports.rs @@ -33,6 +33,7 @@ extern "C" { #[wasm_bindgen(js_name = pub)] fn js_function_named_rust_keyword() -> u32; + #[allow(non_camel_case_types)] type bar; #[wasm_bindgen(js_namespace = bar, js_name = foo)] static FOO: JsValue; diff --git a/vendor/wasm-bindgen/tests/wasm/js_keywords.rs b/vendor/wasm-bindgen/tests/wasm/js_keywords.rs index 57feed7a7..7a4eb4a1b 100644 --- a/vendor/wasm-bindgen/tests/wasm/js_keywords.rs +++ b/vendor/wasm-bindgen/tests/wasm/js_keywords.rs @@ -25,7 +25,7 @@ pub fn arg_is_keyword(class: u8) -> u8 { } #[wasm_bindgen] -struct Class { +pub struct Class { name: String, } #[wasm_bindgen] @@ -50,6 +50,6 @@ impl Class { fn compile() { js_keywords_compile(); assert_eq!(test_keyword_1_as_fn_name(1), 1); - assert_eq!(test_keyword_2_as_fn_name(1, 2), false); + assert!(!test_keyword_2_as_fn_name(1, 2)); assert_eq!(test_keyword_as_fn_arg(1), 1); } diff --git a/vendor/wasm-bindgen/tests/wasm/js_objects.rs b/vendor/wasm-bindgen/tests/wasm/js_objects.rs index 445d5329a..af97ad6ee 100644 --- a/vendor/wasm-bindgen/tests/wasm/js_objects.rs +++ b/vendor/wasm-bindgen/tests/wasm/js_objects.rs @@ -145,6 +145,7 @@ fn another_vector_string_return() { #[cfg(feature = "serde-serialize")] #[wasm_bindgen_test] +#[allow(deprecated)] fn serde() { #[derive(Deserialize, Serialize)] pub struct SerdeFoo { @@ -172,12 +173,12 @@ fn serde() { .unwrap(), ); - let foo = ret.into_serde::<SerdeFoo>().unwrap(); - assert_eq!(foo.a, 2); - assert_eq!(foo.b, "bar"); - assert!(foo.c.is_some()); - assert_eq!(foo.c.as_ref().unwrap().a, 3); - assert_eq!(foo.d.a, 4); + let result = ret.into_serde::<SerdeFoo>().unwrap(); + assert_eq!(result.a, 2); + assert_eq!(result.b, "bar"); + assert!(result.c.is_some()); + assert_eq!(result.c.as_ref().unwrap().a, 3); + assert_eq!(result.d.a, 4); assert_eq!(JsValue::from("bar").into_serde::<String>().unwrap(), "bar"); assert_eq!(JsValue::undefined().into_serde::<i32>().ok(), None); diff --git a/vendor/wasm-bindgen/tests/wasm/main.rs b/vendor/wasm-bindgen/tests/wasm/main.rs index 987962c88..508a9ea1f 100644 --- a/vendor/wasm-bindgen/tests/wasm/main.rs +++ b/vendor/wasm-bindgen/tests/wasm/main.rs @@ -1,4 +1,6 @@ #![cfg(target_arch = "wasm32")] +#![allow(renamed_and_removed_lints)] // clippy::drop_ref will be renamed to drop_ref +#![allow(clippy::drop_ref, clippy::drop_non_drop)] extern crate js_sys; extern crate wasm_bindgen; diff --git a/vendor/wasm-bindgen/tests/wasm/no_shims.rs b/vendor/wasm-bindgen/tests/wasm/no_shims.rs index 2f9455ae2..f56701b69 100644 --- a/vendor/wasm-bindgen/tests/wasm/no_shims.rs +++ b/vendor/wasm-bindgen/tests/wasm/no_shims.rs @@ -22,7 +22,7 @@ use wasm_bindgen_test::*; module.exports.incoming_u32 = function () { return 4294967295; }; module.exports.incoming_i32 = function () { return 0; }; module.exports.incoming_f32 = function () { return 1.5; }; - module.exports.incoming_f64 = function () { return 13.37; }; + module.exports.incoming_f64 = function () { return Math.PI; }; module.exports.outgoing_u8 = function (k) { assert_eq(k, 255); }; module.exports.outgoing_i8 = function (i) { assert_eq(i, -127); }; @@ -30,12 +30,12 @@ use wasm_bindgen_test::*; module.exports.outgoing_i16 = function (j) { assert_eq(j, 32767); }; module.exports.outgoing_i32 = function (x) { assert_eq(x, 0); }; module.exports.outgoing_f32 = function (y) { assert_eq(y, 1.5); }; - module.exports.outgoing_f64 = function (z) { assert_eq(z, 13.37); }; + module.exports.outgoing_f64 = function (pi) { assert_eq(pi, Math.PI); }; - module.exports.many = function (x, y, z) { + module.exports.many = function (x, y, pi) { assert_eq(x, 0); assert_eq(y, 1.5); - assert_eq(z, 13.37); + assert_eq(pi, Math.PI); return 42; }; @@ -45,8 +45,8 @@ use wasm_bindgen_test::*; }; module.exports.MyNamespace = {}; - module.exports.MyNamespace.incoming_namespaced = function () { return 3.14; }; - module.exports.MyNamespace.outgoing_namespaced = function (pi) { assert_eq(3.14, pi); }; + module.exports.MyNamespace.incoming_namespaced = function () { return 13.37; }; + module.exports.MyNamespace.outgoing_namespaced = function (w) { assert_eq(13.37, w); }; ")] extern "C" { #[wasm_bindgen(assert_no_shim)] @@ -132,16 +132,16 @@ fn no_shims() { assert_eq!(y, 1.5); outgoing_f32(y); - let z = incoming_f64(); - assert_eq!(z, 13.37); - outgoing_f64(z); + let pi = incoming_f64(); + assert_eq!(pi, std::f64::consts::PI); + outgoing_f64(pi); - let w = many(x, y, z); - assert_eq!(w, 42); + let z = many(x, y, pi); + assert_eq!(z, 42); - let pi = incoming_namespaced(); - assert_eq!(pi, 3.14); - outgoing_namespaced(pi); + let w = incoming_namespaced(); + assert_eq!(w, 13.37); + outgoing_namespaced(w); let b = incoming_bool(); assert!(b); diff --git a/vendor/wasm-bindgen/tests/wasm/owned.rs b/vendor/wasm-bindgen/tests/wasm/owned.rs index 7d51673a5..97e7d6fda 100644 --- a/vendor/wasm-bindgen/tests/wasm/owned.rs +++ b/vendor/wasm-bindgen/tests/wasm/owned.rs @@ -13,6 +13,7 @@ impl OwnedValue { Self { n } } + #[allow(clippy::should_implement_trait)] // traits unsupported by wasm_bindgen pub fn add(self, other: OwnedValue) -> Self { Self { n: self.n + other.n, diff --git a/vendor/wasm-bindgen/tests/wasm/result.rs b/vendor/wasm-bindgen/tests/wasm/result.rs index c2c043ab8..3f30acc02 100644 --- a/vendor/wasm-bindgen/tests/wasm/result.rs +++ b/vendor/wasm-bindgen/tests/wasm/result.rs @@ -20,9 +20,9 @@ extern "C" { fn error_new(message: &str) -> JsValue; } -impl Into<JsValue> for MyError { - fn into(self) -> JsValue { - error_new(&format!("{}", self)) +impl From<MyError> for JsValue { + fn from(e: MyError) -> Self { + error_new(&format!("{}", e)) } } @@ -87,7 +87,7 @@ impl Struct { #[wasm_bindgen] pub fn new_err() -> Result<Struct, MyError> { - Err(MyError::Variant.into()) + Err(MyError::Variant) } #[wasm_bindgen] diff --git a/vendor/wasm-bindgen/tests/wasm/result_jserror.rs b/vendor/wasm-bindgen/tests/wasm/result_jserror.rs index f714ac2f1..e0ecbac17 100644 --- a/vendor/wasm-bindgen/tests/wasm/result_jserror.rs +++ b/vendor/wasm-bindgen/tests/wasm/result_jserror.rs @@ -45,7 +45,7 @@ call_test!(test_ok, call_ok); #[wasm_bindgen] pub fn make_an_error() -> JsError { - JsError::new("un-thrown error").into() + JsError::new("un-thrown error") } call_test!(test_make_an_error, call_make_an_error); diff --git a/vendor/wasm-bindgen/tests/wasm/should_panic.rs b/vendor/wasm-bindgen/tests/wasm/should_panic.rs new file mode 100644 index 000000000..6c0788b27 --- /dev/null +++ b/vendor/wasm-bindgen/tests/wasm/should_panic.rs @@ -0,0 +1,17 @@ +#[wasm_bindgen_test] +#[should_panic] +fn should_panic() { + panic!() +} + +#[wasm_bindgen_test] +#[should_panic = "error message"] +fn should_panic_string() { + panic!("error message") +} + +#[wasm_bindgen_test] +#[should_panic(expected = "error message")] +fn should_panic_expected() { + panic!("error message") +} diff --git a/vendor/wasm-bindgen/tests/wasm/simple.rs b/vendor/wasm-bindgen/tests/wasm/simple.rs index 5f22b6ea9..db653847a 100644 --- a/vendor/wasm-bindgen/tests/wasm/simple.rs +++ b/vendor/wasm-bindgen/tests/wasm/simple.rs @@ -57,11 +57,9 @@ pub fn simple_return_and_take_bool(a: bool, b: bool) -> bool { } #[wasm_bindgen] -pub fn simple_raw_pointers_work(a: *mut u32, b: *const u8) -> *const u32 { - unsafe { - (*a) = (*b) as u32; - return a; - } +pub unsafe fn simple_raw_pointers_work(a: *mut u32, b: *const u8) -> *const u32 { + (*a) = (*b) as u32; + a } #[wasm_bindgen_test] @@ -218,6 +216,7 @@ pub fn do_string_roundtrip(s: String) -> String { } #[wasm_bindgen_test] +#[allow(clippy::redundant_clone)] // clone to increase heap live count fn externref_heap_live_count() { let x = wasm_bindgen::externref_heap_live_count(); let y = JsValue::null().clone(); diff --git a/vendor/wasm-bindgen/tests/wasm/slice.rs b/vendor/wasm-bindgen/tests/wasm/slice.rs index 2f2457bc1..6e659ce6f 100644 --- a/vendor/wasm-bindgen/tests/wasm/slice.rs +++ b/vendor/wasm-bindgen/tests/wasm/slice.rs @@ -211,6 +211,7 @@ pub struct ReturnVecApplication { #[wasm_bindgen] impl ReturnVecApplication { + #[allow(clippy::vec_init_then_push)] pub fn new() -> ReturnVecApplication { let mut thing = vec![]; thing.push(0); diff --git a/vendor/wasm-bindgen/tests/wasm/truthy_falsy.rs b/vendor/wasm-bindgen/tests/wasm/truthy_falsy.rs index d04abb053..83657ca0a 100644 --- a/vendor/wasm-bindgen/tests/wasm/truthy_falsy.rs +++ b/vendor/wasm-bindgen/tests/wasm/truthy_falsy.rs @@ -3,26 +3,26 @@ use wasm_bindgen_test::*; #[wasm_bindgen_test] fn test_is_truthy() { - assert_eq!(JsValue::from(0).is_truthy(), false); - assert_eq!(JsValue::from("".to_string()).is_truthy(), false); - assert_eq!(JsValue::from(false).is_truthy(), false); - assert_eq!(JsValue::NULL.is_truthy(), false); - assert_eq!(JsValue::UNDEFINED.is_truthy(), false); + assert!(!JsValue::from(0).is_truthy()); + assert!(!JsValue::from("".to_string()).is_truthy()); + assert!(!JsValue::from(false).is_truthy()); + assert!(!JsValue::NULL.is_truthy()); + assert!(!JsValue::UNDEFINED.is_truthy()); - assert_eq!(JsValue::from(10).is_truthy(), true); - assert_eq!(JsValue::from("null".to_string()).is_truthy(), true); - assert_eq!(JsValue::from(true).is_truthy(), true); + assert!(JsValue::from(10).is_truthy()); + assert!(JsValue::from("null".to_string()).is_truthy()); + assert!(JsValue::from(true).is_truthy()); } #[wasm_bindgen_test] fn test_is_falsy() { - assert_eq!(JsValue::from(0).is_falsy(), true); - assert_eq!(JsValue::from("".to_string()).is_falsy(), true); - assert_eq!(JsValue::from(false).is_falsy(), true); - assert_eq!(JsValue::NULL.is_falsy(), true); - assert_eq!(JsValue::UNDEFINED.is_falsy(), true); + assert!(JsValue::from(0).is_falsy()); + assert!(JsValue::from("".to_string()).is_falsy()); + assert!(JsValue::from(false).is_falsy()); + assert!(JsValue::NULL.is_falsy()); + assert!(JsValue::UNDEFINED.is_falsy()); - assert_eq!(JsValue::from(10).is_falsy(), false); - assert_eq!(JsValue::from("null".to_string()).is_falsy(), false); - assert_eq!(JsValue::from(true).is_falsy(), false); + assert!(!JsValue::from(10).is_falsy()); + assert!(!JsValue::from("null".to_string()).is_falsy()); + assert!(!JsValue::from(true).is_falsy()); } |