We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f310d0e commit 0865acdCopy full SHA for 0865acd
library/std/src/f32/tests.rs
@@ -757,3 +757,24 @@ fn test_total_cmp() {
757
assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&f32::INFINITY));
758
assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&s_nan()));
759
}
760
+
761
+#[test]
762
+fn test_lerp_exact() {
763
+ assert_eq!(f32::lerp(0.0, 2.0, 4.0), 2.0);
764
+ assert_eq!(f32::lerp(1.0, 2.0, 4.0), 4.0);
765
+ assert_eq!(f32::lerp(0.0, f32::MIN, f32::MAX), f32::MIN);
766
+ assert_eq!(f32::lerp(1.0, f32::MIN, f32::MAX), f32::MAX);
767
+}
768
769
770
+fn test_lerp_consistent() {
771
+ assert_eq!(f32::lerp(f32::MAX, f32::MIN, f32::MIN), f32::MIN);
772
+ assert_eq!(f32::lerp(f32::MIN, f32::MAX, f32::MAX), f32::MAX);
773
774
775
776
+fn test_lerp_values() {
777
+ assert_eq!(f32::lerp(0.25, 1.0, 2.0), 1.25);
778
+ assert_eq!(f32::lerp(0.50, 1.0, 2.0), 1.50);
779
+ assert_eq!(f32::lerp(0.75, 1.0, 2.0), 1.75);
780
library/std/src/f64/tests.rs
@@ -753,3 +753,24 @@ fn test_total_cmp() {
753
assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&f64::INFINITY));
754
755
756
+ assert_eq!(f64::lerp(0.0, 2.0, 4.0), 2.0);
+ assert_eq!(f64::lerp(1.0, 2.0, 4.0), 4.0);
+ assert_eq!(f64::lerp(0.0, f64::MIN, f64::MAX), f64::MIN);
+ assert_eq!(f64::lerp(1.0, f64::MIN, f64::MAX), f64::MAX);
+ assert_eq!(f64::lerp(f64::MAX, f64::MIN, f64::MIN), f64::MIN);
+ assert_eq!(f64::lerp(f64::MIN, f64::MAX, f64::MAX), f64::MAX);
+ assert_eq!(f64::lerp(0.25, 1.0, 2.0), 1.25);
+ assert_eq!(f64::lerp(0.50, 1.0, 2.0), 1.50);
+ assert_eq!(f64::lerp(0.75, 1.0, 2.0), 1.75);
library/std/src/lib.rs
@@ -268,6 +268,7 @@
268
#![feature(exhaustive_patterns)]
269
#![feature(extend_one)]
270
#![cfg_attr(bootstrap, feature(extended_key_value_attributes))]
271
+#![feature(float_interpolation)]
272
#![feature(fn_traits)]
273
#![feature(format_args_nl)]
274
#![feature(gen_future)]
0 commit comments