Skip to content

Commit

Permalink
All numbers are f64.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaj committed Oct 8, 2024
1 parent fbf8bf4 commit 3abb9ef
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 602 deletions.
2 changes: 0 additions & 2 deletions rsass/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ arc-swap = "1.5.0"
fastrand = "2.0"
lazy_static = "1.0"
nom = "7.0"
num-integer = "0.1.42"
num-rational = { version = "0.4.0", default-features = false }
num-traits = "^0.2.0"
tracing = "0.1.34"

Expand Down
19 changes: 9 additions & 10 deletions rsass/src/parser/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,43 +595,42 @@ mod test {
use super::*;
use crate::sass::CallArgs;
use crate::sass::Value::{Color, List, Literal, Map, Paren};
use crate::value::Rational;
use crate::ScopeRef;

#[test]
fn simple_number() {
check_expr("4;", number(4, 1))
check_expr("4;", number(4.))
}

#[test]
fn simple_number_neg() {
check_expr("-4;", number(-4, 1))
check_expr("-4;", number(-4.))
}

#[test]
fn simple_number_pos() {
check_expr("+4;", Value::scalar(4))
check_expr("+4;", Value::scalar(4.))
}

#[test]
fn simple_number_dec() {
check_expr("4.34;", number(434, 100))
check_expr("4.34;", number(4.34))
}
#[test]
fn simple_number_onlydec() {
check_expr(".34;", number(34, 100))
check_expr(".34;", number(0.34))
}
#[test]
fn simple_number_onlydec_neg() {
check_expr("-.34;", number(-34, 100))
check_expr("-.34;", number(-0.34))
}
#[test]
fn simple_number_onlydec_pos() {
check_expr("+.34;", number(34, 100))
check_expr("+.34;", number(0.34))
}

fn number(nom: i64, denom: i64) -> Value {
Value::scalar(Rational::new(nom, denom))
fn number(value: f64) -> Value {
Value::scalar(value)
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion rsass/src/value/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod unitset;

pub use self::colors::{Color, Hsla, Hwba, RgbFormat, Rgba};
pub use self::list_separator::ListSeparator;
pub use self::number::{BadNumber, Number, Rational};
pub use self::number::Number;
pub use self::numeric::Numeric;
pub use self::operator::{BadOp, Operator};
pub use self::quotes::Quotes;
Expand Down
Loading

0 comments on commit 3abb9ef

Please sign in to comment.