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 @@ -294,6 +294,14 @@ extern {
294
294
#[ wasm_bindgen( static_method_of = Math ) ]
295
295
pub fn atanh ( x : i32 ) -> Number ;
296
296
297
+
298
+ /// The Math.cbrt() function returns the cube root of a number, that is
299
+ /// Math.cbrt(x) = x^3 = the unique y such that y^3 = x
300
+ ///
301
+ /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt
302
+ #[ wasm_bindgen( static_method_of = Math ) ]
303
+ pub fn cbrt ( x : i32 ) -> Number ;
304
+
297
305
}
298
306
299
307
// Number.
Original file line number Diff line number Diff line change @@ -212,3 +212,29 @@ fn atanh() {
212
212
"# )
213
213
. test ( )
214
214
}
215
+
216
+ #[ test]
217
+ fn cbrt ( ) {
218
+ project ( )
219
+ . file ( "src/lib.rs" , r#"
220
+ #![feature(proc_macro, wasm_custom_section)]
221
+
222
+ extern crate wasm_bindgen;
223
+ use wasm_bindgen::prelude::*;
224
+ use wasm_bindgen::js;
225
+
226
+ #[wasm_bindgen]
227
+ pub fn cbrt(x: i32) -> js::Number {
228
+ js::Math::cbrt(x)
229
+ }
230
+ "# )
231
+ . file ( "test.ts" , r#"
232
+ import * as assert from "assert";
233
+ import * as wasm from "./out";
234
+
235
+ export function test() {
236
+ assert.equal(wasm.cbrt(27), 3);
237
+ }
238
+ "# )
239
+ . test ( )
240
+ }
You can’t perform that action at this time.
0 commit comments