aboutsummaryrefslogtreecommitdiff
path: root/vendor/instant/tests/wasm.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
committerValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
commita990de90fe41456a23e58bd087d2f107d321f3a1 (patch)
tree15afc392522a9e85dc3332235e311b7d39352ea9 /vendor/instant/tests/wasm.rs
parent3d48cd3f81164bbfc1a755dc1d4a9a02f98c8ddd (diff)
downloadfparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.tar.xz
fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.zip
Deleted vendor folder
Diffstat (limited to 'vendor/instant/tests/wasm.rs')
-rw-r--r--vendor/instant/tests/wasm.rs57
1 files changed, 0 insertions, 57 deletions
diff --git a/vendor/instant/tests/wasm.rs b/vendor/instant/tests/wasm.rs
deleted file mode 100644
index e858faa..0000000
--- a/vendor/instant/tests/wasm.rs
+++ /dev/null
@@ -1,57 +0,0 @@
-extern crate wasm_bindgen_test;
-
-use instant::{Instant, SystemTime};
-use std::time::Duration;
-use wasm_bindgen_test::*;
-
-wasm_bindgen_test_configure!(run_in_browser);
-// run these tests using: wasm-pack test --chrome --headless -- --features wasm-bindgen
-
-#[wasm_bindgen_test]
-fn test_instant_now() {
- let now = Instant::now();
- #[cfg(feature = "inaccurate")]
- while now.elapsed().as_millis() == 0 {}
- #[cfg(not(feature = "inaccurate"))]
- assert!(now.elapsed().as_nanos() > 0);
-}
-
-#[wasm_bindgen_test]
-fn test_duration() {
- let now = Instant::now();
- let one_sec = Duration::from_secs(1);
- assert!(now.elapsed() < one_sec);
-}
-
-// Duration::new will overflow when you have u64::MAX seconds and one billion nanoseconds.
-// <https://doc.rust-lang.org/std/time/struct.Duration.html#method.new>
-const ONE_BILLION: u32 = 1_000_000_000;
-
-#[wasm_bindgen_test]
-fn test_checked_add() {
- let now = Instant::now();
-
- assert!(now.checked_add(Duration::from_millis(1)).is_some());
- assert_eq!(
- None,
- now.checked_add(Duration::new(u64::MAX, ONE_BILLION - 1))
- );
-}
-
-#[wasm_bindgen_test]
-fn test_checked_sub() {
- let now = Instant::now();
-
- assert!(now.checked_sub(Duration::from_millis(1)).is_some());
- assert!(now
- .checked_sub(Duration::new(u64::MAX, ONE_BILLION - 1))
- .is_none());
-}
-
-#[wasm_bindgen_test]
-fn test_system_time() {
- assert!(SystemTime::UNIX_EPOCH
- .duration_since(SystemTime::now())
- .is_err());
-}
-