Clean up; Fix tests
This commit is contained in:
parent
012728b00a
commit
f2e5b8d499
@ -376,7 +376,7 @@ impl Display for ContextError {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{parse, run, Vm};
|
||||
use crate::{parse, Vm};
|
||||
|
||||
use super::*;
|
||||
|
||||
|
@ -11,7 +11,8 @@ use std::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
ast::*, Context, DustError, Identifier, LexError, Lexer, Token, TokenKind, TokenOwned, Type,
|
||||
ast::*, core_library, Context, DustError, Identifier, LexError, Lexer, Token, TokenKind,
|
||||
TokenOwned, Type,
|
||||
};
|
||||
|
||||
/// Parses the input into an abstract syntax tree.
|
||||
@ -110,7 +111,7 @@ impl<'src> Parser<'src> {
|
||||
current_token,
|
||||
current_position,
|
||||
mode: ParserMode::Normal,
|
||||
context: Context::new(),
|
||||
context: core_library().create_child(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,9 +21,9 @@ use crate::{
|
||||
StructDefinition, StructExpression,
|
||||
},
|
||||
constructor::ConstructError,
|
||||
core_library, parse, Analyzer, BuiltInFunctionError, Context, ContextData, ContextError,
|
||||
DustError, Evaluation, Expression, Function, FunctionCallError, Identifier, ParseError,
|
||||
StructType, Type, Value, ValueData, ValueError,
|
||||
parse, Analyzer, BuiltInFunctionError, Context, ContextData, ContextError, DustError,
|
||||
Evaluation, Expression, Function, FunctionCallError, Identifier, ParseError, StructType, Type,
|
||||
Value, ValueData, ValueError,
|
||||
};
|
||||
|
||||
/// Run the source code and return the result.
|
||||
@ -1424,7 +1424,7 @@ impl Display for RuntimeError {
|
||||
mod tests {
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::Struct;
|
||||
use crate::{AnalysisError, Struct};
|
||||
|
||||
use super::*;
|
||||
|
||||
@ -1493,13 +1493,12 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
run(source),
|
||||
Err(DustError::Runtime {
|
||||
runtime_error: RuntimeError::UnassociatedIdentifier {
|
||||
identifier: Identifier::new("x"),
|
||||
position: (16, 17)
|
||||
},
|
||||
Err(DustError::analysis(
|
||||
[AnalysisError::UndefinedVariable {
|
||||
identifier: Node::new(Identifier::new("x"), (16, 17))
|
||||
}],
|
||||
source
|
||||
})
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
@ -1509,16 +1508,12 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
run(source),
|
||||
Err(DustError::Runtime {
|
||||
runtime_error: RuntimeError::Expression {
|
||||
error: Box::new(RuntimeError::UnassociatedIdentifier {
|
||||
identifier: Identifier::new("x"),
|
||||
position: (18, 19)
|
||||
}),
|
||||
position: (16, 21)
|
||||
},
|
||||
Err(DustError::analysis(
|
||||
[AnalysisError::UndefinedVariable {
|
||||
identifier: Node::new(Identifier::new("x"), (18, 19))
|
||||
}],
|
||||
source
|
||||
})
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user