77 lines
1.7 KiB
Rust
77 lines
1.7 KiB
Rust
////////////////////////////
|
|
// Automatically Generated//
|
|
////////////////////////////
|
|
use crate::logger::messages::Message;
|
|
use crate::parsing::lexer::lex;
|
|
use crate::parsing::lexer::lex_tokens::LexToken;
|
|
use crate::parsing::parser::parse;
|
|
use crate::parsing::parser::parsed_statement::ParsedStatement;
|
|
use crate::span::Span;
|
|
|
|
fn ignore_error(_msg: Message, _: Span) {
|
|
}
|
|
|
|
fn panic_on_error(msg: Message, _: Span) {
|
|
std::panic::panic_any(msg.stringify());
|
|
}
|
|
#[test]
|
|
fn integration_class_with_many_statements() {
|
|
let script = "final shared class Foobar {
|
|
int _a;
|
|
int _b;
|
|
|
|
Foobar(int a, int b) {
|
|
_a = a;
|
|
_b = b;
|
|
}
|
|
|
|
int GetA(){
|
|
return _a;
|
|
}
|
|
|
|
int Add() {
|
|
return _a + _b;
|
|
}
|
|
|
|
class Inner {
|
|
int a;
|
|
}
|
|
}";
|
|
let lexed_tokens = lex(script, &mut panic_on_error);
|
|
println!("Lexed tokens JSON: {}", serde_json::to_string(&lexed_tokens).unwrap());
|
|
|
|
let parsed_tree = parse(lexed_tokens, &mut panic_on_error);
|
|
println!("Parsed Tree JSON: {}", serde_json::to_string(&parsed_tree).unwrap());
|
|
}
|
|
// A substring of a script should never panic, even though it might be completely invalid.
|
|
#[test]
|
|
fn integration_class_with_many_statements_substring() {
|
|
let mut script = "final shared class Foobar {
|
|
int _a;
|
|
int _b;
|
|
|
|
Foobar(int a, int b) {
|
|
_a = a;
|
|
_b = b;
|
|
}
|
|
|
|
int GetA(){
|
|
return _a;
|
|
}
|
|
|
|
int Add() {
|
|
return _a + _b;
|
|
}
|
|
|
|
class Inner {
|
|
int a;
|
|
}
|
|
}".to_string();
|
|
for _ in 0..script.len() {
|
|
script.pop();
|
|
let lexed_tokens = lex(script.as_str(), &mut ignore_error);
|
|
let _parsed_tree = parse(lexed_tokens, &mut ignore_error);
|
|
}
|
|
|
|
}
|
|
|