File tree 2 files changed +30
-0
lines changed
2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -1191,6 +1191,18 @@ extern "C" {
1191
1191
#[ wasm_bindgen( static_method_of = Math ) ]
1192
1192
pub fn log2 ( x : f64 ) -> f64 ;
1193
1193
1194
+ /// The Math.max() function returns the largest of two numbers.
1195
+ ///
1196
+ /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max
1197
+ #[ wasm_bindgen( static_method_of = Math ) ]
1198
+ pub fn max ( x : f64 , y : f64 ) -> f64 ;
1199
+
1200
+ /// The static function Math.min() returns the lowest-valued number passed into it.
1201
+ ///
1202
+ /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min
1203
+ #[ wasm_bindgen( static_method_of = Math ) ]
1204
+ pub fn min ( x : f64 , y : f64 ) -> f64 ;
1205
+
1194
1206
/// The Math.pow() function returns the base to the exponent power, that is, base^exponent.
1195
1207
///
1196
1208
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow
Original file line number Diff line number Diff line change @@ -172,6 +172,24 @@ fn log2() {
172
172
assert_eq ! ( Math :: log2( 0. ) , NEG_INFINITY ) ;
173
173
}
174
174
175
+ #[ wasm_bindgen_test]
176
+ fn max ( ) {
177
+ assert_eq ! ( Math :: max( 3. , 1. ) , 3. ) ;
178
+ assert_eq ! ( Math :: max( -3. , 1. ) , 1. ) ;
179
+ assert_eq ! ( Math :: max( 9913. , 43.4 ) , 9913. ) ;
180
+ assert_eq ! ( Math :: max( -27. , -43. ) , -27. ) ;
181
+ assert_eq ! ( Math :: max( -423.27 , -43.1 ) , -43.1 ) ;
182
+ }
183
+
184
+ #[ wasm_bindgen_test]
185
+ fn min ( ) {
186
+ assert_eq ! ( Math :: min( 3. , 1. ) , 1. ) ;
187
+ assert_eq ! ( Math :: min( -3. , 1. ) , -3. ) ;
188
+ assert_eq ! ( Math :: min( 9913. , 43.4 ) , 43.4 ) ;
189
+ assert_eq ! ( Math :: min( -27. , -43. ) , -43. ) ;
190
+ assert_eq ! ( Math :: min( -423.27 , -43.1 ) , -423.27 ) ;
191
+ }
192
+
175
193
#[ wasm_bindgen_test]
176
194
fn pow ( ) {
177
195
assert_eq ! ( Math :: pow( 7. , 2. ) , 49. ) ;
You can’t perform that action at this time.
0 commit comments