feat: generate unified AST and editor contracts from ASDL
Verify databases and deploy Aster VM / verify-and-deploy (push) Successful in 7m55s
Verify databases and deploy Aster VM / verify-and-deploy (push) Successful in 7m55s
This commit is contained in:
@@ -105,3 +105,35 @@ fn parse_command_reads_stdin_to_eof_and_reports_its_origin() {
|
||||
.contains("<stdin>: invalid UTF-8 at byte 0")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_command_exports_versioned_json_for_expression_and_interactive_inputs() {
|
||||
for (mode, source) in [("expression", "f(\"日\")"), ("interactive", "let x = 1")] {
|
||||
let source = SourceFile::new(source.as_bytes());
|
||||
let output = Command::new(env!("CARGO_BIN_EXE_cli"))
|
||||
.args(["parse", "--json", "--mode", mode])
|
||||
.arg(&source.0)
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(
|
||||
output.status.success(),
|
||||
"{}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
let document =
|
||||
frontend::ast::AstDocument::from_json(std::str::from_utf8(&output.stdout).unwrap())
|
||||
.unwrap();
|
||||
assert_eq!(document.schema, frontend::ast::AST_SCHEMA_ID);
|
||||
match (mode, document.root) {
|
||||
("expression", frontend::ast::AstRoot::Expression(_))
|
||||
| ("interactive", frontend::ast::AstRoot::Interactive(_)) => {}
|
||||
_ => panic!("incorrect parse mode"),
|
||||
}
|
||||
}
|
||||
let output = Command::new(env!("CARGO_BIN_EXE_cli"))
|
||||
.args(["parse", "--mode", "unknown", "-"])
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(!output.status.success());
|
||||
assert!(output.stdout.is_empty());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user