diff options
author | JJ | 2023-04-12 03:24:44 +0000 |
---|---|---|
committer | JJ | 2023-04-12 03:25:42 +0000 |
commit | 7b4442af8549b212d38e8ecfbf8a62217db7b220 (patch) | |
tree | 730303e0ab14676d10bb413772f3c76d03d6bfb4 /tests/test_parser.rs | |
parent | 0c980d4575a210f0ff4835500bc0bee315b66a10 (diff) |
https://youtu.be/GwQW3KW3DCc?t=63
Diffstat (limited to 'tests/test_parser.rs')
-rw-r--r-- | tests/test_parser.rs | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/tests/test_parser.rs b/tests/test_parser.rs index c619745..e33cdfa 100644 --- a/tests/test_parser.rs +++ b/tests/test_parser.rs @@ -52,43 +52,36 @@ fn test_complex_annotations() { } const program: &'static str = -"func foo() = - bar - if this: +"func foo(x): (int -> int) = + if this = that - else: + else = this hello foo bar baz -func foo = +func foo: (bool -> int) = this - if that: - then this "; const lexed: &'static str = -"func foo() = { - bar; - if this: { +"func foo(x): (int -> int) = { + if this = { that; - } - else: { + }; + else = { this; - } -} + }; +}; hello; foo; bar; baz; -func foo = { +func foo: (bool -> int) = { this; - if that: { - then this; - } -}"; +};"; #[test] fn test_lexer() { @@ -96,3 +89,19 @@ fn test_lexer() { assert!(result.is_ok()); assert_eq!(result.unwrap(), lexed); } + +#[test] +fn test_parser() { + let result = parse_lang(lexed); + assert!(result.is_err()); + + let file = std::fs::read_to_string("tests/src/negate.nim"); + assert!(file.is_ok()); + let result = parse_lang(&file.unwrap()); + assert!(result.is_err()); + + let file = std::fs::read_to_string("tests/src/fib.nim"); + assert!(file.is_ok()); + let result = parse_lang(&file.unwrap()); + assert!(result.is_err()); +} |