File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -308,6 +308,13 @@ extern {
308
308
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil
309
309
#[ wasm_bindgen( static_method_of = Math ) ]
310
310
pub fn ceil ( x : f32 ) -> Number ;
311
+
312
+ /// The Math.clz32() function returns the number of leading zero bits in
313
+ /// the 32-bit binary representation of a number.
314
+ ///
315
+ /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32
316
+ #[ wasm_bindgen( static_method_of = Math ) ]
317
+ pub fn clz32 ( x : i32 ) -> Number ;
311
318
}
312
319
313
320
// Number.
Original file line number Diff line number Diff line change @@ -265,3 +265,30 @@ fn ceil() {
265
265
"# )
266
266
. test ( )
267
267
}
268
+
269
+ #[ test]
270
+ fn clz32 ( ) {
271
+ project ( )
272
+ . file ( "src/lib.rs" , r#"
273
+ #![feature(proc_macro, wasm_custom_section)]
274
+
275
+ extern crate wasm_bindgen;
276
+ use wasm_bindgen::prelude::*;
277
+ use wasm_bindgen::js;
278
+
279
+ #[wasm_bindgen]
280
+ pub fn clz32(x: i32) -> js::Number {
281
+ js::Math::clz32(x)
282
+ }
283
+ "# )
284
+ . file ( "test.ts" , r#"
285
+ import * as assert from "assert";
286
+ import * as wasm from "./out";
287
+
288
+ export function test() {
289
+ assert.equal(wasm.clz32(1), 31);
290
+ assert.equal(wasm.clz32(1000), 22);
291
+ }
292
+ "# )
293
+ . test ( )
294
+ }
You can’t perform that action at this time.
0 commit comments