diff --git a/Cargo.lock b/Cargo.lock index eebac4a..3c07822 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,4 +4,4 @@ version = 3 [[package]] name = "frostwalker" -version = "0.0.7" +version = "0.0.8" diff --git a/Cargo.toml b/Cargo.toml index b8faa49..d8f4d0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "frostwalker" -version = "0.0.7" +version = "0.0.8" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/formatter.rs b/src/formatter.rs index f6c7a36..1de4a36 100644 --- a/src/formatter.rs +++ b/src/formatter.rs @@ -13,7 +13,7 @@ pub fn format(tree: Vec) -> HashMap { continue; } - if tree[i].class == Class::LITERAL && current_key != "".to_string() { + if (tree[i].class == Class::LITERAL || tree[i].class == Class::BOOLEAN) && current_key != "".to_string() { output.insert(current_key, tree[i].value.clone().unwrap_or("".to_string())); current_key = "".to_string(); i = i + 1; diff --git a/src/lexer.rs b/src/lexer.rs index 3f4a149..4a673b1 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -10,7 +10,6 @@ pub fn tokenize(source: &str) -> Vec { let mut tree: Vec = vec![]; for line in lines { - println!("{}", line); let mut added = false; let mut words: Vec<&str> = line.split(" ").collect(); let mut i = 0; diff --git a/tests/integration.rs b/tests/integration.rs index c35b247..32009f9 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -45,6 +45,19 @@ fn full_stack_single_key() { } } +#[test] +fn full_stack_boolean() { + let tree = lexer::tokenize("key = true\r\nkey2 = false"); + let result = validator::validate(&tree); + if result.is_some() { + panic!("{}", result.unwrap()); + } + let hashmap = formatter::format(tree); + if !(hashmap.get("key").unwrap() == "true") || !(hashmap.get("key2").unwrap() == "false") { + panic!("Formatter error."); + } +} + #[test] fn full_stack_varied_array() { let tree = lexer::tokenize("key = [ \"value\", 150, -30, \"\\\"value\" ]");