mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-06 20:27:48 +00:00

Distribute everything from `libm/` to better locations in the repo. `libm/libm/*` has not moved yet to avoid Git seeing the move as an edit to `Cargo.toml`. Files that remain to be merged somehow are in `etc/libm`.
39 lines
955 B
Rust
39 lines
955 B
Rust
#[libm_macros::function_enum(BaseName)]
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
|
pub enum Identifier {}
|
|
|
|
#[libm_macros::base_name_enum]
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
|
pub enum BaseName {}
|
|
|
|
#[test]
|
|
fn as_str() {
|
|
assert_eq!(Identifier::Sin.as_str(), "sin");
|
|
assert_eq!(Identifier::Sinf.as_str(), "sinf");
|
|
}
|
|
|
|
#[test]
|
|
fn from_str() {
|
|
assert_eq!(Identifier::from_str("sin").unwrap(), Identifier::Sin);
|
|
assert_eq!(Identifier::from_str("sinf").unwrap(), Identifier::Sinf);
|
|
}
|
|
|
|
#[test]
|
|
fn basename() {
|
|
assert_eq!(Identifier::Sin.base_name(), BaseName::Sin);
|
|
assert_eq!(Identifier::Sinf.base_name(), BaseName::Sin);
|
|
}
|
|
|
|
#[test]
|
|
fn math_op() {
|
|
assert_eq!(Identifier::Sin.math_op().float_ty, FloatTy::F64);
|
|
assert_eq!(Identifier::Sinf.math_op().float_ty, FloatTy::F32);
|
|
}
|
|
|
|
// Replicate the structure that we have in `libm-test`
|
|
mod op {
|
|
include!("../../libm-macros/src/shared.rs");
|
|
}
|
|
|
|
use op::FloatTy;
|