Skip to content

Commit

Permalink
avm1: Math tests: Substitute some trivial expected values and add TOD…
Browse files Browse the repository at this point in the history
…Os about @epsilon
  • Loading branch information
torokati44 committed Aug 11, 2024
1 parent 3573322 commit c3529af
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions core/src/avm1/globals/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,20 @@ mod tests {
[19] => {
[] => f64::NAN,
[Value::Null] => f64::NAN,
// TODO: figure out the exact f64 returned, and add @epsilon as needed, see test_exp
[-1.0] => f64::acos(-1.0),
[0.0] => f64::acos(0.0),
[1.0] => f64::acos(1.0)
[1.0] => 0.0 // f64::acos(1.0)
}
);

test_method!(test_asin, "asin", setup,
[19] => {
[] => f64::NAN,
[Value::Null] => f64::NAN,
// TODO: figure out the exact f64 returned, and add @epsilon as needed, see test_exp
[-1.0] => f64::asin(-1.0),
[0.0] => f64::asin(0.0),
[0.0] => 0.0, // f64::asin(0.0),
[1.0] => f64::asin(1.0)
}
);
Expand All @@ -219,8 +221,9 @@ mod tests {
[19] => {
[] => f64::NAN,
[Value::Null] => f64::NAN,
// TODO: figure out the exact f64 returned, and add @epsilon as needed, see test_exp
[-1.0] => f64::atan(-1.0),
[0.0] => f64::atan(0.0),
[0.0] => 0.0, // f64::atan(0.0),
[1.0] => f64::atan(1.0)
}
);
Expand All @@ -238,7 +241,7 @@ mod tests {
[] => f64::NAN,
[Value::Null] => f64::NAN,
[0.0] => 1.0,
[std::f64::consts::PI] => f64::cos(std::f64::consts::PI)
[std::f64::consts::PI] => -1.0 // f64::cos(std::f64::consts::PI)
}
);

Expand Down Expand Up @@ -298,16 +301,17 @@ mod tests {
[19] => {
[] => f64::NAN,
[Value::Null] => f64::NAN,
[0.0] => f64::sin(0.0),
[std::f64::consts::PI / 2.0] => f64::sin(std::f64::consts::PI / 2.0)
[0.0] => 0.0, // f64::sin(0.0),
[std::f64::consts::PI / 2.0] => 1.0 // f64::sin(std::f64::consts::PI / 2.0)
}
);

test_method!(test_sqrt, "sqrt", setup,
[19] => {
[] => f64::NAN,
[Value::Null] => f64::NAN,
[0.0] => f64::sqrt(0.0),
[0.0] => 0.0, // f64::sqrt(0.0),
// TODO: figure out the exact f64 returned, and add @epsilon as needed, see test_exp
[5.0] => f64::sqrt(5.0)
}
);
Expand All @@ -316,7 +320,8 @@ mod tests {
[19] => {
[] => f64::NAN,
[Value::Null] => f64::NAN,
[0.0] => f64::tan(0.0),
[0.0] => 0.0, // f64::tan(0.0),
// TODO: figure out the exact f64 returned, and add @epsilon as needed, see test_exp
[1.0] => f64::tan(1.0)
}
);
Expand Down Expand Up @@ -346,9 +351,10 @@ mod tests {
[19] => {
[] => f64::NAN,
[Value::Null] => f64::NAN,
// TODO: figure out the exact f64 returned, and add @epsilon as needed, see test_exp
[2.0] => f64::ln(2.0),
[0.0] => f64::ln(0.0),
[1.0] => f64::ln(1.0)
[0.0] => f64::NEG_INFINITY, // f64::ln(0.0),
[1.0] => 0 // f64::ln(1.0)
}
);

Expand Down

0 comments on commit c3529af

Please sign in to comment.