[fine] OK

This commit is contained in:
John Doty 2024-01-13 15:07:38 -08:00
parent 50eb7a9673
commit 65fef78c44
10 changed files with 81 additions and 25 deletions

View file

@ -37,7 +37,7 @@ e.g., a test might look like this:
The various assertions are as follows:
- The `// @disabled` directive marks the test as ignored.
- The `// @ignore` directive marks the test as ignored.
- The `// @concrete:` assertion says that the following lines
(prefixed with `// | `, as above) describe the concrete syntax tree

View file

@ -1,6 +1,6 @@
use fine::compiler::{compile, Function, Module};
use fine::parser::SyntaxTree;
use fine::semantics::{Semantics, Type};
use fine::semantics::{check, Error, Semantics, Type};
use fine::tokens::Lines;
use pretty_assertions::assert_eq;
use std::fmt::Write as _;
@ -243,4 +243,19 @@ fn assert_compiles_to(tree: &SyntaxTree, lines: &Lines, expected: &str, source_p
}
}
fn assert_no_errors(tree: &SyntaxTree, lines: &Lines) {
let semantics = Semantics::new(tree, lines);
check(&semantics);
let expected_errors: Vec<Error> = Vec::new();
let errors = semantics.snapshot_errors();
semantic_assert_eq!(
&semantics,
None,
expected_errors,
errors,
"expected no errors"
);
}
include!(concat!(env!("OUT_DIR"), "/generated_tests.rs"));

View file

@ -36,5 +36,6 @@ fun foo(x: f64) {
// | 2: FloatAdd
// | function << module >> (0 args, 0 locals):
// | strings (0):
// | code (0):
// | code (1):
// | 0: PushNothing
// |

View file

@ -25,7 +25,7 @@
// @compiles-to:
// | function << module >> (0 args, 0 locals):
// | strings (0):
// | code (10):
// | code (11):
// | 0: PushFloat(1.0)
// | 1: PushFloat(2.0)
// | 2: FloatMultiply
@ -36,4 +36,5 @@
// | 7: FloatMultiply
// | 8: FloatAdd
// | 9: Discard
// | 10: PushNothing
// |

View file

@ -1,5 +1,14 @@
// @disabled
// @concrete:
// |
;
// @no-errors
// @concrete:
// | File
// | ExpressionStatement
// | Semicolon:'";"'
// |
// @compiles-to:
// | function << module >> (0 args, 0 locals):
// | strings (0):
// | code (1):
// | 0: PushNothing
// |

View file

@ -3,6 +3,7 @@ let y = x * 2;
let z = print(y);
z;
// @no-errors
// @type: 41 f64
// @concrete:
// | File
@ -46,7 +47,7 @@ z;
// @compiles-to:
// | function << module >> (0 args, 0 locals):
// | strings (0):
// | code (12):
// | code (13):
// | 0: PushFloat(23.0)
// | 1: StoreModule(0)
// | 2: LoadModule(0)
@ -59,4 +60,5 @@ z;
// | 9: StoreModule(2)
// | 10: LoadModule(2)
// | 11: Discard
// | 12: PushNothing
// |