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