Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More test coverage #43

Merged
merged 4 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: clippy
  • Loading branch information
can-keklik committed Dec 6, 2024
commit 19bb033b07da9cf002be8160ecbb2fe8ebd1301c
6 changes: 3 additions & 3 deletions lykiadb-lang/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,11 +628,11 @@ impl<'a> Parser<'a> {
}));
}

return Ok(self.expect_get_path(expr, sym!(DoubleColon))?);
return self.expect_get_path(expr, sym!(DoubleColon));
}
}

Ok(self.expect_get_path(expr, sym!(Dot))?)
self.expect_get_path(expr, sym!(Dot))
}

fn finish_call(&mut self, callee: Box<Expr>) -> ParseResult<Box<Expr>> {
Expand Down Expand Up @@ -777,7 +777,7 @@ impl<'a> Parser<'a> {
}

fn expected(&mut self, expected_tok_type: &TokenType) -> ParseResult<&Token> {
if self.cmp_tok(&expected_tok_type) {
if self.cmp_tok(expected_tok_type) {
return Ok(self.advance());
};
let prev_token = self.peek_bw(1);
Expand Down
6 changes: 6 additions & 0 deletions lykiadb-server/src/engine/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,12 @@ pub struct Output {
out: Vec<RV>,
}

impl Default for Output {
fn default() -> Self {
Self::new()
}
}

impl Output {
pub fn new() -> Output {
Output { out: Vec::new() }
Expand Down
10 changes: 8 additions & 2 deletions lykiadb-server/src/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ pub mod test_helpers {
runtime: Runtime,
}

impl Default for RuntimeTester {
fn default() -> Self {
Self::new()
}
}

impl RuntimeTester {
pub fn new() -> RuntimeTester {
let out = alloc_shared(Output::new());
Expand Down Expand Up @@ -127,7 +133,7 @@ pub mod test_helpers {
assert_eq!(errors.iter().map(|x| x.to_string()).collect::<Vec<String>>().join("\n"), part[3..].trim());
}

else if part.starts_with(">") {
else if part.starts_with('>') {
let result = self.runtime.interpret(part[1..].trim());

if let Err(err) = result {
Expand All @@ -139,7 +145,7 @@ pub mod test_helpers {
self.out.write().unwrap().expect(vec![RV::Str(Arc::new(part.to_string()))]);
}
else {
self.out.write().unwrap().expect_str(part.to_string().split("\n").map(|x| x.to_string()).collect());
self.out.write().unwrap().expect_str(part.to_string().split('\n').map(|x| x.to_string()).collect());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lykiadb-server/src/plan/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, fmt::Display};
use std::fmt::Display;

use lykiadb_lang::{
ast::{
Expand Down
4 changes: 2 additions & 2 deletions lykiadb-server/src/plan/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl<'a> Planner<'a> {
if core.projection.as_slice() != [SqlProjection::All { collection: None }] {
for projection in &core.projection {
if let SqlProjection::Expr { expr, .. } = projection {
self.build_expr(&expr, false, true)?;
self.build_expr(expr, false, true)?;
}
}
node = Node::Projection {
Expand Down Expand Up @@ -110,7 +110,7 @@ impl<'a> Planner<'a> {
None
}
Expr::FieldPath { head, tail, .. } => {
println!("FieldPath {} {}", head.to_string(), tail.iter().map(|x| x.to_string()).collect::<String>());
println!("FieldPath {} {}", head, tail.iter().map(|x| x.to_string()).collect::<String>());
None
}
Expr::Call { callee, args, .. } => {
Expand Down