Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl<'a> JsonAta<'a> {

#[cfg(test)]
mod tests {
use chrono::{DateTime, Datelike, Local, Offset};
use chrono::{DateTime, Datelike, Offset, Utc};
use regress::Regex;

use bumpalo::collections::String as BumpString;
Expand Down Expand Up @@ -797,7 +797,7 @@ mod tests {
let result = jsonata.evaluate(None, None).unwrap();

// Dynamically compute the expected result
let now = Local::now();
let now = Utc::now();
let expected = format!(
"{:02}{:02}{:02}",
now.year() % 100, // Last two digits of the year
Expand Down
6 changes: 3 additions & 3 deletions src/parser/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ impl<'a> Tokenizer<'a> {
}

fn get_codepoint(&mut self) -> Result<u16> {
Ok(self.get_hex_digit()? << 12
| self.get_hex_digit()? << 8
| self.get_hex_digit()? << 4
Ok((self.get_hex_digit()? << 12)
| (self.get_hex_digit()? << 8)
| (self.get_hex_digit()? << 4)
| self.get_hex_digit()?)
}

Expand Down
7 changes: 7 additions & 0 deletions tests/customsuite/datasets/customdataset0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"arrayOfArrays": [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
}
7 changes: 7 additions & 0 deletions tests/customsuite/flatten/case000.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"comment": "using an asterisk path should flatten an array",
"expr": "$reduce($.arrayOfArrays, $append)",
"dataset": "customdataset0",
"bindings": {},
"result": [1, 2, 3, 4, 5, 6, 7, 8, 9]
}
7 changes: 7 additions & 0 deletions tests/customsuite/flatten/skip/case001.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"comment": "using an asterisk path should flatten an array",
"expr": "$.arrayOfArrays.*",
"dataset": "customdataset0",
"bindings": {},
"result": [1, 2, 3, 4, 5, 6, 7, 8, 9]
}
7 changes: 6 additions & 1 deletion tests/testsuite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ fn test_case(resource: &str) {
let dataset = &case["dataset"];

let data = if dataset.is_string() {
let dataset = format!("tests/testsuite/datasets/{}.json", dataset.as_str());
let subdir = if resource.contains("customsuite") {
"customsuite"
} else {
"testsuite"
};
let dataset = format!("tests/{subdir}/datasets/{}.json", dataset.as_str());
fs::read_to_string(&dataset).unwrap()
} else if data.is_undefined() {
"".to_string()
Expand Down