File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -302,6 +302,12 @@ extern {
302
302
#[ wasm_bindgen( static_method_of = Math ) ]
303
303
pub fn cbrt ( x : i32 ) -> Number ;
304
304
305
+ /// The Math.ceil() function returns the smallest integer greater than
306
+ /// or equal to a given number.
307
+ ///
308
+ /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil
309
+ #[ wasm_bindgen( static_method_of = Math ) ]
310
+ pub fn ceil ( x : f32 ) -> Number ;
305
311
}
306
312
307
313
// Number.
Original file line number Diff line number Diff line change @@ -238,3 +238,30 @@ fn cbrt() {
238
238
"# )
239
239
. test ( )
240
240
}
241
+
242
+ #[ test]
243
+ fn ceil ( ) {
244
+ project ( )
245
+ . file ( "src/lib.rs" , r#"
246
+ #![feature(proc_macro, wasm_custom_section)]
247
+
248
+ extern crate wasm_bindgen;
249
+ use wasm_bindgen::prelude::*;
250
+ use wasm_bindgen::js;
251
+
252
+ #[wasm_bindgen]
253
+ pub fn ceil(x: f32) -> js::Number {
254
+ js::Math::ceil(x)
255
+ }
256
+ "# )
257
+ . file ( "test.ts" , r#"
258
+ import * as assert from "assert";
259
+ import * as wasm from "./out";
260
+
261
+ export function test() {
262
+ assert.equal(wasm.ceil(1.1), 2);
263
+ assert.equal(wasm.ceil(-1.1), -1);
264
+ }
265
+ "# )
266
+ . test ( )
267
+ }
You can’t perform that action at this time.
0 commit comments