diff --git a/core/engine/src/value/operations.rs b/core/engine/src/value/operations.rs index c26a0b00ba..d243315bea 100644 --- a/core/engine/src/value/operations.rs +++ b/core/engine/src/value/operations.rs @@ -477,10 +477,9 @@ impl JsValue { ), Self::String(ref str) => Self::new(-str.to_number()), Self::Rational(num) => Self::new(-num), - Self::Integer(0) => Self::new(-f64::from(0)), + Self::Integer(0) | Self::Boolean(false) | Self::Null => Self::new(-f64::from(0)), Self::Integer(num) => Self::new(-num), - Self::Boolean(true) => Self::new(1), - Self::Boolean(false) | Self::Null => Self::new(0), + Self::Boolean(true) => Self::new(-f64::from(1)), Self::BigInt(ref x) => Self::new(JsBigInt::neg(x)), }) } diff --git a/core/engine/src/value/tests.rs b/core/engine/src/value/tests.rs index 4d8fffc169..c689a1fc3c 100644 --- a/core/engine/src/value/tests.rs +++ b/core/engine/src/value/tests.rs @@ -64,6 +64,9 @@ fn abstract_equality_comparison() { TestAction::assert("+0 == 0"), TestAction::assert("-0 == 0"), TestAction::assert("0 == false"), + TestAction::assert("-0 == -false"), + TestAction::assert("-0 == -null"), + TestAction::assert("-1 == -true"), TestAction::assert("'' == false"), TestAction::assert("'' == 0"), TestAction::assert("'17' == 17"),