Add support for negative integers.

This commit is contained in:
Tom Alexander
2020-06-13 16:06:31 -04:00
parent 02bcefb75c
commit d99aa44d8e
3 changed files with 129 additions and 14 deletions

View File

@@ -335,6 +335,11 @@ impl CompareContextElement for serde_json::Value {
return self
.equals(&serde_json::Value::Number(other_json_num) as &dyn ContextElement);
}
Some(OwnedLiteral::LNegativeInteger(other_num)) => {
let other_json_num: serde_json::Number = std::convert::From::from(*other_num);
return self
.equals(&serde_json::Value::Number(other_json_num) as &dyn ContextElement);
}
Some(OwnedLiteral::LFloat(other_num)) => {
let other_json_num = serde_json::Number::from_f64(*other_num);
match other_json_num {
@@ -463,6 +468,7 @@ impl From<&OwnedLiteral> for JsonNumber {
fn from(original: &OwnedLiteral) -> Self {
match original {
OwnedLiteral::LPositiveInteger(num) => JsonNumber::UnsignedInteger(*num),
OwnedLiteral::LNegativeInteger(num) => JsonNumber::SignedInteger(*num),
OwnedLiteral::LString(text) => text.into(),
OwnedLiteral::LFloat(num) => {
if num.is_nan() {