From f30dfe64313e6d056241a18860f76653a8dd11e3 Mon Sep 17 00:00:00 2001 From: Jeff Date: Thu, 5 Oct 2023 08:42:23 -0400 Subject: [PATCH] Fix errors --- src/interface.rs | 2 +- src/value/mod.rs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/interface.rs b/src/interface.rs index 57addc5..3389c05 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -521,7 +521,7 @@ mod tests { map.set_value("foo".to_string(), Value::String("bar".to_string())) .unwrap(); - assert_eq!(eval("map { x = 1 foo = 'bar' }"), vec![Ok(Value::Map(map))]); + assert_eq!(eval("{ x = 1 foo = 'bar' }"), vec![Ok(Value::Map(map))]); } #[test] diff --git a/src/value/mod.rs b/src/value/mod.rs index 4e71596..406ff86 100644 --- a/src/value/mod.rs +++ b/src/value/mod.rs @@ -67,7 +67,7 @@ impl Value { Ok(Value::Float(raw_value)) } "string" => { - let byte_range_without_quotes = child.start_byte() - 1..child.end_byte(); + let byte_range_without_quotes = child.start_byte() + 1..child.end_byte() - 1; let text = &source[byte_range_without_quotes]; Ok(Value::String(text.to_string())) @@ -438,11 +438,16 @@ impl Eq for Value {} impl PartialEq for Value { fn eq(&self, other: &Self) -> bool { match (self, other) { + (Value::Integer(left), Value::Integer(right)) => left == right, + (Value::Float(left), Value::Float(right)) => left == right, + (Value::Boolean(left), Value::Boolean(right)) => left == right, + (Value::String(left), Value::String(right)) => left == right, (Value::List(left), Value::List(right)) => left == right, (Value::Map(left), Value::Map(right)) => left == right, (Value::Table(left), Value::Table(right)) => left == right, (Value::Time(left), Value::Time(right)) => left == right, (Value::Function(left), Value::Function(right)) => left == right, + (Value::Empty, Value::Empty) => true, _ => false, } } @@ -475,6 +480,7 @@ impl Ord for Value { (Value::Function(_), _) => Ordering::Greater, (Value::Time(left), Value::Time(right)) => left.cmp(right), (Value::Time(_), _) => Ordering::Greater, + (Value::Empty, Value::Empty) => Ordering::Equal, (Value::Empty, _) => Ordering::Less, } }