diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..16d3d98 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,14 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - repo: https://github.com/doublify/pre-commit-rust + rev: v1.0 + hooks: + - id: fmt + - id: clippy + args: [ '--tests', '--examples', '--', '-D', 'warnings' ] diff --git a/lox-examples/hello.lox b/lox-examples/hello.lox index 9e788ff..7079fe5 100644 --- a/lox-examples/hello.lox +++ b/lox-examples/hello.lox @@ -1,2 +1,2 @@ print "Hello, world"; -// print 1 + 1 == 2 and true; \ No newline at end of file +// print 1 + 1 == 2 and true; diff --git a/src/parser.rs b/src/parser.rs index f8ec021..3781457 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -984,8 +984,8 @@ mod tests { let e = parse_to_expr(&format!("true {input} false")); let (left, parsed_op, right) = e.unwrap_logical(); assert_eq!(parsed_op, expected_op, "should parse to `{expected_op:?}`"); - assert_eq!(left.unwrap_literal().unwrap_bool(), true); - assert_eq!(right.unwrap_literal().unwrap_bool(), false); + assert!(left.unwrap_literal().unwrap_bool()); + assert!(!right.unwrap_literal().unwrap_bool()); } }