Skip to content

Commit

Permalink
Add tests for inline functions
Browse files Browse the repository at this point in the history
  • Loading branch information
garritfra committed Apr 5, 2024
1 parent b64a4c0 commit bd5503e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 1 addition & 3 deletions examples/greeter.sb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ fn main() {
println(greet("World"))
}

fn greet(name: string): string {
return "Hello " + name
}
fn greet(name: string) = "Hello " + name
10 changes: 10 additions & 0 deletions src/parser/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ fn test_parse_function_with_return() {
assert!(tree.is_ok())
}

#[test]
fn test_parse_inline_function() {
let raw = "
fn main() = 1
";
let tokens = tokenize(raw).unwrap();
let tree = parse(tokens, Some(raw.to_string()), "".into());
assert!(tree.is_ok())
}

#[test]
fn test_parse_redundant_semicolon() {
let raw = "
Expand Down

0 comments on commit bd5503e

Please sign in to comment.