Skip to content

Commit

Permalink
Merge pull request #2180 from CosmWasm/co/cleanup
Browse files Browse the repository at this point in the history
Various cleanup
  • Loading branch information
chipshort authored Jun 26, 2024
2 parents 7b0d0c7 + 2b4d9fc commit 2b19b49
Show file tree
Hide file tree
Showing 18 changed files with 41 additions and 43 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
82 changes: 41 additions & 41 deletions contracts/floaty/src/floats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,54 +126,54 @@ pub fn random_subnormal_64(rng: &mut impl RngCore) -> u64 {
}
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Class {
Normal,
Subnormal,
Zero,
Infinite,
NaN,
}
#[cfg(test)]
mod tests {
use rand_chacha::rand_core::SeedableRng;

pub trait Classifier {
fn classify(&self) -> Class;
}
use super::*;

impl Classifier for u32 {
fn classify(&self) -> Class {
let exponent = self & EXPONENT_MASK_32;
let mantissa = self & MANTISSA_MASK_32;

match (exponent, mantissa) {
(0, 0) => Class::Zero,
(0, _) => Class::Subnormal,
(EXPONENT_MASK_32, 0) => Class::Infinite,
(EXPONENT_MASK_32, _) => Class::NaN,
_ => Class::Normal,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Class {
Normal,
Subnormal,
Zero,
Infinite,
NaN,
}
}

impl Classifier for u64 {
fn classify(&self) -> Class {
let exponent = self & EXPONENT_MASK_64;
let mantissa = self & MANTISSA_MASK_64;

match (exponent, mantissa) {
(0, 0) => Class::Zero,
(0, _) => Class::Subnormal,
(EXPONENT_MASK_64, 0) => Class::Infinite,
(EXPONENT_MASK_64, _) => Class::NaN,
_ => Class::Normal,
}
pub trait Classifier {
fn classify(&self) -> Class;
}
}

#[cfg(test)]
mod tests {
use rand_chacha::rand_core::SeedableRng;
impl Classifier for u32 {
fn classify(&self) -> Class {
let exponent = self & EXPONENT_MASK_32;
let mantissa = self & MANTISSA_MASK_32;

match (exponent, mantissa) {
(0, 0) => Class::Zero,
(0, _) => Class::Subnormal,
(EXPONENT_MASK_32, 0) => Class::Infinite,
(EXPONENT_MASK_32, _) => Class::NaN,
_ => Class::Normal,
}
}
}

use super::*;
impl Classifier for u64 {
fn classify(&self) -> Class {
let exponent = self & EXPONENT_MASK_64;
let mantissa = self & MANTISSA_MASK_64;

match (exponent, mantissa) {
(0, 0) => Class::Zero,
(0, _) => Class::Subnormal,
(EXPONENT_MASK_64, 0) => Class::Infinite,
(EXPONENT_MASK_64, _) => Class::NaN,
_ => Class::Normal,
}
}
}

#[test]
fn test_constants() {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion packages/schema/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ thiserror = "1.0.26"

[dev-dependencies]
anyhow = "1.0.57"
cosmwasm-std = { version = "2.1.0-rc.1", path = "../std" }
semver = "1"
tempfile = "3"
File renamed without changes.

0 comments on commit 2b19b49

Please sign in to comment.